5
4
Does createrawtransaction always use the following script?
scriptPubKey: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
scriptSig: <sig> <pubKey>
If so, how do you create a transaction that uses a custom scriptPubKey value? If not, what is the syntax for writing the JSON that enables custom scriptPubKey values for the transaction using createrawtransaction?
I have a good idea of how the stack works, and I don't want to use an external site to create my transactions. I'm assuming brainwallet is open source and I can view how they modify the
scriptPubKeythere? There is no way to simply write{address:amount,scriptPubKey:stuffhere}in the second field ofcreaterawtransaction? – bvpx – 2013-10-21T17:51:57.377Also, what does "Yes, that's correct" refer to? – bvpx – 2013-10-21T17:54:31.877
about createrawtransaction, yes that's correct, it only uses the basic script. about trusting an external site... you dont, its only for convenience... you should always check with decoderawtransaction that it will do what you really want – Jonas Oestman – 2013-10-21T18:02:20.060
It's not about trust, I want to learn how to do it myself, I guess at this point the best way is to read the sourcecode of brainwallet and understand how they are doing it. Unless there is documentation somewhere outlining the process. – bvpx – 2013-10-21T18:47:45.570
brainwallet is only one implementation of how to make a raw transaction, here you can learn about the raw hex and what every bit means https://en.bitcoin.it/wiki/Protocol_specification#tx
– Jonas Oestman – 2013-10-21T20:23:58.610Okay, so I would construct a raw transaction using that specification, then sign it and send it with bitcoind after I am sure the data is correct using
decoderawtransaction? – bvpx – 2013-10-21T20:32:45.823Yes that is exactly right! You can check an already signed transaction with signrawtransaction with empty arguments like so [] [], and if all is good it will respond with the same raw transaction and complete:true – Jonas Oestman – 2013-10-21T21:37:19.577
I'm a bit confused about the transaction header. I've dug up some raw transactions I've signed previously with
createrawtransactionthensignrawtransaction, I am finding that the first 4 bytes are always the same (as expected). However the next 12 bytes that represent the "tx command" are different. How is that possible? Also, what exactly is the 4 byte payload checksum, and how is it derived? – bvpx – 2013-10-21T21:50:39.420The transaction starts with 01 00 00 00, so you dont need to care about how the transaction is broadcasted and how the payload checksum is calculated or why
– Jonas Oestman – 2013-10-21T22:26:33.560Sorry to keep this thread going, but... what do you mean "I don't need to care"? If I'm writing this entire transaction by hand, how do I know what to write for those bits? You're saying I can write anything there and it will be fine? It's extremely frustrating to try to learn this protocol because the documentation is very poor. – bvpx – 2013-10-21T22:30:57.963
Are you going to create software that can broadcast your transaction to the bitcoin network? If you are, go to the github repository. If you will use sendrawtransaction from bitcoin-qt or bitcoind, then you do not need to use the Message header.
– Jonas Oestman – 2013-10-22T00:44:02.537Something is very unclear to me: if I can't use
createrawtransactionto write a transaction with a custom script, how do I build the raw transaction that I eventually sign and broadcast withsendrawtransaction? – bvpx – 2013-10-22T04:46:48.883Your script need to collect "prev_outputs" that you know you can sign later. Then create a JSON transaction. Convert that JSON to a raw hex transaction and sign it with signrawtransaction (or you can write your own code). I found how you can send it with python
– Jonas Oestman – 2013-10-22T05:51:33.913I mean, I know how to create a standard raw transaction with
createrawtransaction, sign it and broadcast it. My question refers to adding custom OPcodes to thescriptPubKey, if I can't do that withcreaterawtransactionthen how is it done? I want to create this transaction however possible then send it with regular bitcoind. – bvpx – 2013-10-22T06:00:51.320createrawtransaction is only a first step, to be able to play around with transactions. I don't think they will ever add the ability to do custom OPcodes. I want the same thing, make transactions by code, but I dont know how. Ask at bitcointalk – Jonas Oestman – 2013-10-22T06:11:01.430