mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
lndclient: add list sweeps to wallet cilent
This commit is contained in:
parent
c76f2c4cf1
commit
fbb1a3b204
3 changed files with 34 additions and 0 deletions
|
|
@ -57,6 +57,11 @@ type WalletKitClient interface {
|
|||
|
||||
EstimateFee(ctx context.Context, confTarget int32) (chainfee.SatPerKWeight,
|
||||
error)
|
||||
|
||||
// ListSweeps returns a list of sweep transaction ids known to our node.
|
||||
// Note that this function only looks up transaction ids, and does not
|
||||
// query our wallet for the full set of transactions.
|
||||
ListSweeps(ctx context.Context) ([]string, error)
|
||||
}
|
||||
|
||||
type walletKitClient struct {
|
||||
|
|
@ -319,3 +324,26 @@ func (m *walletKitClient) EstimateFee(ctx context.Context, confTarget int32) (
|
|||
|
||||
return chainfee.SatPerKWeight(resp.SatPerKw), nil
|
||||
}
|
||||
|
||||
// ListSweeps returns a list of sweep transaction ids known to our node.
|
||||
// Note that this function only looks up transaction ids (Verbose=false), and
|
||||
// does not query our wallet for the full set of transactions.
|
||||
func (m *walletKitClient) ListSweeps(ctx context.Context) ([]string, error) {
|
||||
rpcCtx, cancel := context.WithTimeout(ctx, rpcTimeout)
|
||||
defer cancel()
|
||||
|
||||
resp, err := m.client.ListSweeps(
|
||||
m.walletKitMac.WithMacaroonAuth(rpcCtx),
|
||||
&walletrpc.ListSweepsRequest{
|
||||
Verbose: false,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Since we have requested the abbreviated response from lnd, we can
|
||||
// just get our response to a list of sweeps and return it.
|
||||
sweeps := resp.GetTransactionIds()
|
||||
return sweeps.TransactionIds, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ type LndMockServices struct {
|
|||
SignatureMsg string
|
||||
|
||||
Transactions []lndclient.Transaction
|
||||
Sweeps []string
|
||||
|
||||
// Invoices is a set of invoices that have been created by the mock,
|
||||
// keyed by hash string.
|
||||
|
|
|
|||
|
|
@ -126,3 +126,8 @@ func (m *mockWalletKit) EstimateFee(ctx context.Context, confTarget int32) (
|
|||
|
||||
return feeEstimate, nil
|
||||
}
|
||||
|
||||
// ListSweeps returns a list of the sweep transaction ids known to our node.
|
||||
func (m *mockWalletKit) ListSweeps(_ context.Context) ([]string, error) {
|
||||
return m.lnd.Sweeps, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue