Author

Topic: bitcoin-cli cold sign raw transaction (Read 141 times)

newbie
Activity: 21
Merit: 16
January 06, 2021, 12:30:42 PM
#5
Quote
It would also be helpful if you decode your transaction hex into JSON and post it here, erasing parts like addresses which you don't want to show if any. I suspect you could be having the same symptoms as the other thread, the vins having an empty ScriptSig.
More than that: you can run your client with regtest mode and then reproduce it with worthless regtest coins and paste results here. You can use one client as a miner, create some blocks and then use another instance of a regtest client pointed to different directory and different port, then try to sign a transaction from the second client. If both clients are disconnected from each other, it should be enough to reproduce it.
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
January 05, 2021, 05:33:47 AM
#4
Yes, I passed it, this is when I received the "Unable to sign input, missing keys".
Probably the problem is with the fact that the address is e bech32 address. Should I try with a legacy address?

Using a legacy address in the place of bech32 is just going to eliminate the witnessScript part of the prevtxs argument, which I don't think is causing the missing keys error.

Are there and logs in debug.log or bitcoind output showing activity that's happening inside this RPC call? I don't think there are any but it's worth a shot.

It would also be helpful if you decode your transaction hex into JSON and post it here, erasing parts like addresses which you don't want to show if any. I suspect you could be having the same symptoms as the other thread, the vins having an empty ScriptSig.
member
Activity: 162
Merit: 24
January 05, 2021, 02:56:43 AM
#3
Yes, I passed it, this is when I received the "Unable to sign input, missing keys".
Probably the problem is with the fact that the address is e bech32 address. Should I try with a legacy address?
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
January 04, 2021, 05:33:16 PM
#2
signrawtransactionwithwallet isn't going to work on an offline wallet because it does not know any of the inputs that are being spent hence the "Input not found" part of the error.

In the second argument to signrawtransactionwithwallet did you pass the list of previous transactions for the inputs you are trying to spend? It is a JSON array so you can decode the previous transaction hex strings to get the required information to this RPC call. It has this format:

...
Arguments:
1. hexstring                        (string, required) The transaction hex string
2. prevtxs                          (json array, optional) A json array of previous dependent transaction outputs
     [
       {                            (json object)
         "txid": "hex",             (string, required) The transaction id
         "vout": n,                 (numeric, required) The output number
         "scriptPubKey": "hex",     (string, required) script key
         "redeemScript": "hex",     (string) (required for P2SH) redeem script
         "witnessScript": "hex",    (string) (required for P2WSH or P2SH-P2WSH) witness script
         "amount": amount,          (numeric or string, required) The amount spent
       },
       ...
     ]
member
Activity: 162
Merit: 24
January 04, 2021, 04:59:42 PM
#1
I am having problems offline signing a raw transaction I generated from bitcoin-cli listunspent command.
So, I generated the raw transaction with 1 input (bc1a...) and 1 output (bc1b...).
I then used the hash on my offline wallet (no blockchain data at all, just the bitcoin-cli client and the passphrased wallet.dat). When I issued the command:
"bitcoin-cli signrawtransactionwithwallet hex"
I got this response:
"Input not found or already spent"

Then, I passed to the signrawtransactionwithwallet hex command the txid, vout and scriptpubkey as explained here: https://bitcointalksearch.org/topic/input-not-found-or-already-spent-signrawtransaction-2585018

But now I receive: "Unable to sign input, missing keys"

I am 100% sure that the input I am trying to spend belongs to an address (bc1a...) generated on the offline wallet I am using to sign the transaction.

What am I doing wrong?
Jump to: