libwallet

package module
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: MIT Imports: 55 Imported by: 0

README

muun

About

This is the source code repository for muun's wallet core library. Muun is a non-custodial 2-of-2 multisig wallet with a special focus on security and ease of use.

This library is used by our mobile wallets with gomobile.

Responsible Disclosure

Send us an email to report any security related bugs or vulnerabilities at security@muun.com.

You can encrypt your email message using our public PGP key.

Public key fingerprint: 1299 28C1 E79F E011 6DA4 C80F 8DB7 FD0F 61E6 ED76

Documentation

Index

Constants

View Source
const (
	AddressVersionV1      = addresses.V1
	AddressVersionV2      = addresses.V2
	AddressVersionV3      = addresses.V3
	AddressVersionV4      = addresses.V4
	AddressVersionV5      = addresses.V5
	AddressVersionSwapsV1 = addresses.SubmarineSwapV1
	AddressVersionSwapsV2 = addresses.SubmarineSwapV2
)

These constants are here for clients usage.

View Source
const (
	// EncodedKeyLength is the size of a modern encoded key, as exported by the clients.
	EncodedKeyLength = 147

	// EncodedKeyLengthLegacy is the size of a legacy key, when salt resided only in the 2nd key.
	EncodedKeyLengthLegacy = 136
)
View Source
const (
	EKVersionNeverExported = -1
	// EKVersionOnlyKeys is the encrypted keys to be written down / emailed
	EKVersionOnlyKeys = 1
	// EKVersionDescriptors is the first PDF including the descriptors
	EKVersionDescriptors = 2
	// EKVersionMusig add the musig descriptors
	EKVersionMusig = 3
)
View Source
const (
	ErrUnknown               = 1
	ErrInvalidURI            = 2
	ErrNetwork               = 3
	ErrInvalidPrivateKey     = 4
	ErrInvalidDerivationPath = 5
	ErrInvalidInvoice        = 6
)
View Source
const (
	BackendFeatureTaproot              = "TAPROOT"
	BackendFeatureTaprootPreactivation = "TAPROOT_PREACTIVATION"
	BackendFeatureApolloBiometrics     = "APOLLO_BIOMETRICS"

	UserActivatedFeatureStatusOff                 = "off"
	UserActivatedFeatureStatusCanPreactivate      = "can_preactivate"
	UserActivatedFeatureStatusCanActivate         = "can_activate"
	UserActivatedFeatureStatusPreactivated        = "preactivated"
	UserActivatedFeatureStatusScheduledActivation = "scheduled_activation"
	UserActivatedFeatureStatusActive              = "active"
)
View Source
const (
	LNURLErrDecode              = lnurl.ErrDecode
	LNURLErrUnsafeURL           = lnurl.ErrUnsafeURL
	LNURLErrUnreachable         = lnurl.ErrUnreachable
	LNURLErrInvalidResponse     = lnurl.ErrInvalidResponse
	LNURLErrResponse            = lnurl.ErrResponse
	LNURLErrUnknown             = lnurl.ErrUnknown
	LNURLErrWrongTag            = lnurl.ErrWrongTag
	LNURLErrNoAvailableBalance  = lnurl.ErrNoAvailableBalance
	LNURLErrRequestExpired      = lnurl.ErrRequestExpired
	LNURLErrNoRoute             = lnurl.ErrNoRoute
	LNURLErrTorNotSupported     = lnurl.ErrTorNotSupported
	LNURLErrAlreadyUsed         = lnurl.ErrAlreadyUsed
	LNURLErrForbidden           = lnurl.ErrForbidden
	LNURLErrCountryNotSupported = lnurl.ErrCountryNotSupported
	LNURLStatusContacting       = lnurl.StatusContacting
	LNURLStatusInvoiceCreated   = lnurl.StatusInvoiceCreated
	LNURLStatusReceiving        = lnurl.StatusReceiving
)
View Source
const MaxUnusedSecrets = 5
View Source
const PKEncryptionVersion = 1
View Source
const RecoveryCodeAlphabet = recoverycode.Alphabet

RecoveryCodeAlphabet contains all upper-case characters except for numbers/letters that look alike.

Variables

View Source
var File_bip70_proto protoreflect.FileDescriptor

Functions

func AddEmergencyKitMetadata

func AddEmergencyKitMetadata(metadataText string, srcFile string, dstFile string) error

AddEmergencyKitMetadata produces a copy of the PDF file at `srcFile` with embedded metadata, writing it into `dstFile`. The provided metadata must be the same opaque string produced by `GenerateEmergencyKitHTML`.

func DetermineUserActivatedFeatureStatus added in v0.9.0

func DetermineUserActivatedFeatureStatus(
	feature UserActivatedFeature,
	blockHeight int,
	exportedKitVersions *IntList,
	backendFeatures *StringList,
	network *Network,
) string

