2 of 3 multisig transaction fails

0 votes

Hi, I created a 2 of 3 multisignature transaction with the following sequence of commands:

./multichain-cli virttestchain preparelockunspent '{"CHF":100}'

{

    "txid" : "d534b5048ceabc7bee6a6f1f89a541ac381c920e5a89f8c4c7fbd624d995b18c",

    "vout" : 1

}

./multichain-cli virttestchain createmultisig 2 '["1Xy5y7tVyXpttEgGpuXhqYExc8ad8uf1TXvZc1","1Eo3DFcAPDEEhqjspk2XW6P5grAeUGAY6SLKzN","02014bb27baaaeb06674903a7f62555db80edc46dc3abe97ccc26de516768c6295"]'

{

"address" : "4Af3ki83UgR5Qtup2DZo6LivRRm7LXhLRk7HEG",

    "redeemScript" : "52210399ab7e452f277c827f418f5a9a538b80f6430345aff..."

}

./multichain-cli virttestchain createrawtransaction '[{"txid":"d534b5048ceabc7bee6a6f1f89a541ac381c920e5a89f8c4c7fbd624d995b18c","vout":1}]' '{"4Af3ki83UgR5Qtup2DZo6LivRRm7LXhLRk7HEG":{"CHF":100.0}}'

01000000018cb195d924d6fbc7c4f8895a0e921c38ac41a5891f6f6aee7bbcea...

./multichain-cli virttestchain signrawtransaction 01000000018cb195d924d6fbc7c4f8895a0e921c38ac41a5891f6f6aee7bbcea...

{

    "hex" : "01000000018cb195d924d6fbc7c4f8895a0e921c38ac41a5891f6f6aee7bbcea...",

    "complete" : true

}

./multichain-cli virttestchain decoderawtransaction 01000000018cb195d924d6fbc7c4f8895a0e921c38ac41a5891f6f6aee7bbcea...

