I've been able to do multisig between two addresses from electrum and one from bitcoind.
[root@test bin]# bitcoin-cli -testnet getnewaddress
n3JewuY82cprdRvxHdRNG8C3iTkJBKeLbz
[root@test bin]# bitcoin-cli -testnet getaddressinfo n3JewuY82cprdRvxHdRNG8C3iTkJBKeLbz
{
"address": "n3JewuY82cprdRvxHdRNG8C3iTkJBKeLbz",
"scriptPubKey": "76a914eeff4b7b1c133c7f72c1b28c4d3c45fdf377c38788ac",
"ismine": true,
"solvable": true,
"desc": "pkh([55e0eacd/0'/0'/23']0361ac153cfc0c5cefb74fa904ca83105ccdcbaa3c1ebb8266a03212619ae1006a)#egqffv76",
"iswatchonly": false,
"isscript": false,
"iswitness": false,
"pubkey": "0361ac153cfc0c5cefb74fa904ca83105ccdcbaa3c1ebb8266a03212619ae1006a",
"iscompressed": true,
"label": "",
"ischange": false,
"timestamp": 1576329907,
"hdkeypath": "m/0'/0'/23'",
"hdseedid": "763fc03352a1f347f5b5f1c57bf8e1bd1f1043ed",
"hdmasterfingerprint": "55e0eacd",
"labels": [
{
"name": "",
"purpose": "receive"
}
]
}
[root@test bin]# bitcoin-cli -testnet dumpprivkey n3JewuY82cprdRvxHdRNG8C3iTkJBKeLbz
cVvXTPL6ozGX9ckrNQ7gEudkPnEb6sPdtKPFEsLaQG38JdX1TXqn
I've created an address like this.
Wallet 1 (Electrum)
addr: tb1qp23cmwgn8qnv8cg5h595ne7nuvlvjhpxssee4d
pubkey: 02b1c24ff14bc3e9cab5ff65eda5365fc215449b8fbacb7615a6c8fe0c64ea2bba
privkey: cUY49HJ18YJXoBnbnbRwRFZN6ab89BtPinogSNeqqF6XdyU3R4xp
Wallet 2 (Electrum)
addr: tb1qvrtgw5pe3h97mk3kshqmkw7aff4qu6ftyy9v3a
pubkey: 039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900c
privkey: cNP1KSiJ2MZ8JfdjdyHjPHBJpnBeKLhF2xXTdbsD8CyV72GxiTeJ
Wallet 3 (bitcoind)
addr: n3JewuY82cprdRvxHdRNG8C3iTkJBKeLbz
pubkey: 0361ac153cfc0c5cefb74fa904ca83105ccdcbaa3c1ebb8266a03212619ae1006a
privkey: cVvXTPL6ozGX9ckrNQ7gEudkPnEb6sPdtKPFEsLaQG38JdX1TXqn
Here are the infos of those wallets.
[root@test bin]# bitcoin-cli -testnet createmultisig 2 '["02b1c24ff14bc3e9cab5ff65eda5365fc215449b8fbacb7615a6c8fe0c64ea2bba", "039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900c", "0361ac153cfc0c5cefb74fa904ca83105ccdcbaa3c1ebb8266a03212619ae1006a"]'
{
"address": "2Mw3vye5PHPyjZJiLhNt2g7bBpv6MukAsqS",
"redeemScript": "522102b1c24ff14bc3e9cab5ff65eda5365fc215449b8fbacb7615a6c8fe0c64ea2bba21039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900c210361ac153cfc0c5cefb74fa904ca83105ccdcbaa3c1ebb8266a03212619ae1006a53ae"
}
And created a legacy multisig address. After funding the multisig address, I created a spend transaction.
[root@test bin]# bitcoin-cli -testnet listunspent 0 9999 '["2Mw3vye5PHPyjZJiLhNt2g7bBpv6MukAsqS"]'
[
{
"txid": "c02b2342d8894092a2d89d45ebb140b3ec1c667b9167ee91e07efb67272f6c62",
"vout": 0,
"address": "2Mw3vye5PHPyjZJiLhNt2g7bBpv6MukAsqS",
"label": "",
"scriptPubKey": "a91429bdba3711f894e5876e4fe812be9adb25188e1c87",
"amount": 0.00004000,
"confirmations": 0,
"spendable": false,
"solvable": false,
"safe": false
}
]
[root@test bin]# bitcoin-cli -testnet createrawtransaction '[{"txid":"c02b2342d8894092a2d89d45ebb140b3ec1c667b9167ee91e07efb67272f6c62","vout":0,"scriptPubKey":"a91429bdba3711f894e5876e4fe812be9adb25188e1c87","redeemScript":"522102b1c24ff14bc3e9cab5ff65eda5365fc215449b8fbacb7615a6c8fe0c64ea2bba21039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900c210361ac153cfc0c5cefb74fa904ca83105ccdcbaa3c1ebb8266a03212619ae1006a53ae"}]' '{"tb1qnkvqy9p399dcjuqtmw8d6c49u53nf66g5z238w":0.000036}'
0200000001626c2f2767fb7ee091ee67917b661cecb340b1eb459dd8a2924089d842232bc00000000000ffffffff01100e0000000000001600149d98021431295b89700bdb8edd62a5e52334eb4800000000
[root@test bin]# bitcoin-cli -testnet signrawtransactionwithkey 0200000001626c2f2767fb7ee091ee67917b661cecb340b1eb459dd8a2924089d842232bc00000000000ffffffff01100e0000000000001600149d98021431295b89700bdb8edd62a5e52334eb4800000000 '["cVvXTPL6ozGX9ckrNQ7gEudkPnEb6sPdtKPFEsLaQG38JdX1TXqn"]' '[{"txid":"c02b2342d8894092a2d89d45ebb140b3ec1c667b9167ee91e07efb67272f6c62","vout":0,"scriptPubKey":"a91429bdba3711f894e5876e4fe812be9adb25188e1c87","redeemScript":"522102b1c24ff14bc3e9cab5ff65eda5365fc215449b8fbacb7615a6c8fe0c64ea2bba21039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900c210361ac153cfc0c5cefb74fa904ca83105ccdcbaa3c1ebb8266a03212619ae1006a53ae"}]'
{
"hex": "0200000001626c2f2767fb7ee091ee67917b661cecb340b1eb459dd8a2924089d842232bc000000000b500473044022066c276bfe5fe2fe420119d780c6c1ee971ed7dce34c3a938d965464ab164098e02205dfaf4e6a6eab939ccc0f2efbd7a347ab02abb734e33684b925c873f521d496601004c69522102b1c24ff14bc3e9cab5ff65eda5365fc215449b8fbacb7615a6c8fe0c64ea2bba21039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900c210361ac153cfc0c5cefb74fa904ca83105ccdcbaa3c1ebb8266a03212619ae1006a53aeffffffff01100e0000000000001600149d98021431295b89700bdb8edd62a5e52334eb4800000000",
"complete": false,
"errors": [
{
"txid": "c02b2342d8894092a2d89d45ebb140b3ec1c667b9167ee91e07efb67272f6c62",
"vout": 0,
"witness": [
],
"scriptSig": "00473044022066c276bfe5fe2fe420119d780c6c1ee971ed7dce34c3a938d965464ab164098e02205dfaf4e6a6eab939ccc0f2efbd7a347ab02abb734e33684b925c873f521d496601004c69522102b1c24ff14bc3e9cab5ff65eda5365fc215449b8fbacb7615a6c8fe0c64ea2bba21039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900c210361ac153cfc0c5cefb74fa904ca83105ccdcbaa3c1ebb8266a03212619ae1006a53ae",
"sequence": 4294967295,
"error": "CHECK(MULTI)SIG failing with non-zero signature (possibly need more signatures)"
}
]
}
After signing the transaction with another wallet, I was able to broadcast the transaction with no hassle. Here's the result.
https://blockstream.info/testnet/tx/3420c45740088a85b2ae2ec439e1bafe3485358eb6f97cb73730b21ae69eac2b
So, with this method, I tried again but this time with bech32 address to save fee.
[root@test bin]# bitcoin-cli -testnet getnewaddress '' bech32
tb1qantln64pdda5qwngxdqrq8dcghhu6w9r7ple9j
[root@test bin]# bitcoin-cli -testnet getaddressinfo tb1qantln64pdda5qwngxdqrq8dcghhu6w9r7ple9j
{
"address": "tb1qantln64pdda5qwngxdqrq8dcghhu6w9r7ple9j",
"scriptPubKey": "0014ecd7f9eaa16b7b403a683340301db845efcd38a3",
"ismine": true,
"solvable": true,
"desc": "wpkh([55e0eacd/0'/0'/25']024cf34774923ce01a24faa65508d7b09f29aa50a64e11f204c8f3b2ad7a307ffd)#mjfxaggy",
"iswatchonly": false,
"isscript": false,
"iswitness": true,
"witness_version": 0,
"witness_program": "ecd7f9eaa16b7b403a683340301db845efcd38a3",
"pubkey": "024cf34774923ce01a24faa65508d7b09f29aa50a64e11f204c8f3b2ad7a307ffd",
"label": "",
"ischange": false,
"timestamp": 1576329907,
"hdkeypath": "m/0'/0'/25'",
"hdseedid": "763fc03352a1f347f5b5f1c57bf8e1bd1f1043ed",
"hdmasterfingerprint": "55e0eacd",
"labels": [
{
"name": "",
"purpose": "receive"
}
]
}
[root@test bin]# bitcoin-cli -testnet dumpprivkey tb1qantln64pdda5qwngxdqrq8dcghhu6w9r7ple9j
cVoNiYk51W5E6xos2sMvP7XsR8QhDsw8JR6dof9cHw7S1UsechZd
Wallet 1 (Electrum)
addr: tb1qp23cmwgn8qnv8cg5h595ne7nuvlvjhpxssee4d
pubkey: 02b1c24ff14bc3e9cab5ff65eda5365fc215449b8fbacb7615a6c8fe0c64ea2bba
privkey: cUY49HJ18YJXoBnbnbRwRFZN6ab89BtPinogSNeqqF6XdyU3R4xp
Wallet 2 (Electrum)
addr: tb1qvrtgw5pe3h97mk3kshqmkw7aff4qu6ftyy9v3a
pubkey: 039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900c
privkey: cNP1KSiJ2MZ8JfdjdyHjPHBJpnBeKLhF2xXTdbsD8CyV72GxiTeJ
Wallet 3 (bitcoind)
addr: tb1qantln64pdda5qwngxdqrq8dcghhu6w9r7ple9j
pubkey: 024cf34774923ce01a24faa65508d7b09f29aa50a64e11f204c8f3b2ad7a307ffd
privkey: cVoNiYk51W5E6xos2sMvP7XsR8QhDsw8JR6dof9cHw7S1UsechZd
I created a bech32 multisig address.
[root@test bin]# bitcoin-cli -testnet createmultisig 2 '["02b1c24ff14bc3e9cab5ff65eda5365fc215449b8fbacb7615a6c8fe0c64ea2bba", "039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900c", "024cf34774923ce01a24faa65508d7b09f29aa50a64e11f204c8f3b2ad7a307ffd"]' bech32
{
"address": "tb1qxs6nsj4guvuxftz6pf8gydg6ga4d8flw342y2603vn52vyjm0u3qgxchhk",
"redeemScript": "522102b1c24ff14bc3e9cab5ff65eda5365fc215449b8fbacb7615a6c8fe0c64ea2bba21039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900c21024cf34774923ce01a24faa65508d7b09f29aa50a64e11f204c8f3b2ad7a307ffd53ae"
}
And funded it and created a spend transaction.
[root@test bin]# bitcoin-cli -testnet listunspent 0 9999 '["tb1qxs6nsj4guvuxftz6pf8gydg6ga4d8flw342y2603vn52vyjm0u3qgxchhk"]'
[
{
"txid": "d064d63f54175f6bf4b745cb4019ab92d075a59d18001e00be7eaaa760add2c7",
"vout": 1,
"address": "tb1qxs6nsj4guvuxftz6pf8gydg6ga4d8flw342y2603vn52vyjm0u3qgxchhk",
"label": "",
"scriptPubKey": "00203435384aa8e33864ac5a0a4e82351a476ad3a7ee8d544569f164e8a6125b7f22",
"amount": 0.00004000,
"confirmations": 0,
"spendable": false,
"solvable": false,
"safe": false
}
]
[root@test bin]# bitcoin-cli -testnet createrawtransaction '[{"txid":"d064d63f54175f6bf4b745cb4019ab92d075a59d18001e00be7eaaa760add2c7","vout":1,"scriptPubKey":"00203435384aa8e33864ac5a0a4e82351a476ad3a7ee8d544569f164e8a6125b7f22","redeemScript":"522102b1c24ff14bc3e9cab5ff65eda5365fc215449b8fbacb7615a6c8fe0c64ea2bba21039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900c21024cf34774923ce01a24faa65508d7b09f29aa50a64e11f204c8f3b2ad7a307ffd53ae"}]' '{"tb1qnkvqy9p399dcjuqtmw8d6c49u53nf66g5z238w":0.000036}'
0200000001c7d2ad60a7aa7ebe001e00189da575d092ab1940cb45b7f46b5f17543fd664d00100000000ffffffff01100e0000000000001600149d98021431295b89700bdb8edd62a5e52334eb4800000000
[root@test bin]# bitcoin-cli -testnet signrawtransactionwithkey 0200000001c7d2ad60a7aa7ebe001e00189da575d092ab1940cb45b7f46b5f17543fd664d00100000000ffffffff01100e0000000000001600149d98021431295b89700bdb8edd62a5e52334eb4800000000 '["cVoNiYk51W5E6xos2sMvP7XsR8QhDsw8JR6dof9cHw7S1UsechZd"]' '[{"txid":"d064d63f54175f6bf4b745cb4019ab92d075a59d18001e00be7eaaa760add2c7","vout":1,"scriptPubKey":"00203435384aa8e33864ac5a0a4e82351a476ad3a7ee8d544569f164e8a6125b7f22","redeemScript":"522102b1c24ff14bc3e9cab5ff65eda5365fc215449b8fbacb7615a6c8fe0c64ea2bba21039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900c21024cf34774923ce01a24faa65508d7b09f29aa50a64e11f204c8f3b2ad7a307ffd53ae"}]'
error code: -3
error message:
Missing amount for CTxOut(nValue=21000000.00000000, scriptPubKey=00203435384aa8e33864ac5a0a4e82)
I encountered an error, but solved it by adding address to tx data.
[root@test bin]# bitcoin-cli -testnet createrawtransaction '[{"txid":"d064d63f54175f6bf4b745cb4019ab92d075a59d18001e00be7eaaa760add2c7","vout":1,"scriptPubKey":"00203435384aa8e33864ac5a0a4e82351a476ad3a7ee8d544569f164e8a6125b7f22","redeemScript":"522102b1c24ff14bc3e9cab5ff65eda5365fc215449b8fbacb7615a6c8fe0c64ea2bba21039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900c21024cf34774923ce01a24faa65508d7b09f29aa50a64e11f204c8f3b2ad7a307ffd53ae", "amount":0.00004}]' '{"tb1qnkvqy9p399dcjuqtmw8d6c49u53nf66g5z238w":0.000036}'
0200000001c7d2ad60a7aa7ebe001e00189da575d092ab1940cb45b7f46b5f17543fd664d00100000000ffffffff01100e0000000000001600149d98021431295b89700bdb8edd62a5e52334eb4800000000
[root@test bin]# bitcoin-cli -testnet signrawtransactionwithkey 0200000001c7d2ad60a7aa7ebe001e00189da575d092ab1940cb45b7f46b5f17543fd664d00100000000ffffffff01100e0000000000001600149d98021431295b89700bdb8edd62a5e52334eb4800000000 '["cVoNiYk51W5E6xos2sMvP7XsR8QhDsw8JR6dof9cHw7S1UsechZd"]' '[{"txid":"d064d63f54175f6bf4b745cb4019ab92d075a59d18001e00be7eaaa760add2c7","vout":1,"scriptPubKey":"00203435384aa8e33864ac5a0a4e82351a476ad3a7ee8d544569f164e8a6125b7f22","redeemScript":"522102b1c24ff14bc3e9cab5ff65eda5365fc215449b8fbacb7615a6c8fe0c64ea2bba21039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900c21024cf34774923ce01a24faa65508d7b09f29aa50a64e11f204c8f3b2ad7a307ffd53ae", "amount":0.00004}]'
{
"hex": "02000000000101c7d2ad60a7aa7ebe001e00189da575d092ab1940cb45b7f46b5f17543fd664d00100000000ffffffff01100e0000000000001600149d98021431295b89700bdb8edd62a5e52334eb4804004730440220195bd6db9ad006c953e1d093faab2044a7238a04061575d43421487b97767b7202206ae6acabeb123c3e621b4199d894a3cde00cede6abfe95cd2e19e68baede5e03010069522102b1c24ff14bc3e9cab5ff65eda5365fc215449b8fbacb7615a6c8fe0c64ea2bba21039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900c21024cf34774923ce01a24faa65508d7b09f29aa50a64e11f204c8f3b2ad7a307ffd53ae00000000",
"complete": false,
"errors": [
{
"txid": "d064d63f54175f6bf4b745cb4019ab92d075a59d18001e00be7eaaa760add2c7",
"vout": 1,
"witness": [
"",
"30440220195bd6db9ad006c953e1d093faab2044a7238a04061575d43421487b97767b7202206ae6acabeb123c3e621b4199d894a3cde00cede6abfe95cd2e19e68baede5e0301",
"",
"522102b1c24ff14bc3e9cab5ff65eda5365fc215449b8fbacb7615a6c8fe0c64ea2bba21039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900c21024cf34774923ce01a24faa65508d7b09f29aa50a64e11f204c8f3b2ad7a307ffd53ae"
],
"scriptSig": "",
"sequence": 4294967295,
"error": "CHECK(MULTI)SIG failing with non-zero signature (possibly need more signatures)"
}
]
}
Finally, I got the spend transaction. I signed it with another wallet and tried broadcasting it.
[root@develop bin]# bitcoin-cli -testnet sendrawtransaction 02000000000101c7d2ad60a7aa7ebe001e00189da575d092ab1940cb45b7f46b5f17543fd664d0010000006a47304402200569cb5c803b6e37debb7417ddd7882d31267f6be761302e4484bc3e6b4eb62f02206bd37ca84156e9f32862038e520781a561f97c70441eeb3734c224cc31cace9b0121039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900cffffffff01100e0000000000001600149d98021431295b89700bdb8edd62a5e52334eb4804004730440220195bd6db9ad006c953e1d093faab2044a7238a04061575d43421487b97767b7202206ae6acabeb123c3e621b4199d894a3cde00cede6abfe95cd2e19e68baede5e03010069522102b1c24ff14bc3e9cab5ff65eda5365fc215449b8fbacb7615a6c8fe0c64ea2bba21039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900c21024cf34774923ce01a24faa65508d7b09f29aa50a64e11f204c8f3b2ad7a307ffd53ae00000000
error code: -26
error message:
non-mandatory-script-verify-flag (Witness requires empty scriptSig) (code 64)
But got this error.
[root@develop bin]# bitcoin-cli -testnet decoderawtransaction 02000000000101c7d2ad60a7aa7ebe001e00189da575d092ab1940cb45b7f46b5f17543fd664d0010000006a47304402200569cb5c803b6e37debb7417ddd7882d31267f6be761302e4484bc3e6b4eb62f02206bd37ca84156e9f32862038e520781a561f97c70441eeb3734c224cc31cace9b0121039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900cffffffff01100e0000000000001600149d98021431295b89700bdb8edd62a5e52334eb4804004730440220195bd6db9ad006c953e1d093faab2044a7238a04061575d43421487b97767b7202206ae6acabeb123c3e621b4199d894a3cde00cede6abfe95cd2e19e68baede5e03010069522102b1c24ff14bc3e9cab5ff65eda5365fc215449b8fbacb7615a6c8fe0c64ea2bba21039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900c21024cf34774923ce01a24faa65508d7b09f29aa50a64e11f204c8f3b2ad7a307ffd53ae00000000
{
"txid": "0aa837cedcc84ff726b8f9ec4dafedee0d1ce46f8d64dfd222065900a5e63d55",
"hash": "ebdf0df0e81eda872cec80f784b1e5003028c6c28385c5c817f23d2c8041a85d",
"version": 2,
"size": 371,
"vsize": 234,
"weight": 935,
"locktime": 0,
"vin": [
{
"txid": "d064d63f54175f6bf4b745cb4019ab92d075a59d18001e00be7eaaa760add2c7",
"vout": 1,
"scriptSig": {
"asm": "304402200569cb5c803b6e37debb7417ddd7882d31267f6be761302e4484bc3e6b4eb62f02206bd37ca84156e9f32862038e520781a561f97c70441eeb3734c224cc31cace9b[ALL] 039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900c",
"hex": "47304402200569cb5c803b6e37debb7417ddd7882d31267f6be761302e4484bc3e6b4eb62f02206bd37ca84156e9f32862038e520781a561f97c70441eeb3734c224cc31cace9b0121039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900c"
},
"txinwitness": [
"",
"30440220195bd6db9ad006c953e1d093faab2044a7238a04061575d43421487b97767b7202206ae6acabeb123c3e621b4199d894a3cde00cede6abfe95cd2e19e68baede5e0301",
"",
"522102b1c24ff14bc3e9cab5ff65eda5365fc215449b8fbacb7615a6c8fe0c64ea2bba21039e28363fe72c1d84b04a15e491f3e85ee853be9f6e65257c373cb464c294900c21024cf34774923ce01a24faa65508d7b09f29aa50a64e11f204c8f3b2ad7a307ffd53ae"
],
"sequence": 4294967295
}
],
"vout": [
{
"value": 0.00003600,
"n": 0,
"scriptPubKey": {
"asm": "0 9d98021431295b89700bdb8edd62a5e52334eb48",
"hex": "00149d98021431295b89700bdb8edd62a5e52334eb48",
"reqSigs": 1,
"type": "witness_v0_keyhash",
"addresses": [
"tb1qnkvqy9p399dcjuqtmw8d6c49u53nf66g5z238w"
]
}
}
]
}
What's wrong with my method? What do I have to do if I want a bech32 multisig address?