func ErrorCode

func ErrorCode(err error) int64

func GenerateRecoveryCode

func GenerateRecoveryCode() string

GenerateRecoveryCode generates a new random recovery code using a cryptographically secure random number generator.

func GetInvoiceMetadata added in v0.9.0

func GetInvoiceMetadata(paymentHash []byte) (string, error)

func GetRecoveryCodeVersion

func GetRecoveryCodeVersion(code string) (int, error)

GetRecoveryCodeVersion returns the version for the recovery code given. If no version can be recognized, it returns an error.

func Init

func Init(c *Config)

Init configures the libwallet

func KeyEncrypt

func KeyEncrypt(privKey *HDPrivateKey, passphrase string) (string, error)

KeyEncrypt encrypts an HD priv key using a user-provided secret into a string We use SCrypt256 for key derivation and AES-CBC-PKCS7 for encryption. The returned string has information about version, derivation path, scrypt and AES parameters.

func LNURLValidate added in v0.9.0

func LNURLValidate(qr string) bool

func LNURLWithdraw added in v0.9.0

func LNURLWithdraw(invoiceBuilder *InvoiceBuilder, qr string, listener LNURLListener)

Withdraw will parse an LNURL withdraw QR and begin a withdraw process. Caller must wait for the actual payment after this function has notified success.

func PersistInvoiceSecrets

func PersistInvoiceSecrets(list *InvoiceSecretsList) error

PersistInvoiceSecrets stores secrets registered with the remote server in the device local database. These secrets can be used to craft new Lightning invoices.

func SHA256 added in v0.9.0

func SHA256(data []byte) []byte

func Scrypt256

func Scrypt256(data, salt []byte) []byte

func SignWithPrivateKey added in v0.9.0

func SignWithPrivateKey(key *HDPrivateKey, data []byte) ([]byte, error)

func ValidateRecoveryCode

func ValidateRecoveryCode(code string) error

ValidateRecoveryCode returns an error if the recovery code is not valid or nil otherwise.

func ValidateSubmarineSwap

func ValidateSubmarineSwap(rawInvoice string, userPublicKey *HDPublicKey, muunPublicKey *HDPublicKey, swap SubmarineSwap, originalExpirationInBlocks int64, network *Network) error

Types

type BestRouteFees

type BestRouteFees struct {
	MaxCapacity              int64
	FeeProportionalMillionth int64
	FeeBase                  int64
}

type BestRouteFeesList

type BestRouteFeesList struct {
	// contains filtered or unexported fields
}

func (*BestRouteFeesList) Add

func (l *BestRouteFeesList) Add(f *BestRouteFees)

type ChallengePrivateKey

type ChallengePrivateKey struct {
	// contains filtered or unexported fields
}

func NewChallengePrivateKey

func NewChallengePrivateKey(input, salt []byte) *ChallengePrivateKey

func RecoveryCodeToKey

func RecoveryCodeToKey(code, salt string) (*ChallengePrivateKey, error)

RecoveryCodeToKey generates a challenge private key using the recovery code as a seed.

The salt parameter is only used for version 1 codes. It will be ignored for version 2+ codes.

func (*ChallengePrivateKey) DecryptKey

func (k *ChallengePrivateKey) DecryptKey(decodedInfo *EncryptedPrivateKeyInfo, network *Network) (*DecryptedPrivateKey, error)

func (*ChallengePrivateKey) DecryptRawKey

func (k *ChallengePrivateKey) DecryptRawKey(encryptedKey string, network *Network) (*DecryptedPrivateKey, error)

func (*ChallengePrivateKey) PubKey

func (*ChallengePrivateKey) PubKeyHex

func (k *ChallengePrivateKey) PubKeyHex() string

func (*ChallengePrivateKey) SignSha

func (k *ChallengePrivateKey) SignSha(payload []byte) ([]byte, error)

SignSha computes the SHA-256 digest of the given payload and signs it.

type ChallengePublicKey

type ChallengePublicKey struct {
	// contains filtered or unexported fields
}

func NewChallengePublicKeyFromSerialized

func NewChallengePublicKeyFromSerialized(serializedKey []byte) (*ChallengePublicKey, error)

func (*ChallengePublicKey) EncryptKey

func (k *ChallengePublicKey) EncryptKey(privKey *HDPrivateKey, recoveryCodeSalt []byte, birthday int) (string, error)

type Config

type Config struct {
	DataDir  string
	Listener Listener
}

Config defines the global libwallet configuration.

type DecryptOperation added in v0.9.0

type DecryptOperation struct {
	// contains filtered or unexported fields
}

func NewDecryptOperation added in v0.9.0

func NewDecryptOperation(key *HDPrivateKey, payload string) *DecryptOperation

