Kixunil / payjoin

Rust PayJoin (BIP78) implementation
23 stars 5 forks source link

This implementation and BIP 78 spec conflict with BIP 174 PSBT spec #39

Open DanGould opened 1 year ago

DanGould commented 1 year ago

According to BIP 78 spec

  • For each inputs in the proposal:
    • If it is one of the sender's input
    • Verify that non_witness_utxo and witness_utxo are not specified.

which we follow here https://github.com/Kixunil/payjoin/blob/a225bafa1bfb99e80ab19687038c860dfee112e9/bip78/src/sender/mod.rs#L249-L250

According to the psbt Input Finalizer spec "All other data except the UTXO and unknown fields in the input key-value map should be cleared from the PSBT. The UTXO should be kept to allow Transaction Extractors to verify the final network serialized transaction." In Bip78, the receiver clears this data after it finalizes its inputs, even if the utxo belongs to the sender which needs that data.

I ran into a problem where LND's FinalizePsbt gRPC fails when this utxo data is missing. I see no good reason to remove this utxo information from the PSBT. I think LND's RPC should also succeed regardless of this data being present because it can look it up with the unsigned_tx's input outpoint (that's what bitcoind does). Still I think LND's RPC is technically BIP-0174 spec-compliant while BIP-0078 seems not to be.

https://github.com/lightningnetwork/lnd/blob/cf9a9864cf253dbbcac5904d360bbbde763e1ebe/lnwallet/rpcwallet/rpcwallet.go#L270-L286

cc @nickfarrow

Kixunil commented 1 year ago

My brain has maybe 20% capacity but I think since it's the sender input you could just restore the known information before calling LND RPC? I think the point of that check is that the sender already knows the previous input so the receiver shouldn't tell the sender which it is.

DanGould commented 1 year ago

Yes, and maybe checking Original PSBT in == PayJoin PSBT should be a check in that case