-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
swap: calculate required balance including fee #303
Conversation
During swap-out, conduct a pre-swap check, including the payment of the fee invoice.
LND swap-out is canceled but the error peerswap prints is unclear:
LND logs:
CLN swap-out is also canceled and the error message is more clear:
|
The prepayment probe, which includes the expected payment amount for the fee invoice, is conducted at the start of the swapout. The prepayment probe at this stage is inaccurate and may cause unnecessary communication, so it will be removed.
Fixes the calculation of the SpendableMsat and ReceivableMsat.
Thank you. 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:
Mine:
|
The cause is due to the difference in where the error is detected. My error passes the check at the SwapOut start stage and is detected at the PayFeeInvoiceAction stage, which is part of the recent changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm!
ACK 76fa0cb
@@ -131,7 +131,7 @@ func (l *Client) SpendableMsat(scid string) (uint64, error) { | |||
return 0, err | |||
} | |||
spendable := (uint64(ch.GetLocalBalance()) - | |||
ch.GetLocalConstraints().GetChanReserveSat()*1000) | |||
ch.GetLocalConstraints().GetChanReserveSat()) * 1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
During swap-out, conduct a pre-swap check, including the payment of the fee invoice.