func NewDecryptOperationFrom added in v0.9.0

func NewDecryptOperationFrom(sender *PublicKey, key *HDPrivateKey, payload string) *DecryptOperation

func (*DecryptOperation) Decrypt added in v0.9.0

func (o *DecryptOperation) Decrypt() ([]byte, error)

type DecryptedKey

type DecryptedKey struct {
	Key  *HDPrivateKey
	Path string
}

func KeyDecrypt

func KeyDecrypt(value, passphrase string, network *Network) (*DecryptedKey, error)

KeyDecrypt decrypts a key encrypted with KeyEncrypt

type DecryptedPrivateKey

type DecryptedPrivateKey struct {
	Key      *HDPrivateKey
	Birthday int
}

type Decrypter

type Decrypter interface {
	// Decrypt a payload generated by Encrypter
	Decrypt(payload string) ([]byte, error)
}

type EKInput

type EKInput struct {
	FirstEncryptedKey  string
	FirstFingerprint   string
	SecondEncryptedKey string
	SecondFingerprint  string
}

EKInput input struct to fill the PDF

type EKOutput

type EKOutput struct {
	HTML             string
	VerificationCode string
	Metadata         string
	Version          int
}

EKOutput with the html as string and the verification code

func GenerateEmergencyKitHTML

func GenerateEmergencyKitHTML(ekParams *EKInput, language string) (*EKOutput, error)

GenerateEmergencyKitHTML returns the translated html as a string along with the verification code and the kit metadata, represented in an opaque string. After calling this method, clients should use their Chromium/WebKit implementations to render the HTML into a PDF (better done there), and then come back to call `AddEmergencyKitMetadata` and produce the final PDF (better done here).

type EncryptOperation added in v0.9.0

type EncryptOperation struct {
	// contains filtered or unexported fields
}

func NewEncryptOperation added in v0.9.0

func NewEncryptOperation(key *HDPrivateKey, payload []byte) *EncryptOperation

func (*EncryptOperation) Encrypt added in v0.9.0

func (o *EncryptOperation) Encrypt() (string, error)

type EncryptedPrivateKeyInfo

type EncryptedPrivateKeyInfo struct {
	Version      int
	Birthday     int
	EphPublicKey string
	CipherText   string
	Salt         string
}

EncryptedPrivateKeyInfo is a Gomobile-compatible version of EncryptedPrivateKey using hex-encoding.

func DecodeEncryptedPrivateKey

func DecodeEncryptedPrivateKey(encodedKey string) (*EncryptedPrivateKeyInfo, error)

type Encrypter

type Encrypter interface {
	// Encrypt the payload and return a string with the necesary information for decryption
	Encrypt(payload []byte) (string, error)
}

type FundingOutputPolicies

type FundingOutputPolicies struct {
	MaximumDebt       int64
	PotentialCollect  int64
	MaxAmountFor0Conf int64
}

type HDPrivateKey

type HDPrivateKey struct {
	Network *Network
	Path    string
	// contains filtered or unexported fields
}

HDPrivateKey is an HD capable priv key

func NewHDPrivateKey

func NewHDPrivateKey(seed []byte, network *Network) (*HDPrivateKey, error)

NewHDPrivateKey builds an HD priv key from a seed for a given network

func NewHDPrivateKeyFromBytes

func NewHDPrivateKeyFromBytes(rawKey, chainCode []byte, network *Network) (*HDPrivateKey, error)

NewHDPrivateKeyFromBytes builds an HD priv key from the compress priv and chain code for a given network

func NewHDPrivateKeyFromString

func NewHDPrivateKeyFromString(str, path string, network *Network) (*HDPrivateKey, error)

NewHDPrivateKeyFromString creates an HD priv key from a base58-encoded string If the parsed key is public, it returns an error

func (*HDPrivateKey) Decrypter

func (p *HDPrivateKey) Decrypter() Decrypter

func (*HDPrivateKey) DecrypterFrom

func (p *HDPrivateKey) DecrypterFrom(senderKey *PublicKey) Decrypter

func (*HDPrivateKey) DeriveTo

func (p *HDPrivateKey) DeriveTo(path string) (*HDPrivateKey, error)

func (*HDPrivateKey) DerivedAt

func (p *HDPrivateKey) DerivedAt(index int64, hardened bool) (*HDPrivateKey, error)

DerivedAt derives a new child priv key, which may be hardened index should be uint32 but for java compat we use int64

func (*HDPrivateKey) Encrypter

func (p *HDPrivateKey) Encrypter() Encrypter

func (*HDPrivateKey) EncrypterTo

func (p *HDPrivateKey) EncrypterTo(receiver *HDPublicKey) Encrypter

func (*HDPrivateKey) PublicKey

func (p *HDPrivateKey) PublicKey() *HDPublicKey

