Author

Topic: Previous output scriptPubKey mismatch: (Read 1109 times)

jr. member
Activity: 43
Merit: 0
July 18, 2015, 11:12:02 AM
#8
Thanks a lot, your advices very important.

Do I have any chance to get TXID without additional services like https://www.blocktrail.com/tBTC/address/2NEV6KKpFiWb3HKb75TqEupePDXaznTqGaC/transactions ?

For example

1) createmultisig 2
2) addmultisigaddress 2
3) monitoring incomming TX id ?

BR!
sr. member
Activity: 412
Merit: 266
July 15, 2015, 09:08:36 AM
#7
Actually, I see what it is now.

Your problem is step 3; decode tx and get scriptPubKey.

You are decoding your new Tx, taking the scriptPubKey that moves money to your pay-to-pubkey-hash (n/m..... address). This is NOT the scriptPubKey to use to redeem funds at the multisig.

Instead, what you need to do is: getrawtransaction on the txid that puts the money into the multisig address.
Take the scriptPubKey that sends to your multisig address. It will be the only OP_HASH160 OP_EQUAL output.

[Btw - if you already have the txid, and know which address that txid is for, you can create the scriptPubKey in your code without decoding anything.]

Then, with the scriptPubKey that sent the money to the multisig.. and so signrawtransaction with the correct scriptPubKey.

Because you were using the wrong pubkey, bitcoind didn't know how to sign your transaction. You told it was pay-to-pubkey-hash, and gave it two private keys. but the private keys are for the multisig, hence couldn't have signed the transaction you were making.
member
Activity: 112
Merit: 10
July 15, 2015, 09:04:42 AM
#6
Here, I don't see redeemScript in your signing the TX, and the transaction pubkey hex is wrong as well..
Quote
./bitcoin-cli createrawtransaction '[{"txid":"fba4b0a1e11b68c587aae3578844d68131c807913767a1efc9a699d38ecd9f06","vout":1,"scriptPubKey":"a914e8fa0f97c663ba132bd81e6d657c46825d390e6c87",
"redeemscript":"524104d9546728bb1d1bf309ef3c2c7278d8d306052ecf7dc81443f16e75ae607099dfcfc573a3e 71553bd8321d91c209bab03aa999befa6e77734c0f4dd34ef78ebfd41041050ff637a97fa462dff a19d0bc013869f6231895019bd9f263a0a55a067665cfca4473aab1dc38e8aecf359e23ce6bb35f f900bc84fdd890a3b982ea50dd92f4104e086dce7893384cbfa89fbbf7d33de3f1ee01279a1e981 0d952f1c440e91fc7ee7cb9cf070dfbdee397e123c363d140221e81610b7bd695905fbf198edfd7 1a153ae"}]' '{"motbFuaf7Q7xWqBbo7zFu83sdNBspvYkFY":0.0001}'
0100000001069fcd8ed399a6c9efa167379107c83181d6448857e3aa87c5681be1a1b0a4fb01000 00000ffffffff0110270000000000001976a9145bd898bbe4a000cda4418c1fd28178ec99cd653e 88ac00000000
Quote
./bitcoin-cli signrawtransaction '0100000001069fcd8ed399a6c9efa167379107c83181d6448857e3aa87c5681be1a1b0a4fb01000 00000ffffffff0110270000000000001976a9145bd898bbe4a000cda4418c1fd28178ec99cd653e 88ac00000000' '[{"txid":"fba4b0a1e11b68c587aae3578844d68131c807913767a1efc9a699d38ecd9f06","vout":1,"scriptPubKey":"a914e8fa0f97c663ba132bd81e6d657c46825d390e6c87",
"redeemScript":"524104d9546728bb1d1bf309ef3c2c7278d8d306052ecf7dc81443f16e75ae607099dfcfc573a3e 71553bd8321d91c209bab03aa999befa6e77734c0f4dd34ef78ebfd41041050ff637a97fa462dff a19d0bc013869f6231895019bd9f263a0a55a067665cfca4473aab1dc38e8aecf359e23ce6bb35f f900bc84fdd890a3b982ea50dd92f4104e086dce7893384cbfa89fbbf7d33de3f1ee01279a1e981 0d952f1c440e91fc7ee7cb9cf070dfbdee397e123c363d140221e81610b7bd695905fbf198edfd7 1a153ae"}]' '["91gFomEpagA1ETnqsfAK5VFeuaR3YnanbfK2L2FfR1yKdcFjmvG","92cDL4Nvw8jvfkrVJYLFVSENY4NPk9NTELQ2CWzPQ6FKmUb2y5t"]'
{
    "hex" : "0100000001069fcd8ed399a6c9efa167379107c83181d6448857e3aa87c5681be1a1b0a4fb01000 000fd5e0100483045022100c63ea2311dab496c9529b958c89a407fde5fd413a9584ff92a27cf9d 2e7bb0d3022017dec19c3bd85bf0e39ef05ffd90e049af5d1a86381b31c1a8172d4e7ccc3669014 83045022100830829bc79f2b837620456eb385bd6d6acf4da23f68b2394a8244c2594f9d4420220 47c309975696408cb6f46057f4f163c7010ba39785f8dc2e823b1a6a2de1b782014cc9524104d95 46728bb1d1bf309ef3c2c7278d8d306052ecf7dc81443f16e75ae607099dfcfc573a3e71553bd83 21d91c209bab03aa999befa6e77734c0f4dd34ef78ebfd41041050ff637a97fa462dffa19d0bc01 3869f6231895019bd9f263a0a55a067665cfca4473aab1dc38e8aecf359e23ce6bb35ff900bc84f dd890a3b982ea50dd92f4104e086dce7893384cbfa89fbbf7d33de3f1ee01279a1e9810d952f1c4 40e91fc7ee7cb9cf070dfbdee397e123c363d140221e81610b7bd695905fbf198edfd71a153aeff ffffff0110270000000000001976a9145bd898bbe4a000cda4418c1fd28178ec99cd653e88ac000 00000",
    "complete" : true
}

