Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: oshirowanen on June 07, 2014, 05:21:43 PM



Title: Getting error when using createrawtransaction
Post by: oshirowanen on June 07, 2014, 05:21:43 PM
Anyone know why the following command is not working for me in bitcoin-qt [testnet] > debug window > console?

createrawtransaction [{"txid":d3be60aaf98ef888a9137928fa405806cd2e0c762f5205b3d9ba3e6ad26a5262,"vout":1}]{mxgxQ52kYRVPfLeYpXugkCAGhjLfUaZk3g:0.05}

Error: Error parsing JSON:[{"txid":d3be60aaf98ef888a9137928fa405806cd2e0c762f5205b3d9ba3e6ad26a5262,"vout":1}]{mxgxQ52kYRVPfLeYpXugkCAGhjLfUaZk3g:0.05}

I got the txid and vout values from listunspent:

listunspent
[
{
"txid" : "d3be60aaf98ef888a9137928fa405806cd2e0c762f5205b3d9ba3e6ad26a5262",
"vout" : 1,
"address" : "mvDLEEymmEijZXyrrNRL3aPMhH8q2m8vE1",
"account" : "From http://faucet.xeno-genesis.com/",
"scriptPubKey" : "76a914a134b5919d09350f6232260ed1313f73ac6b7bae88ac",
"amount" : 1.25004817,
"confirmations" : 2
}
]


Title: Re: Getting error when using createrawtransaction
Post by: DannyHamilton on June 08, 2014, 12:37:04 AM
Anyone know why the following command is not working for me in bitcoin-qt [testnet] > debug window > console?

createrawtransaction [{"txid":d3be60aaf98ef888a9137928fa405806cd2e0c762f5205b3d9ba3e6ad26a5262,"vout":1}]{mxgxQ52kYRVPfLeYpXugkCAGhjLfUaZk3g:0.05}

Error: Error parsing JSON:[{"txid":d3be60aaf98ef888a9137928fa405806cd2e0c762f5205b3d9ba3e6ad26a5262,"vout":1}]{mxgxQ52kYRVPfLeYpXugkCAGhjLfUaZk3g:0.05}

I got the txid and vout values from listunspent:

listunspent
[
{
"txid" : "d3be60aaf98ef888a9137928fa405806cd2e0c762f5205b3d9ba3e6ad26a5262",
"vout" : 1,
"address" : "mvDLEEymmEijZXyrrNRL3aPMhH8q2m8vE1",
"account" : "From http://faucet.xeno-genesis.com/",
"scriptPubKey" : "76a914a134b5919d09350f6232260ed1313f73ac6b7bae88ac",
"amount" : 1.25004817,
"confirmations" : 2
}
]


Does this work?

Code:
createrawtransaction '[{"txid":"d3be60aaf98ef888a9137928fa405806cd2e0c762f5205b3d9ba3e6ad26a5262","vout":1}]' '{"mxgxQ52kYRVPfLeYpXugkCAGhjLfUaZk3g":0.05000000,"mvDLEEymmEijZXyrrNRL3aPMhH8q2m8vE1":1.19994817}'

???


Title: Re: Getting error when using createrawtransaction
Post by: oshirowanen on June 08, 2014, 08:17:16 AM
Does this work?

Code:
createrawtransaction '[{"txid":"d3be60aaf98ef888a9137928fa405806cd2e0c762f5205b3d9ba3e6ad26a5262","vout":1}]' '{"mxgxQ52kYRVPfLeYpXugkCAGhjLfUaZk3g":0.05000000,"mvDLEEymmEijZXyrrNRL3aPMhH8q2m8vE1":1.19994817}'

???

It does't return the JSON error which is a step forward.  Thanks!

Looks like I also missed out the change return address.  I have noticed that you worked out the change to be less by 0.0001BTC, which I assume goes towards fees?  If that is the case, how did you work out the fees?  Is it always 0.0001BTC?


Title: Re: Getting error when using createrawtransaction
Post by: Yuki1988 on June 08, 2014, 08:29:14 AM
I have noticed that you worked out the change to be less by 0.0001BTC, which I assume goes towards fees?

