From 4104a9bcde4a9513038a074b99a0271b30253bbf Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 27 Jul 2016 12:15:31 -0700 Subject: [PATCH] lnwallet: never create zero-value outputs within the commitment transaction --- lnwallet/channel.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 8f2dbca4..6b796172 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -1421,9 +1421,14 @@ func createCommitTx(fundingOutput *wire.TxIn, selfKey, theirKey *btcec.PublicKey commitTx := wire.NewMsgTx() commitTx.Version = 2 commitTx.AddTxIn(fundingOutput) - // TODO(roasbeef): don't make 0 BTC output... - commitTx.AddTxOut(wire.NewTxOut(int64(amountToSelf), payToUsScriptHash)) - commitTx.AddTxOut(wire.NewTxOut(int64(amountToThem), theirWitnessKeyHash)) + + // Avoid creating zero value outputs within the commitment transaction. + if amountToSelf != 0 { + commitTx.AddTxOut(wire.NewTxOut(int64(amountToSelf), payToUsScriptHash)) + } + if amountToThem != 0 { + commitTx.AddTxOut(wire.NewTxOut(int64(amountToThem), theirWitnessKeyHash)) + } return commitTx, nil }