Skip to content

Commit 7ef6018

Browse files
committed
staticaddr: show address on ListStaticAddressDepositsResponse
1 parent 8628cd4 commit 7ef6018

File tree

4 files changed

+416
-386
lines changed

4 files changed

+416
-386
lines changed

loopd/swapclient_server.go

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

1710+
network, err := s.network.ChainParams()
1711+
if err != nil {
1712+
return nil, err
1713+
}
1714+
17101715
// Deposits filtered by state or outpoints.
17111716
var filteredDeposits []*looprpc.Deposit
17121717
if len(outpoints) > 0 {
@@ -1718,7 +1723,7 @@ func (s *swapClientServer) ListStaticAddressDeposits(ctx context.Context,
17181723
}
17191724
return false
17201725
}
1721-
filteredDeposits = filter(allDeposits, f)
1726+
filteredDeposits = filter(allDeposits, network, f)
17221727

17231728
if len(outpoints) != len(filteredDeposits) {
17241729
return nil, fmt.Errorf("not all outpoints found in " +
@@ -1734,7 +1739,7 @@ func (s *swapClientServer) ListStaticAddressDeposits(ctx context.Context,
17341739

17351740
return d.IsInState(toServerState(req.StateFilter))
17361741
}
1737-
filteredDeposits = filter(allDeposits, f)
1742+
filteredDeposits = filter(allDeposits, network, f)
17381743
}
17391744

17401745
// Calculate the blocks until expiry for each deposit.
@@ -2107,7 +2112,9 @@ func (s *swapClientServer) StaticAddressLoopIn(ctx context.Context,
21072112

21082113
type filterFunc func(deposits *deposit.Deposit) bool
21092114

2110-
func filter(deposits []*deposit.Deposit, f filterFunc) []*looprpc.Deposit {
2115+
func filter(deposits []*deposit.Deposit, network *chaincfg.Params,
2116+
f filterFunc) []*looprpc.Deposit {
2117+
21112118
var clientDeposits []*looprpc.Deposit
21122119
for _, d := range deposits {
21132120
if !f(d) {
@@ -2121,6 +2128,7 @@ func filter(deposits []*deposit.Deposit, f filterFunc) []*looprpc.Deposit {
21212128

21222129
hash := d.Hash
21232130
outpoint := wire.NewOutPoint(&hash, d.Index).String()
2131+
staticAddr, _ := d.AddressParams.TaprootAddress(network)
21242132
deposit := &looprpc.Deposit{
21252133
Id: d.ID[:],
21262134
State: toClientDepositState(
@@ -2130,6 +2138,7 @@ func filter(deposits []*deposit.Deposit, f filterFunc) []*looprpc.Deposit {
21302138
Value: int64(d.Value),
21312139
ConfirmationHeight: d.ConfirmationHeight,
21322140
SwapHash: swapHash,
2141+
StaticAddress: staticAddr,
21332142
}
21342143

21352144
clientDeposits = append(clientDeposits, deposit)

0 commit comments

Comments
 (0)