Browse Source

lnwallet: expose optional account filter for several WalletController methods

master
Wilmer Paulino 3 years ago
parent
commit
f91e7cde59
No known key found for this signature in database
GPG Key ID: 6DF57B9F9514972F
  1. 11
      lnrpc/walletrpc/walletkit_server.go
  2. 7
      lntest/mock/walletcontroller.go
  3. 49
      lnwallet/btcwallet/btcwallet.go
  4. 21
      lnwallet/interface.go
  5. 32
      lnwallet/test/test_interface.go
  6. 41
      lnwallet/wallet.go
  7. 5
      pilot.go
  8. 16
      rpcserver.go
  9. 2
      sweep/backend_mock_test.go
  10. 13
      sweep/interface.go
  11. 4
      sweep/tx_input_set.go
  12. 2
      sweep/tx_input_set_test.go
  13. 9
      sweep/walletsweep.go
  14. 2
      sweep/walletsweep_test.go

11
lnrpc/walletrpc/walletkit_server.go

@ -321,7 +321,9 @@ func (w *WalletKit) ListUnspent(ctx context.Context,
// be shown available to us.
var utxos []*lnwallet.Utxo
err = w.cfg.CoinSelectionLocker.WithCoinSelectLock(func() error {
utxos, err = w.cfg.Wallet.ListUnspentWitness(minConfs, maxConfs)
utxos, err = w.cfg.Wallet.ListUnspentWitness(
minConfs, maxConfs, "",
)
return err
})
if err != nil {
@ -854,9 +856,10 @@ func (w *WalletKit) ListSweeps(ctx context.Context,
// Some of our sweeps could have been replaced by fee, or dropped out
// of the mempool. Here, we lookup our wallet transactions so that we
// can match our list of sweeps against the list of transactions that
// the wallet is still tracking.
// the wallet is still tracking. Sweeps are currently always swept to
// the default wallet account.
transactions, err := w.cfg.Wallet.ListTransactionDetails(
0, btcwallet.UnconfirmedHeight,
0, btcwallet.UnconfirmedHeight, lnwallet.DefaultAccountName,
)
if err != nil {
return nil, err
@ -1057,7 +1060,7 @@ func (w *WalletKit) FundPsbt(_ context.Context,
if len(packet.UnsignedTx.TxIn) > 0 {
// Get a list of all unspent witness outputs.
utxos, err := w.cfg.Wallet.ListUnspentWitness(
defaultMinConf, defaultMaxConf,
defaultMinConf, defaultMaxConf, "",
)
if err != nil {
return err

7
lntest/mock/walletcontroller.go

@ -52,7 +52,8 @@ func (w *WalletController) FetchInputInfo(
}
// ConfirmedBalance currently returns dummy values.
func (w *WalletController) ConfirmedBalance(confs int32) (btcutil.Amount, error) {
func (w *WalletController) ConfirmedBalance(confs int32,
_ string) (btcutil.Amount, error) {
return 0, nil
}
@ -94,7 +95,7 @@ func (w *WalletController) CreateSimpleTx(outputs []*wire.TxOut,
// ListUnspentWitness is called by the wallet when doing coin selection. We just
// need one unspent for the funding transaction.
func (w *WalletController) ListUnspentWitness(minconfirms,
maxconfirms int32) ([]*lnwallet.Utxo, error) {
maxconfirms int32, _ string) ([]*lnwallet.Utxo, error) {
// If the mock already has a list of utxos, return it.
if w.Utxos != nil {
@ -119,7 +120,7 @@ func (w *WalletController) ListUnspentWitness(minconfirms,
// ListTransactionDetails currently returns dummy values.
func (w *WalletController) ListTransactionDetails(_,
_ int32) ([]*lnwallet.TransactionDetail, error) {
_ int32, _ string) ([]*lnwallet.TransactionDetail, error) {
return nil, nil
}

49
lnwallet/btcwallet/btcwallet.go

@ -223,13 +223,19 @@ func (b *BtcWallet) Stop() error {
// ConfirmedBalance returns the sum of all the wallet's unspent outputs that
// have at least confs confirmations. If confs is set to zero, then all unspent
// outputs, including those currently in the mempool will be included in the
// final sum.
// final sum. The account parameter serves as a filter to retrieve the balance
// for a specific account. When empty, the confirmed balance of all wallet
// accounts is returned.
//
// This is a part of the WalletController interface.
func (b *BtcWallet) ConfirmedBalance(confs int32) (btcutil.Amount, error) {
func (b *BtcWallet) ConfirmedBalance(confs int32,
accountFilter string) (btcutil.Amount, error) {
var balance btcutil.Amount
witnessOutputs, err := b.ListUnspentWitness(confs, math.MaxInt32)
witnessOutputs, err := b.ListUnspentWitness(
confs, math.MaxInt32, accountFilter,
)
if err != nil {
return 0, err
}
@ -463,16 +469,25 @@ func (b *BtcWallet) ReleaseOutput(id wtxmgr.LockID, op wire.OutPoint) error {
return b.wallet.ReleaseOutput(id, op)
}
// ListUnspentWitness returns a slice of all the unspent outputs the wallet
// controls which pay to witness programs either directly or indirectly.
// ListUnspentWitness returns all unspent outputs which are version 0 witness
// programs. The 'minconfirms' and 'maxconfirms' parameters indicate the minimum
// and maximum number of confirmations an output needs in order to be returned
// by this method. Passing -1 as 'minconfirms' indicates that even unconfirmed
// outputs should be returned. Using MaxInt32 as 'maxconfirms' implies returning
// all outputs with at least 'minconfirms'. The account parameter serves as a
// filter to retrieve the unspent outputs for a specific account. When empty,
// the unspent outputs of all wallet accounts are returned.
//
// NOTE: This method requires the global coin selection lock to be held.
//
// This is a part of the WalletController interface.
func (b *BtcWallet) ListUnspentWitness(minConfs, maxConfs int32) (
[]*lnwallet.Utxo, error) {
func (b *BtcWallet) ListUnspentWitness(minConfs, maxConfs int32,
accountFilter string) ([]*lnwallet.Utxo, error) {
// First, grab all the unfiltered currently unspent outputs.
unspentOutputs, err := b.wallet.ListUnspent(minConfs, maxConfs, "")
unspentOutputs, err := b.wallet.ListUnspent(
minConfs, maxConfs, accountFilter,
)
if err != nil {
return nil, err
}
@ -690,14 +705,18 @@ func unminedTransactionsToDetail(
return txDetail, nil
}
// ListTransactionDetails returns a list of all transactions which are
// relevant to the wallet. It takes inclusive start and end height to allow
// paginated queries. Unconfirmed transactions can be included in the query
// by providing endHeight = UnconfirmedHeight (= -1).
// ListTransactionDetails returns a list of all transactions which are relevant
// to the wallet over [startHeight;endHeight]. If start height is greater than
// end height, the transactions will be retrieved in reverse order. To include
// unconfirmed transactions, endHeight should be set to the special value -1.
// This will return transactions from the tip of the chain until the start
// height (inclusive) and unconfirmed transactions. The account parameter serves
// as a filter to retrieve the transactions relevant to a specific account. When
// empty, transactions of all wallet accounts are returned.
//
// This is a part of the WalletController interface.
func (b *BtcWallet) ListTransactionDetails(startHeight,
endHeight int32) ([]*lnwallet.TransactionDetail, error) {
func (b *BtcWallet) ListTransactionDetails(startHeight, endHeight int32,
accountFilter string) ([]*lnwallet.TransactionDetail, error) {
// Grab the best block the wallet knows of, we'll use this to calculate
// # of confirmations shortly below.
@ -707,7 +726,7 @@ func (b *BtcWallet) ListTransactionDetails(startHeight,
// We'll attempt to find all transactions from start to end height.
start := base.NewBlockIdentifierFromHeight(startHeight)
stop := base.NewBlockIdentifierFromHeight(endHeight)
txns, err := b.wallet.GetTransactions(start, stop, "", nil)
txns, err := b.wallet.GetTransactions(start, stop, accountFilter, nil)
if err != nil {
return nil, err
}

21
lnwallet/interface.go

@ -159,12 +159,14 @@ type WalletController interface {
// ConfirmedBalance returns the sum of all the wallet's unspent outputs
// that have at least confs confirmations. If confs is set to zero,
// then all unspent outputs, including those currently in the mempool
// will be included in the final sum.
// will be included in the final sum. The account parameter serves as a
// filter to retrieve the balance for a specific account. When empty,
// the confirmed balance of all wallet accounts is returned.
//
// NOTE: Only witness outputs should be included in the computation of
// the total spendable balance of the wallet. We require this as only
// witness inputs can be used for funding channels.
ConfirmedBalance(confs int32) (btcutil.Amount, error)
ConfirmedBalance(confs int32, accountFilter string) (btcutil.Amount, error)
// NewAddress returns the next external or internal address for the
// wallet dictated by the value of the `change` parameter. If change is
@ -221,10 +223,13 @@ type WalletController interface {
// needs in order to be returned by this method. Passing -1 as
// 'minconfirms' indicates that even unconfirmed outputs should be
// returned. Using MaxInt32 as 'maxconfirms' implies returning all
// outputs with at least 'minconfirms'.
// outputs with at least 'minconfirms'. The account parameter serves as
// a filter to retrieve the unspent outputs for a specific account.
// When empty, the unspent outputs of all wallet accounts are returned.
//
// NOTE: This method requires the global coin selection lock to be held.
ListUnspentWitness(minconfirms, maxconfirms int32) ([]*Utxo, error)
ListUnspentWitness(minconfirms, maxconfirms int32,
accountFilter string) ([]*Utxo, error)
// ListTransactionDetails returns a list of all transactions which are
// relevant to the wallet over [startHeight;endHeight]. If start height
@ -232,9 +237,11 @@ type WalletController interface {
// reverse order. To include unconfirmed transactions, endHeight should
// be set to the special value -1. This will return transactions from
// the tip of the chain until the start height (inclusive) and
// unconfirmed transactions.
ListTransactionDetails(startHeight,
endHeight int32) ([]*TransactionDetail, error)
// unconfirmed transactions. The account parameter serves as a filter to
// retrieve the transactions relevant to a specific account. When
// empty, transactions of all wallet accounts are returned.
ListTransactionDetails(startHeight, endHeight int32,
accountFilter string) ([]*TransactionDetail, error)
// LockOutpoint marks an outpoint as locked meaning it will no longer
// be deemed as eligible for coin selection. Locking outputs are

32
lnwallet/test/test_interface.go

@ -101,7 +101,7 @@ var (
func assertProperBalance(t *testing.T, lw *lnwallet.LightningWallet,
numConfirms int32, amount float64) {
balance, err := lw.ConfirmedBalance(numConfirms)
balance, err := lw.ConfirmedBalance(numConfirms, lnwallet.DefaultAccountName)
if err != nil {
t.Fatalf("unable to query for balance: %v", err)
}
@ -208,7 +208,7 @@ func assertTxInWallet(t *testing.T, w *lnwallet.LightningWallet,
// We'll fetch all of our transaction and go through each one until
// finding the expected transaction with its expected confirmation
// status.
txs, err := w.ListTransactionDetails(0, btcwallet.UnconfirmedHeight)
txs, err := w.ListTransactionDetails(0, btcwallet.UnconfirmedHeight, "")
if err != nil {
t.Fatalf("unable to retrieve transactions: %v", err)
}
@ -248,7 +248,7 @@ func loadTestCredits(miner *rpctest.Harness, w *lnwallet.LightningWallet,
if err != nil {
return fmt.Errorf("unable to create amt: %v", err)
}
expectedBalance, err := w.ConfirmedBalance(1)
expectedBalance, err := w.ConfirmedBalance(1, lnwallet.DefaultAccountName)
if err != nil {
return err
}
@ -294,7 +294,7 @@ func loadTestCredits(miner *rpctest.Harness, w *lnwallet.LightningWallet,
timeout := time.After(30 * time.Second)
for range ticker.C {
balance, err := w.ConfirmedBalance(1)
balance, err := w.ConfirmedBalance(1, lnwallet.DefaultAccountName)
if err != nil {
return err
}
@ -1191,7 +1191,7 @@ func testListTransactionDetails(miner *rpctest.Harness,
t.Fatalf("Couldn't sync Alice's wallet: %v", err)
}
txDetails, err := alice.ListTransactionDetails(
startHeight, chainTip,
startHeight, chainTip, "",
)
if err != nil {
t.Fatalf("unable to fetch tx details: %v", err)
@ -1305,7 +1305,7 @@ func testListTransactionDetails(miner *rpctest.Harness,
// with a confirmation height of 0, indicating that it has not been
// mined yet.
txDetails, err = alice.ListTransactionDetails(
chainTip, btcwallet.UnconfirmedHeight,
chainTip, btcwallet.UnconfirmedHeight, "",
)
if err != nil {
t.Fatalf("unable to fetch tx details: %v", err)
@ -1361,9 +1361,7 @@ func testListTransactionDetails(miner *rpctest.Harness,
if err != nil {
t.Fatalf("Couldn't sync Alice's wallet: %v", err)
}
txDetails, err = alice.ListTransactionDetails(
chainTip, chainTip,
)
txDetails, err = alice.ListTransactionDetails(chainTip, chainTip, "")
if err != nil {
t.Fatalf("unable to fetch tx details: %v", err)
}
@ -1410,9 +1408,7 @@ func testListTransactionDetails(miner *rpctest.Harness,
// Query for transactions only in the latest block. We do not expect
// any transactions to be returned.
txDetails, err = alice.ListTransactionDetails(
chainTip, chainTip,
)
txDetails, err = alice.ListTransactionDetails(chainTip, chainTip, "")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
@ -2189,7 +2185,7 @@ func testReorgWalletBalance(r *rpctest.Harness, w *lnwallet.LightningWallet,
}
// Get the original balance.
origBalance, err := w.ConfirmedBalance(1)
origBalance, err := w.ConfirmedBalance(1, lnwallet.DefaultAccountName)
if err != nil {
t.Fatalf("unable to query for balance: %v", err)
}
@ -2205,7 +2201,7 @@ func testReorgWalletBalance(r *rpctest.Harness, w *lnwallet.LightningWallet,
t.Fatalf("unable to set up mining node: %v", err)
}
defer r2.TearDown()
newBalance, err := w.ConfirmedBalance(1)
newBalance, err := w.ConfirmedBalance(1, lnwallet.DefaultAccountName)
if err != nil {
t.Fatalf("unable to query for balance: %v", err)
}
@ -2297,7 +2293,7 @@ func testReorgWalletBalance(r *rpctest.Harness, w *lnwallet.LightningWallet,
}
// Now we check that the wallet balance stays the same.
newBalance, err = w.ConfirmedBalance(1)
newBalance, err = w.ConfirmedBalance(1, lnwallet.DefaultAccountName)
if err != nil {
t.Fatalf("unable to query for balance: %v", err)
}
@ -2320,7 +2316,7 @@ func testChangeOutputSpendConfirmation(r *rpctest.Harness,
// Assuming a balance of 80 BTC and a transaction fee of 2500 sat/kw,
// we'll craft the following transaction so that Alice doesn't have any
// UTXOs left.
aliceBalance, err := alice.ConfirmedBalance(0)
aliceBalance, err := alice.ConfirmedBalance(0, lnwallet.DefaultAccountName)
if err != nil {
t.Fatalf("unable to retrieve alice's balance: %v", err)
}
@ -2345,7 +2341,7 @@ func testChangeOutputSpendConfirmation(r *rpctest.Harness,
// With the transaction sent and confirmed, Alice's balance should now
// be 0.
aliceBalance, err = alice.ConfirmedBalance(0)
aliceBalance, err = alice.ConfirmedBalance(0, lnwallet.DefaultAccountName)
if err != nil {
t.Fatalf("unable to retrieve alice's balance: %v", err)
}
@ -2401,7 +2397,7 @@ func testSpendUnconfirmed(miner *rpctest.Harness,
// First we will empty out bob's wallet, sending the entire balance
// to alice.
bobBalance, err := bob.ConfirmedBalance(0)
bobBalance, err := bob.ConfirmedBalance(0, lnwallet.DefaultAccountName)
if err != nil {
t.Fatalf("unable to retrieve bob's balance: %v", err)
}

41
lnwallet/wallet.go

@ -396,14 +396,33 @@ func (l *LightningWallet) Shutdown() error {
return nil
}
// ConfirmedBalance returns the current confirmed balance of the wallet. This
// methods wraps the interal WalletController method so we're able to properly
// hold the coin select mutex while we compute the balance.
func (l *LightningWallet) ConfirmedBalance(confs int32) (btcutil.Amount, error) {
// ConfirmedBalance returns the current confirmed balance of a wallet account.
// This methods wraps the internal WalletController method so we're able to
// properly hold the coin select mutex while we compute the balance.
func (l *LightningWallet) ConfirmedBalance(confs int32,
account string) (btcutil.Amount, error) {
l.coinSelectMtx.Lock()
defer l.coinSelectMtx.Unlock()
return l.WalletController.ConfirmedBalance(confs)
return l.WalletController.ConfirmedBalance(confs, account)
}
// ListUnspentWitnessFromDefaultAccount returns all unspent outputs from the
// default wallet account which are version 0 witness programs. The 'minConfs'
// and 'maxConfs' parameters indicate the minimum and maximum number of
// confirmations an output needs in order to be returned by this method. Passing
// -1 as 'minConfs' indicates that even unconfirmed outputs should be returned.
// Using MaxInt32 as 'maxConfs' implies returning all outputs with at least
// 'minConfs'.
//
// NOTE: This method requires the global coin selection lock to be held.
func (l *LightningWallet) ListUnspentWitnessFromDefaultAccount(
minConfs, maxConfs int32) ([]*Utxo, error) {
return l.WalletController.ListUnspentWitness(
minConfs, maxConfs, DefaultAccountName,
)
}
// LockedOutpoints returns a list of all currently locked outpoint.
@ -922,8 +941,12 @@ func (l *LightningWallet) currentNumAnchorChans() (int, error) {
func (l *LightningWallet) CheckReservedValue(in []wire.OutPoint,
out []*wire.TxOut, numAnchorChans int) (btcutil.Amount, error) {
// Get all unspent coins in the wallet.
witnessOutputs, err := l.ListUnspentWitness(0, math.MaxInt32)
// Get all unspent coins in the wallet. We only care about those part of
// the wallet's default account as we know we can readily sign for those
// at any time.
witnessOutputs, err := l.ListUnspentWitnessFromDefaultAccount(
0, math.MaxInt32,
)
if err != nil {
return 0, err
}
@ -2022,7 +2045,9 @@ func NewCoinSource(w *LightningWallet) *CoinSource {
func (c *CoinSource) ListCoins(minConfs int32,
maxConfs int32) ([]chanfunding.Coin, error) {
utxos, err := c.wallet.ListUnspentWitness(minConfs, maxConfs)
utxos, err := c.wallet.ListUnspentWitnessFromDefaultAccount(
minConfs, maxConfs,
)
if err != nil {
return nil, err
}

5
pilot.go

@ -12,6 +12,7 @@ import (
"github.com/lightningnetwork/lnd/chainreg"
"github.com/lightningnetwork/lnd/funding"
"github.com/lightningnetwork/lnd/lncfg"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/tor"
)
@ -180,7 +181,9 @@ func initAutoPilot(svr *server, cfg *lncfg.AutoPilot,
netParams: netParams,
},
WalletBalance: func() (btcutil.Amount, error) {
return svr.cc.Wallet.ConfirmedBalance(cfg.MinConfs)
return svr.cc.Wallet.ConfirmedBalance(
cfg.MinConfs, lnwallet.DefaultAccountName,
)
},
Graph: autopilot.ChannelGraphFromDatabase(svr.localChanDB.ChannelGraph()),
Constraints: atplConstraints,

16
rpcserver.go

@ -1023,7 +1023,7 @@ func (r *rpcServer) ListUnspent(ctx context.Context,
var utxos []*lnwallet.Utxo
err = r.server.cc.Wallet.WithCoinSelectLock(func() error {
utxos, err = r.server.cc.Wallet.ListUnspentWitness(
minConfs, maxConfs,
minConfs, maxConfs, "",
)
return err
})
@ -1191,7 +1191,7 @@ func (r *rpcServer) SendCoins(ctx context.Context,
sweepTxPkg, err := sweep.CraftSweepAllTx(
feePerKw, lnwallet.DefaultDustLimit(),
uint32(bestHeight), nil, targetAddr, wallet,
wallet.WalletController, wallet.WalletController,
wallet, wallet.WalletController,
r.server.cc.FeeEstimator, r.server.cc.Signer,
)
if err != nil {
@ -1243,7 +1243,7 @@ func (r *rpcServer) SendCoins(ctx context.Context,
sweepTxPkg, err = sweep.CraftSweepAllTx(
feePerKw, lnwallet.DefaultDustLimit(),
uint32(bestHeight), outputs, targetAddr, wallet,
wallet.WalletController, wallet.WalletController,
wallet, wallet.WalletController,
r.server.cc.FeeEstimator, r.server.cc.Signer,
)
if err != nil {
@ -2763,7 +2763,9 @@ func (r *rpcServer) WalletBalance(ctx context.Context,
in *lnrpc.WalletBalanceRequest) (*lnrpc.WalletBalanceResponse, error) {
// Get total balance, from txs that have >= 0 confirmations.
totalBal, err := r.server.cc.Wallet.ConfirmedBalance(0)
totalBal, err := r.server.cc.Wallet.ConfirmedBalance(
0, lnwallet.DefaultAccountName,
)
if err != nil {
return nil, err
}
@ -2771,7 +2773,9 @@ func (r *rpcServer) WalletBalance(ctx context.Context,
// Get confirmed balance, from txs that have >= 1 confirmations.
// TODO(halseth): get both unconfirmed and confirmed balance in one
// call, as this is racy.
confirmedBal, err := r.server.cc.Wallet.ConfirmedBalance(1)
confirmedBal, err := r.server.cc.Wallet.ConfirmedBalance(
1, lnwallet.DefaultAccountName,
)
if err != nil {
return nil, err
}
@ -4963,7 +4967,7 @@ func (r *rpcServer) GetTransactions(ctx context.Context,
}
transactions, err := r.server.cc.Wallet.ListTransactionDetails(
req.StartHeight, endHeight,
req.StartHeight, endHeight, "",
)
if err != nil {
return nil, err

2
sweep/backend_mock_test.go

@ -87,7 +87,7 @@ func (b *mockBackend) PublishTransaction(tx *wire.MsgTx, _ string) error {
return err
}
func (b *mockBackend) ListUnspentWitness(minconfirms, maxconfirms int32) (
func (b *mockBackend) ListUnspentWitnessFromDefaultAccount(minconfirms, maxconfirms int32) (
[]*lnwallet.Utxo, error) {
b.lock.Lock()
defer b.lock.Unlock()

13
sweep/interface.go

@ -11,12 +11,13 @@ type Wallet interface {
// broadcasts the passed transaction to the Bitcoin network.
PublishTransaction(tx *wire.MsgTx, label string) error
// ListUnspentWitness returns all unspent outputs which are version 0
// witness programs. The 'minconfirms' and 'maxconfirms' parameters
// indicate the minimum and maximum number of confirmations an output
// needs in order to be returned by this method.
ListUnspentWitness(minconfirms, maxconfirms int32) ([]*lnwallet.Utxo,
error)
// ListUnspentWitnessFromDefaultAccount returns all unspent outputs
// which are version 0 witness programs from the default wallet account.
// The 'minconfirms' and 'maxconfirms' parameters indicate the minimum
// and maximum number of confirmations an output needs in order to be
// returned by this method.
ListUnspentWitnessFromDefaultAccount(minconfirms, maxconfirms int32) (
[]*lnwallet.Utxo, error)
// WithCoinSelectLock will execute the passed function closure in a
// synchronized manner preventing any coin selection operations from

4
sweep/tx_input_set.go

@ -333,7 +333,9 @@ func (t *txInputSet) tryAddWalletInputsIfNeeded() error {
// Retrieve wallet utxos. Only consider confirmed utxos to prevent
// problems around RBF rules for unconfirmed inputs.
utxos, err := t.wallet.ListUnspentWitness(1, math.MaxInt32)
utxos, err := t.wallet.ListUnspentWitnessFromDefaultAccount(
1, math.MaxInt32,
)
if err != nil {
return err
}

2
sweep/tx_input_set_test.go

@ -112,7 +112,7 @@ type mockWallet struct {
Wallet
}
func (m *mockWallet) ListUnspentWitness(minconfirms, maxconfirms int32) (
func (m *mockWallet) ListUnspentWitnessFromDefaultAccount(minconfirms, maxconfirms int32) (
[]*lnwallet.Utxo, error) {
return []*lnwallet.Utxo{

9
sweep/walletsweep.go

@ -99,9 +99,10 @@ func DetermineFeePerKw(feeEstimator chainfee.Estimator,
// UtxoSource is an interface that allows a caller to access a source of UTXOs
// to use when crafting sweep transactions.
type UtxoSource interface {
// ListUnspentWitness returns all UTXOs from the source that have
// between minConfs and maxConfs number of confirmations.
ListUnspentWitness(minConfs, maxConfs int32) ([]*lnwallet.Utxo, error)
// ListUnspentWitness returns all UTXOs from the default wallet account
// that have between minConfs and maxConfs number of confirmations.
ListUnspentWitnessFromDefaultAccount(minConfs, maxConfs int32) (
[]*lnwallet.Utxo, error)
}
// CoinSelectionLocker is an interface that allows the caller to perform an
@ -192,7 +193,7 @@ func CraftSweepAllTx(feeRate chainfee.SatPerKWeight, dustLimit btcutil.Amount,
// Now that we can be sure that no other coin selection
// operations are going on, we can grab a clean snapshot of the
// current UTXO state of the wallet.
utxos, err := utxoSource.ListUnspentWitness(
utxos, err := utxoSource.ListUnspentWitnessFromDefaultAccount(
1, math.MaxInt32,
)
if err != nil {

2
sweep/walletsweep_test.go

@ -119,7 +119,7 @@ func newMockUtxoSource(utxos []*lnwallet.Utxo) *mockUtxoSource {
}
}
func (m *mockUtxoSource) ListUnspentWitness(minConfs int32,
func (m *mockUtxoSource) ListUnspentWitnessFromDefaultAccount(minConfs int32,
maxConfs int32) ([]*lnwallet.Utxo, error) {
return m.outputs, nil

Loading…
Cancel
Save