From 6103ccb081caa39e1e30b57c41836c20f1991289 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 27 Mar 2018 15:37:03 -0700 Subject: [PATCH] lnwallet: ensure we only accept/produce sane commitments In this commit, we add an additional check within CreateCommitTx to ensure that we will never create or accept a commitment transaction that wasn't valid by consensus. To enforce this check, we use the blockchain.CheckTransactionSanity method. --- lnwallet/channel.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lnwallet/channel.go b/lnwallet/channel.go index cefc3753..22717eda 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -5663,6 +5663,13 @@ func CreateCommitTx(fundingOutput wire.TxIn, }) } + // Finally, we'll ensure that we don't accidentally create a commitment + // transaction which would be invalid by consensus. + uTx := btcutil.NewTx(commitTx) + if err := blockchain.CheckTransactionSanity(uTx); err != nil { + return nil, err + } + return commitTx, nil }