Author

Topic: Using Signrawtransactionwithwallet (Witness is always empty) (Read 119 times)

legendary
Activity: 2534
Merit: 6080
Self-proclaimed Genius
Ok i think i understand, i have to import the descriptor to my wallet partipant and then sign it, thats why it cannot fill the witness probably.
That's how signrawtransactionwithwallet command does since it's a wallet RPC command, it'll use the private key(s) derived from the wallet's descriptors.
Otherwise, signrawtransactionwithkey should be used but the private key wif must be provided.

Yes, once imported on the participant server wallet i could get rid of this issue - getting "Unable to sign input, invalid stack size (possibly missing key)" now but thats at least a way to work forward, i will research more on it now - thanks alot already!
The error is self-explanatory.
The correct descriptor must be imported to the wallet to be able to sign that transaction.
Here's one reference: https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md

But please consider the suggestions in your other thread about using the "send" workflow instead of doing it manually (since you're using wallet commands anyways) .
newbie
Activity: 5
Merit: 3
Yes, once imported on the participant server wallet i could get rid of this issue - getting "Unable to sign input, invalid stack size (possibly missing key)" now but thats at least a way to work forward, i will research more on it now - thanks alot already!

Ok i think i understand, i have to import the descriptor to my wallet partipant and then sign it, thats why it cannot fill the witness probably.
newbie
Activity: 5
Merit: 3
Yes, heres the unsigned raw transaction: 0200000001909b345aa6f80b94f51b97dbaa9f2d6a56a81646ee301b57f67ce78ed07b9e6200000 00000fdffffff02ee280000000000001600140919778cc3bfd64cb3718c09f9aa3c43ce0ae36c49 01000000000000160014f65df156aaeef3504189ee81f6f156eda4ad012400000000

i also tried specifying the "amount" => 0.000013 but the error persists, whats a way to fix this if the values are correct - do i need to specify something intentionally or ? I also read the issue is coming from it being non-standard/uncommon but i am a  bit confused what that means or how to resolve this.

You did import the descriptors on both wallets - is that the way to resolve this ? I also tried importing the descriptors which threw me an error due to one wallet using private keys, importing it on the multisig wallet works just fine.
legendary
Activity: 2534
Merit: 6080
Self-proclaimed Genius
I've tried to reproduce it in v28.0 but I didn't come across any issue, it went smoothly with out without prevtxs.
The entire testing process (in RegTest):
Code:
Imported to "MultiSig_Test_A/B/watching"

Watching:
importdescriptors "[{\"desc\": \"wsh(sortedmulti(2,tpubDDqPbCkV5gA2gLBHDAwWTZPaDxiJMjfPfRvsxnB1GDAtMFSEFEbg6FEDtc7obvMK3HaG9bhqtLVU443yGBr9QAsarthnueKF2K3wT3LiMLq/1/*,tpubDF62y7uDVNqF4MXYC2PdnsqFqA87VYsb9v3tueFaAj8yDdkdwQ4WcA6XRABMKMQ15ypkw3oBw4jNqWeeoe5mNFLtZjEzhs9rXq7oKUdY5ej/1/*))#sa9l8zmy\",\"timestamp\": \"now\",\"watching-only\": false,\"active\": true,\"internal\": true,\"range\": [0,999]}]"
importdescriptors "[{\"desc\": \"wsh(sortedmulti(2,tpubDDqPbCkV5gA2gLBHDAwWTZPaDxiJMjfPfRvsxnB1GDAtMFSEFEbg6FEDtc7obvMK3HaG9bhqtLVU443yGBr9QAsarthnueKF2K3wT3LiMLq/0/*,tpubDF62y7uDVNqF4MXYC2PdnsqFqA87VYsb9v3tueFaAj8yDdkdwQ4WcA6XRABMKMQ15ypkw3oBw4jNqWeeoe5mNFLtZjEzhs9rXq7oKUdY5ej/0/*))#na42zx0h\",\"timestamp\": \"now\",\"watching-only\": false,\"active\": true,\"internal\": false,\"range\": [0,999]}]"

Wallet B:
importdescriptors "[{\"desc\": \"wsh(sortedmulti(2,tprv8h9MSniEwJUMns9VKXGv49jTewCNCQUV68L6gG8hqwNVWmBTcqn5ukcMiV3mTa4grnyEbnMwshYY8WYmXoJ7P8pn7LJ5G3pfQCeCcMoL9mK/1/*,tpubDF62y7uDVNqF4MXYC2PdnsqFqA87VYsb9v3tueFaAj8yDdkdwQ4WcA6XRABMKMQ15ypkw3oBw4jNqWeeoe5mNFLtZjEzhs9rXq7oKUdY5ej/1/*))#dxgctdp2\",\"timestamp\": \"now\",\"watching-only\": false,\"active\": true,\"internal\": true,\"range\": [0,999]}]"
importdescriptors "[{\"desc\": \"wsh(sortedmulti(2,tprv8h9MSniEwJUMns9VKXGv49jTewCNCQUV68L6gG8hqwNVWmBTcqn5ukcMiV3mTa4grnyEbnMwshYY8WYmXoJ7P8pn7LJ5G3pfQCeCcMoL9mK/0/*,tpubDF62y7uDVNqF4MXYC2PdnsqFqA87VYsb9v3tueFaAj8yDdkdwQ4WcA6XRABMKMQ15ypkw3oBw4jNqWeeoe5mNFLtZjEzhs9rXq7oKUdY5ej/0/*))#wxcdwf4e\",\"timestamp\": \"now\",\"watching-only\": false,\"active\": true,\"internal\": false,\"range\": [0,999]}]"

Wallet A:
importdescriptors "[{\"desc\": \"wsh(sortedmulti(2,tprv8iPzphryM19aAtVkJNj3PUB9G8cBLDggacT7d8DGkTLaP9VsK1EvRfUfF2rGsjDWsNWgt99o9pZe14YCQ8DQirvHUg31zfSXycp1U8SMjBi/1/*,tpubDDqPbCkV5gA2gLBHDAwWTZPaDxiJMjfPfRvsxnB1GDAtMFSEFEbg6FEDtc7obvMK3HaG9bhqtLVU443yGBr9QAsarthnueKF2K3wT3LiMLq/1/*))#mudw5up4\",\"timestamp\": \"now\",\"watching-only\": false,\"active\": true,\"internal\": true,\"range\": [0,999]}]"
importdescriptors "[{\"desc\": \"wsh(sortedmulti(2,tprv8iPzphryM19aAtVkJNj3PUB9G8cBLDggacT7d8DGkTLaP9VsK1EvRfUfF2rGsjDWsNWgt99o9pZe14YCQ8DQirvHUg31zfSXycp1U8SMjBi/0/*,tpubDDqPbCkV5gA2gLBHDAwWTZPaDxiJMjfPfRvsxnB1GDAtMFSEFEbg6FEDtc7obvMK3HaG9bhqtLVU443yGBr9QAsarthnueKF2K3wT3LiMLq/0/*))#cuam3c4x\",\"timestamp\": \"now\",\"watching-only\": false,\"active\": true,\"internal\": false,\"range\": [0,999]}]"
------------------------------------------------------------------------------------------------

Address1:
bcrt1qgk3ep65a579r4p2ngr7dypew8ftugmzp3l5t2amqnee8cxwcmvwquxcgs9
"scriptPubKey": "002045a390ea9da78a3a855340fcd2072e3a57c46c418fe8b577609e727c19d8db1c"
"WitnessScript": "5221034627c1a69c80ac4a73a8901b1fc113f01cef6c85b4b58123fc9ca724b04b9433210363f572dcb5d74849da2ce406fcd070d07288d0d89e2210e429ee31f8bd0e29aa52ae"

UTXO:
84d6dd9b5e679eb201e83c74e026d3de0b288f857ae0cd1900a94bc2f038eb30:0 10 tBTC

createrawtransaction '[{"txid":"84d6dd9b5e679eb201e83c74e026d3de0b288f857ae0cd1900a94bc2f038eb30","vout":0}]' '{"bcrt1q9j9jkrdm6upfdcdszyg0ej8d7ee7d0tn6lp646":"9.995"}'

020000000130eb38f0c24ba90019cde07a858f280bded326e0743ce801b29e675e9bddd6840000000000fdffffff01e028933b000000001600142c8b2b0dbbd70296e1b01110fcc8edf673e6bd7300000000

Sign with Wallet B:
signrawtransactionwithwallet "020000000130eb38f0c24ba90019cde07a858f280bded326e0743ce801b29e675e9bddd6840000000000fdffffff01e028933b000000001600142c8b2b0dbbd70296e1b01110fcc8edf673e6bd7300000000"

Signed 1/2:
0200000000010130eb38f0c24ba90019cde07a858f280bded326e0743ce801b29e675e9bddd6840000000000fdffffff01e028933b000000001600142c8b2b0dbbd70296e1b01110fcc8edf673e6bd730400473044022065c3c308b3465a592bfc279725155b2f9370cf8c7cad882341836108f0592545022073d1144d778064a19f45e4f860be70b46e9c9f45437693e4e9478368a53d8ab30100475221034627c1a69c80ac4a73a8901b1fc113f01cef6c85b4b58123fc9ca724b04b9433210363f572dcb5d74849da2ce406fcd070d07288d0d89e2210e429ee31f8bd0e29aa52ae00000000

Sign with Wallet A:
signrawtransactionwithwallet "0200000000010130eb38f0c24ba90019cde07a858f280bded326e0743ce801b29e675e9bddd6840000000000fdffffff01e028933b000000001600142c8b2b0dbbd70296e1b01110fcc8edf673e6bd730400473044022065c3c308b3465a592bfc279725155b2f9370cf8c7cad882341836108f0592545022073d1144d778064a19f45e4f860be70b46e9c9f45437693e4e9478368a53d8ab30100475221034627c1a69c80ac4a73a8901b1fc113f01cef6c85b4b58123fc9ca724b04b9433210363f572dcb5d74849da2ce406fcd070d07288d0d89e2210e429ee31f8bd0e29aa52ae00000000" '[{"txid":"84d6dd9b5e679eb201e83c74e026d3de0b288f857ae0cd1900a94bc2f038eb30","vout":0,"scriptPubKey":"002045a390ea9da78a3a855340fcd2072e3a57c46c418fe8b577609e727c19d8db1c","witnessScript":"5221034627c1a69c80ac4a73a8901b1fc113f01cef6c85b4b58123fc9ca724b04b9433210363f572dcb5d74849da2ce406fcd070d07288d0d89e2210e429ee31f8bd0e29aa52ae","amount":10}]'

Signed 2/2:
0200000000010130eb38f0c24ba90019cde07a858f280bded326e0743ce801b29e675e9bddd6840000000000fdffffff01e028933b000000001600142c8b2b0dbbd70296e1b01110fcc8edf673e6bd730400473044022065c3c308b3465a592bfc279725155b2f9370cf8c7cad882341836108f0592545022073d1144d778064a19f45e4f860be70b46e9c9f45437693e4e9478368a53d8ab301473044022074631ece8ed88639ee893c3be0dc475a735f0e92a0e1cae2dee41fb8d74691a102203461fca712751867cde0117b491c131d0d41cc2eaa310bf0e2a132ee4e31f3b301475221034627c1a69c80ac4a73a8901b1fc113f01cef6c85b4b58123fc9ca724b04b9433210363f572dcb5d74849da2ce406fcd070d07288d0d89e2210e429ee31f8bd0e29aa52ae00000000

testmempoolaccept '["0200000000010130eb38f0c24ba90019cde07a858f280bded326e0743ce801b29e675e9bddd6840000000000fdffffff01e028933b000000001600142c8b2b0dbbd70296e1b01110fcc8edf673e6bd730400473044022065c3c308b3465a592bfc279725155b2f9370cf8c7cad882341836108f0592545022073d1144d778064a19f45e4f860be70b46e9c9f45437693e4e9478368a53d8ab301473044022074631ece8ed88639ee893c3be0dc475a735f0e92a0e1cae2dee41fb8d74691a102203461fca712751867cde0117b491c131d0d41cc2eaa310bf0e2a132ee4e31f3b301475221034627c1a69c80ac4a73a8901b1fc113f01cef6c85b4b58123fc9ca724b04b9433210363f572dcb5d74849da2ce406fcd070d07288d0d89e2210e429ee31f8bd0e29aa52ae00000000"]'

    "txid": "832be510004ca58a1e37e65f0cb45584161eb968a837e89eb3ea1528b20b6c5f",
    "wtxid": "9317dbc7e2ee85e2bf8bf1b8ba298eb03aa828220d0201dec7bd3c5880e53b0a",
    "allowed": true,

Which does look correct i think - anyway once i run it, i receive "Witness program was passed an empty witness". I am not certainly sure how to fix this since the redeemScript seems to be fine, as well as the scriptPubKey and no more data is requested, also using getaddressinfo of the multisig address is giving me the correct response of the "hex" parameter.
AFAIK, that error usually occur when the transaction that you're signing is non-standard or uncommon. (can you share the unsigned raw transaction?)
Neither of those values will result with that error. If ever your scriptPubKey or WitnessScript are wrong, the error should be specific to those values.
Additionally, since you've used prevtxs and since it's SegWit, you're required to include the amount but that didn't caused the error.
newbie
Activity: 5
Merit: 3
Good day,

i am trying to sign a raw transaction but i cannot get beyond the point of "Witness program was passed an empty witness" which is a bit confusing.

I am using a P2WSH address to generate a 2/3 multisig - create a raw transaction using an unspent utxo which works fine, then i receive a 0200 hex string (the raw transaction) and try to sign it with one of the included wallets of the multisig.

I do
- Get an unspent UTXO
- createrawtransaction
- Receive a 0200 hex string
- Try to run signrawtransactionwithwallet using
Code:
$this->request('signrawtransactionwithwallet', [
            $rawTx,
            [[
                'txid' => $txid,
                'vout' => $vout,
                'scriptPubKey' => $utxo->scriptPubKey,
                'witnessScript' => $redeemScript],
            ], 'ALL']);

The scriptPubKey is: 0020a194d46d50030743524e6ceaee1a93232fae9a434a5f0f4238514d18c62d2323
and redeemScript is 5221028e7ddd8cbb55983fd50a13ff1fc57714e5c32e9852406ad701a13bd1fbedb1a52102be48f ffd641af599c59158511cdd4c99e9cfa6a3ba221420da3ce7f507ed48e72103461f3cece9363b05 f1a076c6c7f4e3580cb9d8c13684034a02c1fab6391b217853ae

Which does look correct i think - anyway once i run it, i receive "Witness program was passed an empty witness". I am not certainly sure how to fix this since the redeemScript seems to be fine, as well as the scriptPubKey and no more data is requested, also using getaddressinfo of the multisig address is giving me the correct response of the "hex" parameter.

Any help would be appreciated, tried it the past 6 hours but could not really get beyond this point and its just confusing as i might miss something im simply not aware of.

Signing the raw transaction on a website like Coinbin works just fine, so i suppose it does not check it as detailed as using my bitcoin node itself ?
Jump to: