lnwallet: move pubKey comparison for funding output spend into spendMultiSig func
* This change makes the spendMultiSig function testable independent of the reservation workflow.
This commit is contained in:
1 parent
4632894562
commit
fa05ee9a22
3 files changed
+19
-24
No files matched your search
+5
-12
@@ -1,7 +1,6 @@
|
||||
package lnwallet
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -934,18 +933,12 @@ func (l *LightningWallet) handleFundingCounterPartySigs(msg *addCounterPartySigs
|
||||
|
||||
// Next, create the spending scriptSig, and then verify that the script
|
||||
// is complete, allowing us to spend from the funding transaction.
|
||||
//
|
||||
// When initially generating the redeemScript, we sorted the serialized
|
||||
// public keys in descending order. So we do a quick comparison in order
|
||||
// ensure the signatures appear on the Script Virual Machine stack in
|
||||
// the correct order.
|
||||
var scriptSig []byte
|
||||
theirCommitSig := msg.theirCommitmentSig
|
||||
if bytes.Compare(ourKey.PubKey().SerializeCompressed(), theirKey.SerializeCompressed()) == -1 {
|
||||
scriptSig, err = spendMultiSig(redeemScript, theirCommitSig, ourCommitSig)
|
||||
} else {
|
||||
scriptSig, err = spendMultiSig(redeemScript, ourCommitSig, theirCommitSig)
|
||||
}
|
||||
ourKeySer := ourKey.PubKey().SerializeCompressed()
|
||||
theirKeySer := theirKey.SerializeCompressed()
|
||||
scriptSig, err := spendMultiSig(redeemScript, ourKeySer, ourCommitSig,
|
||||
theirKeySer,
|
||||
theirCommitSig)
|
||||
if err != nil {
|
||||
msg.err <- err
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user