Skip to content

Commit f615ea7

Browse files
committed
staticaddr: show address on ListStaticAddressDepositsResponse
1 parent dd713ea commit f615ea7

File tree

4 files changed

+421
-392
lines changed

4 files changed

+421
-392
lines changed

loopd/swapclient_server.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,6 +1772,11 @@ func (s *swapClientServer) ListStaticAddressDeposits(ctx context.Context,
17721772
return nil, err
17731773
}
17741774

1775+
network, err := s.network.ChainParams()
1776+
if err != nil {
1777+
return nil, err
1778+
}
1779+
17751780
// Deposits filtered by state or outpoints.
17761781
var filteredDeposits []*looprpc.Deposit
17771782
if len(outpoints) > 0 {
@@ -1783,7 +1788,7 @@ func (s *swapClientServer) ListStaticAddressDeposits(ctx context.Context,
17831788
}
17841789
return false
17851790
}
1786-
filteredDeposits = filter(allDeposits, f)
1791+
filteredDeposits = filter(allDeposits, network, f)
17871792

17881793
if len(outpoints) != len(filteredDeposits) {
17891794
return nil, fmt.Errorf("not all outpoints found in " +
@@ -1799,7 +1804,7 @@ func (s *swapClientServer) ListStaticAddressDeposits(ctx context.Context,
17991804

18001805
return d.IsInState(toServerState(req.StateFilter))
18011806
}
1802-
filteredDeposits = filter(allDeposits, f)
1807+
filteredDeposits = filter(allDeposits, network, f)
18031808
}
18041809

18051810
// Calculate the blocks until expiry for each deposit.
@@ -2176,7 +2181,9 @@ func (s *swapClientServer) StaticAddressLoopIn(ctx context.Context,
21762181

21772182
type filterFunc func(deposits *deposit.Deposit) bool
21782183

2179-
func filter(deposits []*deposit.Deposit, f filterFunc) []*looprpc.Deposit {
2184+
func filter(deposits []*deposit.Deposit, network *chaincfg.Params,
2185+
f filterFunc) []*looprpc.Deposit {
2186+
21802187
var clientDeposits []*looprpc.Deposit
21812188
for _, d := range deposits {
21822189
if !f(d) {
@@ -2190,6 +2197,7 @@ func filter(deposits []*deposit.Deposit, f filterFunc) []*looprpc.Deposit {
21902197

21912198
hash := d.Hash
21922199
outpoint := wire.NewOutPoint(&hash, d.Index).String()
2200+
staticAddr, _ := d.AddressParams.TaprootAddress(network)
21932201
deposit := &looprpc.Deposit{
21942202
Id: d.ID[:],
21952203
State: toClientDepositState(
@@ -2199,6 +2207,7 @@ func filter(deposits []*deposit.Deposit, f filterFunc) []*looprpc.Deposit {
21992207
Value: int64(d.Value),
22002208
ConfirmationHeight: d.ConfirmationHeight,
22012209
SwapHash: swapHash,
2210+
StaticAddress: staticAddr,
22022211
}
22032212

22042213
clientDeposits = append(clientDeposits, deposit)

0 commit comments

Comments
 (0)