<p>I can calculate the <a href="https://en.bitcoin.it/wiki/Transaction_fees#Technical_info" rel="nofollow">priority</a> of the transaction (527 confirmations currently, ~452 bytes):</p>

<pre><code>119994817 * 527 / 452 = 139,905,461
</code></pre>

<p>Since this is over the minimum of 57,600,000 and meets the other <a href="https://en.bitcoin.it/wiki/Transaction_fees" rel="nofollow">rules for free transactions</a>: namely, that the transaction is under 1000 bytes and has no outputs under 0.01 BTC, this transaction can be free. You do not need to include a transaction fee: make the sum of the outputs equal the input amount exactly.</p>

<p>If your transaction didn't meet the requirements for a free transaction, or if you don't wish it to be treated as a free transaction (which have some limits in transmitting, etc. that <em>might</em> slow down their inclusion in a block), you would need to include 0.0001 BTC transaction fee per thousand bytes (e.g. up to 1000 bytes is 0.0001, 1001-2000 bytes is 0.0002, etc.)</p>

<p>(this is assuming the testnet has the same rules for transaction fees as Bitcoin's mainnet)</p>

CC BY-SA 3.0
2014-06-10T18:29:20.130Z
How about the number of inputs and outputs?  How do I get those values?
oshirowanen
CC BY-SA 3.0
2014-06-10T18:41:26.507Z
You already specified that when you said "If I want to send 0.05XBT from: mvDLEEymmEijZXyrrNRL3aPMhH8q2m8vE1 to mxgxQ52kYRVPfLeYpXugkCAGhjLfUaZk3g.". Since mvDLEE... only has one unspent output credited to it, you must have one input. And since you only want to give a portion of that to mxgx... you must have at least one change address. Unless you're adding unnecessary complexity, then, the number of inputs is 1 and the number of outputs is 2. In some cases, the transaction fee might change this, but this is a simple example.
Tim S.
CC BY-SA 3.0
2014-06-10T12:08:30.180Z
2014-06-10T12:18:42.837Z
2014-06-10T12:18:42.837Z
Tim S.
<p>I am having difficulty working out how to work out a transaction fee.  I've read the theory, but don't understand how to get the values to put the theory to practice.</p>

<p>Can someone please help me work this out step by step?  If I want to send 0.05XBT from: <code>mvDLEEymmEijZXyrrNRL3aPMhH8q2m8vE1</code> to <code>mxgxQ52kYRVPfLeYpXugkCAGhjLfUaZk3g</code>.  How do I work out the transaction fee?</p>

<p>If your answer could use these public keys so I can try them out based on the instructions in your answer, I would really appreciate that.</p>

<p>Using bitcoin-qt's command line, I have the following details:</p>

<blockquote>
  <p>listunspent [ { "txid" :
  "9df9c897af413505c02f158a7421b39000b40248a3bb826831ff458aee84f8ca",
  "vout" : 1, "address" : "mvDLEEymmEijZXyrrNRL3aPMhH8q2m8vE1",
  "account" : "From <a href="http://faucet.xeno-genesis.com/" rel="nofollow">http://faucet.xeno-genesis.com/</a>", "scriptPubKey" :
  "76a914a134b5919d09350f6232260ed1313f73ac6b7bae88ac", "amount" :
  1.19994817, "confirmations" : 364 } ]</p>
</blockquote>

<p>Then I could use this:</p>

<blockquote>
  <p>createrawtransaction
  '[{"txid":"d3be60aaf98ef888a9137928fa405806cd2e0c762f5205b3d9ba3e6ad26a5262","vout":1}]'
  '{"mxgxQ52kYRVPfLeYpXugkCAGhjLfUaZk3g":0.05,"mvDLEEymmEijZXyrrNRL3aPMhH8q2m8vE1":1.14974817
  }'</p>
</blockquote>

<p>But this "assumes" a 0.0002XBT fee.</p>

<p>I can then sign the transaction like so:</p>

