lndclient: add list sweeps to wallet cilent

pull/221/head
carla 4 years ago
parent c76f2c4cf1
commit fbb1a3b204
No known key found for this signature in database
GPG Key ID: 4CA7FE54A6213C91

@ -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…
Cancel
Save