Skip to content

Commit a74a290

Browse files
committed
staticaddr: show address on ListStaticAddressDepositsResponse
1 parent 59ec90c commit a74a290

File tree

4 files changed

+604
-575
lines changed

4 files changed

+604
-575
lines changed

loopd/swapclient_server.go

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

1790+
network, err := s.network.ChainParams()
1791+
if err != nil {
1792+
return nil, err
1793+
}
1794+
17901795
// Deposits filtered by state or outpoints.
17911796
var filteredDeposits []*looprpc.Deposit
17921797
if len(outpoints) > 0 {
@@ -1798,7 +1803,7 @@ func (s *swapClientServer) ListStaticAddressDeposits(ctx context.Context,
17981803
}
17991804
return false
18001805
}
1801-
filteredDeposits = filter(allDeposits, f)
1806+
filteredDeposits = filter(allDeposits, network, f)
18021807

18031808
if len(outpoints) != len(filteredDeposits) {
18041809
return nil, fmt.Errorf("not all outpoints found in " +
@@ -1814,7 +1819,7 @@ func (s *swapClientServer) ListStaticAddressDeposits(ctx context.Context,
18141819

18151820
return d.IsInState(toServerState(req.StateFilter))
18161821
}
1817-
filteredDeposits = filter(allDeposits, f)
1822+
filteredDeposits = filter(allDeposits, network, f)
18181823
}
18191824

18201825
// Calculate the blocks until expiry for each deposit.
@@ -2267,7 +2272,9 @@ func (s *swapClientServer) StaticOpenChannel(ctx context.Context,
22672272

22682273
type filterFunc func(deposits *deposit.Deposit) bool
22692274

2270-
func filter(deposits []*deposit.Deposit, f filterFunc) []*looprpc.Deposit {
2275+
func filter(deposits []*deposit.Deposit, network *chaincfg.Params,
2276+
f filterFunc) []*looprpc.Deposit {
2277+
22712278
var clientDeposits []*looprpc.Deposit
22722279
for _, d := range deposits {
22732280
if !f(d) {
@@ -2281,6 +2288,7 @@ func filter(deposits []*deposit.Deposit, f filterFunc) []*looprpc.Deposit {
22812288

22822289
hash := d.Hash
22832290
outpoint := wire.NewOutPoint(&hash, d.Index).String()
2291+
staticAddr, _ := d.AddressParams.TaprootAddress(network)
22842292
deposit := &looprpc.Deposit{
22852293
Id: d.ID[:],
22862294
State: toClientDepositState(
@@ -2290,6 +2298,7 @@ func filter(deposits []*deposit.Deposit, f filterFunc) []*looprpc.Deposit {
22902298
Value: int64(d.Value),
22912299
ConfirmationHeight: d.ConfirmationHeight,
22922300
SwapHash: swapHash,
2301+
StaticAddress: staticAddr,
22932302
}
22942303

22952304
clientDeposits = append(clientDeposits, deposit)

0 commit comments

Comments
 (0)