<blockquote>
  <p>signrawtransaction
  '010000000162526ad26a3ebad9b305522f760c2ecd065840fa287913a988f88ef9aa60bed30100000000ffffffff02404b4c00000000001976a914bc5e62709adc296640dfed6871f0ebff5a7d11c588ac6160da06000000001976a914a134b5919d09350f6232260ed1313f73ac6b7bae88ac00000000'
  '[{"txid" :
  "d3be60aaf98ef888a9137928fa405806cd2e0c762f5205b3d9ba3e6ad26a5262","vout"
  : 1,"scriptPubKey" :
  "76a914a134b5919d09350f6232260ed1313f73ac6b7bae88ac"}]' '["private key
  here"]'</p>
</blockquote>

<p>Which gives me this:</p>

<blockquote>
  <p>010000000162526ad26a3ebad9b305522f760c2ecd065840fa287913a988f88ef9aa60bed3010000006b483045022100f447788e6b40a1f8bd22b084c8507a7710bd5c8cb33b08082c308a7a0edc86d402204024287053715bc096e56744e45683bb63b32ebe56a2f2070fd318216512641d012103ca4eab4b394090c9f4c10b6a9c2674dfc14c7dee55b6d3eb72c4263fc325c37effffffff02404b4c00000000001976a914bc5e62709adc296640dfed6871f0ebff5a7d11c588ac6160da06000000001976a914a134b5919d09350f6232260ed1313f73ac6b7bae88ac00000000</p>
</blockquote>

<p>Which is 452 bytes.</p>

<p>Apparently I am supposted count the number of inputs and outputs too?  I understand that the fee can get more complex based on the age of the transaction and if I send a very small amount.  But just for example purposes, How would I work out the transaction fee using the 2 public keys above if I wanted to send 0.05XBT? so I can subtract the fee from the change when using the <code>createrawtransaction</code> command in bitcoin-qt?</p>

<bitcoind><bitcoin-core><transaction-fees><raw-transaction>
Help me work out a transaction fee
oshirowanen
# Help me work out a transaction fee

(Asked by: username_0 on 2014-06-09)

I am having difficulty working out how to work out a transaction fee. I've read the theory, but don't understand how to get the values to put the theory to practice.

Can someone please help me work this out step by step? If I want to send 0.05XBT from: `mvDLEEymmEijZXyrrNRL3aPMhH8q2m8vE1` to `mxgxQ52kYRVPfLeYpXugkCAGhjLfUaZk3g`. How do I work out the transaction fee?

If your answer could use these public keys so I can try them out based on the instructions in your answer, I would really appreciate that.

Using bitcoin-qt's command line, I have the following details:

> listunspent [ { "txid" :
> "9df9c897af413505c02f158a7421b39000b40248a3bb826831ff458aee84f8ca",
> "vout" : 1, "address" : "mvDLEEymmEijZXyrrNRL3aPMhH8q2m8vE1",
> "account" : "From <http://faucet.xeno-genesis.com/>", "scriptPubKey" :
> "76a914a134b5919d09350f6232260ed1313f73ac6b7bae88ac", "amount" :
> 1.19994817, "confirmations" : 364 } ]

Then I could use this:

> createrawtransaction
> '[{"txid":"d3be60aaf98ef888a9137928fa405806cd2e0c762f5205b3d9ba3e6ad26a5262","vout":1}]'
> '{"mxgxQ52kYRVPfLeYpXugkCAGhjLfUaZk3g":0.05,"mvDLEEymmEijZXyrrNRL3aPMhH8q2m8vE1":1.14974817
> }'

But this "assumes" a 0.0002XBT fee.

I can then sign the transaction like so:

> signrawtransaction
> '010000000162526ad26a3ebad9b305522f760c2ecd065840fa287913a988f88ef9aa60bed30100000000ffffffff02404b4c00000000001976a914bc5e62709adc296640dfed6871f0ebff5a7d11c588ac6160da06000000001976a914a134b5919d09350f6232260ed1313f73ac6b7bae88ac00000000'
> '[{"txid" :
> "d3be60aaf98ef888a9137928fa405806cd2e0c762f5205b3d9ba3e6ad26a5262","vout"
> : 1,"scriptPubKey" :
> "76a914a134b5919d09350f6232260ed1313f73ac6b7bae88ac"}]' '["private key
> here"]'

Which gives me this:

> 010000000162526ad26a3ebad9b305522f760c2ecd065840fa287913a988f88ef9aa60bed3010000006b483045022100f447788e6b40a1f8bd22b084c8507a7710bd5c8cb33b08082c308a7a0edc86d402204024287053715bc096e56744e45683bb63b32ebe56a2f2070fd318216512641d012103ca4eab4b394090c9f4c10b6a9c2674dfc14c7dee55b6d3eb72c4263fc325c37effffffff02404b4c00000000001976a914bc5e62709adc296640dfed6871f0ebff5a7d11c588ac6160da06000000001976a914a134b5919d09350f6232260ed1313f73ac6b7bae88ac00000000

Which is 452 bytes.

Apparently I am supposted count the number of inputs and outputs too? I understand that the fee can get more complex based on the age of the transaction and if I send a very small amount. But just for example purposes, How would I work out the transaction fee using the 2 public keys above if I wanted to send 0.05XBT? so I can subtract the fee from the change when using the `createrawtransaction` command in bitcoin-qt?

**Tags:** bitcoind, bitcoin-core, transaction-fees, raw-transaction


---

## 1 answers

### Answer by username_1 on 2014-06-10. Score: 2

I can calculate the [priority](https://en.bitcoin.it/wiki/Transaction_fees#Technical_info) of the transaction (527 confirmations currently, ~452 bytes):

```
119994817 * 527 / 452 = 139,905,461

```

Since this is over the minimum of 57,600,000 and meets the other [rules for free transactions](https://en.bitcoin.it/wiki/Transaction_fees): namely, that the transaction is under 1000 bytes and has no outputs under 0.01 BTC, this transaction can be free. You do not need to include a transaction fee: make the sum of the outputs equal the input amount exactly.

If your transaction didn't meet the requirements for a free transaction, or if you don't wish it to be treated as a free transaction (which have some limits in transmitting, etc. that *might* slow down their inclusion in a block), you would need to include 0.0001 BTC transaction fee per thousand bytes (e.g. up to 1000 bytes is 0.0001, 1001-2000 bytes is 0.0002, etc.)

(this is assuming the testnet has the same rules for transaction fees as Bitcoin's mainnet)

> **Comments:**
> **username_0**: How about the number of inputs and outputs?  How do I get those values?  
> **username_1**: You already specified that when you said "If I want to send 0.05XBT from: mvDLEEymmEijZXyrrNRL3aPMhH8q2m8vE1 to mxgxQ52kYRVPfLeYpXugkCAGhjLfUaZk3g.". Since mvDLEE... only has one unspent output credited to it, you must have one input. And since you only want to give a portion of that to mxgx... you must have at least one change address. Unless you're adding unnecessary complexity, then, the number of inputs is 1 and the number of outputs is 2. In some cases, the transaction fee might change this, but this is a simple example.  

---