PublicKey returns the matching pub key

func (*HDPrivateKey) Sign

func (p *HDPrivateKey) Sign(data []byte) ([]byte, error)

Sign a payload using the backing EC key

func (*HDPrivateKey) String

func (p *HDPrivateKey) String() string

String return the key base58-encoded

type HDPublicKey

type HDPublicKey struct {
	Network *Network
	Path    string
	// contains filtered or unexported fields
}

HDPublicKey is an HD capable pub key

func NewHDPublicKeyFromString

func NewHDPublicKeyFromString(str, path string, network *Network) (*HDPublicKey, error)

NewHDPublicKeyFromString creates an HD pub key from a base58-encoded string If the parsed key is private, it returns an error

func (*HDPublicKey) DeriveTo

func (p *HDPublicKey) DeriveTo(path string) (*HDPublicKey, error)

func (*HDPublicKey) DerivedAt

func (p *HDPublicKey) DerivedAt(index int64) (*HDPublicKey, error)

DerivedAt derives a new child pub key index should be uint32 but for java compat we use int64

func (*HDPublicKey) Fingerprint

func (p *HDPublicKey) Fingerprint() []byte

Fingerprint returns the 4-byte fingerprint for this pubkey

func (*HDPublicKey) Raw

func (p *HDPublicKey) Raw() []byte

Raw returns the backing EC compressed raw key

func (*HDPublicKey) String

func (p *HDPublicKey) String() string

String return the key base58-encoded

type IncomingSwap

type IncomingSwap struct {
	Htlc             *IncomingSwapHtlc
	SphinxPacket     []byte
	PaymentHash      []byte
	PaymentAmountSat int64
	CollectSat       int64
}

func (*IncomingSwap) Fulfill added in v0.9.0

Fulfill validates and creates a fulfillment tx for the incoming swap. It returns the fullfillment tx and the preimage.

func (*IncomingSwap) FulfillFullDebt added in v0.9.0

func (s *IncomingSwap) FulfillFullDebt() (*IncomingSwapFulfillmentResult, error)

FulfillFullDebt gives the preimage matching a payment hash if we have it

func (*IncomingSwap) VerifyFulfillable added in v0.9.0

func (s *IncomingSwap) VerifyFulfillable(userKey *HDPrivateKey, net *Network) error

VerifyFulfillable checks that an incoming swap is fulfillable.

type IncomingSwapFulfillmentData added in v0.9.0

type IncomingSwapFulfillmentData struct {
	FulfillmentTx      []byte
	MuunSignature      []byte
	OutputVersion      int    // unused
	OutputPath         string // unused
	MerkleTree         []byte // unused
	HtlcBlock          []byte // unused
	BlockHeight        int64  // unused
	ConfirmationTarget int64  // to validate fee rate, unused for now
}

type IncomingSwapFulfillmentResult added in v0.9.0

type IncomingSwapFulfillmentResult struct {
	FulfillmentTx []byte
	Preimage      []byte
}

type IncomingSwapHtlc added in v0.9.0

type IncomingSwapHtlc struct {
	HtlcTx              []byte
	ExpirationHeight    int64
	SwapServerPublicKey []byte
}

type Input

type Input interface {
	OutPoint() Outpoint
	Address() MuunAddress
	UserSignature() []byte
	MuunSignature() []byte
	SubmarineSwapV1() InputSubmarineSwapV1
	SubmarineSwapV2() InputSubmarineSwapV2
	IncomingSwap() InputIncomingSwap
	MuunPublicNonce() []byte
}

type InputIncomingSwap

type InputIncomingSwap interface {
	Sphinx() []byte
	HtlcTx() []byte
	PaymentHash256() []byte
	SwapServerPublicKey() string
	ExpirationHeight() int64
	CollectInSats() int64
}

type InputList

type InputList struct {
	// contains filtered or unexported fields
}

func (*InputList) Add

func (l *InputList) Add(input Input)

func (*InputList) Inputs

func (l *InputList) Inputs() []Input

type InputSubmarineSwapV1

type InputSubmarineSwapV1 interface {
	RefundAddress() string
	PaymentHash256() []byte
	ServerPublicKey() []byte
	LockTime() int64
}

type InputSubmarineSwapV2

type InputSubmarineSwapV2 interface {
	PaymentHash256() []byte
	UserPublicKey() []byte
	MuunPublicKey() []byte
	ServerPublicKey() []byte
	BlocksForExpiration() int64
	ServerSignature() []byte
}

type IntList added in v0.9.0

type IntList struct {
	// contains filtered or unexported fields
}

func NewIntList added in v0.9.0

func NewIntList() *IntList

func (*IntList) Add added in v0.9.0

func (l *IntList) Add(number int)

func (*IntList) Contains added in v0.9.0

