20% difference between settxfee and actual transaction

2

I set transaction fee with :

$ bitcoin-cli settxfee 0.00003000

Here is what i observe from block explorer for my transaction : https://testnet.blockexplorer.com/tx/789d578d22ee07e11ceca9e94aacbf51d36a41223f792035cac26e91830f39c3

Fee Rate    0.000036 BTC per kB

I've tested with different transaction fees for several times; difference always 20% more.

I am on testnet3; using bitcoind version 0.16.0

Edit :

As Adam's answer; now i am more skeptical about byte calculation of blockchain monitoring sites (or whatever they are called).

I've inspected my transaction with getransaction call. But i still dont see fee per kB is matching with calculation. According to hex parameter; it should be 250 bytes. So total fee should be 0.00000750. Shouldn't i take hex parameter as size of transaction?

If adam's calculation correct; (seem like it is) then 180 * 0.00003000 / 1024 = 0.00000527. Closest answer so far with %4.5 difference.

Is my calculation correct?

bitcoin-cli gettransaction 789d578d22ee07e11ceca9e94aacbf51d36a41223f792035cac26e91830f39c3
{
  "amount": -0.00005000,
  "fee": -0.00000504,
  "confirmations": 190,
  "blockhash": "0000000000000287661d724d67bed9c1a8861179413e056ee0d16a8b132ad380",
  "blockindex": 12,
  "blocktime": 1527979564,
  "txid": "789d578d22ee07e11ceca9e94aacbf51d36a41223f792035cac26e91830f39c3",
  "walletconflicts": [
  ],
  "time": 1527979516,
  "timereceived": 1527979516,
  "bip125-replaceable": "no",
  "details": [
    {
      "account": "",
      "address": "momFk8PtAZoN4j7Y6jnbucEfc6teUKECEB",
      "category": "send",
      "amount": -0.00005000,
      "vout": 0,
      "fee": -0.00000504,
      "abandoned": false
    }
  ],
  "hex": "020000000001014bb52fb3493598763b53d5ba3cb41f2486cd1ec1b61bae2727d2b9fc74a7454800000000171600148febee6ac4a40d4474c2665c77bbf02350d1bb63feffffff0288130000000000001976a9145a756559278c3795092c07f49c6cf47d360bb1be88acc7c70f000000000017a914849901fe3e003ebf5be1afaf737305158d8865a58702483045022100e23a7e22a21da25f3363bbccbe0bfc94f8044e48236f20b595a456f6bc6d708b02206fc6acdc3636904458cd81770a346a75cc7d5e8ad3868168e387c9cff521b9680121038dc51cc27a4ae2f7ae52503ae4a23862cde107001b59a65639522925527a3e4788291400"
}

Kerem atam

Posted 2018-06-02T23:12:56.577

Reputation: 93

It's likely a difference between fee calculation using segwit and non-segwit sizes.Raghav Sood 2018-06-03T01:20:12.017

Answers

1

The problem is not with bitcoin core, it's definitely of the block explorer.

Transaction size is 104 + 32 + 34 + 10 = 180 byte, they are saying transaction size 140 byte. I don't understand how did they calculate it.

Blockchain.info saying transactions size is 250

You should not trust them for that matters, try

bitcoin-cli gettransaction 789d578d22ee07e11ceca9e94aacbf51d36a41223f792035cac26e91830f39c3

and see transaction size.

Adam

Posted 2018-06-02T23:12:56.577

Reputation: 3 215

You are right. But still i coundnt reach the exact calculation. I have shared output of gettransaction call.Kerem atam 2018-06-03T10:03:53.463

You can't reach exact calculation because transaction header size isn't always 10 byte and input size as well, take a look at this answer here

Adam 2018-06-03T11:49:33.037

Got it! How about bitcoin-cli command output. I cant see 180 but 250 as blockchain.infoKerem atam 2018-06-03T14:38:06.870

where do you see 250 byte?Adam 2018-06-03T15:42:25.160

hex parameter in gettransaction returns 250 byte valueKerem atam 2018-06-03T15:59:26.427

2The size that matters is the virtual size (or 1/4th of the weight), which takes the SegWit discount into account), not the byte size.Pieter Wuille 2018-06-03T17:08:53.030

Thanks for explanations. @PieterWuille can you suggest comprehensive documentation where i can calculate my transaction in detail for different address types. Seriously; i am sick of wandering around Github repos and Stackexchange topics.Kerem atam 2018-06-03T20:06:52.243

1Weight is defined in BIP141 as 3*bytes_when_serialized_without_witnesses + bytes_when_serialized_with_witnesses.Pieter Wuille 2018-06-03T21:45:24.850