From b17db4a32ac370684f6c8a8e58ec89149cb2b3a9 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Thu, 8 Aug 2024 21:55:10 +0800 Subject: [PATCH] lntest+lnwallet: remove the method `FetchInputInfo` This method is no longer used. In addition, the `Derivation` field on the `Utxo` is also removed to avoid nil dereference. --- lntest/mock/walletcontroller.go | 15 ------------- lnwallet/btcwallet/signer.go | 38 --------------------------------- lnwallet/interface.go | 8 +------ lnwallet/mock.go | 16 -------------- 4 files changed, 1 insertion(+), 76 deletions(-) diff --git a/lntest/mock/walletcontroller.go b/lntest/mock/walletcontroller.go index e8d65570b..bfef14ee0 100644 --- a/lntest/mock/walletcontroller.go +++ b/lntest/mock/walletcontroller.go @@ -43,21 +43,6 @@ func (w *WalletController) BackEnd() string { return "mock" } -// FetchInputInfo will be called to get info about the inputs to the funding -// transaction. -func (w *WalletController) FetchInputInfo( - prevOut *wire.OutPoint) (*lnwallet.Utxo, error) { - - utxo := &lnwallet.Utxo{ - AddressType: lnwallet.WitnessPubKey, - Value: 10 * btcutil.SatoshiPerBitcoin, - PkScript: []byte("dummy"), - Confirmations: 1, - OutPoint: *prevOut, - } - return utxo, nil -} - // FetchOutpointInfo will be called to get info about the inputs to the funding // transaction. func (w *WalletController) FetchOutpointInfo( diff --git a/lnwallet/btcwallet/signer.go b/lnwallet/btcwallet/signer.go index e6021f12a..97832a789 100644 --- a/lnwallet/btcwallet/signer.go +++ b/lnwallet/btcwallet/signer.go @@ -19,44 +19,6 @@ import ( "github.com/lightningnetwork/lnd/lnwallet" ) -// FetchInputInfo queries for the WalletController's knowledge of the passed -// outpoint. If the base wallet determines this output is under its control, -// then the original txout should be returned. Otherwise, a non-nil error value -// of ErrNotMine should be returned instead. -// -// This is a part of the WalletController interface. -func (b *BtcWallet) FetchInputInfo(prevOut *wire.OutPoint) (*lnwallet.Utxo, - error) { - - prevTx, txOut, bip32, confirmations, err := b.wallet.FetchInputInfo( - prevOut, - ) - if err != nil { - return nil, err - } - - // Then, we'll populate all of the information required by the struct. - addressType := lnwallet.UnknownAddressType - switch { - case txscript.IsPayToWitnessPubKeyHash(txOut.PkScript): - addressType = lnwallet.WitnessPubKey - case txscript.IsPayToScriptHash(txOut.PkScript): - addressType = lnwallet.NestedWitnessPubKey - case txscript.IsPayToTaproot(txOut.PkScript): - addressType = lnwallet.TaprootPubkey - } - - return &lnwallet.Utxo{ - AddressType: addressType, - Value: btcutil.Amount(txOut.Value), - PkScript: txOut.PkScript, - Confirmations: confirmations, - OutPoint: *prevOut, - Derivation: bip32, - PrevTx: prevTx, - }, nil -} - // FetchOutpointInfo queries for the WalletController's knowledge of the passed // outpoint. If the base wallet determines this output is under its control, // then the original txout should be returned. Otherwise, a non-nil error value diff --git a/lnwallet/interface.go b/lnwallet/interface.go index 37568cfa6..94478f111 100644 --- a/lnwallet/interface.go +++ b/lnwallet/interface.go @@ -126,8 +126,7 @@ type Utxo struct { Confirmations int64 PkScript []byte wire.OutPoint - Derivation *psbt.Bip32Derivation - PrevTx *wire.MsgTx + PrevTx *wire.MsgTx } // OutputDetail contains additional information on a destination address. @@ -227,11 +226,6 @@ type TransactionSubscription interface { // behavior of all interface methods in order to ensure identical behavior // across all concrete implementations. type WalletController interface { - // FetchInputInfo queries for the WalletController's knowledge of the - // passed outpoint. It returns the same info as `FetchOutpointInfo` - // plus the Bip32Derivation info. - FetchInputInfo(prevOut *wire.OutPoint) (*Utxo, error) - // FetchOutpointInfo queries for the WalletController's knowledge of // the passed outpoint. If the base wallet determines this output is // under its control, then the original txout should be returned. diff --git a/lnwallet/mock.go b/lnwallet/mock.go index 62efd6145..5016fa0d6 100644 --- a/lnwallet/mock.go +++ b/lnwallet/mock.go @@ -45,22 +45,6 @@ func (w *mockWalletController) BackEnd() string { return "mock" } -// FetchInputInfo will be called to get info about the inputs to the funding -// transaction. -func (w *mockWalletController) FetchInputInfo( - prevOut *wire.OutPoint) (*Utxo, error) { - - utxo := &Utxo{ - AddressType: WitnessPubKey, - Value: 10 * btcutil.SatoshiPerBitcoin, - PkScript: []byte("dummy"), - Confirmations: 1, - OutPoint: *prevOut, - } - - return utxo, nil -} - // FetchOutpointInfo will be called to get info about the inputs to the funding // transaction. func (w *mockWalletController) FetchOutpointInfo(