Open mrfelton opened 12 months ago
I'd like take up this issue.
With https://github.com/ElementsProject/peerswap/pull/281, I have implemented setting the payment_request for lightning payment.
I will address Labeling of onchain transactions separately.
With https://github.com/ElementsProject/peerswap/pull/282, I have implemented labeling transactions.
Peerswap adds a memo to some of the lightning invoices related to swapins that enable easy identification and categorisation of some of the off chain payments related to those swaps. However, labels are not added to the counterpart onchain transactions. This lack of identifying labels for the onchain transactions prevents easy categorisation of the economic activity, and therefore difficulties in accounting and reconciliation.
Additionally, when doing a BTC swapout, there is no way to identify either the onchain receive, or either of the lightning payments as being related to the swap - The onchain receive isn't labeled, and the lightning payments are non-identifiable in lnd. The issue is that peerswaps is paying directly to a payment hash, rather than to a payment request, and as a result payments in lnd's database have no association to the invoices that were paid and therefore no access to the memo from those invoices.
Ideally, we'd be able to use faraday's audit tool to properly classify all of the component parts of a swap,. but this is not currently possible because of the missing correlation points.
For example, the following faraday audit command should allow for classification of all parts of the swaps, but currently only the some are included in the output.
The onchain transactions corresponding to the swaps have the
label
is set to the default value ofexternal
, which is why they are not being categorised as peerswaps by faraday:For more info, see:
Notes
Currently when performing a swap-out, appropriate descriptions are added to the invoices that the recipient creates. e.g.
fee:
peerswap lbtc fee 110x1x1 571e3c0ce9e504e0bda94e01144ed0164021574ce686c719d79488a7e1ac0949
claim:
peerswap lbtc claim 110x1x1 571e3c0ce9e504e0bda94e01144ed0164021574ce686c719d79488a7e1ac0949
However, when the payer pays these invoices, it's not paying to the payment request, but instead it's paying directly to the payment hash. See here https://github.com/ElementsProject/peerswap/blob/aef7098f9e57d4490db9799a1680baa1f60715d3/lnd/client.go#L321C26-L323
Notice in the following output from
lnd1 listpayments
thatpayment_request
is not set in either of the payments that relate to the peerswap, and because of this, the sender doesn't have a reference to the payment requests that it paid:Suggested fix
Do not use
SendToRoute
to send the payments here: https://github.com/ElementsProject/peerswap/blob/aef7098f9e57d4490db9799a1680baa1f60715d3/lnd/client.go#L321-L324Instead, use the SendPaymentV2 RPC and set
payment_request
in the request. This will ensure that the payments are linked to the peerswap invoices that were paid.Additionally, when making onchain payments, set a label on the transaction (both in the sender and the recipient's wallets) in order to identify them as peerswaps.
For example, for BTC swaps, when publishing the onchain transaction here: https://github.com/ElementsProject/peerswap/blob/aef7098f9e57d4490db9799a1680baa1f60715d3/lnd/lnd_wallet.go#L203
Set the
label
parameter when calling the PublishTransaction RPC.And on the receiving side, use the LabelTransaction RPC to label the incoming onchain transaction once it has been detected.