Bitcoin Forum
April 26, 2024, 03:51:54 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: bitcoin-cli cold sign raw transaction  (Read 128 times)
zoltanb (OP)
Member
**
Offline Offline

Activity: 162
Merit: 24


View Profile
January 04, 2021, 09: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://bitcointalk.org/index.php?topic=2585018.0

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?
1714103514
Hero Member
*
Offline Offline

Posts: 1714103514

View Profile Personal Message (Offline)

Ignore
1714103514
Reply with quote  #2

1714103514
Report to moderator
1714103514
Hero Member
*
Offline Offline

Posts: 1714103514

View Profile Personal Message (Offline)

Ignore
1714103514
Reply with quote  #2

1714103514
Report to moderator
1714103514
Hero Member
*
Offline Offline

Posts: 1714103514

View Profile Personal Message (Offline)

Ignore
1714103514
Reply with quote  #2

1714103514
Report to moderator
BitcoinCleanup.com: Learn why Bitcoin isn't bad for the environment
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
NotATether
Legendary
*
Offline Offline

Activity: 1582
Merit: 6681


bitcoincleanup.com / bitmixlist.org


View Profile WWW
January 04, 2021, 10:33:16 PM
Merited by ABCbits (1)
 #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
       },
       ...
     ]

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
zoltanb (OP)
Member
**
Offline Offline

Activity: 162
Merit: 24


View Profile
January 05, 2021, 07: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?
NotATether
Legendary
*
Offline Offline

Activity: 1582
Merit: 6681


bitcoincleanup.com / bitmixlist.org


View Profile WWW
January 05, 2021, 10: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.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
coinlatte
Newbie
*
Offline Offline

Activity: 21
Merit: 16


View Profile
January 06, 2021, 05: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.
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!