mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-28 13:52:55 +02:00
htlcswitch: add awareness of new partial sig fields and musig2 nonces
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/btcsuite/btcd/btcec/v2/schnorr/musig2"
|
||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/btcsuite/btclog"
|
"github.com/btcsuite/btclog"
|
||||||
@@ -738,6 +739,26 @@ func (l *channelLink) syncChanStates() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Before we process the ChanSync message, if this is a taproot
|
||||||
|
// channel, then we'll init our musig2 nonces state.
|
||||||
|
if chanState.ChanType.IsTaproot() {
|
||||||
|
l.log.Infof("initializing musig2 nonces")
|
||||||
|
|
||||||
|
if remoteChanSyncMsg.LocalNonce == nil {
|
||||||
|
return fmt.Errorf("remote nonce is nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
syncMsg := remoteChanSyncMsg
|
||||||
|
remoteNonce := &musig2.Nonces{
|
||||||
|
PubNonce: *syncMsg.LocalNonce,
|
||||||
|
}
|
||||||
|
err := l.channel.InitRemoteMusigNonces(remoteNonce)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to init musig2 "+
|
||||||
|
"nonces: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// In any case, we'll then process their ChanSync message.
|
// In any case, we'll then process their ChanSync message.
|
||||||
l.log.Info("received re-establishment message from remote side")
|
l.log.Info("received re-establishment message from remote side")
|
||||||
|
|
||||||
@@ -1909,6 +1930,7 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
|
|||||||
err = l.channel.ReceiveNewCommitment(&lnwallet.CommitSigs{
|
err = l.channel.ReceiveNewCommitment(&lnwallet.CommitSigs{
|
||||||
CommitSig: msg.CommitSig,
|
CommitSig: msg.CommitSig,
|
||||||
HtlcSigs: msg.HtlcSigs,
|
HtlcSigs: msg.HtlcSigs,
|
||||||
|
PartialSig: msg.PartialSig,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If we were unable to reconstruct their proposed
|
// If we were unable to reconstruct their proposed
|
||||||
@@ -2275,6 +2297,7 @@ func (l *channelLink) updateCommitTx() error {
|
|||||||
ChanID: l.ChanID(),
|
ChanID: l.ChanID(),
|
||||||
CommitSig: newCommit.CommitSig,
|
CommitSig: newCommit.CommitSig,
|
||||||
HtlcSigs: newCommit.HtlcSigs,
|
HtlcSigs: newCommit.HtlcSigs,
|
||||||
|
PartialSig: newCommit.PartialSig,
|
||||||
}
|
}
|
||||||
l.cfg.Peer.SendMessage(false, commitSig)
|
l.cfg.Peer.SendMessage(false, commitSig)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user