@@ -2078,18 +2078,42 @@ func (s *swapClientServer) StaticAddressLoopIn(ctx context.Context,
20782078 return nil , err
20792079 }
20802080
2081+ // Build a list of used deposits for the response.
2082+ usedDeposits := filter (
2083+ loopIn .Deposits , func (d * deposit.Deposit ) bool { return true },
2084+ )
2085+
2086+ // Determine the actual swap amount and change based on the selected
2087+ // amount and the total value of the selected deposits.
2088+ total := loopIn .TotalDepositAmount ()
2089+ swapAmt := total
2090+ var changeAmt btcutil.Amount
2091+ if loopIn .SelectedAmount > 0 {
2092+ amt , err := loopin .DeduceSwapAmount (
2093+ total , loopIn .SelectedAmount ,
2094+ )
2095+ if err == nil {
2096+ swapAmt = amt
2097+ changeAmt = total - amt
2098+ }
2099+ }
2100+
20812101 return & looprpc.StaticAddressLoopInResponse {
20822102 SwapHash : loopIn .SwapHash [:],
20832103 State : string (loopIn .GetState ()),
2084- Amount : uint64 (loopIn .TotalDepositAmount ()),
2104+ Amount : uint64 (total ),
2105+ SwapAmount : uint64 (swapAmt ),
2106+ Change : int64 (changeAmt ),
2107+ QuotedSwapFeeSatoshis : int64 (loopIn .QuotedSwapFee ),
2108+ Fast : loopIn .Fast ,
20852109 HtlcCltv : loopIn .HtlcCltvExpiry ,
20862110 MaxSwapFeeSatoshis : int64 (loopIn .MaxSwapFee ),
20872111 InitiationHeight : loopIn .InitiationHeight ,
20882112 ProtocolVersion : loopIn .ProtocolVersion .String (),
20892113 Initiator : loopIn .Initiator ,
20902114 Label : loopIn .Label ,
20912115 PaymentTimeoutSeconds : loopIn .PaymentTimeoutSeconds ,
2092- QuotedSwapFeeSatoshis : int64 ( loopIn . QuotedSwapFee ) ,
2116+ UsedDeposits : usedDeposits ,
20932117 }, nil
20942118}
20952119
0 commit comments