From 17645cd196af0dee223e236aa85dabb23418ef15 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 6 Feb 2024 12:25:54 +0100 Subject: [PATCH] multi: add DecorateInputs to WalletController interface This commit adds the new DecorateInputs method of the base wallet to the WalletController interface. --- lntest/mock/walletcontroller.go | 5 +++++ lnwallet/btcwallet/psbt.go | 12 ++++++++++++ lnwallet/interface.go | 6 ++++++ lnwallet/mock.go | 5 +++++ 4 files changed, 28 insertions(+) diff --git a/lntest/mock/walletcontroller.go b/lntest/mock/walletcontroller.go index d641137eb..6c0f3e6a9 100644 --- a/lntest/mock/walletcontroller.go +++ b/lntest/mock/walletcontroller.go @@ -227,6 +227,11 @@ func (w *WalletController) FinalizePsbt(_ *psbt.Packet, _ string) error { return nil } +// DecorateInputs currently does nothing. +func (w *WalletController) DecorateInputs(*psbt.Packet, bool) error { + return nil +} + // PublishTransaction sends a transaction to the PublishedTransactions chan. func (w *WalletController) PublishTransaction(tx *wire.MsgTx, _ string) error { w.PublishedTransactions <- tx diff --git a/lnwallet/btcwallet/psbt.go b/lnwallet/btcwallet/psbt.go index a91346afa..ffb8fd2fd 100644 --- a/lnwallet/btcwallet/psbt.go +++ b/lnwallet/btcwallet/psbt.go @@ -596,6 +596,18 @@ func (b *BtcWallet) FinalizePsbt(packet *psbt.Packet, accountName string) error return b.wallet.FinalizePsbt(keyScope, accountNum, packet) } +// DecorateInputs fetches the UTXO information of all inputs it can identify and +// adds the required information to the package's inputs. The failOnUnknown +// boolean controls whether the method should return an error if it cannot +// identify an input or if it should just skip it. +// +// This is a part of the WalletController interface. +func (b *BtcWallet) DecorateInputs(packet *psbt.Packet, + failOnUnknown bool) error { + + return b.wallet.DecorateInputs(packet, failOnUnknown) +} + // lookupFirstCustomAccount returns the first custom account found. In theory, // there should be only one custom account for the given name. However, due to a // lack of check, users could have created custom accounts with various key diff --git a/lnwallet/interface.go b/lnwallet/interface.go index 72f9069fd..da7630e31 100644 --- a/lnwallet/interface.go +++ b/lnwallet/interface.go @@ -501,6 +501,12 @@ type WalletController interface { // finalized successfully. FinalizePsbt(packet *psbt.Packet, account string) error + // DecorateInputs fetches the UTXO information of all inputs it can + // identify and adds the required information to the package's inputs. + // The failOnUnknown boolean controls whether the method should return + // an error if it cannot identify an input or if it should just skip it. + DecorateInputs(packet *psbt.Packet, failOnUnknown bool) error + // SubscribeTransactions returns a TransactionSubscription client which // is capable of receiving async notifications as new transactions // related to the wallet are seen within the network, or found in diff --git a/lnwallet/mock.go b/lnwallet/mock.go index 476915b5a..dc59c63ac 100644 --- a/lnwallet/mock.go +++ b/lnwallet/mock.go @@ -235,6 +235,11 @@ func (w *mockWalletController) FinalizePsbt(_ *psbt.Packet, _ string) error { return nil } +// DecorateInputs currently does nothing. +func (w *mockWalletController) DecorateInputs(*psbt.Packet, bool) error { + return nil +} + // PublishTransaction sends a transaction to the PublishedTransactions chan. func (w *mockWalletController) PublishTransaction(tx *wire.MsgTx, _ string) error {