Quote
./bitcoin-cli getrawtransaction fba4b0a1e11b68c587aae3578844d68131c807913767a1efc9a699d38ecd9f06 1
{
    "hex" : "0100000001b77e855cb62c5d03629bc2b344b434f8904fb94273810666381e38c2e9ff1fbf00000 0006b483045022100a3c055d4cf7055e89a2b27e9bcde43c07bb359532ce7b25a5f1464913539ff 4802205d50de84ebd2cd8b28eea3c4f095200a2eabbed8964646cc79d686e0fd6612c6012103e18 091525834a2a0b62d858cef086fe9a8eb5186131c44df47594b386b9c54dcffffffff02e85a453b 000000001976a91433716532e143818dde6f6b74d08f61c7e4abfdbc88aca08601000000000017a 914e8fa0f97c663ba132bd81e6d657c46825d390e6c8700000000",
    "txid" : "fba4b0a1e11b68c587aae3578844d68131c807913767a1efc9a699d38ecd9f06",
    "version" : 1,
    "locktime" : 0,
    "vin" : [
        {
            "txid" : "bf1fffe9c2381e386606817342b94f90f834b444b3c29b62035d2cb65c857eb7",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "3045022100a3c055d4cf7055e89a2b27e9bcde43c07bb359532ce7b25a5f1464913539ff4802205 d50de84ebd2cd8b28eea3c4f095200a2eabbed8964646cc79d686e0fd6612c601 03e18091525834a2a0b62d858cef086fe9a8eb5186131c44df47594b386b9c54dc",
                "hex" : "483045022100a3c055d4cf7055e89a2b27e9bcde43c07bb359532ce7b25a5f1464913539ff48022 05d50de84ebd2cd8b28eea3c4f095200a2eabbed8964646cc79d686e0fd6612c6012103e1809152 5834a2a0b62d858cef086fe9a8eb5186131c44df47594b386b9c54dc"
            },
            "sequence" : 4294967295
        }
    ],
    "vout" : [
        {
            "value" : 9.94401000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 33716532e143818dde6f6b74d08f61c7e4abfdbc OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a91433716532e143818dde6f6b74d08f61c7e4abfdbc88ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "mkCxbgUiqLyLnyzMipp9zebDVxB1Xt6mZF"
                ]
            }
        },
        {
            "value" : 0.00100000,
            "n" : 1,
            "scriptPubKey" : {
                "asm" : "OP_HASH160 e8fa0f97c663ba132bd81e6d657c46825d390e6c OP_EQUAL",
                "hex" : "a914e8fa0f97c663ba132bd81e6d657c46825d390e6c87",
                "reqSigs" : 1,
                "type" : "scripthash",
                "addresses" : [
                    "2NEV6KKpFiWb3HKb75TqEupePDXaznTqGaC"
                ]
            }
        }
    ],
    "blockhash" : "000000009f5c376c206b2bfc64a505afbea5b3e4b7d03f56d21e4c7ef76d750c",
    "confirmations" : 2135,
    "time" : 1436770837,
    "blocktime" : 1436770837
}
sr. member
Activity: 412
Merit: 266
July 15, 2015, 08:58:48 AM
#5
FYI - normally you have a hard time learning what the txid, vout, and scriptPubKey are when doing multisig with the RPC.

