Skip to content

Commit bfe6dc4

Browse files
committed
staticaddr: show address on ListStaticAddressDepositsResponse
1 parent 6aee413 commit bfe6dc4

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
@@ -1765,6 +1765,11 @@ func (s *swapClientServer) ListStaticAddressDeposits(ctx context.Context,
17651765
return nil, err
17661766
}
17671767

1768+
network, err := s.network.ChainParams()
1769+
if err != nil {
1770+
return nil, err
1771+
}
1772+
17681773
// Deposits filtered by state or outpoints.
17691774
var filteredDeposits []*looprpc.Deposit
17701775
if len(outpoints) > 0 {
@@ -1776,7 +1781,7 @@ func (s *swapClientServer) ListStaticAddressDeposits(ctx context.Context,
17761781
}
17771782
return false
17781783
}
1779-
filteredDeposits = filter(allDeposits, f)
1784+
filteredDeposits = filter(allDeposits, network, f)
17801785

17811786
if len(outpoints) != len(filteredDeposits) {
17821787
return nil, fmt.Errorf("not all outpoints found in " +
@@ -1792,7 +1797,7 @@ func (s *swapClientServer) ListStaticAddressDeposits(ctx context.Context,
17921797

17931798
return d.IsInState(toServerState(req.StateFilter))
17941799
}
1795-
filteredDeposits = filter(allDeposits, f)
1800+
filteredDeposits = filter(allDeposits, network, f)
17961801
}
17971802

17981803
// Calculate the blocks until expiry for each deposit.
@@ -2169,7 +2174,9 @@ func (s *swapClientServer) StaticAddressLoopIn(ctx context.Context,
21692174

21702175
type filterFunc func(deposits *deposit.Deposit) bool
21712176

2172-
func filter(deposits []*deposit.Deposit, f filterFunc) []*looprpc.Deposit {
2177+
func filter(deposits []*deposit.Deposit, network *chaincfg.Params,
2178+
f filterFunc) []*looprpc.Deposit {
2179+
21732180
var clientDeposits []*looprpc.Deposit
21742181
for _, d := range deposits {
21752182
if !f(d) {
@@ -2183,6 +2190,7 @@ func filter(deposits []*deposit.Deposit, f filterFunc) []*looprpc.Deposit {
21832190

21842191
hash := d.Hash
21852192
outpoint := wire.NewOutPoint(&hash, d.Index).String()
2193+
staticAddr, _ := d.AddressParams.TaprootAddress(network)
21862194
deposit := &looprpc.Deposit{
21872195
Id: d.ID[:],
21882196
State: toClientDepositState(
@@ -2192,6 +2200,7 @@ func filter(deposits []*deposit.Deposit, f filterFunc) []*looprpc.Deposit {
21922200
Value: int64(d.Value),
21932201
ConfirmationHeight: d.ConfirmationHeight,
21942202
SwapHash: swapHash,
2203+
StaticAddress: staticAddr,
21952204
}
21962205

21972206
clientDeposits = append(clientDeposits, deposit)

0 commit comments

Comments
 (0)