Yup, the difference between inputs and outputs will go towards tx fee. So, please never ever forget to include the change.

If that is the case, how did you work out the fees?  Is it always 0.0001BTC?

It depends on the tx size in KB (number of inputs and outputs).
For details, please refer to http://bitcoinfees.com/




Title: Re: Getting error when using createrawtransaction
Post by: oshirowanen on June 08, 2014, 08:45:40 AM
I have noticed that you worked out the change to be less by 0.0001BTC, which I assume goes towards fees?

Yup, the difference between inputs and outputs will go towards tx fee. So, please never ever forget to include the change.

If that is the case, how did you work out the fees?  Is it always 0.0001BTC?

It depends on the tx size in KB (number of inputs and outputs).
For details, please refer to http://bitcoinfees.com/




Thanks, based on http://bitcoinfees.com/, I didn't have to pay a fee in this particular case.  Is that correct?  As it says:

Quote from: bitcoinfees.com
f any of the outputs (including any change) of your transaction are less than 0.01 XBT, then a fee of 0.0001 XBT is required

So as I was sending 0.05XBT, the fee was optional.  Is that right?


Title: Re: Getting error when using createrawtransaction
Post by: Yuki1988 on June 08, 2014, 09:00:59 AM
based on http://bitcoinfees.com/, I didn't have to pay a fee in this particular case.  Is that correct?  As it says:

Quote from: bitcoinfees.com
f any of the outputs (including any change) of your transaction are less than 0.01 XBT, then a fee of 0.0001 XBT is required

So as I was sending 0.05XBT, the fee was optional.  Is that right?

You should continue reading section 3. :)
Quote
If the coins you're spending are too small or too new then your transaction won't qualify as free.

Basically speaking, if you transaction qualifies as "high-priority" (https://en.bitcoin.it/wiki/Transaction_fees#Technical_info) and have no dust outputs, you can choose to not pay any transaction fee.
It may take a little bit more time to get your transaction included in a block though.


Title: Re: Getting error when using createrawtransaction
Post by: oshirowanen on June 08, 2014, 09:18:21 AM
Thanks for all the help!


Title: Re: Getting error when using createrawtransaction
Post by: DannyHamilton on June 08, 2014, 07:39:02 PM
Yup, the difference between inputs and outputs will go towards tx fee. So, please never ever forget to include the change.

This is important enough, that it's worth repeating.

The inputs provide value to the transaction.  Add up all the value from all the inputs, and that is the total transaction value.

Then the outputs assign that value to one or more outputs.

Any remaining unassigned value is a transaction fee to the miners.



If the total of all your outputs is greater than the total value supplied by all your inputs, then you have an invalid transaction.

If the total of all your outputs is equal to the total value supplied by all your inputs, then you have a valid transaction that is not paying any fee.

If the total of all your outputs is less than the total value supplied by all your inputs, then ALL REMAINING UNASSIGNED VALUE BECOMES TRANSACTION FEES FOR THE MINERS.


Title: Re: Getting error when using createrawtransaction
Post by: ondratra on June 09, 2014, 12:14:01 AM
Yup, the difference between inputs and outputs will go towards tx fee. So, please never ever forget to include the change.

This is important enough, that it's worth repeating.

The inputs provide value to the transaction.  Add up all the value from all the inputs, and that is the total transaction value.

Then the outputs assign that value to one or more outputs.

Any remaining unassigned value is a transaction fee to the miners.



If the total of all your outputs is greater than the total value supplied by all your inputs, then you have an invalid transaction.

If the total of all your outputs is equal to the total value supplied by all your inputs, then you have a valid transaction that is not paying any fee.

If the total of all your outputs is less than the total value supplied by all your inputs, then ALL REMAINING UNASSIGNED VALUE BECOMES TRANSACTION FEES FOR THE MINERS.

Can I use 'sendmany' or any other API call for sending to multiple people(multiple outputs) but paying just one fee??? When I used sendmany I had to pay fee for every address specified. :(