Bitcoind doesn't instantly know everything about a transaction when it syncs. You might find putting txindex=1 into your bitcoin.conf will help you, because you no longer always have to provide the scriptPubKey.

Feel free to PM me and we can do a quick multisig. It helps to write out the commands, and label everything the first time Smiley
sr. member
Activity: 412
Merit: 266
July 15, 2015, 08:55:43 AM
#4
Fair point XX111.

init: This looks wrong..

Code:
Previous output scriptPubKey mismatch:
OP_HASH160 e8fa0f97c663ba132bd81e6d657c46825d390e6c OP_EQUAL
vs:
11 OP_UNKNOWN OP_LSHIFT OP_UNKNOWN OP_UNKNOWN OP_GREATERTHAN 0 OP_UNKNOWN OP_MAX [error] (code -22)

Look where you're passing this. You're telling bitcoind the tx you're trying to spend has a pay-to-pubkey-hash output script. Oops!

This is a hash:
"scriptPubKey":"5bd898bbe4a000cda4418c1fd28178ec99cd653e"}]

This is a pay-to-pubkey-hash output script.
"scriptPubKey":"76a9145bd898bbe4a000cda4418c1fd28178ec99cd653e88ac"

But, you are trying to redeem a pay-to-script-hash script, telling bitcoind it's a pay-to-pubkey-hash script.

So, when you call signrawtransaction {txid, vout, scriptPubKey} - scriptPubKey MUST be the script of the funds you're trying to spend.

jr. member
Activity: 43
Merit: 0
July 13, 2015, 04:04:21 AM
#3
Yes, added like this

Quote
./bitcoind addmultisigaddress 2
'["04D9546728BB1D1BF309EF3C2C7278D8D306052ECF7DC81443F16E75AE607099DFCFC573A3E7155 3BD8321D91C209BAB03AA999BEFA6E77734C0F4DD34EF78EBFD","041050FF637A97FA462DFFA19D0BC013869F6231895019BD9F263A0A55A067665CFCA4473AAB1DC 38E8AECF359E23CE6BB35FF900BC84FDD890A3B982EA50DD92F","04E086DCE7893384CBFA89FBBF7D33DE3F1EE01279A1E9810D952F1C440E91FC7EE7CB9CF070DFB DEE397E123C363D140221E81610B7BD695905FBF198EDFD71A1"]'

But error message the same

Quote
Previous output scriptPubKey mismatch:
OP_HASH160 e8fa0f97c663ba132bd81e6d657c46825d390e6c OP_EQUAL
vs:
11 OP_UNKNOWN OP_LSHIFT OP_UNKNOWN OP_UNKNOWN OP_GREATERTHAN 0 OP_UNKNOWN OP_MAX [error] (code -22)