{

    "txid" : "ed1680144799a2fd3a3e3779c31a1c203d6707550cb778b29e767c4c91c211ba",

    "version" : 1,

    "locktime" : 0,

    "vin" : [

        {

            "txid" : "d534b5048ceabc7bee6a6f1f89a541ac381c920e5a89f8c4c7fbd624d995b18c",

            "vout" : 1,

            ...,

    "vout" : [

        {

            "value" : 0.00000000,

            "n" : 0,

            "scriptPubKey" : {

                "asm" : "OP_HASH160 4edb673c8d0f0596cf49153f9c54473e11c2235b OP_EQUAL 73706b71a70600001a020000b8046400000000000000 OP_DROP",

                "hex" : "a9144edb673c8d0f0596cf49153f9c54473e11c2235b871673706b71a70600001a020000b804640000000000000075",

                "reqSigs" : 1,

                "type" : "scripthash",

                "addresses" : [

                    "4Af3ki83UgR5Qtup2DZo6LivRRm7LXhLRk7HEG"

                ]

            },

            "assets" : [

                {

                    "name" : "CHF",

                    "genesistxid" : "b804617eb762b0815c806a3a3b8769dd8dcc8d31bd3967846515096435908cb0",

                    "assetref" : "1703-538-1208",

                    "qty" : 100.00000000,

                    "raw" : 100

                }

            ],

            "permissions" : [

            ]

        }

    ],

    "data" : [

    ]

}

./multichain-cli virttestchain createrawtransaction '[{"txid":"ed1680144799a2fd3a3e3779c31a1c203d6707550cb778b29e767c4c91c211ba","vout":0,"scriptPubKey":"a9144edb673c8d0f0596cf49153f9c54473e11c2235b871673706b71a70600001a020000b804640000000000000075","redeemScript":"52210399ab7e452f277c827f418f5a9a538..."}]' '{"1Lb1VQh6TtdMyV5TR7gxdJ6Mff179ixz8w8w6K":{"CHF":100}}'

0100000001ba11c2914c7c769eb278b70c5507673d201c1ac379373e3afda29947148016ed...

 

./multichain-cli virttestchain signrawtransaction '0100000001ba11c2914c7c769eb278b70c5507673d201c1ac379373e3afda29947148016ed0...' '[{"txid":"ed1680144799a2fd3a3e3779c31a1c203d6707550cb778b29e767c4c91c211ba","vout":0,"scriptPubKey":"a9144edb673c8d0f0596cf49153f9c54473e11c2235b871673706b71a70600001a020000b804640000000000000075","redeemScript":"52210399ab7e452f277c827f418f5a9a538..."}]' '["VGLUoRxhPupDWCMegsX9xERqSAnGFvyKYBSMiNz2oKxUh4PFaabfnZUm"]'

 

{

    "hex" : "0100000001ba11c2914c7c769eb278b70c5507673d201c1ac379373e3afda29947148016ed...",

    "complete" : false

}

 

NODE 2

./multichain-cli virttestchain signrawtransaction '0100000001ba11c2914c7c769eb278b70c5507673d201c1ac379373e3afda29947148016ed...' '[{"txid":"ed1680144799a2fd3a3e3779c31a1c203d6707550cb778b29e767c4c91c211ba","vout":0,"scriptPubKey":"a9144edb673c8d0f0596cf49153f9c54473e11c2235b871673706b71a70600001a020000b804640000000000000075","redeemScript":"52210399ab7e452f277c827f418f5a9a538..."}]' '["V9ZFqg29YUFriDqpYy3PLgzYvNqutbp9FRRa1Sv9SxazmqnsBjVAsBKs"]'

{

    "hex" : "0100000001ba11c2914c7c769eb278b70c5507673d201c1ac379373e3afda29947148016ed...",

    "complete" : true

}

 

NODE 1

./multichain-cli virttestchain sendrawtransaction 01000000018cb195d924d6fbc7c4f8895a0e921c38ac41a5891f6f6aee7bbcea8c04b534d5...

ed1680144799a2fd3a3e3779c31a1c203d6707550cb778b29e767c4c91c211ba

 

NODE 2

./multichain-cli virttestchain sendrawtransaction 0100000001ba11c2914c7c769eb278b70c5507673d201c1ac379373e3afda29947148016ed...

 

As you can see, that spending transaction is marked as complete, however when I execute the last command I receive and error: {"code":-25,"message":""}

I think the last command fails because the multisig address does not have send permission. Also to be able to send the first (funding) transaction, I had to grant receive permission to the multisig address. 

I have more problems with this:

Why the created multisig address does not have send, receive permission by default?

I cannot grant the multisig address send permission due to an error:

{"code":-4,"message":"Error: The transaction was rejected: 64: Permission script rejected - only receive permission can be set for P2SH"}

Can you help me with this?

asked Oct 16, 2015 by Miklos

1 Answer

0 votes

To send to a P2SH style of multisig, that multisig address needs to have receive permission (since it's not possible to know the individual addresses from which the multisig is created - the scripthash is a one-way hash calculation).

To spend a P2SH style of multisig, at least one of the individual addresses which spends the input must have send permission. 

More information on the page about permissions. Please us know if this doesn't solve the problem.

answered Oct 17, 2015 by MultiChain
As you requested, I ran a test with v0.8:
./multichain-cli virttestchain preparelockunspent '{"HUF":100}'

{
    "txid" : "5a3a73076db45633e6008a65d1a3b287e67ab312dad3f31f334a790cd73c7bb6",
    "vout" : 0
}

./multichain-cli virttestchain getaddressesbyaccount ""

[
    "1FfyLtRNLc7Y5gpDdEdgwyUPPFdqqqszwiDR2E",
    "1LpUfz9xu9Mp2LEjbtjLzcFycX7AtWJuAnSBC5"
]

./multichain-cli virttestchain getaddressesbyaccount ""

[
    "17gChmcmQZzNCgFSZy3wSnYAYkdq6DNNUqYKep"
]

./multichain-cli virttestchain validateaddress 17gChmcmQZzNCgFSZy3wSnYAYkdq6DNNUqYKep

{
    "isvalid" : true,
    "address" : "17gChmcmQZzNCgFSZy3wSnYAYkdq6DNNUqYKep",
    "ismine" : true,
    "iswatchonly" : false,
    "isscript" : false,
    "pubkey" : "03f60e00106be063b86e2652a40b40eedc57ad7c899965d363bfee734c2b3e32c6",
    "iscompressed" : true,
    "account" : ""
}

./multichain-cli virttestchain createmultisig 2 '["1FfyLtRNLc7Y5gpDdEdgwyUPPFdqqqszwiDR2E","1LpUfz9xu9Mp2LEjbtjLzcFycX7AtWJuAnSBC5","03f60e00106be063b86e2652a40b40eedc57ad7c899965d363bfee734c2b3e32c6"]'
 
{
    "address" : "4E5iqJYBXa4qgu3i1BmV3xSsJYXCgaKczeyyEh",
    "redeemScript" : "522102c2edeba1fbb92b1a044bca49b379c282..."
}

./multichain-cli virttestchain createrawtransaction '[{"txid":"5a3a73076db45633e600...","vout":0}]' '{"4E5iqJYBXa4qgu3i1BmV3xSsJYXCgaKczeyyEh":{"HUF":100.0}}'

0100000001b67b3cd70c794a331ff3d3...

./multichain-cli virttestchain signrawtransaction 0100000001b67b3cd70c794a331ff3d3...

{
    "hex" : "0100000001b67b3cd70c794a331ff3d3...",
    "complete" : true
}

./multichain-cli virttestchain decoderawtransaction 0100000001b67b3cd70c794a331ff3d3...

{
    "txid" : "f30a4ada46162b01202fef2109fccf66977298011602cbd76385dad33f1440a9",
    "version" : 1,
    "locktime" : 0,
    "vin" : [
        {
            "txid" : "5a3a73076db45633e6008a65d1a3b287e67ab312dad3f31f334a790cd73c7bb6",
            "vout" : 0,
            ...
        }
    ],
    "vout" : [
        {
            "value" : 0.00000000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_HASH160 68338ed5aa5dead34afce218b2f92dbc9718d26c OP_EQUAL 73706b716c00000009010000044d6400000000000000 OP_DROP",
                "hex" : "a91468338ed5aa5dead34afce218...",
                "reqSigs" : 1,
                "type" : "scripthash",
                "addresses" : [
                    "4E5iqJYBXa4qgu3i1BmV3xSsJYXCgaKczeyyEh"
                ]
            },
            "assets" : [
                {
                    "name" : "HUF",
                    "genesistxid" : "044d8db4e34b47ceba59e3dc49f88756912b3c71578668bceea2e7dec0883f83",
                    "assetref" : "108-265-19716",
                    "qty" : 100.00000000,
                    "raw" : 100
                }
            ],
            "permissions" : [
            ]
        }
    ],
    "data" : [
    ]
}

./multichain-cli virttestchain grant 4E5iqJYBXa4qgu3i1BmV3xSsJYXCgaKczeyyEh receive

349aeff4e57ad2ebce3118538f64ee28f2f1bad96cccb6827f019075fed97784

./multichain-cli virttestchain sendrawtransaction 0100000001b67b3cd70c794a331ff3d3...

f30a4ada46162b01202fef2109fccf66977298011602cbd76385dad33f1440a9

./multichain-cli virttestchain createrawtransaction '[{"txid":"f30a4ada46162b01202fef2109fccf66977298011602cbd76385dad33f1440a9","vout":0,"scriptPubKey":"a91468338ed5aa5dead34afce218...","redeemScript":"522102c2edeba1fbb92b1a044bca49b379c282..."}]' '{"17gChmcmQZzNCgFSZy3wSnYAYkdq6DNNUqYKep":{"HUF":100}}'

0100000001a940143fd3da8563d7cb02160198729766cffc0921ef2f20012b1646da4a0af3...

./multichain-cli virttestchain dumpprivkey 1FfyLtRNLc7Y5gpDdEdgwyUPPFdqqqszwiDR2E

VAmFE5sGfQZ1rKJX6CzZyV78tCoUcApW2NzbCUzqNhsJyv1WY3QVxJMw

./multichain-cli virttestchain signrawtransaction '0100000001a940143fd3da8563d7cb02160198729766cffc0921ef2f20012b1646da4a0af3...' '[{"txid":"f30a4ada46162b01202fef2109fccf66977298011602cbd76385dad33f1440a9","vout":0,"scriptPubKey":"a91468338ed5aa5dead34afce218...","redeemScript":"522102c2edeba1fbb92b1a044bca49b379c282..."}]' '["VAmFE5sGfQZ1rKJX6CzZyV78tCoUcApW2NzbCUzqNhsJyv1WY3QVxJMw"]'

{
    "hex" : "0100000001a940143fd3da8563d7cb02160198729766cffc0921ef2f20012b1646da4a0af3...",
    "complete" : false
}


NODE 2

./multichain-cli virttestchain dumpprivkey 17gChmcmQZzNCgFSZy3wSnYAYkdq6DNNUqYKep

VH22impviVW6551TW1ayYE1Ud2Q3ysmZVKcK9jRy3izeYPU1XtsDugRu

./multichain-cli virttestchain signrawtransaction '0100000001a940143fd3da8563d7cb02160198729766cffc0921ef2f20012b1646da4a0af3...' '[{"txid":"f30a4ada46162b01202fef2109fccf66977298011602cbd76385dad33f1440a9","vout":0,"scriptPubKey":"a91468338ed5aa5dead34afce218...","redeemScript":"522102c2edeba1fbb92b1a044bca49b379c282..."}]' '["VH22impviVW6551TW1ayYE1Ud2Q3ysmZVKcK9jRy3izeYPU1XtsDugRu"]'

{
    "hex" : "0100000001a940143fd3da8563d7cb02160198729766cffc0921ef2f20012b1646da4a0af3...",
    "complete" : true
}

./multichain-cli virttestchain sendrawtransaction 0100000001a940143fd3da8563d7cb02160198729766cffc0921ef2f20012b1646da4a0af3...

error: {"code":-25,"message":""}
Thanks for posting this. Just confirming that one of 1FfyLtRNLc7Y5gpDdEdgwyUPPFdqqqszwiDR2E and 1LpUfz9xu9Mp2LEjbtjLzcFycX7AtWJuAnSBC5 have the 'send' permission?

Also when you call createmultisig, you need only pass the two addresses, not the pubkeys as well. Note sure if that's related to the problem, but just a tip.

Another FYI - if you call addmultisigaddress instead of createmultisig, you should be able to call signrawtransaction without passing the private key, so you can also skip the dumpprivkey step.

Anyway please check the send permission situation, and if that does not resolve it, we will look into it further. In any event we will fix that error message.
Thanks for your reply.
- All addresses have send, receive, issue, connect, admin permissions.
- I needed to pass the public key of the third address as it is on node 2, thus on node 1 it is not resolvable.
- If I use addmultisigaddress and call signrawtransaction, how will the system know which address should be used to sign the transaction?
- The current test setup is: there are 2 addresses on Node 1, there is 1 (target) address on Node 2
Do you have any other idea or workaround to make this work? Thanks a lot!
Thanks for your reply. About passing the public key for createmultisig, you should not be using public keys at all in this parameter, but rather only public addresses. So if there are 3 different addresses in the multisig, then it makes sense to have 3 elements in the array - there's just no need to pass public keys.

When you call signrawtransaction, the node can examine the unsigned transaction to find out which private key is required to sign it, since the address is embedded inside the output which is linked to the input to be signed.

Please let me know if the problem still appears when you call createmultisig/addmultisigaddress with addresses only (and without duplicates).
Hi, you have to use the public key, otherwise you get the following error:
error: {"code":-5,"message":"Invalid address: 1FfyLtRNLc7Y5gpDdEdgwyUPPFdqqqszwiDR2E./multichain-cli"}

I guess it's related to the fact that when I use validateaddress on the node which owns the address I get all information including public key, but if I use it on a different node I receive only the address (which is already known) and a flag: mine=false
That error message you showed me looks like you made a typo?
yeah, sorry, I copied the wrong error message... so the command and the response:
multichain-cli virttestchain createmultisig 2 '["1FfyLtRNLc7Y5gpDdEdgwyUPPFdqqqszwiDR2E","1LpUfz9xu9Mp2LEjbtjLzcFycX7AtWJuAnSBC5","17gChmcmQZzNCgFSZy3wSnYAYkdq6DNNUqYKep"]'

error: {"code":-1,"message":"no full public key for address 17gChmcmQZzNCgFSZy3wSnYAYkdq6DNNUqYKep"}
OK, got it, thanks. So this does look like a bug on our end. I'll have the team look into it.
So we tried this here (I will send you the transcript by email) and couldn't reproduce the problem. Alpha 9 will fix the error message to show more information, so hopefully then we'll be able to see what's happening in your case.
...