mirror of
https://github.com/muun/recovery.git
synced 2025-11-09 21:49:47 -05:00
Release v2.2.0
This commit is contained in:
1
vendor/github.com/muun/libwallet/addresses/addresses.go
generated
vendored
1
vendor/github.com/muun/libwallet/addresses/addresses.go
generated
vendored
@@ -12,6 +12,7 @@ const (
|
||||
V2 = 2
|
||||
V3 = 3
|
||||
V4 = 4
|
||||
V5 = 5
|
||||
SubmarineSwapV1 = 101
|
||||
SubmarineSwapV2 = 102
|
||||
IncomingSwap = 201
|
||||
|
||||
50
vendor/github.com/muun/libwallet/addresses/v5.go
generated
vendored
Normal file
50
vendor/github.com/muun/libwallet/addresses/v5.go
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
package addresses
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcutil/hdkeychain"
|
||||
"github.com/muun/libwallet/btcsuitew/btcutilw"
|
||||
"github.com/muun/libwallet/musig"
|
||||
)
|
||||
|
||||
// CreateAddressV5 returns a P2TR WalletAddress using Musig with the signing and cosigning keys.
|
||||
func CreateAddressV5(userKey, muunKey *hdkeychain.ExtendedKey, path string, network *chaincfg.Params) (*WalletAddress, error) {
|
||||
witnessProgram, err := CreateWitnessScriptV5(userKey, muunKey)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to generate witness script v5: %w", err)
|
||||
}
|
||||
|
||||
address, err := btcutilw.NewAddressTaprootKey(witnessProgram, network)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &WalletAddress{
|
||||
address: address.EncodeAddress(),
|
||||
version: V5,
|
||||
derivationPath: path,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func CreateWitnessScriptV5(userKey, muunKey *hdkeychain.ExtendedKey) ([]byte, error) {
|
||||
userPublicKey, err := userKey.ECPubKey()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
muunPublicKey, err := muunKey.ECPubKey()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
combined, err := musig.CombinePubKeysWithTweak(userPublicKey, muunPublicKey, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
xOnlyCombined := combined.SerializeCompressed()[1:]
|
||||
|
||||
return xOnlyCombined, nil
|
||||
}
|
||||
Reference in New Issue
Block a user