lnwallet: return ErrNoOutputs in case no outputs are sent to

This commit is contained in:
Johan T. Halseth 2019-03-05 14:22:30 +01:00
parent a5becc2063
commit 306c0c8aab
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26
2 changed files with 11 additions and 0 deletions

@ -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 {

@ -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 {