Bitcoin Forum
April 24, 2024, 10:49:34 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Cold signing a transaction using bitcoin-qt  (Read 2582 times)
oshirowanen (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 10


View Profile
June 13, 2014, 08:39:06 PM
 #1

I'm trying to learn how to sign an offline transaction using bitcoin-qt. I understand armory and electum make such actions easy, so using those wouldn't really help me "learn" how to do such a cold transaction using bitcoin-qt. Just in-case anyone asks. Smiley

If my cold wallet (bitcoin-qt) does not have the full block chain, how do I figure out the scriptPubKey?
1713998974
Hero Member
*
Offline Offline

Posts: 1713998974

View Profile Personal Message (Offline)

Ignore
1713998974
Reply with quote  #2

1713998974
Report to moderator
1713998974
Hero Member
*
Offline Offline

Posts: 1713998974

View Profile Personal Message (Offline)

Ignore
1713998974
Reply with quote  #2

1713998974
Report to moderator
1713998974
Hero Member
*
Offline Offline

Posts: 1713998974

View Profile Personal Message (Offline)

Ignore
1713998974
Reply with quote  #2

1713998974
Report to moderator
Activity + Trust + Earned Merit == The Most Recognized Users on Bitcointalk
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713998974
Hero Member
*
Offline Offline

Posts: 1713998974

View Profile Personal Message (Offline)

Ignore
1713998974
Reply with quote  #2

1713998974
Report to moderator
DeathAndTaxes
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
June 13, 2014, 11:08:01 PM
 #2

You don't.  You create the tx on the hot wallet but don't sign it.  In Bitcoin-core the only way to do that is with RPC call (CreateRawTransaction).  The output will be a hex string which is the unsigned version of the tx.  You transfer that to the cold wallet, sign it (SignRawTransaction), and the output will be a signed copy of the same tx.  You transfer that back to the hot wallet and send it to the network (SendRawTransaction).
dexX7
Legendary
*
Offline Offline

Activity: 1106
Merit: 1024



View Profile WWW
June 14, 2014, 11:33:53 AM
Last edit: June 14, 2014, 12:17:57 PM by dexX7
Merited by DarkStar_ (4), hatshepsut93 (1)
 #3

If my cold wallet (bitcoin-qt) does not have the full block chain, how do I figure out the scriptPubKey?

This seems trivial, just write it down or save it otherwise. If you want to spend outputs of transactions which you create yourself, you already have everything you need: txid, vout#, scripts. The Core client provides the following commands which can be helpful to get the data from raw transactions or (on an online machine) from the blockchain: "decoderawtransaction", "getrawtransaction" or "gettxout". Most block explorers such as blockchain.info display scripts and other stuff, too.

Some general information which may be useful to others who like to sign transactions with an unsynchronized client:

Transaction inputs are references to outputs of other transactions and when you sign a transaction, those references are replaced by the referenced data. An offline client usually has no clue about any transaction and therefore also no idea what you actually like to sign, therefore you need to provide the scriptPubKey(s) explicitly.

I'm going to use bitcoind via command line to demonstrate the whole process. Leave out all "./bitcoind", if you use the -Qt client's debug console which can be opened via "Help" - "Debug window" - "Console".

Say I want to spend some testnet coins associated with n4EmA9R4VmxLnxu9G8yZMDxvBBha8bUtEQ. I need to know which outputs can be spent and to get a list of unspent outputs with at least 1 and at most 9999999 confirmations:

Code:
./bitcoind listunspent 1 9999999 '["n4EmA9R4VmxLnxu9G8yZMDxvBBha8bUtEQ"']

[{
  "txid": "77d35b87d1ad549011b66dbb06ec7b6d84b06325ee9c18cf6f3467e9b7a7bda2",
  "vout": 0,
  "address": "n4EmA9R4VmxLnxu9G8yZMDxvBBha8bUtEQ",
  "account": "",
  "scriptPubKey": "76a914f93af105187d21ed6adfa5d71bfada7d7324e53c88ac",
  "amount": 1.90978096,
  "confirmations": 233
}]

Txid and vout are used to create a raw transaction:

