lnwallet: expose optional account filter for several WalletController methods

This commit is contained in:
Wilmer Paulino committed 2021-04-05 15:41:06 -07:00
1 parent f38bf4d7fa
commit f91e7cde59
14 files changed
+138 -76

No files matched your search

+1 -1
View File
@@ -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()
+7 -6
View File
@@ -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
+3 -1
View File
@@ -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
}
+1 -1
View File
@@ -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{
+5 -4
View File
@@ -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 {
+1 -1
View File
@@ -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