diff --git a/lnwallet/btcwallet/blockchain.go b/lnwallet/btcwallet/blockchain.go index 93411786..27b64e83 100644 --- a/lnwallet/btcwallet/blockchain.go +++ b/lnwallet/btcwallet/blockchain.go @@ -2,11 +2,18 @@ package btcwallet import ( "encoding/hex" + "errors" "github.com/lightningnetwork/lnd/lnwallet" "github.com/roasbeef/btcd/wire" ) +var ( + // ErrOutputSpent is returned by the GetUtxo method if the target output + // for lookup has already been spent. + ErrOutputSpent = errors.New("target output has been spent") +) + // GetBestBlock returns the current height and hash of the best known block // within the main chain. // @@ -22,6 +29,8 @@ func (b *BtcWallet) GetUtxo(txid *wire.ShaHash, index uint32) (*wire.TxOut, erro txout, err := b.rpc.GetTxOut(txid, index, false) if err != nil { return nil, err + } else if txout == nil { + return nil, ErrOutputSpent } pkScript, err := hex.DecodeString(txout.ScriptPubKey.Hex)