diff --git a/lnwallet/btcwallet/btcwallet.go b/lnwallet/btcwallet/btcwallet.go index 668e78401..f0cc40491 100644 --- a/lnwallet/btcwallet/btcwallet.go +++ b/lnwallet/btcwallet/btcwallet.go @@ -299,6 +299,10 @@ func (b *BtcWallet) SendOutputs(outputs []*wire.TxOut, // SendOutputs. feeSatPerKB := btcutil.Amount(feeRate.FeePerKVByte()) + // Sanity check outputs. + if len(outputs) < 1 { + return nil, lnwallet.ErrNoOutputs + } return b.wallet.SendOutputs(outputs, defaultAccount, 1, feeSatPerKB) } @@ -321,6 +325,9 @@ func (b *BtcWallet) CreateSimpleTx(outputs []*wire.TxOut, feeSatPerKB := btcutil.Amount(feeRate.FeePerKVByte()) // Sanity check outputs. + if len(outputs) < 1 { + return nil, lnwallet.ErrNoOutputs + } for _, output := range outputs { err := txrules.CheckOutput(output, feeSatPerKB) if err != nil { diff --git a/lnwallet/interface.go b/lnwallet/interface.go index 66c9d8a54..d3f53a0e0 100644 --- a/lnwallet/interface.go +++ b/lnwallet/interface.go @@ -49,6 +49,10 @@ var ( ErrNotMine = errors.New("the passed output doesn't belong to the wallet") ) +// ErrNoOutputs is returned if we try to create a transaction with no outputs +// or send coins to a set of outputs that is empty. +var ErrNoOutputs = errors.New("no outputs") + // Utxo is an unspent output denoted by its outpoint, and output value of the // original output. type Utxo struct {