Also tried to use

Quote
76a9145bd898bbe4a000cda4418c1fd28178ec99cd653e88ac

5bd898bbe4a000cda4418c1fd28178ec99cd653e


From decoded transaction


Quote
"value" : 0.00010000,
"n" : 0,
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 5bd898bbe4a000cda4418c1fd28178ec99cd653e OP_EQUALVERIFY OP_CHECKSIG",
"hex" : "76a9145bd898bbe4a000cda4418c1fd28178ec99cd653e88ac",
"reqSigs" : 1,
"type" : "pubkeyhash",
"addresses" : [
"motbFuaf7Q7xWqBbo7zFu83sdNBspvYkFY"
]
}

Like

Quote
signrawtransaction '0100000001069fcd8ed399a6c9efa167379107c83181d6448857e3aa87c5681be1a1b0a4fb01000 00000ffffffff0110270000000000001976a9145bd898bbe4a000cda4418c1fd28178ec99cd653e 88ac00000000'
'[{"txid":"fba4b0a1e11b68c587aae3578844d68131c807913767a1efc9a699d38ecd9f06","vout":1,"scriptPubKey":"5bd898bbe4a000cda4418c1fd28178ec99cd653e"}]' '["91gFomEpagA1ETnqsfAK5VFeuaR3YnanbfK2L2FfR1yKdcFjmvG","92cDL4Nvw8jvfkrVJYLFVSENY4NPk9NTELQ2CWzPQ6FKmUb2y5t"]'

Or

Quote
signrawtransaction '0100000001069fcd8ed399a6c9efa167379107c83181d6448857e3aa87c5681be1a1b0a4fb01000 00000ffffffff0110270000000000001976a9145bd898bbe4a000cda4418c1fd28178ec99cd653e 88ac00000000'
'[{"txid":"fba4b0a1e11b68c587aae3578844d68131c807913767a1efc9a699d38ecd9f06","vout":1,"scriptPubKey":"76a9145bd898bbe4a000cda4418c1fd28178ec99cd653e88ac"}]' '["91gFomEpagA1ETnqsfAK5VFeuaR3YnanbfK2L2FfR1yKdcFjmvG","92cDL4Nvw8jvfkrVJYLFVSENY4NPk9NTELQ2CWzPQ6FKmUb2y5t"]'

BR!
legendary
Activity: 1260
Merit: 1019
July 13, 2015, 03:50:29 AM
#2
http://bitcoin.stackexchange.com/questions/3712/how-can-i-create-a-multi-signature-2-of-3-transaction

have you added the address by addmultisigaddress command?
you should do it before signing
jr. member
Activity: 43
Merit: 0
July 13, 2015, 03:46:48 AM
#1
Hello,

Tried to create and spend from multi signature address


1) Create 2of3 
Quote
./bitcoind createmultisig 2 '["04D9546728BB1D1BF309EF3C2C7278D8D306052ECF7DC81443F16E75AE607099DFCFC573A3E7155 3BD8321D91C209BAB03AA999BEFA6E77734C0F4DD34EF78EBFD","041050FF637A97FA462DFFA19D0BC013869F6231895019BD9F263A0A55A067665CFCA4473AAB1DC 38E8AECF359E23CE6BB35FF900BC84FDD890A3B982EA50DD92F","04E086DCE7893384CBFA89FBBF7D33DE3F1EE01279A1E9810D952F1C440E91FC7EE7CB9CF070DFB DEE397E123C363D140221E81610B7BD695905FBF198EDFD71A1"]'
 
