So if I want to send money from mvNAGP5nNef6MHfB6Tcu426MJboBqrwJZV to mvDLEEymmEijZXyrrNRL3aPMhH8q2m8vE1, I am not sure which txid to use from the output of getrawtransaction?
Should I use txid 3d01e3b94195808a866bd75cd5a9a3d1d6ee0385fdd20025aacb4215bb9117e2 or txid 860b46a942df6e82e5b89d1a18dc43743f94fa63bbbf464ce377592dee99e5d4. Also, do I use vout 0 or vout 1?
Lets take a look at the transaction that contains the output that you want to spend:
{
"hex" : "big long string of hex bytes, this is just the hex representation of the signed transaction",
"txid" : "3d01e3b94195808a866bd75cd5a9a3d1d6ee0385fdd20025aacb4215bb9117e2",
There you are. There's the transactionID of this transaction.
"version" : 1,
"locktime" : 0,
"vin" : [
{
"txid" : "860b46a942df6e82e5b89d1a18dc43743f94fa63bbbf464ce377592dee99e5d4",
See there? That "vin" followed by the square bracket? That indicates that all the stuff inside the set of square brackets are elements of an array of "inputs" into transactionID 3d01e3b94195808a866bd75cd5a9a3d1d6ee0385fdd20025aacb4215bb9117e2. In other words, 860b46a942df6e82e5b89d1a18dc43743f94fa63bbbf464ce377592dee99e5d4 is the transactionID of the previous output which was used as an input and SPENT already in the creation of transaction 3d01e3b94195808a866bd75cd5a9a3d1d6ee0385fdd20025aacb4215bb9117e2. Therefore, that output is no longer available for spending.
"vout" : 1,
And then that "vout" is an indication of which output from transactionID 860b46a942df6e82e5b89d1a18dc43743f94fa63bbbf464ce377592dee99e5d4 was being spent in transactionID 3d01e3b94195808a866bd75cd5a9a3d1d6ee0385fdd20025aacb4215bb9117e2.
"scriptSig" : {
"asm" : "big long string of hex bytes",
"hex" : "big long string of hex bytes, this is just the hex representation of the signature from when this output was spent"
},
"sequence" : 4294967295
}
],
And that's the end of the array of inputs to transactionID 3d01e3b94195808a866bd75cd5a9a3d1d6ee0385fdd20025aacb4215bb9117e2. In this case, the transaction only had the one input. Next comes the array of outputs (indicated with the tag "vout"). You are trying to spend one of these upcoming outputs.
"vout" : [
{
"value" : 0.57000000,
There's that 0.57 BTC output that you want to spend.
"n" : 0,
And theres the index indicating the offset to the output that you are trying to spend. So we see here that you are trying to spend "txid" : "3d01e3b94195808a866bd75cd5a9a3d1d6ee0385fdd20025aacb4215bb9117e2", "vout" : 0
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 a2e022d91aaceb732f138117d8ea142510d89eb3 OP_EQUALVERIFY OP_CHECKSIG",
"hex" : "76a914a2e022d91aaceb732f138117d8ea142510d89eb388ac",
And there's the scriptPubKey that you'll need to give the offline wallet so that it knows how to provide the appropriate signature.
"reqSigs" : 1,
"type" : "pubkeyhash",
"addresses" : [ "mvNAGP5nNef6MHfB6Tcu426MJboBqrwJZV" ]
Here we see that this 0.57 BTC output was sent to address mvNAGP5nNef6MHfB6Tcu426MJboBqrwJZV, which confirms for us that this is the output that you want.
}
},
And that ends that output. Next comes the 0.57974817 output with index 1.
{
"value" : 0.57974817,
"n" : 1,
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 546e2062ba7c72e2e2589e5ad89a4cbc35b595eb OP_EQUALVERIFY OP_CHECKSIG",
"hex" : "76a914546e2062ba7c72e2e2589e5ad89a4cbc35b595eb88ac",
"reqSigs" : 1,
"type" : "pubkeyhash",
"addresses" : [ "moDNytfZa69vc2Hz1ELjPaSJ2DheWiCjT6" ]
}
}
That's the end of the array of outputs. Next comes the closing bracket to indicate there are not more outputs, and a bit more info about the transaction itself (confirmations, time, block hash, etc)
],
"blockhash" : "000000007c6196cdb6969f3f0630da9da5df8c2e687510ce6e25f21ccbc99e0f",
"confirmations" : 275,
"time" : 1402603913,
"blocktime" : 1402603913
}