func (l *IntList) Contains(number int) bool

func (*IntList) Get added in v0.9.0

func (l *IntList) Get(index int) int

func (*IntList) Length added in v0.9.0

func (l *IntList) Length() int

type Invoice

type Invoice struct {
	RawInvoice      string
	FallbackAddress *MuunPaymentURI
	Network         *Network
	MilliSat        string
	Destination     []byte
	PaymentHash     []byte
	Expiry          int64
	Description     string
	Sats            int64
}

Invoice is muun's invoice struct

func ParseInvoice

func ParseInvoice(rawInput string, network *Network) (*Invoice, error)

ParseInvoice parses an Invoice from an invoice string and a network

type InvoiceBuilder added in v0.11.0

type InvoiceBuilder struct {
	// contains filtered or unexported fields
}

func (*InvoiceBuilder) AddRouteHints added in v0.11.0

func (i *InvoiceBuilder) AddRouteHints(routeHints *RouteHints) *InvoiceBuilder

func (*InvoiceBuilder) AmountMSat added in v0.11.0

func (i *InvoiceBuilder) AmountMSat(amountMSat int64) *InvoiceBuilder

func (*InvoiceBuilder) AmountSat added in v0.11.0

func (i *InvoiceBuilder) AmountSat(amountSat int64) *InvoiceBuilder

func (*InvoiceBuilder) Build added in v0.11.0

func (i *InvoiceBuilder) Build() (string, error)

func (*InvoiceBuilder) Description added in v0.11.0

func (i *InvoiceBuilder) Description(description string) *InvoiceBuilder

func (*InvoiceBuilder) Metadata added in v0.11.0

func (i *InvoiceBuilder) Metadata(metadata *OperationMetadata) *InvoiceBuilder

func (*InvoiceBuilder) Network added in v0.11.0

func (i *InvoiceBuilder) Network(net *Network) *InvoiceBuilder

func (*InvoiceBuilder) UserKey added in v0.11.0

func (i *InvoiceBuilder) UserKey(userKey *HDPrivateKey) *InvoiceBuilder

type InvoiceOptions

type InvoiceOptions struct {
	Description string
	AmountSat   int64 // deprecated
	AmountMSat  int64
	Metadata    *OperationMetadata
}

InvoiceOptions defines additional options that can be configured when creating a new invoice.

type InvoiceSecrets

type InvoiceSecrets struct {
	PaymentHash []byte
	IdentityKey *HDPublicKey
	UserHtlcKey *HDPublicKey
	MuunHtlcKey *HDPublicKey
	ShortChanId int64
	// contains filtered or unexported fields
}

InvoiceSecrets represents a bundle of secrets required to generate invoices from the client. These secrets must be registered with the remote server and persisted in the client database before use.

type InvoiceSecretsList

type InvoiceSecretsList struct {
	// contains filtered or unexported fields
}

InvoiceSecretsList is a wrapper around an InvoiceSecrets slice to be able to pass through the gomobile bridge.

func GenerateInvoiceSecrets

func GenerateInvoiceSecrets(userKey, muunKey *HDPublicKey) (*InvoiceSecretsList, error)

GenerateInvoiceSecrets returns a slice of new secrets to register with the remote server. Once registered, those invoices should be stored with the PersistInvoiceSecrets method.

func (*InvoiceSecretsList) Get

Get returns the secret at the given index.

func (*InvoiceSecretsList) Length

func (l *InvoiceSecretsList) Length() int

Length returns the number of secrets in the list.

type LNURLEvent added in v0.9.0

type LNURLEvent struct {
	Code     int
	Message  string
	Metadata *LNURLEventMetadata
}

type LNURLEventMetadata added in v0.9.0

type LNURLEventMetadata struct {
	Host    string
	Invoice string
}

type LNURLListener added in v0.9.0

type LNURLListener interface {
	OnUpdate(e *LNURLEvent)
	OnError(e *LNURLEvent)
}

type Listener

type Listener interface {
	OnDataChanged(tag string)
}

Listener is an interface implemented by the apps to receive notifications of data changes from the libwallet code. Each change is reported with a string tag identifying the type of change.

type MusigNonces added in v0.9.0

type MusigNonces struct {
	// contains filtered or unexported fields
}

func GenerateMusigNonces added in v0.9.0

func GenerateMusigNonces(count int) *MusigNonces

func (*MusigNonces) GetPubnonceHex added in v0.9.0

func (m *MusigNonces) GetPubnonceHex(index int) string

type MuunAddress

type MuunAddress interface {
	Version() int
	DerivationPath() string
	Address() string
}

func CreateAddressV1

func CreateAddressV1(publicKey *HDPublicKey) (MuunAddress, error)

CreateAddressV1 returns a P2PKH MuunAddress from a publicKey for use in TransactionSchemeV1

