ElementsProject / peerswap-spec

6 stars 3 forks source link

Provide onchain UTXOs early (`swap_in_request` and `swap_out_agreement`) for early abort #11

Open ZmnSCPxj-jr opened 1 year ago

ZmnSCPxj-jr commented 1 year ago

In some cases, a node offering peerswap services may be located or under a jurisdiction which legally requires sanctioning particular UTXos or addresses. Such a node would, with the current protocol, reject such UTXOs "late", i.e. when the transaction spending such a UTXO has already been spent into the onchain HTLC, thus forcing the onchain HTLC maker to use an expensive funds recovery on abort.

By adding a list of UTXOs in the swap_in_request and swap_out_agreement, the receiver of the onchain funds can inspect the UTXOs before the onchain HTLC is instantiated. So while it has to still reject the swap, at least the rejection is "early", before the sender of the onchain HTLC has created and broadcasted a transaction that spends those UTXOs.

My proposal is to add an array of strings (if using JSON format still) or a variable-length field, planned_utxos, to both swap_in_request and swap_out_agreement.

The receiver of swap_in_request or swap_out_agreement would have:

Then, in the section "Doing the Swap", for the receiver of the opening_tx_broadcast message, we would add the clause:

This feature affects forwardable peerswaps. If the node you are forwarding to is in a jurisdiction that requires legal sanctioning of particular UTXOs, then it is best to ask them early so you have an opportunity to select a different next hop that might accept the proposed UTXOs.