Code:
./bitcoind createrawtransaction '[{"txid" : "77d35b87d1ad549011b66dbb06ec7b6d84b06325ee9c18cf6f3467e9b7a7bda2","vout":0}]' '{"n4EmA9R4VmxLnxu9G8yZMDxvBBha8bUtEQ":1.90968096}'

0100000001a2bda7b7e967346fcf189cee2563b0846d7bec06bb6db6119054add1875bd3770000000000ffffffff0120f1610b000000001976a914f93af105187d21ed6adfa5d71bfada7d7324e53c88ac00000000

Some details about this unsigned transaction:

Code:
./bitcoind decoderawtransaction 0100000001a2bda7b7e967346fcf189cee2563b0846d7bec06bb6db6119054add1875bd3770000000000ffffffff0120f1610b000000001976a914f93af105187d21ed6adfa5d71bfada7d7324e53c88ac00000000

{
  "txid": "e8ecde1d813f320a96ed34f7791e9f62fc86070d5d96b881397285ddbebd7fff",
  "version": 1,
  "locktime": 0,
  "vin": [{
    "txid": "77d35b87d1ad549011b66dbb06ec7b6d84b06325ee9c18cf6f3467e9b7a7bda2",
    "vout": 0,
    "scriptSig": {
      "asm": "",
      "hex": ""
    },
    "sequence": 4294967295
  }],
  "vout": [{
    "value": 1.90968096,
    "n": 0,
    "scriptPubKey": {
      "asm": "OP_DUP OP_HASH160 f93af105187d21ed6adfa5d71bfada7d7324e53c OP_EQUALVERIFY OP_CHECKSIG",
      "hex": "76a914f93af105187d21ed6adfa5d71bfada7d7324e53c88ac",
      "reqSigs": 1,
      "type": "pubkeyhash",
      "addresses": [
        "n4EmA9R4VmxLnxu9G8yZMDxvBBha8bUtEQ"
      ]
    }
  }]
}

What's important is the scriptPubKey of the output that I try to spend. This is "76a914f93af105187d21ed6adfa5d71bfada7d7324e53c88ac" in this case. The hex of the raw transaction, txid and vout# of the output to spent as well as the private key to sign the transaction are also required.

This data is used on an offline machine to sign the transaction:

Code:
./bitcoind signrawtransaction 0100000001a2bda7b7e967346fcf189cee2563b0846d7bec06bb6db6119054add1875bd3770000000000ffffffff0120f1610b000000001976a914f93af105187d21ed6adfa5d71bfada7d7324e53c88ac00000000 '[{"txid":"77d35b87d1ad549011b66dbb06ec7b6d84b06325ee9c18cf6f3467e9b7a7bda2","vout":0,"scriptPubKey":"76a914f93af105187d21ed6adfa5d71bfada7d7324e53c88ac"}]' '["cSf2Lcme2kSpkZ1s5AW8a2K2Y41P8HYGoXAevNzPUna6iXDw9boC"]'

{
  "hex": "0100000001a2bda7b7e967346fcf189cee2563b0846d7bec06bb6db6119054add1875bd377000000006a4730440220528e92bc890b362efcab0ab1af0f9427d501909be59fe22dbdb4c26eac17418102206eb9c83360ad46c9f17be32ea15a08d2765a934e08ce6f2578b3379bbfa03afd0121024451fc7d9e271fab77265bd0292fc274ee231e7ecc076bf6269999c0cbbf9f90ffffffff0120f1610b000000001976a914f93af105187d21ed6adfa5d71bfada7d7324e53c88ac00000000",
  "complete": true
}

Back on my online machine I broadcast the signed transaction:

Code:
./bitcoind sendrawtransaction 0100000001a2bda7b7e967346fcf189cee2563b0846d7bec06bb6db6119054add1875bd377000000006a4730440220528e92bc890b362efcab0ab1af0f9427d501909be59fe22dbdb4c26eac17418102206eb9c83360ad46c9f17be32ea15a08d2765a934e08ce6f2578b3379bbfa03afd0121024451fc7d9e271fab77265bd0292fc274ee231e7ecc076bf6269999c0cbbf9f90ffffffff0120f1610b000000001976a914f93af105187d21ed6adfa5d71bfada7d7324e53c88ac00000000

d1432ed0ea9409bea9bf4aaea8752d76a8708b3f6c10231879b4871e423cac92

