Closed YusukeShimizu closed 4 months ago
LND swap-out is canceled but the error peerswap prints is unclear:
$ ./builds/peerswap/out/pscli swapout --sat_amt 9001400 --channel_id 214039729557274624 --asset lbtc
2024/07/18 11:05:42 rpc error: code = Unknown desc = BuildRoute() rpc error: code = Unknown desc = no matching outgoing channel available for node 0 (035ca2fe4793a5e789ce846062eb4834f573c060d9200ce77544a29b48a0aa5923)
LND logs:
2024-07-18 11:05:36.273 [WRN] CRTR: ShortChannelID=194668:21:0: cannot add outgoing htlc: commitment transaction dips peer below chan reserve: our balance below chan reserve
2024-07-18 11:05:36.273 [ERR] CRTR: Cannot find policy with amt=9001400000 mSAT for node 035ca2fe4793a5e789ce846062eb4834f573c060d9200ce77544a29b48a0aa5923
2024-07-18 11:05:36.273 [ERR] RPCS: [/routerrpc.Router/BuildRoute]: no matching outgoing channel available for node 0 (035ca2fe4793a5e789ce846062eb4834f573c060d9200ce77544a29b48a0aa5923)
2024-07-18 11:05:36.791 [WRN] CRTR: ShortChannelID=194668:21:0: cannot add outgoing htlc: commitment transaction dips peer below chan reserve: our balance below chan reserve
2024-07-18 11:05:36.791 [ERR] CRTR: Cannot find policy with amt=9001400000 mSAT for node 035ca2fe4793a5e789ce846062eb4834f573c060d9200ce77544a29b48a0aa5923
2024-07-18 11:05:36.791 [ERR] RPCS: [/routerrpc.Router/BuildRoute]: no matching outgoing channel available for node 0 (035ca2fe4793a5e789ce846062eb4834f573c060d9200ce77544a29b48a0aa5923)
2024-07-18 11:05:37.678 [WRN] CRTR: ShortChannelID=194668:21:0: cannot add outgoing htlc: commitment transaction dips peer below chan reserve: our balance below chan reserve
2024-07-18 11:05:37.678 [ERR] CRTR: Cannot find policy with amt=9001400000 mSAT for node 035ca2fe4793a5e789ce846062eb4834f573c060d9200ce77544a29b48a0aa5923
2024-07-18 11:05:37.678 [ERR] RPCS: [/routerrpc.Router/BuildRoute]: no matching outgoing channel available for node 0 (035ca2fe4793a5e789ce846062eb4834f573c060d9200ce77544a29b48a0aa5923)
2024-07-18 11:05:38.478 [WRN] CRTR: ShortChannelID=194668:21:0: cannot add outgoing htlc: commitment transaction dips peer below chan reserve: our balance below chan reserve
2024-07-18 11:05:38.478 [ERR] CRTR: Cannot find policy with amt=9001400000 mSAT for node 035ca2fe4793a5e789ce846062eb4834f573c060d9200ce77544a29b48a0aa5923
2024-07-18 11:05:38.479 [ERR] RPCS: [/routerrpc.Router/BuildRoute]: no matching outgoing channel available for node 0 (035ca2fe4793a5e789ce846062eb4834f573c060d9200ce77544a29b48a0aa5923)
2024-07-18 11:05:39.489 [WRN] CRTR: ShortChannelID=194668:21:0: cannot add outgoing htlc: commitment transaction dips peer below chan reserve: our balance below chan reserve
2024-07-18 11:05:39.489 [ERR] CRTR: Cannot find policy with amt=9001400000 mSAT for node 035ca2fe4793a5e789ce846062eb4834f573c060d9200ce77544a29b48a0aa5923
2024-07-18 11:05:39.490 [ERR] RPCS: [/routerrpc.Router/BuildRoute]: no matching outgoing channel available for node 0 (035ca2fe4793a5e789ce846062eb4834f573c060d9200ce77544a29b48a0aa5923)
2024-07-18 11:05:42.432 [WRN] CRTR: ShortChannelID=194668:21:0: cannot add outgoing htlc: commitment transaction dips peer below chan reserve: our balance below chan reserve
2024-07-18 11:05:42.432 [ERR] CRTR: Cannot find policy with amt=9001400000 mSAT for node 035ca2fe4793a5e789ce846062eb4834f573c060d9200ce77544a29b48a0aa5923
2024-07-18 11:05:42.433 [ERR] RPCS: [/routerrpc.Router/BuildRoute]: no matching outgoing channel available for node 0 (035ca2fe4793a5e789ce846062eb4834f573c060d9200ce77544a29b48a0aa5923)
CLN swap-out is also canceled and the error message is more clear:
$ lightning-cli --signet peerswap-swap-out 194668x21x0 188986293 lbtc
{
"code": -1,
"message": "swap canceled, reason: not enough spendable msat: 188986294000, expected: 188986593000"
}
Thank you. There was an error in calculating the spendable amount in LND.
I confirmed that the behavior is as expected on our end.
./bin/lncli lnd1 listchannels | jq '.channels[] | {local_balance, local_chan_reserve_sat}'
{
"local_balance": "99996530",
"local_chan_reserve_sat": "1000000"
}
result=$(./bin/lncli lnd1 listchannels | jq -r '.channels[] | (.local_balance | tonumber) - (.local_chan_reserve_sat | tonumber)')
AMOUNT=$((result - 200))
./out/pscli swapout --channel_id 127543348887553 --sat_amt $AMOUNT --asset lbtc
2024/07/19 11:07:50 rpc error: code = Unknown desc = not enough spendable msat: 98996530000, expected: 98996630000
It looks like my error slightly differs from yours?
Yours:
2024/07/19 11:07:50 rpc error: code = Unknown desc = not enough spendable msat: 98996530000, expected: 98996630000
Mine:
2024/07/22 09:53:08 rpc error: code = Unknown desc = exceeding spendable amount_msat: 6108700000
The cause is due to the difference in where the error is detected.
Your error is detected at the check stage of SwapOut start, where the fee invoice is not considered. This is because the amount of the fee invoice is unknown at this stage.
Therefore, it seems that the amount is insufficient even without including the fee invoice.
https://github.com/ElementsProject/peerswap/blob/pre-swapcheck-fee/swap/service.go#L390
My error passes the check at the SwapOut start stage and is detected at the PayFeeInvoiceAction stage, which is part of the recent changes.
At this stage, the fee invoice is also taken into account.
https://github.com/ElementsProject/peerswap/blob/pre-swapcheck-fee/swap/actions.go#L609
During swap-out, conduct a pre-swap check, including the payment of the fee invoice.