Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: bit_kevin on June 23, 2013, 05:03:17 AM



Title: which address will get the money in multisig?
Post by: bit_kevin on June 23, 2013, 05:03:17 AM
Transaction:
https://blockchain.info/tx/60a20bd93aa49ab4b28d514ec10b06e1829ce6818ec06cd3aabd013ebcdc4bb1

Dump Tx raw, here is vout part:

Quote
    "vout" : [
        {
            "value" : 0.01000000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "1 04cc71eb30d653c0c3163990c47b976f3fb3f37cccdcbedb169a1dfef58bbfbfaff7d8a473e7e2e 6d317b87bafe8bde97e3cf8f065dec022b51d11fcdd0d348ac4 0461cbdcc5409fb4b4d42b51d33381354d80e550078cb532a34bfa2fcfdeb7d76519aecc62770f5 b0e4ef8551946d8a540911abe3e7854a26f39f58b25c15342af 2 OP_CHECKMULTISIG",
                "hex" : "514104cc71eb30d653c0c3163990c47b976f3fb3f37cccdcbedb169a1dfef58bbfbfaff7d8a473e 7e2e6d317b87bafe8bde97e3cf8f065dec022b51d11fcdd0d348ac4410461cbdcc5409fb4b4d42b 51d33381354d80e550078cb532a34bfa2fcfdeb7d76519aecc62770f5b0e4ef8551946d8a540911 abe3e7854a26f39f58b25c15342af52ae",
                "reqSigs" : 1,
                "type" : "multisig",
                "addresses" : [
                    "1AJbsFZ64EpEfS5UAjAfcUG8pH8Jn3rn1F",
                    "1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq"
                ]
            }
        },
        {
            "value" : 0.46452304,
            "n" : 1,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 c812a297b8e0e778d7a22bb2cd6d23c3e789472b OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a914c812a297b8e0e778d7a22bb2cd6d23c3e789472b88ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "1KEtUA8f76CpHmFukC28uUsfsUduexvsSB"
                ]
            }
        },
        {
            "value" : 0.00500000,
            "n" : 2,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 641ad5051edd97029a003fe9efb29359fcee409d OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a914641ad5051edd97029a003fe9efb29359fcee409d88ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq"
                ]
            }
        }
    ],

In vout[0], there are two address("1AJbsFZ64EpEfS5UAjAfcUG8pH8Jn3rn1F", "1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq") got value 0.01000000, but which address gets the money?


Title: Re: which address will get the money in multisig?
Post by: domob on June 23, 2013, 09:14:48 AM
I would say "neither of those" gets the money, or maybe "both".  Since this seems to be a "1 of 1" multisig (according to blockchain.info), it means that either owner of one of those addresses can spend the 0.01 BTC (think: "whoever comes first").  Where the money is sent in this case is decided by the one spending it.


Title: Re: which address will get the money in multisig?
Post by: bluemeanie1 on June 24, 2013, 03:11:07 AM
Seems a lot of people don't understand what a multisig transaction is.

It requires 2+ crypto keys to unlock the transaction and the output can then be put into any address the owners of those two keys wish.

as far as I know, no wallets will show this particular transaction as part of the balance for either address.

so in that sense, it's in a special JOINT ACCOUNT.  It might be possible to make a special kind of wallet app that can show the balance of such a joint account(perhaps one already exists), however this balance cannot be spent without BOTH private keys.


Title: Re: which address will get the money in multisig?
Post by: bit_kevin on June 25, 2013, 11:27:26 AM
Seems a lot of people don't understand what a multisig transaction is.

It requires 2+ crypto keys to unlock the transaction and the output can then be put into any address the owners of those two keys wish.

as far as I know, no wallets will show this particular transaction as part of the balance for either address.

so in that sense, it's in a special JOINT ACCOUNT.  It might be possible to make a special kind of wallet app that can show the balance of such a joint account(perhaps one already exists), however this balance cannot be spent without BOTH private keys.

so what's the difference between p2sh and multisig?


Title: Re: which address will get the money in multisig?
Post by: kjj on June 25, 2013, 12:07:12 PM
In P2SH, there are two scripts.  The first script is a stub that makes other nodes recognize it as a P2SH script, and it includes the hash of the second script.  The second script can be anything, and it isn't revealed until the transaction is redeemed.  The hash of the revealed script must match the hash embedded in the stub.