... and fetch it once more, just for the sake of getting some data which includes the scriptPubKey:

Code:
./bitcoind getrawtransaction d1432ed0ea9409bea9bf4aaea8752d76a8708b3f6c10231879b4871e423cac92 1

{
  "hex": "0100000001a2bda7b7e967346fcf189cee2563b0846d7bec06bb6db6119054add1875bd377000000006a4730440220528e92bc890b362efcab0ab1af0f9427d501909be59fe22dbdb4c26eac17418102206eb9c83360ad46c9f17be32ea15a08d2765a934e08ce6f2578b3379bbfa03afd0121024451fc7d9e271fab77265bd0292fc274ee231e7ecc076bf6269999c0cbbf9f90ffffffff0120f1610b000000001976a914f93af105187d21ed6adfa5d71bfada7d7324e53c88ac00000000",
  "txid": "d1432ed0ea9409bea9bf4aaea8752d76a8708b3f6c10231879b4871e423cac92",
  "version": 1,
  "locktime": 0,
  "vin": [{
    "txid": "77d35b87d1ad549011b66dbb06ec7b6d84b06325ee9c18cf6f3467e9b7a7bda2",
    "vout": 0,
    "scriptSig": {
      "asm": "30440220528e92bc890b362efcab0ab1af0f9427d501909be59fe22dbdb4c26eac17418102206eb9c83360ad46c9f17be32ea15a08d2765a934e08ce6f2578b3379bbfa03afd01 024451fc7d9e271fab77265bd0292fc274ee231e7ecc076bf6269999c0cbbf9f90",
      "hex": "4730440220528e92bc890b362efcab0ab1af0f9427d501909be59fe22dbdb4c26eac17418102206eb9c83360ad46c9f17be32ea15a08d2765a934e08ce6f2578b3379bbfa03afd0121024451fc7d9e271fab77265bd0292fc274ee231e7ecc076bf6269999c0cbbf9f90"
    },
    "sequence": 4294967295
  }],
  "vout": [{
    "value": 1.90968096,
    "n": 0,
    "scriptPubKey": {
      "asm": "OP_DUP OP_HASH160 f93af105187d21ed6adfa5d71bfada7d7324e53c OP_EQUALVERIFY OP_CHECKSIG",
      "hex": "76a914f93af105187d21ed6adfa5d71bfada7d7324e53c88ac",
      "reqSigs": 1,
      "type": "pubkeyhash",
      "addresses": [
        "n4EmA9R4VmxLnxu9G8yZMDxvBBha8bUtEQ"
      ]
    }
  }]
}

To get information of the (unspent) output of this new transaction:

Code:
./bitcoind gettxout d1432ed0ea9409bea9bf4aaea8752d76a8708b3f6c10231879b4871e423cac92 0

{
  "bestblock": "0000000039ba07b3b39ef2c7b31a9942fb1d44528cf654e1ea956a9fdbc191b6",
  "confirmations": 0,
  "value": 1.90968096,
  "scriptPubKey": {
    "asm": "OP_DUP OP_HASH160 f93af105187d21ed6adfa5d71bfada7d7324e53c OP_EQUALVERIFY OP_CHECKSIG",
    "hex": "76a914f93af105187d21ed6adfa5d71bfada7d7324e53c88ac",
    "reqSigs": 1,
    "type": "pubkeyhash",
    "addresses": [
      "n4EmA9R4VmxLnxu9G8yZMDxvBBha8bUtEQ"
    ]
  },
  "version": 1,
  "coinbase": false
}

oshirowanen (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 10


View Profile
June 14, 2014, 01:02:50 PM
 #4

What have I done wrong?

From a hot wallet, I start off by executing listunspent
listunspent
[
{
"txid" : "3d01e3b94195808a866bd75cd5a9a3d1d6ee0385fdd20025aacb4215bb9117e2",
"vout" : 1,
"address" : "moDNytfZa69vc2Hz1ELjPaSJ2DheWiCjT6",
"scriptPubKey" : "76a914546e2062ba7c72e2e2589e5ad89a4cbc35b595eb88ac",
"amount" : 0.57974817,
"confirmations" : 223
}
]

So basically I want to send to a hot wallet public key (mvDLEEymmEijZXyrrNRL3aPMhH8q2m8vE1) from cold wallet public key (mvNAGP5nNef6MHfB6Tcu426MJboBqrwJZV). The cold wallet only has 0.57 - 0.0001 fee = send 0.5699, which means the cold wallet will be empty if the transaction is successful, so no change address needed I guess?  Therefore, I run the following from the hot wallet:
createrawtransaction '[{"txid":"3d01e3b94195808a866bd75cd5a9a3d1d6ee0385fdd20025aacb4215bb9117e2","vout":1}]' '{"mvDLEEymmEijZXyrrNRL3aPMhH8q2m8vE1":0.5699
}'