func CreateAddressV2

func CreateAddressV2(userKey, muunKey *HDPublicKey) (MuunAddress, error)

func CreateAddressV3

func CreateAddressV3(userKey, muunKey *HDPublicKey) (MuunAddress, error)

func CreateAddressV4

func CreateAddressV4(userKey, muunKey *HDPublicKey) (MuunAddress, error)

CreateAddressV4 returns a P2WSH MuunAddress from a user HD-pubkey and a Muun co-signing HD-pubkey.

func CreateAddressV5 added in v0.9.0

func CreateAddressV5(userKey, muunKey *HDPublicKey) (MuunAddress, error)

CreateAddressV5 returns a P2TR MuunAddress using Musig with the signing and cosigning keys.

type MuunPaymentURI

type MuunPaymentURI struct {
	Address      string
	Label        string
	Message      string
	Amount       string
	Uri          string
	Bip70Url     string
	CreationTime string
	ExpiresTime  string
	Invoice      *Invoice
}

MuunPaymentURI is muun's uri struct

func DoPaymentRequestCall

func DoPaymentRequestCall(url string, network *Network) (*MuunPaymentURI, error)

DoPaymentRequestCall builds a MuunPaymentUri from a url and a network. Handling BIP70 to 72

func GetPaymentURI

func GetPaymentURI(rawInput string, network *Network) (*MuunPaymentURI, error)

GetPaymentURI builds a MuunPaymentURI from text (Bitcoin Uri, Muun Uri or address) and a network

type Network

type Network struct {
	// contains filtered or unexported fields
}

Network has the parameters for operating in a given Bitcoin network

func Mainnet

func Mainnet() *Network

Mainnet returns an instance of the Bitcoin Main Network

func Regtest

func Regtest() *Network

Regtest returns an instance of the Bitcoin Regression Network

func Testnet

func Testnet() *Network

Testnet returns an instance of the Bitcoin Test Network

func (*Network) Name

func (n *Network) Name() string

Name returns the Network's name

func (*Network) ToParams added in v0.10.0

func (n *Network) ToParams() *chaincfg.Params

ToParams returns the chaincfg.Params associated with this network (only available via Go code)

type OperationMetadata added in v0.9.0

type OperationMetadata struct {
	Invoice     string `json:"invoice,omitempty"`
	LnurlSender string `json:"lnurlSender,omitempty"`
}

type Outpoint

type Outpoint interface {
	TxId() []byte
	Index() int
	Amount() int64
}

type Output

type Output struct {
	Amount uint64 `protobuf:"varint,1,opt,name=amount,proto3" json:"amount,omitempty"` // amount is integer-number-of-satoshis
	Script []byte `protobuf:"bytes,2,opt,name=script,proto3" json:"script,omitempty"`  // usually one of the standard Script forms
	// contains filtered or unexported fields
}

Generalized form of "send payment to this/these bitcoin addresses"

func (*Output) Descriptor deprecated

func (*Output) Descriptor() ([]byte, []int)

Deprecated: Use Output.ProtoReflect.Descriptor instead.

func (*Output) GetAmount added in v0.11.0

func (x *Output) GetAmount() uint64

func (*Output) ProtoMessage

func (*Output) ProtoMessage()

func (*Output) ProtoReflect

func (x *Output) ProtoReflect() protoreflect.Message

func (*Output) Reset

func (x *Output) Reset()

func (*Output) String

func (x *Output) String() string

type PartiallySignedTransaction

type PartiallySignedTransaction struct {
	// contains filtered or unexported fields
}

func NewPartiallySignedTransaction

func NewPartiallySignedTransaction(
	inputs *InputList, rawTx []byte, nonces *MusigNonces,
) (*PartiallySignedTransaction, error)

func (*PartiallySignedTransaction) FullySign

func (p *PartiallySignedTransaction) FullySign(userKey, muunKey *HDPrivateKey) (*Transaction, error)

func (*PartiallySignedTransaction) Sign

func (p *PartiallySignedTransaction) Sign(userKey *HDPrivateKey, muunKey *HDPublicKey) (*Transaction, error)

func (*PartiallySignedTransaction) Verify

func (p *PartiallySignedTransaction) Verify(expectations *SigningExpectations, userPublicKey *HDPublicKey, muunPublickKey *HDPublicKey) error

type Payment

type Payment struct {
	MerchantData []byte    `protobuf:"bytes,1,opt,name=merchant_data,json=merchantData,proto3" json:"merchant_data,omitempty"` // From PaymentDetails.merchant_data
	Transactions [][]byte  `protobuf:"bytes,2,rep,name=transactions,proto3" json:"transactions,omitempty"`                     // Signed transactions that satisfy PaymentDetails.outputs
	RefundTo     []*Output `protobuf:"bytes,3,rep,name=refund_to,json=refundTo,proto3" json:"refund_to,omitempty"`             // Where to send refunds, if a refund is necessary
	Memo         string    `protobuf:"bytes,4,opt,name=memo,proto3" json:"memo,omitempty"`                                     // Human-readable message for the merchant
	// contains filtered or unexported fields
}

