multi: Add utxo restriction for batchchannel openings.

Add utxo restrictions for psbt internal wallet funded lightning
channels. This also includes batchopening channels backed by the
internal wallet.
This commit is contained in:
ziggie committed 2024-04-24 13:58:20 +01:00
1 parent 62a52b4d7c
commit ab7634b276
5 files changed
+79 -7

No files matched your search

+9 -1
View File
@@ -15,6 +15,7 @@ import (
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcwallet/waddrmgr"
"github.com/btcsuite/btcwallet/wallet"
"github.com/btcsuite/btcwallet/wtxmgr"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnwallet"
@@ -60,6 +61,9 @@ var (
// imported public keys. For custom account, no key scope should be provided
// as the coin selection key scope will always be used to generate the change
// address.
// The function argument `allowUtxo` specifies a filter function for utxos
// during coin selection. It should return true for utxos that can be used and
// false for those that should be excluded.
//
// NOTE: If the packet doesn't contain any inputs, coin selection is performed
// automatically. The account parameter must be non-empty as it determines which
@@ -74,7 +78,8 @@ var (
func (b *BtcWallet) FundPsbt(packet *psbt.Packet, minConfs int32,
feeRate chainfee.SatPerKWeight, accountName string,
changeScope *waddrmgr.KeyScope,
strategy wallet.CoinSelectionStrategy) (int32, error) {
strategy wallet.CoinSelectionStrategy,
allowUtxo func(wtxmgr.Credit) bool) (int32, error) {
// The fee rate is passed in using units of sat/kw, so we'll convert
// this to sat/KB as the CreateSimpleTx method requires this unit.
@@ -130,6 +135,9 @@ func (b *BtcWallet) FundPsbt(packet *psbt.Packet, minConfs int32,
if changeScope != nil {
opts = append(opts, wallet.WithCustomChangeScope(changeScope))
}
if allowUtxo != nil {
opts = append(opts, wallet.WithUtxoFilter(allowUtxo))
}
// Let the wallet handle coin selection and/or fee estimation based on
// the partial TX information in the packet.
+2 -1
View File
@@ -468,7 +468,8 @@ type WalletController interface {
FundPsbt(packet *psbt.Packet, minConfs int32,
feeRate chainfee.SatPerKWeight, account string,
changeScope *waddrmgr.KeyScope,
strategy base.CoinSelectionStrategy) (int32, error)
strategy base.CoinSelectionStrategy,
allowUtxo func(wtxmgr.Credit) bool) (int32, error)
// SignPsbt expects a partial transaction with all inputs and outputs
// fully declared and tries to sign all unsigned inputs that have all
+2 -1
View File
@@ -217,7 +217,8 @@ func (w *mockWalletController) ListLeasedOutputs() (
// FundPsbt currently does nothing.
func (w *mockWalletController) FundPsbt(*psbt.Packet, int32,
chainfee.SatPerKWeight, string, *waddrmgr.KeyScope,
base.CoinSelectionStrategy) (int32, error) {
base.CoinSelectionStrategy, func(utxo wtxmgr.Credit) bool) (int32,
error) {
return 0, nil
}