Browse Source

Merge JoinMarket-Org/joinmarket-clientserver#1700: Support payjoin PSBT with multiple sender inputs

865247cf8d Support payjoin PSBT with multiple sender inputs (spacebear)

Pull request description:

  [Compatibility testing with PDK](https://github.com/payjoin/rust-payjoin/issues/51#issuecomment-2100765588) 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 865247cf8d
  kristapsk:
    re-ACK 865247cf8d

Tree-SHA512: cf25e161be229bc440e1f0a5ad16d529e30c1470e7f6ba450ab912458f6c4db05b3ed9e463549685c5a52f37c234809f4d042522f358a0293a36932c005bbe0d
master
Kristaps Kaupe 2 years ago
parent
commit
ef0afbd4c5
No known key found for this signature in database
GPG Key ID: 33E472FE870C7E5D
  1. 8
      src/jmclient/payjoin.py

8
src/jmclient/payjoin.py

@ -852,6 +852,7 @@ class PayjoinConverter(object):
# to create the PSBT we need the spent_outs for each input, # to create the PSBT we need the spent_outs for each input,
# in the right order: # in the right order:
spent_outs = [] spent_outs = []
sender_indices = []
for i, inp in enumerate(unsigned_payjoin_tx.vin): for i, inp in enumerate(unsigned_payjoin_tx.vin):
input_found = False input_found = False
for j, inp2 in enumerate(payment_psbt.unsigned_tx.vin): for j, inp2 in enumerate(payment_psbt.unsigned_tx.vin):
@ -862,7 +863,7 @@ class PayjoinConverter(object):
inp.nSequence = inp2.nSequence inp.nSequence = inp2.nSequence
spent_outs.append(payment_psbt.inputs[j].utxo) spent_outs.append(payment_psbt.inputs[j].utxo)
input_found = True input_found = True
sender_index = i sender_indices.append(i)
break break
if input_found: if input_found:
continue continue
@ -900,10 +901,11 @@ class PayjoinConverter(object):
assert not signresult.is_final assert not signresult.is_final
# with signing successful, remove the utxo field from the # 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 # do this on PSBT creation as the psbt signing code throws ValueError
# unless utxos are present. # 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( log.debug("Receiver signing successful. Payjoin PSBT is now:\n{}".format(
self.wallet_service.human_readable_psbt(receiver_signed_psbt))) self.wallet_service.human_readable_psbt(receiver_signed_psbt)))
# construct txoutset for the wallet service callback; we cannot use # construct txoutset for the wallet service callback; we cannot use

Loading…
Cancel
Save