func (*Payment) Descriptor deprecated

func (*Payment) Descriptor() ([]byte, []int)

Deprecated: Use Payment.ProtoReflect.Descriptor instead.

func (*Payment) GetRefundTo added in v0.11.0

func (x *Payment) GetRefundTo() []*Output

func (*Payment) GetTransactions added in v0.11.0

func (x *Payment) GetTransactions() [][]byte

func (*Payment) ProtoMessage

func (*Payment) ProtoMessage()

func (*Payment) ProtoReflect

func (x *Payment) ProtoReflect() protoreflect.Message

func (*Payment) Reset

func (x *Payment) Reset()

func (*Payment) String

func (x *Payment) String() string

type PaymentACK

type PaymentACK struct {
	Payment *Payment `protobuf:"bytes,1,opt,name=payment,proto3" json:"payment,omitempty"` // Payment message that triggered this ACK
	Memo    string   `protobuf:"bytes,2,opt,name=memo,proto3" json:"memo,omitempty"`       // human-readable message for customer
	// contains filtered or unexported fields
}

func (*PaymentACK) Descriptor deprecated

func (*PaymentACK) Descriptor() ([]byte, []int)

Deprecated: Use PaymentACK.ProtoReflect.Descriptor instead.

func (*PaymentACK) ProtoMessage

func (*PaymentACK) ProtoMessage()

func (*PaymentACK) ProtoReflect

func (x *PaymentACK) ProtoReflect() protoreflect.Message

func (*PaymentACK) Reset

func (x *PaymentACK) Reset()

func (*PaymentACK) String

func (x *PaymentACK) String() string

type PaymentDetails

type PaymentDetails struct {
	Network      string    `protobuf:"bytes,1,opt,name=network,proto3" json:"network,omitempty"`                               // "main" or "test"
	Outputs      []*Output `protobuf:"bytes,2,rep,name=outputs,proto3" json:"outputs,omitempty"`                               // Where payment should be sent
	Time         uint64    `protobuf:"varint,3,opt,name=time,proto3" json:"time,omitempty"`                                    // Timestamp; when payment request created
	Expires      uint64    `protobuf:"varint,4,opt,name=expires,proto3" json:"expires,omitempty"`                              // Timestamp; when this request should be considered invalid
	Memo         string    `protobuf:"bytes,5,opt,name=memo,proto3" json:"memo,omitempty"`                                     // Human-readable description of request for the customer
	PaymentUrl   string    `protobuf:"bytes,6,opt,name=payment_url,json=paymentUrl,proto3" json:"payment_url,omitempty"`       // URL to send Payment and get PaymentACK
	MerchantData []byte    `protobuf:"bytes,7,opt,name=merchant_data,json=merchantData,proto3" json:"merchant_data,omitempty"` // Arbitrary data to include in the Payment message
	// contains filtered or unexported fields
}

func (*PaymentDetails) Descriptor deprecated

func (*PaymentDetails) Descriptor() ([]byte, []int)

Deprecated: Use PaymentDetails.ProtoReflect.Descriptor instead.

func (*PaymentDetails) GetExpires added in v0.11.0

func (x *PaymentDetails) GetExpires() uint64

func (*PaymentDetails) GetOutputs added in v0.11.0

func (x *PaymentDetails) GetOutputs() []*Output

func (*PaymentDetails) GetTime added in v0.11.0

func (x *PaymentDetails) GetTime() uint64

func (*PaymentDetails) ProtoMessage

func (*PaymentDetails) ProtoMessage()

func (*PaymentDetails) ProtoReflect

func (x *PaymentDetails) ProtoReflect() protoreflect.Message

func (*PaymentDetails) Reset

func (x *PaymentDetails) Reset()

func (*PaymentDetails) String

func (x *PaymentDetails) String() string

type PaymentRequest

type PaymentRequest struct {
	PaymentDetailsVersion    uint32 ``                                                                                   /* 127-byte string literal not displayed */
	PkiType                  string `protobuf:"bytes,2,opt,name=pki_type,json=pkiType,proto3" json:"pki_type,omitempty"` // none / x509+sha256 / x509+sha1
	PkiData                  []byte `protobuf:"bytes,3,opt,name=pki_data,json=pkiData,proto3" json:"pki_data,omitempty"` // depends on pki_type
	SerializedPaymentDetails []byte ``                                                                                   // PaymentDetails
	/* 135-byte string literal not displayed */
	Signature []byte `protobuf:"bytes,5,opt,name=signature,proto3" json:"signature,omitempty"` // pki-dependent signature
	// contains filtered or unexported fields
}

