Skip to content

Commit

Permalink
lntest+lnwallet: remove the method FetchInputInfo
Browse files Browse the repository at this point in the history
This method is no longer used. In addition, the `Derivation` field on
the `Utxo` is also removed to avoid nil dereference.
  • Loading branch information
yyforyongyu committed Aug 8, 2024
1 parent b50edbd commit 4bd04b1
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 76 deletions.
15 changes: 0 additions & 15 deletions lntest/mock/walletcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
38 changes: 0 additions & 38 deletions lnwallet/btcwallet/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions lnwallet/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
16 changes: 0 additions & 16 deletions lnwallet/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 4bd04b1

Please sign in to comment.