Which in-turn returned the following value. 0100000001e21791bb1542cbaa2500d2fd8503eed6d1a3a9d55cd76b868a809541b9e3013d01000 00000ffffffff0130996503000000001976a914a134b5919d09350f6232260ed1313f73ac6b7bae 88ac00000000

Then from the cold wallet, I get the private key:
dumpprivkey mvNAGP5nNef6MHfB6Tcu426MJboBqrwJZV

And I try to sign the transaction from the cold wallet
signrawtransaction '0100000001e21791bb1542cbaa2500d2fd8503eed6d1a3a9d55cd76b868a809541b9e3013d01000 00000ffffffff0130996503000000001976a914a134b5919d09350f6232260ed1313f73ac6b7bae 88ac00000000'  '[{"txid" : "3d01e3b94195808a866bd75cd5a9a3d1d6ee0385fdd20025aacb4215bb9117e2","vout" : 1,"scriptPubKey" : "76a914546e2062ba7c72e2e2589e5ad89a4cbc35b595eb88ac"}]' '["mvNAGP5nNef6MHfB6Tcu426MJboBqrwJZV's private key here"]'

but it returns:
{
"hex" : "0100000001e21791bb1542cbaa2500d2fd8503eed6d1a3a9d55cd76b868a809541b9e3013d01000 00000ffffffff0130996503000000001976a914a134b5919d09350f6232260ed1313f73ac6b7bae 88ac00000000",
"complete" : false
}

What am I doing wrong?
justusranvier
Legendary
*
Offline Offline

Activity: 1400
Merit: 1009



View Profile
June 14, 2014, 02:11:13 PM
 #5

What am I doing wrong?
You're trying to do raw transactions yourself instead of just using Armory.
oshirowanen (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 10


View Profile
June 14, 2014, 03:49:52 PM
 #6

What am I doing wrong?
You're trying to do raw transactions yourself instead of just using Armory.

Bitcoin-qt / raw transactions are my only choice because I have tried both armory and electrum and I can't get them to work on my computer.  Plus, having read all the theory about raw transactions, I am trying to put theory into practice for educational purposes, so using armory won't help in this case.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3374
Merit: 4606



View Profile
June 14, 2014, 03:53:08 PM
 #7

What have I done wrong?

From a hot wallet, I start off by executing listunspent
listunspent
[
{
"txid" : "3d01e3b94195808a866bd75cd5a9a3d1d6ee0385fdd20025aacb4215bb9117e2",
"vout" : 1,
"address" : "moDNytfZa69vc2Hz1ELjPaSJ2DheWiCjT6",
"scriptPubKey" : "76a914546e2062ba7c72e2e2589e5ad89a4cbc35b595eb88ac",
"amount" : 0.57974817,
"confirmations" : 223
}
]

So basically I want to send to a hot wallet public key (mvDLEEymmEijZXyrrNRL3aPMhH8q2m8vE1) from cold wallet public key (mvNAGP5nNef6MHfB6Tcu426MJboBqrwJZV).


You are mistaken.  That unspent output was received at moDNytfZa69vc2Hz1ELjPaSJ2DheWiCjT6 (not at mvNAGP5nNef6MHfB6Tcu426MJboBqrwJZV).  See where it says "address" in the output?

The cold wallet only has 0.57 - 0.0001 fee = send 0.5699, which means the cold wallet will be empty if the transaction is successful, so no change address needed I guess?

You are mistaken.  The output is 0.57974817 BTC.  If you send 0.57 and include a 0.0001 fee, then there will be 0.00964817 BTC change.  If you do not send this change to an address, then the fee will be 0.00974817 BTC.

Therefore, I run the following from the hot wallet:
createrawtransaction '[{"txid":"3d01e3b94195808a866bd75cd5a9a3d1d6ee0385fdd20025aacb4215bb9117e2","vout":1}]' '{"mvDLEEymmEijZXyrrNRL3aPMhH8q2m8vE1":0.5699
}'