func (*PaymentRequest) Descriptor deprecated

func (*PaymentRequest) Descriptor() ([]byte, []int)

Deprecated: Use PaymentRequest.ProtoReflect.Descriptor instead.

func (*PaymentRequest) GetPaymentDetailsVersion added in v0.11.0

func (x *PaymentRequest) GetPaymentDetailsVersion() uint32

func (*PaymentRequest) ProtoMessage

func (*PaymentRequest) ProtoMessage()

func (*PaymentRequest) ProtoReflect

func (x *PaymentRequest) ProtoReflect() protoreflect.Message

func (*PaymentRequest) Reset

func (x *PaymentRequest) Reset()

func (*PaymentRequest) String

func (x *PaymentRequest) String() string

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

func NewPublicKeyFromBytes

func NewPublicKeyFromBytes(bytes []byte) (*PublicKey, error)

type RouteHints

type RouteHints struct {
	Pubkey                    string
	FeeBaseMsat               int64
	FeeProportionalMillionths int64
	CltvExpiryDelta           int32
}

RouteHints is a struct returned by the remote server containing the data necessary for constructing an invoice locally.

type SigningExpectations

type SigningExpectations struct {
	// contains filtered or unexported fields
}

func NewSigningExpectations

func NewSigningExpectations(destination string, amount int64, change MuunAddress, fee int64) *SigningExpectations

type StringList added in v0.9.0

type StringList struct {
	// contains filtered or unexported fields
}

func NewStringList added in v0.9.0

func NewStringList() *StringList

func NewStringListWithElements added in v0.10.0

func NewStringListWithElements(elems []string) *StringList

func (*StringList) Add added in v0.9.0

func (l *StringList) Add(s string)

func (*StringList) Contains added in v0.9.0

func (l *StringList) Contains(s string) bool

func (*StringList) Get added in v0.9.0

func (l *StringList) Get(index int) string

func (*StringList) Length added in v0.9.0

func (l *StringList) Length() int

type SubmarineSwap

type SubmarineSwap interface {
	Invoice() string
	Receiver() SubmarineSwapReceiver
	FundingOutput() SubmarineSwapFundingOutput

	PreimageInHex() string
}

type SubmarineSwapFundingOutput

type SubmarineSwapFundingOutput interface {
	ScriptVersion() int64

	OutputAddress() string
	OutputAmount() int64
	ConfirmationsNeeded() int
	ServerPaymentHashInHex() string
	ServerPublicKeyInHex() string

	UserLockTime() int64

	// v1 only
	UserRefundAddress() MuunAddress

	// v2 only
	ExpirationInBlocks() int64
	UserPublicKey() *HDPublicKey
	MuunPublicKey() *HDPublicKey
}

type SubmarineSwapReceiver

type SubmarineSwapReceiver interface {
	Alias() string
	PublicKey() string
}

type SwapFees

type SwapFees struct {
	RoutingFee          int64
	SweepFee            int64 // TODO: this should be called outputPadding, keeping name for retrocompat for now
	DebtType            string
	DebtAmount          int64
	ConfirmationsNeeded int64
}

func ComputeSwapFees

func ComputeSwapFees(amount int64, bestRouteFees *BestRouteFeesList, policies *FundingOutputPolicies) *SwapFees

type Transaction

type Transaction struct {
	Hash  string
	Bytes []byte
}

type UserActivatedFeature added in v0.9.0

type UserActivatedFeature interface {
	Blockheight(*Network) int
	RequiredKitVersion() int
	BackendFeature() string
	BackendPreactivationFeature() string
}
var UserActivatedFeatureTaproot UserActivatedFeature = &taprootUserActivatedFeature{}

type X509Certificates

type X509Certificates struct {
	Certificate [][]byte `protobuf:"bytes,1,rep,name=certificate,proto3" json:"certificate,omitempty"` // DER-encoded X.509 certificate chain
	// contains filtered or unexported fields
}

func (*X509Certificates) Descriptor deprecated

func (*X509Certificates) Descriptor() ([]byte, []int)

Deprecated: Use X509Certificates.ProtoReflect.Descriptor instead.

func (*X509Certificates) GetCertificate added in v0.11.0

func (x *X509Certificates) GetCertificate() [][]byte

func (*X509Certificates) ProtoMessage

func (*X509Certificates) ProtoMessage()

func (*X509Certificates) ProtoReflect

func (x *X509Certificates) ProtoReflect() protoreflect.Message

func (*X509Certificates) Reset

func (x *X509Certificates) Reset()

func (*X509Certificates) String

func (x *X509Certificates) String() string

Jump to

Keyboard shortcuts

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