diff --git a/lnwallet/btcwallet/signer.go b/lnwallet/btcwallet/signer.go index 98b9d909..21f09592 100644 --- a/lnwallet/btcwallet/signer.go +++ b/lnwallet/btcwallet/signer.go @@ -44,7 +44,14 @@ func (b *BtcWallet) FetchInputInfo(prevOut *wire.OutPoint) (*wire.TxOut, error) return nil, lnwallet.ErrNotMine } + // With the output retrieved, we'll make an additional check to ensure + // we actually have control of this output. We do this because the check + // above only guarantees that the transaction is somehow relevant to us, + // like in the event of us being the sender of the transaction. output = txDetail.TxRecord.MsgTx.TxOut[prevOut.Index] + if _, err := b.fetchOutputAddr(output.PkScript); err != nil { + return nil, err + } b.cacheMtx.Lock() b.utxoCache[*prevOut] = output @@ -72,7 +79,7 @@ func (b *BtcWallet) fetchOutputAddr(script []byte) (waddrmgr.ManagedAddress, err } } - return nil, errors.Errorf("address not found") + return nil, lnwallet.ErrNotMine } // fetchPrivKey attempts to retrieve the raw private key corresponding to the @@ -196,7 +203,7 @@ func (b *BtcWallet) ComputeInputScript(tx *wire.MsgTx, outputScript := signDesc.Output.PkScript walletAddr, err := b.fetchOutputAddr(outputScript) if err != nil { - return nil, nil + return nil, err } pka := walletAddr.(waddrmgr.ManagedPubKeyAddress)