Which in-turn returned the following value. 0100000001e21791bb1542cbaa2500d2fd8503eed6d1a3a9d55cd76b868a809541b9e3013d01000 00000ffffffff0130996503000000001976a914a134b5919d09350f6232260ed1313f73ac6b7bae 88ac00000000

So that seemed to work.

Then from the cold wallet, I get the private key:
dumpprivkey mvNAGP5nNef6MHfB6Tcu426MJboBqrwJZV

Wrong private key.  You needed to run:

Code:
dumpprivkey moDNytfZa69vc2Hz1ELjPaSJ2DheWiCjT6

And I try to sign the transaction from the cold wallet
signrawtransaction '0100000001e21791bb1542cbaa2500d2fd8503eed6d1a3a9d55cd76b868a809541b9e3013d01000 00000ffffffff0130996503000000001976a914a134b5919d09350f6232260ed1313f73ac6b7bae 88ac00000000'  '[{"txid" : "3d01e3b94195808a866bd75cd5a9a3d1d6ee0385fdd20025aacb4215bb9117e2","vout" : 1,"scriptPubKey" : "76a914546e2062ba7c72e2e2589e5ad89a4cbc35b595eb88ac"}]' '["mvNAGP5nNef6MHfB6Tcu426MJboBqrwJZV's private key here"]'

but it returns:
{
"hex" : "0100000001e21791bb1542cbaa2500d2fd8503eed6d1a3a9d55cd76b868a809541b9e3013d01000 00000ffffffff0130996503000000001976a914a134b5919d09350f6232260ed1313f73ac6b7bae 88ac00000000",
"complete" : false
}

What am I doing wrong?

You're using the wrong private key.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3374
Merit: 4606



View Profile
June 14, 2014, 03:55:14 PM
 #8

What am I doing wrong?
You're trying to do raw transactions yourself instead of just using Armory.

Bitcoin-qt / raw transactions are my only choice because I have tried both armory and electrum and I can't get them to work on my computer.  Plus, having read all the theory about raw transactions, I am trying to put theory into practice for educational purposes, so using armory won't help in this case.

You are playing with this on testnet, right?

Attempting to learn how to use raw transactions on the real bitcoin network is a great way to lose money.
justusranvier
Legendary
*
Offline Offline

Activity: 1400
Merit: 1009



View Profile
June 14, 2014, 04:01:13 PM
 #9

Bitcoin-qt / raw transactions are my only choice because I have tried both armory and electrum and I can't get them to work on my computer.  Plus, having read all the theory about raw transactions, I am trying to put theory into practice for educational purposes, so using armory won't help in this case.
If you can't get Armory working, why would you expect raw transactions to be easier/safer?

