Skip to content

Commit

Permalink
Merge #1700: Support payjoin PSBT with multiple sender inputs
Browse files Browse the repository at this point in the history
865247c Support payjoin PSBT with multiple sender inputs (spacebear)

Pull request description:

  [Compatibility testing with PDK](payjoin/rust-payjoin#51 (comment)) revealed that the JoinMarket payjoin receiver doesn't support signing for PSBTs that contain multiple sender inputs. This patch fixes that.

ACKs for top commit:
  AdamISZ:
    tACK 865247c
  kristapsk:
    re-ACK 865247c

Tree-SHA512: cf25e161be229bc440e1f0a5ad16d529e30c1470e7f6ba450ab912458f6c4db05b3ed9e463549685c5a52f37c234809f4d042522f358a0293a36932c005bbe0d
  • Loading branch information
kristapsk committed May 19, 2024
2 parents 527d27c + 865247c commit ef0afbd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/jmclient/payjoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ def request_to_psbt(self, payment_psbt_base64, sender_parameters):
# to create the PSBT we need the spent_outs for each input,
# in the right order:
spent_outs = []
sender_indices = []
for i, inp in enumerate(unsigned_payjoin_tx.vin):
input_found = False
for j, inp2 in enumerate(payment_psbt.unsigned_tx.vin):
Expand All @@ -862,7 +863,7 @@ def request_to_psbt(self, payment_psbt_base64, sender_parameters):
inp.nSequence = inp2.nSequence
spent_outs.append(payment_psbt.inputs[j].utxo)
input_found = True
sender_index = i
sender_indices.append(i)
break
if input_found:
continue
Expand Down Expand Up @@ -900,10 +901,11 @@ def request_to_psbt(self, payment_psbt_base64, sender_parameters):
assert not signresult.is_final

# with signing successful, remove the utxo field from the
# counterparty's input (this is required by BIP78). Note we don't
# counterparty's inputs (this is required by BIP78). Note we don't
# do this on PSBT creation as the psbt signing code throws ValueError
# unless utxos are present.
receiver_signed_psbt.inputs[sender_index] = btc.PSBT_Input(index=sender_index)
for sender_index in sender_indices:
receiver_signed_psbt.inputs[sender_index] = btc.PSBT_Input(index=sender_index)
log.debug("Receiver signing successful. Payjoin PSBT is now:\n{}".format(
self.wallet_service.human_readable_psbt(receiver_signed_psbt)))
# construct txoutset for the wallet service callback; we cannot use
Expand Down

0 comments on commit ef0afbd

Please sign in to comment.