Multisig is just a special script that has an instruction that verifies that at least M-of-N signatures are present.  This script can be in a normal transaction, or it can be in a P2SH transaction.

The stock client understands multisig via P2SH.  There are commands to create P2SH multisig addresses, and the client will understand them correctly.  If the client knows the P2SH address in question, and knows enough of the keys to redeem it, then the transaction will show up in listunspent, and the value will be calculated in your wallet balance, etc.


Title: Re: which address will get the money in multisig?
Post by: bit_kevin on June 25, 2013, 03:21:22 PM
In P2SH, there are two scripts.  The first script is a stub that makes other nodes recognize it as a P2SH script, and it includes the hash of the second script.  The second script can be anything, and it isn't revealed until the transaction is redeemed.  The hash of the revealed script must match the hash embedded in the stub.

Multisig is just a special script that has an instruction that verifies that at least M-of-N signatures are present.  This script can be in a normal transaction, or it can be in a P2SH transaction.

The stock client understands multisig via P2SH.  There are commands to create P2SH multisig addresses, and the client will understand them correctly.  If the client knows the P2SH address in question, and knows enough of the keys to redeem it, then the transaction will show up in listunspent, and the value will be calculated in your wallet balance, etc.

They all share some coin, P2SH is just one address(generated from multi public key) with redeemScript, Multisig has at least one address.
The coin which they shared is not belong to any one of these addresses.
To spend the coin, they all need at least one private key to sign.
Use command "#bitcoind gettxout xxxxx n" can find them before spend.

I think they the same thing, just looks different. P2SH looks more simple than multisig.


Title: Re: which address will get the money in multisig?
Post by: dserrano5 on June 25, 2013, 07:14:30 PM
In P2SH, there are two scripts.  The first script is a stub that makes other nodes recognize it as a P2SH script, and it includes the hash of the second script.  The second script can be anything, and it isn't revealed until the transaction is redeemed.  The hash of the revealed script must match the hash embedded in the stub.

Multisig is just a special script that has an instruction that verifies that at least M-of-N signatures are present.  This script can be in a normal transaction, or it can be in a P2SH transaction.

The stock client understands multisig via P2SH.  There are commands to create P2SH multisig addresses, and the client will understand them correctly.  If the client knows the P2SH address in question, and knows enough of the keys to redeem it, then the transaction will show up in listunspent, and the value will be calculated in your wallet balance, etc.

Thank for this good explanation, however I don't understand a thing in the last paragraph: if the client knows the P2SH address, it knows the hash of the script but doesn't know the script itself, so isn't able to determine if it has enough of the keys to redeem it, therefore it can't appear in listunspent etc. Now, is this correct or am I overseeing something?


Title: Re: which address will get the money in multisig?
Post by: kjj on June 25, 2013, 07:53:46 PM
In P2SH, there are two scripts.  The first script is a stub that makes other nodes recognize it as a P2SH script, and it includes the hash of the second script.  The second script can be anything, and it isn't revealed until the transaction is redeemed.  The hash of the revealed script must match the hash embedded in the stub.

Multisig is just a special script that has an instruction that verifies that at least M-of-N signatures are present.  This script can be in a normal transaction, or it can be in a P2SH transaction.

The stock client understands multisig via P2SH.  There are commands to create P2SH multisig addresses, and the client will understand them correctly.  If the client knows the P2SH address in question, and knows enough of the keys to redeem it, then the transaction will show up in listunspent, and the value will be calculated in your wallet balance, etc.

Thank for this good explanation, however I don't understand a thing in the last paragraph: if the client knows the P2SH address, it knows the hash of the script but doesn't know the script itself, so isn't able to determine if it has enough of the keys to redeem it, therefore it can't appear in listunspent etc. Now, is this correct or am I overseeing something?

Knowing the script is what I mean by knowing the address.

The node doesn't try every key it has against every transaction it sees to see if it can redeem it, it cheats.  It stores something called the scriptPubKey and uses that to look up secrets.  The secrets are usually private keys, but in this case, it is the redemption script.


Title: Re: which address will get the money in multisig?
Post by: dserrano5 on June 26, 2013, 07:14:44 AM
The secrets are usually private keys, but in this case, it is the redemption script.

Aha this was my missing bit. Thanks again.