lnd

package
v0.13.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 57 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MnemonicEnvName   = "AEZEED_MNEMONIC"
	PassphraseEnvName = "AEZEED_PASSPHRASE"
	PasswordEnvName   = "WALLET_PASSWORD"
)
View Source
const (
	HardenedKeyStart            = uint32(hdkeychain.HardenedKeyStart)
	WalletDefaultDerivationPath = "m/84'/0'/0'"
	WalletBIP49DerivationPath   = "m/49'/0'/0'"
	WalletBIP86DerivationPath   = "m/86'/0'/0'"
	LndDerivationPath           = "m/1017'/%d'/%d'"

	AddressDeriveFromWallet = "fromseed"
)
View Source
const (
	DefaultOpenTimeout = time.Second * 10
)

Variables

View Source
var (

	// Namespace from github.com/btcsuite/btcwallet/wallet/wallet.go.
	WaddrmgrNamespaceKey = []byte("waddrmgr")
)

Functions

func AllDerivationPaths

func AllDerivationPaths(params *chaincfg.Params) ([]string, [][]uint32, error)

func AllNodeChannels

func AllNodeChannels(graph *lnrpc.ChannelGraph,
	nodePubKey string) []*lnrpc.ChannelEdge

func CheckAddress added in v0.12.1

func CheckAddress(addr string, chainParams *chaincfg.Params, allowDerive bool,
	hint string, allowedTypes ...AddrType) error

func ConnectPeer

func ConnectPeer(conn *brontide.Conn, connReq *connmgr.ConnReq,
	netParams *chaincfg.Params,
	identityECDH keychain.SingleKeyECDH) (*peer.Brontide, error)

func CreateChannelBackup

func CreateChannelBackup(db *channeldb.DB, multiFile *chanbackup.MultiFile,
	ring keychain.KeyRing) error

CreateChannelBackup creates a channel backup file from all channels found in the given DB file, encrypted with the key in the key ring.

func DecodeAddressHash

func DecodeAddressHash(addr string, chainParams *chaincfg.Params) ([]byte, bool,
	error)

DecodeAddressHash returns the public key or script hash encoded in a native bech32 encoded SegWit address and whether it's a script hash or not.

func DecryptWalletRootKey added in v0.13.0

func DecryptWalletRootKey(db walletdb.DB,
	privatePassphrase []byte) ([]byte, error)

DecryptWalletRootKey decrypts a lnd compatible wallet's root key.

func DeriveChildren

func DeriveChildren(key *hdkeychain.ExtendedKey, path []uint32) (
	*hdkeychain.ExtendedKey, error)

func DeriveKey

func DeriveKey(extendedKey *hdkeychain.ExtendedKey, path string,
	params *chaincfg.Params) (*hdkeychain.ExtendedKey, *btcec.PublicKey,
	*btcutil.WIF, error)

DeriveKey derives the public key and private key in the WIF format for a given key path of the extended key.

func ECDH

func ECDH(privKey *btcec.PrivateKey, pub *btcec.PublicKey) ([32]byte, error)

ECDH performs a scalar multiplication (ECDH-like operation) between the target private key and remote public key. The output returned will be the sha256 of the resulting shared point serialized in compressed format. If k is our private key, and P is the public key, we perform the following operation:

sx := k*P s := sha256(sx.SerializeCompressed())

func ExtractChannel added in v0.12.1

func ExtractChannel(extendedKey *hdkeychain.ExtendedKey,
	chainParams *chaincfg.Params, multiFilePath,
	channelPoint string) (*dump.BackupSingle, error)

ExtractChannel extracts a single channel from the given backup file and returns it as a dump.BackupSingle struct.

func FindCommonEdges

func FindCommonEdges(graph *lnrpc.ChannelGraph, node1,
	node2 string) []*lnrpc.ChannelEdge

func FindNode

func FindNode(graph *lnrpc.ChannelGraph,
	nodePubKey string) (*lnrpc.LightningNode, error)

func GetP2WPKHScript

func GetP2WPKHScript(addr string, chainParams *chaincfg.Params) ([]byte,
	error)

GetP2WPKHScript creates a P2WKH output script from an address. If the address is not a P2WKH address, an error is returned.

func GetP2WSHScript

func GetP2WSHScript(addr string, chainParams *chaincfg.Params) ([]byte,
	error)

GetP2WSHScript creates a P2WSH output script from an address. If the address is not a P2WSH address, an error is returned.

func GetWitnessAddrScript

func GetWitnessAddrScript(addr btcutil.Address,
	chainParams *chaincfg.Params) ([]byte, error)

func HardenedKey

func HardenedKey(key uint32) uint32

func IdentityPath

func IdentityPath(params *chaincfg.Params) string

func MultisigPath

func MultisigPath(params *chaincfg.Params, index int) string

func NP2WKHAddr

func NP2WKHAddr(pubKey *btcec.PublicKey,
	params *chaincfg.Params) (*btcutil.AddressScriptHash, error)

func OpenDB

func OpenDB(dbPath string, readonly bool) (*channeldb.DB, error)

func OpenWallet added in v0.13.0

func OpenWallet(walletDbPath string,
	chainParams *chaincfg.Params) (*wallet.Wallet, []byte, func() error,
	error)

OpenWallet opens a lnd compatible wallet and returns it, along with the private wallet password.

func P2AnchorStaticRemote

func P2AnchorStaticRemote(pubKey *btcec.PublicKey,
	params *chaincfg.Params) (*btcutil.AddressWitnessScriptHash, []byte,
	error)

func P2PKHAddr

func P2PKHAddr(pubKey *btcec.PublicKey,
	params *chaincfg.Params) (*btcutil.AddressPubKeyHash, error)

