mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 09:48:19 +01:00
lnwallet: never create zero-value outputs within the commitment transaction
This commit is contained in:
parent
c0614c0478
commit
4104a9bcde
1 changed files with 8 additions and 3 deletions
|
@ -1421,9 +1421,14 @@ func createCommitTx(fundingOutput *wire.TxIn, selfKey, theirKey *btcec.PublicKey
|
||||||
commitTx := wire.NewMsgTx()
|
commitTx := wire.NewMsgTx()
|
||||||
commitTx.Version = 2
|
commitTx.Version = 2
|
||||||
commitTx.AddTxIn(fundingOutput)
|
commitTx.AddTxIn(fundingOutput)
|
||||||
// TODO(roasbeef): don't make 0 BTC output...
|
|
||||||
|
// Avoid creating zero value outputs within the commitment transaction.
|
||||||
|
if amountToSelf != 0 {
|
||||||
commitTx.AddTxOut(wire.NewTxOut(int64(amountToSelf), payToUsScriptHash))
|
commitTx.AddTxOut(wire.NewTxOut(int64(amountToSelf), payToUsScriptHash))
|
||||||
|
}
|
||||||
|
if amountToThem != 0 {
|
||||||
commitTx.AddTxOut(wire.NewTxOut(int64(amountToThem), theirWitnessKeyHash))
|
commitTx.AddTxOut(wire.NewTxOut(int64(amountToThem), theirWitnessKeyHash))
|
||||||
|
}
|
||||||
|
|
||||||
return commitTx, nil
|
return commitTx, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue