<p>The value you specify for custom fee is in fee per kilobyte. Until recently, the "size" for fee computations was always rounded up to 1 kilobyte anyway, leading some people to believe that the amount they're setting is the absolute amount instead.</p>

<p>Your transaction is 225 bytes, and pays 0.000045 BTC fee. That is exactly 0.0002 BTC per 1000 bytes, so it is working as intended.</p>

CC BY-SA 3.0
2016-10-17T11:52:52.670Z
yeah, i know. Here is even github issue for that. 
https://github.com/bitcoin/bitcoin/issues/7633

and as i can see, they decided to revert feature and now to behaviour should be the same as in old versions. Am i right?
Dmitriy Apollonin
CC BY-SA 3.0
2016-10-17T11:55:30.763Z
They're only reverted in 0.11, because the change was made without announcement there. What I describe in my answer is the intended behaviour, and the one that is implemented in 0.12 and 0.13.
Pieter Wuille
CC BY-SA 3.0
2016-10-17T11:57:48.620Z
oh, i see. So in new versions now it is working lie this... Hm.. not good. 'cos i need to estimate my future transaction size now to show my users what fee would i  take away from their payout... and right now i don't know how to estimate it...
Dmitriy Apollonin
CC BY-SA 3.0
2016-10-17T11:59:47.480Z
Use create/fundrawtransaction to build your transaction, check the fee, show it, and if agreed to, use signrawtransaction/sendrawtransaction to broadcast it.
Pieter Wuille
CC BY-SA 3.0
2016-10-17T12:02:11.557Z
great complication of simple (before) payout process as for users and for developers :(
but thanks for the help!
Dmitriy Apollonin
CC BY-SA 3.0
2016-10-17T12:04:33.487Z
I understand it complicates things, but there is really no way around it. Fee per byte is what matters to the network.
Pieter Wuille
CC BY-SA 3.0
2016-10-17T11:44:23.010Z
2016-10-17T11:44:23.010Z
Pieter Wuille
<p>I'm using Bitcoin API  <a href="https://github.com/aceat64/EasyBitcoin-PHP" rel="nofollow">EasyBitcoin-PHP</a></p>

<p>And also i have my custom transaction fee, that i'd like to pay per each Kb. The problem is that when i used bitcoind v.0.10.2 that was fine and i saw my custom fee (0.0002) in each transaction.
But when i've updated to v. 0.13.0 - it just won't work as it should. Here is the simple code, that i'm testing now</p>

<pre><code>$bitcoin = new Bitcoin($user, $password, $host, $port);

$result = $bitcoin-&gt;settxfee(0.0002); //returns true
$newTxId = $bitcoin-&gt;sendtoaddress('144YsrgtDmRSPC8wUBXLxByCcQAEbV1EUB', 0.001); //returns c3a2fceed1c25624aee8e957c644813bf38808260aad607e623c68e182371ac9
</code></pre>

<p>And as you can see in this <a href="https://blockchain.info/en/tx/c3a2fceed1c25624aee8e957c644813bf38808260aad607e623c68e182371ac9" rel="nofollow">transaction</a> the fee is 0.000045 BTC, not 0.0002 BTC.</p>

<p>I know, that there was a bug in prev version of bitcoind according to fee rounding, but in new version this bug should be fixed.</p>

<p>Maybe there is another trouble here?</p>

<transactions><bitcoind><php>
PHP - Bitcoind sets up wrong transaction fee
Dmitriy Apollonin
# PHP - Bitcoind sets up wrong transaction fee

(Asked by: username_0 on 2016-10-17)

I'm using Bitcoin API [EasyBitcoin-PHP](https://github.com/aceat64/EasyBitcoin-PHP)

And also i have my custom transaction fee, that i'd like to pay per each Kb. The problem is that when i used bitcoind v.0.10.2 that was fine and i saw my custom fee (0.0002) in each transaction.
But when i've updated to v. 0.13.0 - it just won't work as it should. Here is the simple code, that i'm testing now

```
$bitcoin = new Bitcoin($user, $password, $host, $port);

$result = $bitcoin->settxfee(0.0002); //returns true
$newTxId = $bitcoin->sendtoaddress('144YsrgtDmRSPC8wUBXLxByCcQAEbV1EUB', 0.001); //returns c3a2fceed1c25624aee8e957c644813bf38808260aad607e623c68e182371ac9

```

And as you can see in this [transaction](https://blockchain.info/en/tx/c3a2fceed1c25624aee8e957c644813bf38808260aad607e623c68e182371ac9) the fee is 0.000045 BTC, not 0.0002 BTC.

I know, that there was a bug in prev version of bitcoind according to fee rounding, but in new version this bug should be fixed.

Maybe there is another trouble here?

**Tags:** transactions, bitcoind, php


---

## 1 answers

### Answer by username_1 on 2016-10-17. Score: 2 | Accepted answer

The value you specify for custom fee is in fee per kilobyte. Until recently, the "size" for fee computations was always rounded up to 1 kilobyte anyway, leading some people to believe that the amount they're setting is the absolute amount instead.

Your transaction is 225 bytes, and pays 0.000045 BTC fee. That is exactly 0.0002 BTC per 1000 bytes, so it is working as intended.

> **Comments:**
> **username_0**: yeah, i know. Here is even github issue for that.  https://github.com/bitcoin/bitcoin/issues/7633  and as i can see, they decided to revert feature and now to behaviour should be the same as in old versions. Am i right?  
> **username_1**: They're only reverted in 0.11, because the change was made without announcement there. What I describe in my answer is the intended behaviour, and the one that is implemented in 0.12 and 0.13.  
> **username_0**: oh, i see. So in new versions now it is working lie this... Hm.. not good. 'cos i need to estimate my future transaction size now to show my users what fee would i  take away from their payout... and right now i don't know how to estimate it...  
> **username_1**: Use create/fundrawtransaction to build your transaction, check the fee, show it, and if agreed to, use signrawtransaction/sendrawtransaction to broadcast it.  
> **username_0**: great complication of simple (before) payout process as for users and for developers :( but thanks for the help!  
> **username_1**: I understand it complicates things, but there is really no way around it. Fee per byte is what matters to the network.  

---

