mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-29 15:11:09 +02:00
input: ensure sessionOpts is properly threaded through
This commit is contained in:
@@ -2,15 +2,12 @@ package lnwallet
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/hmac"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcec/v2/schnorr"
|
||||
"github.com/btcsuite/btcd/btcec/v2/schnorr/musig2"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
@@ -575,41 +572,3 @@ func NewMusigPairSession(cfg *MusigSessionCfg) *MusigPairSession {
|
||||
signer: cfg.Signer,
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
// taprootRevRootKey is the key used to derive the revocation root for
|
||||
// the taproot nonces. This is done via HMAC of the existing revocation
|
||||
// root.
|
||||
taprootRevRootKey = []byte("taproot-rev-root")
|
||||
)
|
||||
|
||||
// deriveMusig2Shachain derives a shachain producer for the taproot channel
|
||||
// from normal shachain revocation root.
|
||||
func deriveMusig2Shachain(revRoot shachain.Producer) (shachain.Producer, error) {
|
||||
// In order to obtain the revocation root hash to create the taproot
|
||||
// revocation, we'll encode the producer into a buffer, then use that
|
||||
// to derive the shachain root needed.
|
||||
var rootHashBuf bytes.Buffer
|
||||
if err := revRoot.Encode(&rootHashBuf); err != nil {
|
||||
return nil, fmt.Errorf("unable to encode producer: %v", err)
|
||||
}
|
||||
|
||||
revRootHash := chainhash.HashH(rootHashBuf.Bytes())
|
||||
|
||||
// For taproot channel types, we'll also generate a distinct shachain
|
||||
// root using the same seed information. We'll use this to generate
|
||||
// verification nonces for the channel. We'll bind with this a simple
|
||||
// hmac.
|
||||
taprootRevHmac := hmac.New(sha256.New, taprootRevRootKey)
|
||||
if _, err := taprootRevHmac.Write(revRootHash[:]); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
taprootRevRoot := taprootRevHmac.Sum(nil)
|
||||
|
||||
// Once we have the root, we can then generate our shachain producer
|
||||
// and from that generate the per-commitment point.
|
||||
return shachain.NewRevocationProducerFromBytes(
|
||||
taprootRevRoot,
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user