2
1
I am getting confused about the Bitcoin amount presentation in a raw transaction's "value" field.
If i want to spend 0.05 BTC, for instance, which of these is the correct value?
"value" : 0.05
"value" : 50000000
Or are both allowed?
It seems that bitcoin-cli sendfrom ... generates the former representation, and a quick check of some transactions on blockchain.info just showed transactions using the latter one.
I am currently following the example spend-p2sh-txout.py of python-bitcoinlib, in which a raw transaction is being created that uses the Satoshi representation.
Im my application, the following transaction is being created in the regtest mode, decoded via blockchain.info:
{
"lock_time":0,
"size":224,
"inputs":[
{
"prev_out":{
"index":0,
"hash":"bf7a52d8ddbc2faf3f110fe7aef4fb2ef68058ab607c381a098062bc2f53d613"
},
"script":"483045022100dbbcce4fcf6ff6af11c5c365fe736a01ed6808e3a7369f5a54285f3cf7b91b7002202bc38a8b7631d0749ec519d28ae87885a3881afc52b741aec55b8952bda81ef501410468d77eb31494cb851898661e8359f7388283317c7e79cf979af7c99c379a5a641cc476663d0e8a91c458f6c86fdd8b76e3db3e0e06ba0527748690fae4673b13"
}
],
"version":1,
"vin_sz":1,
"hash":"985ca8c35dd2e0bd4c583a3254352f740445fb0c19cca6922a3f71458ede6246",
"vout_sz":1,
"out":[
{
"script_string":"OP_DUP OP_HASH160 cadcdc47fcdbeeb3ad212b4a4657d7b4da759a82 OP_EQUALVERIFY OP_CHECKSIG",
"address":"1KVe5QTdQ4cXfqmtJBxqKQrei5zvCmRpWh",
"value":10000000,
"script":"76a914cadcdc47fcdbeeb3ad212b4a4657d7b4da759a8288ac"
}
]
}
This transaction is meant to simply relay the funds received by previous manual transaction created via bitcoin-cli -regtest sendfrom alice mtx3RXD3DVgc1BDSeHRFkSVcmSw8BfdbS2 0.1, where alice is an existing account. The transaction looks as follows:
{
"hex" : "01000000021fe8d299c9a91892895a7cf1bd03519cc41e37deb723e32abd4d54b089be361000000000494830450221008ea7e7ab056daf158561329f7879c4cddb6dce741be106572902d50aab9e1c110220531e3cbfd2491412d9ddc6f04c77d2e9153b8e76df3676cd1d40cd81700c723901ffffffff9745aa1ff0c8d4f9079e93a30c08ac85f3c1dc6870a2272c59e2915d05f76c40010000006b48304502210085a3a69fdb2242bea5b7fa2bb3889e2d0c04d80614cde72053ba0b63e0acef9c022068b04f769a67ce896c09b0c43efd2d53542a6530f51b0d5144bea06e8ffea98a01210222485cf467f5359416d5dcf20293adce14bd6039cffc246ae7d6f49f541ae3b6ffffffff0227d80f00000000001976a9147b441644e981eaa7b9acbb66ddd029540ae3771388ac80969800000000001976a914935850c4a25f44f4e057aa2109a885537056727288ac00000000",
"txid" : "bf7a52d8ddbc2faf3f110fe7aef4fb2ef68058ab607c381a098062bc2f53d613",
"version" : 1,
"locktime" : 0,
"vin" : [
{
"txid" : "1036be89b0544dbd2ae323b7de371ec49c5103bdf17c5a899218a9c999d2e81f",
"vout" : 0,
"scriptSig" : {
"asm" : "30450221008ea7e7ab056daf158561329f7879c4cddb6dce741be106572902d50aab9e1c110220531e3cbfd2491412d9ddc6f04c77d2e9153b8e76df3676cd1d40cd81700c723901",
"hex" : "4830450221008ea7e7ab056daf158561329f7879c4cddb6dce741be106572902d50aab9e1c110220531e3cbfd2491412d9ddc6f04c77d2e9153b8e76df3676cd1d40cd81700c723901"
},
"sequence" : 4294967295
},
{
"txid" : "406cf7055d91e2592c27a27068dcc1f385ac080ca3939e07f9d4c8f01faa4597",
"vout" : 1,
"scriptSig" : {
"asm" : "304502210085a3a69fdb2242bea5b7fa2bb3889e2d0c04d80614cde72053ba0b63e0acef9c022068b04f769a67ce896c09b0c43efd2d53542a6530f51b0d5144bea06e8ffea98a01 0222485cf467f5359416d5dcf20293adce14bd6039cffc246ae7d6f49f541ae3b6",
"hex" : "48304502210085a3a69fdb2242bea5b7fa2bb3889e2d0c04d80614cde72053ba0b63e0acef9c022068b04f769a67ce896c09b0c43efd2d53542a6530f51b0d5144bea06e8ffea98a01210222485cf467f5359416d5dcf20293adce14bd6039cffc246ae7d6f49f541ae3b6"
},
"sequence" : 4294967295
}
],
"vout" : [
{
"value" : 0.01038375,
"n" : 0,
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 7b441644e981eaa7b9acbb66ddd029540ae37713 OP_EQUALVERIFY OP_CHECKSIG",
"hex" : "76a9147b441644e981eaa7b9acbb66ddd029540ae3771388ac",
"reqSigs" : 1,
"type" : "pubkeyhash",
"addresses" : [
"mrkiyR5zrvxZtCucHYZTXfs3t2Kz9UNuVS"
]
}
},
{
"value" : 0.10000000,
"n" : 1,
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 935850c4a25f44f4e057aa2109a8855370567272 OP_EQUALVERIFY OP_CHECKSIG",
"hex" : "76a914935850c4a25f44f4e057aa2109a885537056727288ac",
"reqSigs" : 1,
"type" : "pubkeyhash",
"addresses" : [
"mtx3RXD3DVgc1BDSeHRFkSVcmSw8BfdbS2"
]
}
}
],
"blockhash" : "0000c177c89fab9ff7b59be7d38b61c94c3b8492a3633863c382fba73f0ede0c",
"confirmations" : 6,
"time" : 1420621337,
"blocktime" : 1420621337
}
The transaction created by my application is being rejected by my local bitcoind instance, debug.log says:
ERROR: CheckInputs() : 985ca8c35dd2e0bd4c583a3254352f740445fb0c19cca6922a3f71458ede6246 value in < value out
Right now, I am suspecting that the error is caused by the different representations, or am I missing another problem?
Thanks for the reply, but what about livenet transactions such as https://blockchain.info/rawtx/bb94762d6d2bbb3550b33940e2ae1f0d5c18604ec42e86f10c302ed93436e358. There, I see
– Rmn – 2015-01-07T12:32:22.187"value" : 2249930000, i.e., the Satoshi representation.@Rmn so that was actually a
blockchain.inforeply? I would suggest you usegetrawtransaction tx-id 1to perform this query and update your question and then maybe we can come up with a solution to your problem. – George Kimionis – 2015-01-07T12:39:02.997The problem is that I am not an active Bitcoin user, but still only developing on
testnetand inregtest, so I have no Blockchain file... would take quite long to obtain it now. I will check ontestnet, though, and update my question. – Rmn – 2015-01-07T12:42:53.460As for
regtest, the blockchain is generated on the fly so you don't really need to download anything else from other connected nodes (which, if any, should belong to you in any case). – George Kimionis – 2015-01-07T12:59:26.867Indeed, simply the parsing of raw transactions of
bitcoindvs.blockchain.infodiffers... So, I will rephrase my whole question. – Rmn – 2015-01-07T13:12:38.730