0

Say I am building a transaction in private:

  1. Input 1 is signed with SIGHASH_SINGLE ( | SIGHASH_ANYONECANPAY)
  2. Input 2 is signed with SIGHASH_NONE | SIGHASH_ANYONECANPAY

SIGHASH_NONE implies that Input 2 will only spend if Input 1 is included in the transaction. Am I able to communicate this privately-signed transaction in such a way that Input 1 is also locked on the condition that Input 2 is included?

For example, I send this partially-signed transaction, with both signatures, to a person I do not trust.

Are they able to spend Input 1 (the SIGHASH_SINGLE) in another transaction without Input 2 included?

What can I do to lock these two inputs together, with one of the inputs also being locked to an output, while still allowing people to add inputs to the transaction?

1 Answer 1

3

SIGHASH_NONE implies that Input 2 will only spend if Input 1 is included in the transaction.

This is false.

Input 2 is essentially a blank check. SIGHASH_NONE signs none of the outputs (I don't care where the BTC goes), and SIGHASH_ANYONECANPAY signs only input 2 (I don't care who else is participating in the tx. This essentially creates an input, which if you give to anyone else, is the equivalent of "Here's a blank check for X BTC, do what you want with it".

Are they able to spend Input 1 (the SIGHASH_SINGLE) in another transaction without Input 2 included?

Since Input 1 is signed using SIGHASH_SINGLE, only output 1 is signed under it. However, the SIGHASH_ANYONECANPAY flag means that only input 1 is signed as well, which completely decouples it from input 2.

Now, if you were to remove the SIGHASH_ANYONECANPAY flag from input 1, then you end up with a tx that is able to spend up to input 1 + input 2 BTC, but is only spending output 1. In this scenario, spending input 1 is dependent on spending input 2 as well. However, since input 1 is SIGHASH_SINGLE, and input 2 is SIGHASH_NONE, anyone you share the tx with is able to add their own outputs to it, but not add any more inputs.

Moreover, since input 2 is SIGHASH_NONE | SIGHASH_ANYONECANPAY, anyone you share the tx with can extract just input 2, and reuse it in a completely different tx without requiring input 1. The way to counter that would be to remove the SIGHASH_ANYONECANPAY , so that it is at least locked to being spent with, and only with, input 1.

What can I do to lock these two inputs together, with one of the inputs also being locked to an output, while still allowing people to add inputs to the transaction?

You could spend to to a single output, then create a new partial tx with that single output being spent with your required destination and amount, and sign that with SIGHASH_SINGLE | SIGHASH_ANYONECANPAY

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.