You're just exponentially increasing the odds that you'll permanently lose Bitcoins.
oshirowanen (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 10


View Profile
June 14, 2014, 04:02:18 PM
 #10

Bitcoin-qt / raw transactions are my only choice because I have tried both armory and electrum and I can't get them to work on my computer.  Plus, having read all the theory about raw transactions, I am trying to put theory into practice for educational purposes, so using armory won't help in this case.
If you can't get Armory working, why would you expect raw transactions to be easier/safer?

You're just exponentially increasing the odds that you'll permanently lose Bitcoins.

I'm testing on testnet.  Plus, I have filed a report with the armory devs, and as soon as they reply back, I'll give it another go.  However, that will not solve the problem of "learning" how to do raw transactions.
oshirowanen (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 10


View Profile
June 14, 2014, 04:15:39 PM
 #11


You are mistaken.  That unspent output was received at moDNytfZa69vc2Hz1ELjPaSJ2DheWiCjT6 (not at mvNAGP5nNef6MHfB6Tcu426MJboBqrwJZV).  See where it says "address" in the output?

Wrong private key.  You needed to run:

Code:
dumpprivkey moDNytfZa69vc2Hz1ELjPaSJ2DheWiCjT6


THanks, going to try again.
oshirowanen (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 10


View Profile
June 14, 2014, 04:21:57 PM
 #12

You are playing with this on testnet, right?

Attempting to learn how to use raw transactions on the real bitcoin network is a great way to lose money.

Yes, I'm using testnet. Smiley

I think testnet pubkeys start with m and they start with 1 (or 3 if using multisig) on the real network?
oshirowanen (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 10


View Profile
June 14, 2014, 07:08:26 PM
 #13

Say I want to spend some testnet coins associated with n4EmA9R4VmxLnxu9G8yZMDxvBBha8bUtEQ. I need to know which outputs can be spent and to get a list of unspent outputs with at least 1 and at most 9999999 confirmations:

Code:
./bitcoind listunspent 1 9999999 '["n4EmA9R4VmxLnxu9G8yZMDxvBBha8bUtEQ"']

[{
  "txid": "77d35b87d1ad549011b66dbb06ec7b6d84b06325ee9c18cf6f3467e9b7a7bda2",
  "vout": 0,
  "address": "n4EmA9R4VmxLnxu9G8yZMDxvBBha8bUtEQ",
  "account": "",
  "scriptPubKey": "76a914f93af105187d21ed6adfa5d71bfada7d7324e53c88ac",
  "amount": 1.90978096,
  "confirmations": 233
}]

I want to send testnet bitcoin from mvNAGP5nNef6MHfB6Tcu426MJboBqrwJZV which has 0.57 TBTC http://tbtc.blockr.io/address/info/mvNAGP5nNef6MHfB6Tcu426MJboBqrwJZV.  This is a public key for cold storage wallet.

So if I run listunspent, all I get is:

Code:
listunspent 1 9999999 '["mvNAGP5nNef6MHfB6Tcu426MJboBqrwJZV"']
[
]

Why is that?

I get the same result from both hot and cold wallets via bitcoin core.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3374
Merit: 4606



View Profile
June 14, 2014, 07:35:36 PM
 #14

I want to send testnet bitcoin from mvNAGP5nNef6MHfB6Tcu426MJboBqrwJZV which has 0.57 TBTC http://tbtc.blockr.io/address/info/mvNAGP5nNef6MHfB6Tcu426MJboBqrwJZV.  This is a public key for cold storage wallet.

So if I run listunspent, all I get is:

Code:
listunspent 1 9999999 '["mvNAGP5nNef6MHfB6Tcu426MJboBqrwJZV"']
[
]

Why is that?

I get the same result from both hot and cold wallets via bitcoin core.

I can't be certain without looking at the wallet, but I suspect that the reason is that the hot wallet doesn't have the mvNAGP5nNef6MHfB6Tcu426MJboBqrwJZV address, so it doesn't recognize the output as being spendable by that hot wallet.  I also suspect that the cold wallet isn't synchronized and therefore doesn't know about the existence of the output.

Try this on each wallet:

Code:
validateaddress mvNAGP5nNef6MHfB6Tcu426MJboBqrwJZV

I suspect the hot wallet will return:
"ismine" : false,

And the cold wallet may (or may not) return:
"ismine" : true,

To get the scriptPubKey from the output you're trying to spend, you'd probably be better off running:

Code:
getrawtransaction 3d01e3b94195808a866bd75cd5a9a3d1d6ee0385fdd20025aacb4215bb9117e2

on the hot wallet.  Then run decoderawtransaction on the output from that.

You should find the "hex" scriptPubKey in the output.  Of course, getrawtransaction will only work on the hot wallet if you have txindex=1 in the bitcoin.conf file and have re-indexed the blockchain.

oshirowanen (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 10


View Profile
June 14, 2014, 07:53:05 PM
Last edit: June 14, 2014, 10:53:33 PM by oshirowanen
 #15

Code:
getrawtransaction 3d01e3b94195808a866bd75cd5a9a3d1d6ee0385fdd20025aacb4215bb9117e2

I get:

Code:
getrawtransaction 3d01e3b94195808a866bd75cd5a9a3d1d6ee0385fdd20025aacb4215bb9117e2 1
{
"hex" : "0100000001d4e599ee2d5977e34c46bfbb63fa943f7443dc181a9db8e5826edf42a9460b86010000006b48304502210081e422796a3c36a2cdf66f97627858f727312357b266349d420d69ae9c8e579402202239de042d594f40dab157dffa0696698e6c10fbc6ee757f695f5735f4187a00012103ca4eab4b394090c9f4c10b6a9c2674dfc14c7dee55b6d3eb72c4263fc325c37effffffff0240c06503000000001976a914a2e022d91aaceb732f138117d8ea142510d89eb388ac21a07403000000001976a914546e2062ba7c72e2e2589e5ad89a4cbc35b595eb88ac00000000",
"txid" : "[b]3d01e3b94195808a866bd75cd5a9a3d1d6ee0385fdd20025aacb4215bb9117e2[/b]",
"version" : 1,
"locktime" : 0,
"vin" : [
{
"txid" : "[b]860b46a942df6e82e5b89d1a18dc43743f94fa63bbbf464ce377592dee99e5d4[/b]",
"vout" : 1,
"scriptSig" : {
"asm" : "304502210081e422796a3c36a2cdf66f97627858f727312357b266349d420d69ae9c8e579402202239de042d594f40dab157dffa0696698e6c10fbc6ee757f695f5735f4187a0001 03ca4eab4b394090c9f4c10b6a9c2674dfc14c7dee55b6d3eb72c4263fc325c37e",
"hex" : "48304502210081e422796a3c36a2cdf66f97627858f727312357b266349d420d69ae9c8e579402202239de042d594f40dab157dffa0696698e6c10fbc6ee757f695f5735f4187a00012103ca4eab4b394090c9f4c10b6a9c2674dfc14c7dee55b6d3eb72c4263fc325c37e"
},
"sequence" : 4294967295
}
],
"vout" : [
{
"value" : 0.57000000,
"n" : [b]0[/b],
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 a2e022d91aaceb732f138117d8ea142510d89eb3 OP_EQUALVERIFY OP_CHECKSIG",
"hex" : "[b]76a914a2e022d91aaceb732f138117d8ea142510d89eb388ac[/b]",
"reqSigs" : 1,
"type" : "pubkeyhash",
"addresses" : [
"mvNAGP5nNef6MHfB6Tcu426MJboBqrwJZV"
]
}
},
{
"value" : 0.57974817,
"n" : [b]1[/b],
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 546e2062ba7c72e2e2589e5ad89a4cbc35b595eb OP_EQUALVERIFY OP_CHECKSIG",
"hex" : "[b]76a914546e2062ba7c72e2e2589e5ad89a4cbc35b595eb88ac[/b]",
"reqSigs" : 1,
"type" : "pubkeyhash",
"addresses" : [
"moDNytfZa69vc2Hz1ELjPaSJ2DheWiCjT6"
]
}
}
],
"blockhash" : "000000007c6196cdb6969f3f0630da9da5df8c2e687510ce6e25f21ccbc99e0f",
"confirmations" : 275,
"time" : 1402603913,
"blocktime" : 1402603913
}

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?
DannyHamilton
Legendary
*
Offline Offline

Activity: 3374
Merit: 4606



View Profile
June 15, 2014, 03:06:44 AM
 #16

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:

Quote
{
    "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.

Quote
    "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.

Quote
            "vout" : 1,

And then that "vout" is an indication of which output from transactionID 860b46a942df6e82e5b89d1a18dc43743f94fa63bbbf464ce377592dee99e5d4 was being spent in transactionID 3d01e3b94195808a866bd75cd5a9a3d1d6ee0385fdd20025aacb4215bb9117e2.

Quote
            "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.

Quote
    "vout" : [
        {
            "value" : 0.57000000,

There's that 0.57 BTC output that you want to spend.

Quote
            "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

Quote
            "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.

Quote
                "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.

Quote

            }
        },

And that ends that output.  Next comes the 0.57974817 output with index 1.

Quote
        {
            "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)

Quote
    ],
    "blockhash" : "000000007c6196cdb6969f3f0630da9da5df8c2e687510ce6e25f21ccbc99e0f",
    "confirmations" : 275,
    "time" : 1402603913,
    "blocktime" : 1402603913
}
oshirowanen (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 10


View Profile
June 15, 2014, 12:54:39 PM
 #17

Thank you very much.  It worked!
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!