func P2TRAddr

func P2TRAddr(pubKey *btcec.PublicKey,
	params *chaincfg.Params) (*btcutil.AddressTaproot, error)

func P2TaprootStaticRemote added in v0.12.1

func P2TaprootStaticRemote(pubKey *btcec.PublicKey,
	params *chaincfg.Params) (*btcutil.AddressTaproot,
	*input.CommitScriptTree, error)

func P2WKHAddr

func P2WKHAddr(pubKey *btcec.PublicKey,
	params *chaincfg.Params) (*btcutil.AddressWitnessPubKeyHash, error)

func ParseAddress

func ParseAddress(addr string, chainParams *chaincfg.Params) (btcutil.Address,
	error)

ParseAddress attempts to parse the given address string into a native address for the given network.

func ParseOutpoint

func ParseOutpoint(s string) (*wire.OutPoint, error)

ParseOutpoint parses a transaction outpoint in the format <txid>:<idx> into the wire format.

func ParsePath

func ParsePath(path string) ([]uint32, error)

func PasswordFromConsole added in v0.13.0

func PasswordFromConsole(userQuery string) ([]byte, error)

PasswordFromConsole reads a password from the console or stdin.

func PrepareWalletAddress added in v0.12.1

func PrepareWalletAddress(addr string, chainParams *chaincfg.Params,
	estimator *input.TxWeightEstimator, rootKey *hdkeychain.ExtendedKey,
	hint string) ([]byte, error)

func PrivKeyFromPath

func PrivKeyFromPath(extendedKey *hdkeychain.ExtendedKey,
	path []uint32) (*btcec.PrivateKey, error)

func ReadAezeed

func ReadAezeed(params *chaincfg.Params) (*hdkeychain.ExtendedKey, time.Time,
	error)

ReadAezeed reads an aezeed from the console or the environment variable.

func ReadPassphrase added in v0.13.0

func ReadPassphrase(verb string) ([]byte, error)

ReadPassphrase reads a cipher seed passphrase from the console or the environment variable.

func ShaChainFromPath

func ShaChainFromPath(extendedKey *hdkeychain.ExtendedKey, path []uint32,
	multiSigPubKey *btcec.PublicKey) (*shachain.RevocationProducer, error)

Types

type AddrType added in v0.12.1

type AddrType int
const (
	AddrTypeP2WKH AddrType = iota
	AddrTypeP2WSH
	AddrTypeP2TR
)

type HDKeyRing

type HDKeyRing struct {
	ExtendedKey *hdkeychain.ExtendedKey
	ChainParams *chaincfg.Params
}

func (*HDKeyRing) CheckDescriptor

func (r *HDKeyRing) CheckDescriptor(
	keyDesc keychain.KeyDescriptor) error

CheckDescriptor checks if a key descriptor is correct by making sure that we can derive the key that it describes.

func (*HDKeyRing) DeriveKey

func (r *HDKeyRing) DeriveKey(keyLoc keychain.KeyLocator) (
	keychain.KeyDescriptor, error)

func (*HDKeyRing) DeriveNextKey

func (r *HDKeyRing) DeriveNextKey(_ keychain.KeyFamily) (
	keychain.KeyDescriptor, error)

func (*HDKeyRing) NodePubKey

func (r *HDKeyRing) NodePubKey() (*btcec.PublicKey, error)

NodePubKey returns the public key that represents an lnd node's public network identity.

type LightningChannel

type LightningChannel struct {
	LocalChanCfg  channeldb.ChannelConfig
	RemoteChanCfg channeldb.ChannelConfig
	SignDesc      *input.SignDescriptor
	ChannelState  *channeldb.OpenChannel
	TXSigner      *Signer
}

func (*LightningChannel) CreateSignDesc

func (lc *LightningChannel) CreateSignDesc() error

CreateSignDesc derives the SignDescriptor for commitment transactions from other fields on the LightningChannel.

func (*LightningChannel) SignedCommitTx

func (lc *LightningChannel) SignedCommitTx() (*wire.MsgTx, error)

SignedCommitTx function take the latest commitment transaction and populate it with witness data.

type Signer

type Signer struct {
	input.MockSigner

	ExtendedKey *hdkeychain.ExtendedKey
	ChainParams *chaincfg.Params
}

func (*Signer) AddPartialSignature

func (s *Signer) AddPartialSignature(packet *psbt.Packet,
	keyDesc keychain.KeyDescriptor, utxo *wire.TxOut, witnessScript []byte,
	inputIndex int) error

func (*Signer) AddPartialSignatureForPrivateKey added in v0.13.0

func (s *Signer) AddPartialSignatureForPrivateKey(packet *psbt.Packet,
	privateKey *btcec.PrivateKey, utxo *wire.TxOut, witnessScript []byte,
	inputIndex int) error

func (*Signer) ComputeInputScript

func (s *Signer) ComputeInputScript(_ *wire.MsgTx, _ *input.SignDescriptor) (
	*input.Script, error)

func (*Signer) FetchPrivateKey added in v0.13.0

func (s *Signer) FetchPrivateKey(descriptor *keychain.KeyDescriptor) (
	*btcec.PrivateKey, error)

func (*Signer) SignOutputRaw

func (s *Signer) SignOutputRaw(tx *wire.MsgTx,
	signDesc *input.SignDescriptor) (input.Signature, error)

func (*Signer) SignOutputRawWithPrivateKey added in v0.13.0

func (s *Signer) SignOutputRawWithPrivateKey(tx *wire.MsgTx,
	signDesc *input.SignDescriptor,
	privKey *secp256k1.PrivateKey) (input.Signature, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL