mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-26 01:33:02 +01:00
lnwallet: add TaprootInternalKey method to ShimIntent
If this is a taproot channel, then we'll return the internal key which'll be useful to callers.
This commit is contained in:
parent
bb71c496f4
commit
a841a9be30
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcec/v2/schnorr/musig2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
@ -105,6 +106,26 @@ func (s *ShimIntent) FundingOutput() ([]byte, *wire.TxOut, error) {
|
||||
)
|
||||
}
|
||||
|
||||
// TaprootInternalKey may return the internal key for a MuSig2 funding output,
|
||||
// but only if this is actually a MuSig2 channel.
|
||||
func (s *ShimIntent) TaprootInternalKey() fn.Option[*btcec.PublicKey] {
|
||||
if !s.musig2 {
|
||||
return fn.None[*btcec.PublicKey]()
|
||||
}
|
||||
|
||||
// Similar to the existing p2wsh script, we'll always ensure the keys
|
||||
// are sorted before use. Since we're only interested in the internal
|
||||
// key, we don't need to take into account any tapscript root.
|
||||
//
|
||||
// We ignore the error here as this is only called after FundingOutput
|
||||
// is called.
|
||||
combinedKey, _, _, _ := musig2.AggregateKeys(
|
||||
[]*btcec.PublicKey{s.localKey.PubKey, s.remoteKey}, true,
|
||||
)
|
||||
|
||||
return fn.Some(combinedKey.PreTweakedKey)
|
||||
}
|
||||
|
||||
// Cancel allows the caller to cancel a funding Intent at any time. This will
|
||||
// return any resources such as coins back to the eligible pool to be used in
|
||||
// order channel fundings.
|
||||
|
Loading…
x
Reference in New Issue
Block a user