lnwallet+contractcourt: publicly export DeriveCommitmentKeys use in chain watcher

In this commit, we consolidate the number of areas where we derive our
commitment keys. Before this commit, the `isOurCommitment` function in
the chain watcher used a custom routine to derive the expected
scripts/keys for our commitment at that height. With the recent changes,
we now have additional logic in `DeriveCommitmentKeys` that wasn't
copied over to this area. As a result, the prior logic would erroneously
detect if it was our commitment that had hit the chain or not.

In this commit, we remove the old custom code, and use
`DeriveCommitmentKeys` wihtin the chain watcher as well. This ensures
that we only need to maintain the key derivation code in a single place,
preventing future bugs of this nature.
This commit is contained in:
Olaoluwa Osuntokun committed 2019-09-25 18:26:13 -07:00
1 parent e497a07d64
commit 6d97bcbacd
3 files changed
+36 -40

No files matched your search

+2 -2
View File
@@ -663,11 +663,11 @@ func CreateCommitmentTxns(localBalance, remoteBalance btcutil.Amount,
fundingTxIn wire.TxIn,
tweaklessCommit bool) (*wire.MsgTx, *wire.MsgTx, error) {
localCommitmentKeys := deriveCommitmentKeys(
localCommitmentKeys := DeriveCommitmentKeys(
localCommitPoint, true, tweaklessCommit, ourChanCfg,
theirChanCfg,
)
remoteCommitmentKeys := deriveCommitmentKeys(
remoteCommitmentKeys := DeriveCommitmentKeys(
remoteCommitPoint, false, tweaklessCommit, ourChanCfg,
theirChanCfg,
)