func derivePrivKey(key *hdkeychain.ExtendedKey, path []uint32) (*hdkeychain.ExtendedKey, error) {
	derivedKey := key
	for _, childNum := range path {
		var err error
		derivedKey, err = derivedKey.Child(childNum)
		if err != nil {
			return nil, err
		}
	}
	return derivedKey, nil
}
returns derived private key at `path` for `key` in extended key format
package btc
import (
	"bytes"
	"encoding/hex"
	"errors"
	"github.com/tyler-smith/go-bip39"
	"github.com/btcsuite/btcutil"
	"github.com/btcsuite/btcd/chaincfg"
	"github.com/btcsuite/btcd/txscript"
	"github.com/btcsuite/btcutil/hdkeychain"
)
func seedFromMnemonic(mnemonic string) []byte {
	return bip39.NewSeed(mnemonic, "")
}
func createWallet(network string, segwit bool) (*wallet, error) {
	entropy, err := bip39.NewEntropy(EntropyBitSize)
	if err != nil {
		return nil, err
	}
	mnemonic, err := bip39.NewMnemonic(entropy)
	if err != nil {
		return nil, err
	}
	purpose := Purpose
	if segwit {
		purpose = SegwitPurpose
	}
	path := []uint32{purpose, CoinType[network], Account, Change}
	wallet := &wallet{
		Mnemonic:       mnemonic,
		Network:        network,
		DerivationPath: path,
		Segwit:         segwit,
	}
	return wallet, nil
}
func createMultiSigWallet(network string, pubkeys []string, m int, n int) (*multiSigWallet, error) {
	w, err := createWallet(network, false)
	if err != nil {
		return nil, err
	}
	seed := seedFromMnemonic(w.Mnemonic)
	masterKey, err := getMasterKey(seed, w.Network)
	if err != nil {
		return nil, err
	}
	privkey, err := derivePrivKey(masterKey, append(w.DerivationPath, MultiSigDefaultAddressIndex))
	if err != nil {
		return nil, err
	}
	pubkey, err := privkey.ECPubKey()
	if err != nil {
		return nil, err
	}
	net, err := getNetworkFromString(w.Network)
	if err != nil {
		return nil, err
	}
	pubkeybytes, err := btcutil.NewAddressPubKey(pubkey.SerializeUncompressed(), net)
	if err != nil {
		return nil, err
	}
	pubkeys = append(pubkeys, pubkeybytes.String())
	redeemScript, err := newRedeemScript(m, n, pubkeys)
	if err != nil {
		return nil, err
	}
	wallet := &multiSigWallet{
		wallet:       w,
		PublicKeys:   pubkeys,
		RedeemScript: redeemScript,
		M:            m,
		N:            n,
	}
	return wallet, nil
}
func createSegWitWallet(network string) (*wallet, error) {
	entropy, err := bip39.NewEntropy(EntropyBitSize)
	if err != nil {
		return nil, err
	}
	mnemonic, err := bip39.NewMnemonic(entropy)
	if err != nil {
		return nil, err
	}
	path := []uint32{NativeSegwitPurpose, CoinType[network], Account, Change}
	wallet := &wallet{
		Mnemonic:       mnemonic,
		Network:        network,
		DerivationPath: path,
	}
	return wallet, nil
}