Browse Source

Merge #708: Removes utxo field from non-receiver inputs

6a8149fe96 Removes utxo field from non-receiver inputs (Adam Gibson)

Pull request description:

  Prior to this commit, the payjoin receiver code
  was signing a PSBT containing the utxo field
  for every input, including the ones it did not
  own, and transferring this to the sender.
  However BIP78 specifies that, for inputs belonging
  to the sender, no utxo field should be included.
  This is corrected in this commit.

ACKs for top commit:
  kristapsk:
    Tested this with BTCPay Server and it succeeded! ACK 6a8149fe96

Tree-SHA512: df5b8770ef9398ede622a4584edc75d3da2665936136b2705c0b72ba108d6268c20e238cb635a97799e1279d468fcd94d47c0b4d87af5e26c4f2790b952f68bc
master
Kristaps Kaupe 5 years ago
parent
commit
70105a4954
No known key found for this signature in database
GPG Key ID: D47B1B4232B55437
  1. 8
      jmclient/jmclient/payjoin.py

8
jmclient/jmclient/payjoin.py

@ -953,6 +953,8 @@ class PayjoinServer(Resource):
# intended (note the outputs will be shuffled next!):
outs[1]["value"] -= our_fee_bump
# TODO this only works for 2 input transactions, otherwise
# pure-shuffle will not be valid as per BIP78 ordering requirement.
unsigned_payjoin_tx = btc.make_shuffled_tx(payjoin_tx_inputs, outs,
version=payment_psbt.unsigned_tx.nVersion,
locktime=payment_psbt.unsigned_tx.nLockTime)
@ -970,6 +972,7 @@ class PayjoinServer(Resource):
inp.nSequence = inp2.nSequence
spent_outs.append(payment_psbt.inputs[j].utxo)
input_found = True
sender_index = i
break
if input_found:
continue
@ -1007,6 +1010,11 @@ class PayjoinServer(Resource):
assert signresult.num_inputs_final == len(receiver_utxos)
assert not signresult.is_final
# with signing succcessful, remove the utxo field from the
# counterparty's input (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)
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

Loading…
Cancel
Save