mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loop: clean up server cost calculation for slightly better UX
Previously we'd calculate the server costs (swap fees) by accounting for both the on-chain HTLC and the off-chain payment which was confusing as server cost fluctuated by the amount of the swap itself. Now we'll only add the actual cost when the swap happened, so the server cost will go form zero to the actual fee value paid.
This commit is contained in:
parent
e1ddb50dfe
commit
5294b4ff07
2 changed files with 6 additions and 14 deletions
|
|
@ -452,7 +452,8 @@ func (s *loopOutSwap) handlePaymentResult(result paymentResult) error {
|
|||
return nil
|
||||
|
||||
case result.status.State == lnrpc.Payment_SUCCEEDED:
|
||||
s.cost.Server += result.status.Value.ToSatoshis()
|
||||
s.cost.Server += result.status.Value.ToSatoshis() -
|
||||
s.AmountRequested
|
||||
s.cost.Offchain += result.status.Fee.ToSatoshis()
|
||||
|
||||
return nil
|
||||
|
|
@ -539,9 +540,7 @@ func (s *loopOutSwap) executeSwap(globalCtx context.Context) error {
|
|||
|
||||
sweepSuccessful := s.htlc.IsSuccessWitness(htlcInput.Witness)
|
||||
if sweepSuccessful {
|
||||
s.cost.Server -= htlcValue
|
||||
s.cost.Onchain = spend.OnChainFeePortion
|
||||
|
||||
s.state = loopdb.StateSuccess
|
||||
} else {
|
||||
s.state = loopdb.StateFailSweepTimeout
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue