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:


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?

1 Answer 1


I can calculate the priority 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: 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)

  • How about the number of inputs and outputs? How do I get those values? Jun 10, 2014 at 18:29
  • 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.
    – Tim S.
    Jun 10, 2014 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.