jon_smark (OP)
Member
Offline
Activity: 90
Merit: 10
|
|
August 18, 2012, 11:47:46 AM |
|
I'm trying to get a good understanding of how Bitcoin works, and the combination of testnet + raw transactions is a wonderful platform for this! I do have some questions concerning the basics, so I'll describe how I reckon a simple transaction can be built, and I hope you'll correct me and/or answer some of my doubts.
Suppose that a past transaction with txid=aaaaaaaa gave 100 BTC to address m1111 on output vout=1. I now want to take these 100 BTC and give 90 BTC to address m2222, 9 BTC to address m3333, and pay the remaining 1 BTC as a transaction fee. These are the steps I think I need to do (in pseudo-code):
First I would need to create a raw transaction:
hex = createrawtransaction [{txid:aaaaaaaa,vout=1}] {m2222=90,m3333=9}
Now I need to sign the transaction. This is where I have a couple of doubts. First, in this simple example, the second parameter of signrawtransaction can be just an empty list, right? Second, what should the sighash parameter normally be?
priv = dumpprivkey m1111 hex2 = signrawtransaction hex [] priv ALL
Finally I can send the transaction:
txid = sendrawtransaction hex2
Is this all or am I missing something? (Thank you for your input!)
|
|
|
|
gmaxwell
Staff
Legendary
Offline
Activity: 4242
Merit: 8684
|
|
August 18, 2012, 09:40:19 PM |
|
I'm trying to get a good understanding of how Bitcoin works, and the combination of testnet + raw transactions is a wonderful platform for this! I do have some questions concerning the basics, so I'll describe how I reckon a simple transaction can be built, and I hope you'll correct me and/or answer some of my doubts. Suppose that a past transaction with txid=aaaaaaaa gave 100 BTC to address m1111 on output vout=1. I now want to take these 100 BTC and give 90 BTC to address m2222, 9 BTC to address m3333, and pay the remaining 1 BTC as a transaction fee. These are the steps I think I need to do (in pseudo-code): [...] Now I need to sign the transaction. This is where I have a couple of doubts. First, in this simple example, the second parameter of signrawtransaction can be just an empty list, right? Second, what should the sighash parameter normally be?
You've basically got it. You don't need to dump or provide the private key: Those parameters are optional— they're used for cases where the relevant keys aren't in your local wallet. Here are some quick walk-throughs I'm working on that use this api: https://people.xiph.org/~greg/escrowexample.txthttps://people.xiph.org/~greg/signdemo.txt
|
|
|
|
jon_smark (OP)
Member
Offline
Activity: 90
Merit: 10
|
|
August 19, 2012, 02:40:51 PM |
|
You've basically got it. You don't need to dump or provide the private key: Those parameters are optional— they're used for cases where the relevant keys aren't in your local wallet.
Thanks for the reply! Indeed, it seems it's even simpler than I thought at first!
|
|
|
|
Jouke
|
|
January 28, 2013, 10:21:42 PM |
|
my gratitude to both Very helpful topic posts
|
Koop en verkoop snel en veilig bitcoins via iDeal op Bitonic.nl
|
|
|
rlh
|
|
October 23, 2013, 06:42:25 PM |
|
Hey guys, I have a quick question. When executing "hex = createrawtransaction [{txid:aaaaaaaa,vout=1}] {m2222=90,m3333=9}", what is the correct value of vout? Is it always 1?
How do you build a rawtransaction from multiple inputs?
|
A Personal Quote on BTT from 2011: "I'd be willing to make a moderate "investment" if the value of the BTC went below $2.00. Otherwise I'll just have to live with my 5 BTC and be happy. :/" ...sigh. If only I knew.
|
|
|
dserrano5
Legendary
Offline
Activity: 1974
Merit: 1029
|
|
October 23, 2013, 07:27:30 PM |
|
Hey guys, I have a quick question. When executing "hex = createrawtransaction [{txid:aaaaaaaa,vout=1}] {m2222=90,m3333=9}", what is the correct value of vout? Is it always 1?
How do you build a rawtransaction from multiple inputs?
Transactions can (and usually do) have more than one output, and you need to specify the specific output you want to redeem in a given transaction. vout serves that purpose. It's 0-based.
|
|
|
|
|
rlh
|
|
October 23, 2013, 07:36:59 PM |
|
Thanks guys. This helps. However, I keep getting nasty "Error Parsing JSON" errors that don't tell me anything. Is there s specific format for the raw transaction details that I need to follow.
In my case, I'm using the bitcoind.exe file-- not a linux or Mac build.
|
A Personal Quote on BTT from 2011: "I'd be willing to make a moderate "investment" if the value of the BTC went below $2.00. Otherwise I'll just have to live with my 5 BTC and be happy. :/" ...sigh. If only I knew.
|
|
|
|
rlh
|
|
October 23, 2013, 08:47:39 PM |
|
Yes, thank you. I had just found that post (and hadn't read it) when I responded.
|
A Personal Quote on BTT from 2011: "I'd be willing to make a moderate "investment" if the value of the BTC went below $2.00. Otherwise I'll just have to live with my 5 BTC and be happy. :/" ...sigh. If only I knew.
|
|
|
DannyHamilton
Legendary
Offline
Activity: 3472
Merit: 4796
|
|
October 24, 2013, 12:02:07 AM |
|
I'm an expert? That's news to me. Let me know if I can help at all.
|
|
|
|
|