OutCast3k / coinbin

Javascript Bitcoin Wallet. Supports Multisig, Stealth, HD, SegWit, Bech32, Time Locked Addresses, RBF and more!
https://coinb.in/
MIT License
907 stars 622 forks source link

multisig 2-of-2, how to create a blank check transaction? #109

Open zilveer opened 7 years ago

zilveer commented 7 years ago

Hello, I have a 2-of-2 multisig address and would like to create a blank check transaction with SIGHASH Single with one private key. Is there anyone here who can tell me or guide me on how to create a a blank check with SIGHASH Single?

zilveer commented 7 years ago

Any ideas?

dabura667 commented 7 years ago

You want to use SIGHASH_NONE mixed with SIGHASH_ANYONECANPAY

  1. Create a transaction using SIGHASH_NONE and SIGHASH_ANYONECANPAY
  2. I think Coinbin will break if you don't add an output, so just make a random one and send it all.
  3. Sign it with 2 keys of 2.
  4. Send the transaction to whoever you want to use it.
  5. They will add any utxo they own with their key as the second input and change the output to send to their own address and account for fees and sign it using SIGHASH_ALL (the default normal one) (This can not be done in the coinbin UI currently, but if you modify the raw transaction manually, it should work.)
  6. The final signed transaction will be one input from your 2of2 signed using NONE and ANYONECANPAY, and one input from the person claiming your check using ALL (default sighash) and sending the outputs to themselves. Then they broadcast it.

Note: If you broadcast the transaction on step 4 it will be valid, and if it is confirmed in a block it will be set in stone... but anyone who sees the transaction could change the outputs and it would still be valid. Though unless you opted in RBF it wouldn't propagate.

zilveer commented 7 years ago

@dabura667 thx for the step by step description of how to do it.

But cannot I use SiGHASH single with a blank check instead ? For example I want user1 sign it priv1key, the amount should be minimal since it will be a blank check. (Could the amount be set to zero here ? And the I use an address which the user 1 holds.

User2 will be the one who will add new outputs and sign the RAW hex which is signed by user1. User2 will sign it with SIGHASH ALL and will broadcast it to the network.

Please correct me if this is correct way of thinking or if there is a better method to do this? Regards