{
"address" : "2NEV6KKpFiWb3HKb75TqEupePDXaznTqGaC",
"redeemScript" : "524104d9546728bb1d1bf309ef3c2c7278d8d306052ecf7dc81443f16e75ae607099dfcfc573a3e 71553bd8321d91c209bab03aa999befa6e77734c0f4dd34ef78ebfd41041050ff637a97fa462dff a19d0bc013869f6231895019bd9f263a0a55a067665cfca4473aab1dc38e8aecf359e23ce6bb35f f900bc84fdd890a3b982ea50dd92f4104e086dce7893384cbfa89fbbf7d33de3f1ee01279a1e981 0d952f1c440e91fc7ee7cb9cf070dfbdee397e123c363d140221e81610b7bd695905fbf198edfd7 1a153ae"
}

2) Send a few coins to the address 
Quote


3) Checked txId for my new address https://www.blocktrail.com/tBTC/address/2NEV6KKpFiWb3HKb75TqEupePDXaznTqGaC/transactions
fba4b0a1e11b68c587aae3578844d68131c807913767a1efc9a699d38ecd9f06Created 
and created RawTX

Quote
createrawtransaction '''
[
{         
"txid": "'fba4b0a1e11b68c587aae3578844d68131c807913767a1efc9a699d38ecd9f06'",
"vout": '1'
}
]
''' '''
{
"motbFuaf7Q7xWqBbo7zFu83sdNBspvYkFY": 0.0001
}'''

0100000001069fcd8ed399a6c9efa167379107c83181d6448857e3aa87c5681be1a1b0a4fb01000 00000ffffffff0110270000000000001976a9145bd898bbe4a000cda4418c1fd28178ec99cd653e 88ac00000000

3) Decoded raw TX and get scriptPubKey hex

Quote
decoderawtransaction
0100000001069fcd8ed399a6c9efa167379107c83181d6448857e3aa87c5681be1a1b0a4fb01000 00000ffffffff0110270000000000001976a9145bd898bbe4a000cda4418c1fd28178ec99cd653e 88ac00000000


{
"txid" : "6b4e025d8a063994401f1de33ab58156f8002a71f74cdf039a1aede84c70af90",
"version" : 1,
"locktime" : 0,
"vin" : [
{
"txid" : "fba4b0a1e11b68c587aae3578844d68131c807913767a1efc9a699d38ecd9f06",
"vout" : 1,
"scriptSig" : {
"asm" : "",
"hex" : ""
},
"sequence" : 4294967295
}
],
"vout" : [
{
"value" : 0.00010000,
"n" : 0,
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 5bd898bbe4a000cda4418c1fd28178ec99cd653e OP_EQUALVERIFY OP_CHECKSIG",
"hex" : "76a9145bd898bbe4a000cda4418c1fd28178ec99cd653e88ac",
"reqSigs" : 1,
"type" : "pubkeyhash",
"addresses" : [
"motbFuaf7Q7xWqBbo7zFu83sdNBspvYkFY"
]
}
}
]
}


4) Tried to signature

Quote
signrawtransaction '0100000001069fcd8ed399a6c9efa167379107c83181d6448857e3aa87c5681be1a1b0a4fb01000 00000ffffffff0110270000000000001976a9145bd898bbe4a000cda4418c1fd28178ec99cd653e 88ac00000000'
'[{"txid":"fba4b0a1e11b68c587aae3578844d68131c807913767a1efc9a699d38ecd9f06","vout":1,"scriptPubKey":"76a9145bd898bbe4a000cda4418c1fd28178ec99cd653e88ac"}]' '["91gFomEpagA1ETnqsfAK5VFeuaR3YnanbfK2L2FfR1yKdcFjmvG","92cDL4Nvw8jvfkrVJYLFVSENY4NPk9NTELQ2CWzPQ6FKmUb2y5t"]'

5) Have got error

Quote
Previous output scriptPubKey mismatch:
OP_HASH160 e8fa0f97c663ba132bd81e6d657c46825d390e6c OP_EQUAL
vs:
OP_DUP OP_HASH160 5bd898bbe4a000cda4418c1fd28178ec99cd653e OP_EQUALVERIFY OP_CHECKSIG (code -22)

Which scriptPubKey should I use? How can I get it?

BR!
Jump to: