db

package
v0.0.0-...-ddb1edc Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//SentPayment is type for sent payments
	SentPayment = PaymentType(0)

	//ReceivedPayment is type for received payments
	ReceivedPayment = PaymentType(1)

	//DepositPayment is type for payment got from add funds
	DepositPayment = PaymentType(2)

	//WithdrawalPayment is type for payment got from remove funds
	WithdrawalPayment = PaymentType(3)

	//ClosedChannelPayment is type for payment got from a closed channel
	ClosedChannelPayment = PaymentType(4)

	WaitingClose   = ChannelCloseStatus(0)
	PendingClose   = ChannelCloseStatus(1)
	ConfirmedClose = ChannelCloseStatus(2)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelCloseStatus

type ChannelCloseStatus byte

type DB

type DB struct {
	*bolt.DB
	// contains filtered or unexported fields
}

DB is the structure for breez database

func Get

func Get(workingDir string) (db *DB, cleanupFn func() error, err error)

Get returns a Ch

func (*DB) AccountEnabled

func (db *DB) AccountEnabled() (bool, error)

AccountEnabled returns the account state

func (*DB) AddAccountPayment

func (db *DB) AddAccountPayment(accPayment *PaymentInfo, receivedIndex uint64, sentTime uint64) (bool, error)

AddAccountPayment adds a payment to the database

func (*DB) AddChannelClosedPayment

func (db *DB) AddChannelClosedPayment(accPayment *PaymentInfo) error

AddChannelClosedPayment adds a payment that reflects channel close to the db.

func (*DB) AddRedeemablePaymentHash

func (db *DB) AddRedeemablePaymentHash(hash string) error

func (*DB) AddZeroConfHash

func (db *DB) AddZeroConfHash(hash []byte, payreq []byte) error

AddZeroConfHash saves a zero conf hash to track.

func (*DB) BackupDb

func (db *DB) BackupDb(dir string) (string, error)

func (*DB) DeleteDB

func (db *DB) DeleteDB() error

DeleteDB deletes the database, mainly for testing

func (*DB) EnableAccount

func (db *DB) EnableAccount(enabled bool) error

EnableAccount sets the account state to either enabled or disabled

func (*DB) FetchAccount

func (db *DB) FetchAccount() ([]byte, error)

FetchAccount fetches the cached account info from the database

func (*DB) FetchAllAccountPayments

func (db *DB) FetchAllAccountPayments() ([]*PaymentInfo, error)

FetchAllAccountPayments fetches all payments in the database sorted by date

func (*DB) FetchAllLNUrlPayInfos

func (db *DB) FetchAllLNUrlPayInfos() ([]*data.LNUrlPayInfo, error)

func (*DB) FetchAllSwapAddresses

func (db *DB) FetchAllSwapAddresses() ([]*SwapAddressInfo, error)

Swap addresses

func (*DB) FetchLNURLAuthKey

func (db *DB) FetchLNURLAuthKey(createNew func() ([]byte, error)) ([]byte, error)

FetchLNURLAuthKey fetches the bip32 master key for lnurl auth.

func (*DB) FetchLNUrlPayInfo

func (db *DB) FetchLNUrlPayInfo(paymentHash string) (*data.LNUrlPayInfo, error)

func (*DB) FetchLastSyncedHeaderTimestamp

func (db *DB) FetchLastSyncedHeaderTimestamp() (int64, error)

FetchLastSyncedHeaderTimestamp the last known header timestamp that the node is synced to.

func (*DB) FetchMismatchedChannels

func (db *DB) FetchMismatchedChannels() (*MismatchedChannels, error)

func (*DB) FetchNostrPrivKey

func (db *DB) FetchNostrPrivKey(createNew func() string) (string, error)

FetchNostrPubKey fetches the nostrPrivatekey for nostr auth.

func (*DB) FetchPaymentGroup

func (db *DB) FetchPaymentGroup(payReqHash string) ([]byte, []byte, error)

FetchPaymentGroup fetches a a tip message related to payment hash

func (*DB) FetchPaymentRequest

func (db *DB) FetchPaymentRequest(payReqHash string) ([]byte, error)

FetchPaymentRequest fetches a payment request by a payment hash

func (*DB) FetchPaymentsSyncInfo

func (db *DB) FetchPaymentsSyncInfo() (lastTime int64, lastSetteledIndex uint64)

FetchPaymentsSyncInfo returns the last payment time and last invoice settled index. This is used for callers to understand when needs to be synchronized into the db

func (*DB) FetchRedeemablePaymentHashes

func (db *DB) FetchRedeemablePaymentHashes() ([]string, error)

func (*DB) FetchReverseSwap

func (db *DB) FetchReverseSwap(hash string) (*data.ReverseSwap, error)

FetchReverseSwap fetches the reverse swap information

func (*DB) FetchSwapAddresses

func (db *DB) FetchSwapAddresses(filterFunc func(addr *SwapAddressInfo) bool) ([]*SwapAddressInfo, error)

func (*DB) FetchTipMessage

func (db *DB) FetchTipMessage(payReqHash string) ([]byte, error)

FetchTipMessage fetches a a tip message related to payment hash

func (*DB) FetchUnconfirmedClaimTransaction

func (db *DB) FetchUnconfirmedClaimTransaction() (*chainrpc.ConfRequest, error)

FetchUnconfirmedClaimTransaction returns the current unconfirmed claim transaction, or nil if there is no unconfimed claim transaction.

func (*DB) FetchUnspendLockupInformation

func (db *DB) FetchUnspendLockupInformation() (*data.UnspendLockupInformation, error)

FetchUnspendLockupInformation returns the current unconfirmed claim transaction, or nil if there is no unconfimed claim transaction.

func (*DB) FetchZeroConfHashes

func (db *DB) FetchZeroConfHashes() ([][]byte, error)

FetchZeroConfHashes fetches all zero conf hashes to track

func (*DB) FetchZeroConfInvoice

func (db *DB) FetchZeroConfInvoice(hash []byte) ([]byte, error)

FetchZeroConfInvoice fetches a zero conf invoice.

func (*DB) GetPeers

func (db *DB) GetPeers(defaults []string) (peers []string, isDefault bool, err error)

func (*DB) GetTorActive

func (db *DB) GetTorActive() (result bool, err error)

func (*DB) GetTxSpentURL

func (db *DB) GetTxSpentURL(defaultURL string) (txSpentURL string, isDefault bool, err error)

func (*DB) IsInvoiceHashPaid

func (db *DB) IsInvoiceHashPaid(payReqHash string) (bool, error)

IsInvoiceHashPaid returns true if the payReqHash was paid by this client.

func (*DB) MigrateAllLNUrlPayMetadata

func (db *DB) MigrateAllLNUrlPayMetadata() error

func (*DB) RemoveChannelMismatch

func (db *DB) RemoveChannelMismatch() error

func (*DB) RemoveZeroConfHash

func (db *DB) RemoveZeroConfHash(hash []byte) error

RemoveZeroConfHash removes a zero conf hash from tracking.

func (*DB) SaveAccount

func (db *DB) SaveAccount(account []byte) error

SaveAccount saves an account information to the database

func (*DB) SaveLNUrlPayInfo

func (db *DB) SaveLNUrlPayInfo(info *data.LNUrlPayInfo) error

func (*DB) SavePaymentGroup

func (db *DB) SavePaymentGroup(payReqHash string, groupKey, groupName []byte) error

SavePaymentGroup saves a tip message related to payment hash into the database

func (*DB) SavePaymentRequest

func (db *DB) SavePaymentRequest(payReqHash string, payReq []byte) error

SavePaymentRequest saves a payment request into the database

func (*DB) SaveReverseSwap

func (db *DB) SaveReverseSwap(rs *data.ReverseSwap) (string, error)

SaveReverseSwap saves the reverse swap information

func (*DB) SaveSwapAddressInfo

func (db *DB) SaveSwapAddressInfo(address *SwapAddressInfo) error

func (*DB) SaveTipMessage

func (db *DB) SaveTipMessage(payReqHash string, message []byte) error

SaveTipMessage saves a tip message related to payment hash into the database

func (*DB) SaveUnconfirmedClaimTransaction

func (db *DB) SaveUnconfirmedClaimTransaction(confRequest *chainrpc.ConfRequest) error

SaveUnconfirmedClaimTransaction saves the unconfirmed claim transaction set confRequest to nil when the transaction is confirmed

func (*DB) SaveUnspendLockupInformation

func (db *DB) SaveUnspendLockupInformation(unspendLockupTransaction *data.UnspendLockupInformation) error

SaveUnspendLockupInformation saves the unconfirmed claim transaction set unspendLockupTransaction to nil when the transaction is confirmed

func (*DB) SetLastSyncedHeaderTimestamp

func (db *DB) SetLastSyncedHeaderTimestamp(ts int64) error

SetLastSyncedHeaderTimestamp saves the last known header timestamp that the node is synced to.

func (*DB) SetMismatchedChannels

func (db *DB) SetMismatchedChannels(mismatched *MismatchedChannels) error

func (*DB) SetPeers

func (db *DB) SetPeers(peers []string) error

func (*DB) SetTorActive

func (db *DB) SetTorActive(active bool) error

func (*DB) SetTxSpentURL

func (db *DB) SetTxSpentURL(txSpentURL string) error

func (*DB) UpdateRedeemTxForPayment

func (db *DB) UpdateRedeemTxForPayment(hash string, txID string) error

func (*DB) UpdateSwapAddress

func (db *DB) UpdateSwapAddress(address string, updateFunc func(*SwapAddressInfo) error) (bool, error)

func (*DB) UpdateSwapAddressByPaymentHash

func (db *DB) UpdateSwapAddressByPaymentHash(pHash []byte, updateFunc func(*SwapAddressInfo) error) (bool, error)

type MismatchedChannel

type MismatchedChannel struct {
	ChanPoint   string
	ShortChanID uint64
}

type MismatchedChannels

type MismatchedChannels struct {
	LSPPubkey  string
	ChanPoints []MismatchedChannel
}

type PaymentInfo

type PaymentInfo struct {
	Type                       PaymentType
	Amount                     int64
	Fee                        int64
	CreationTimestamp          int64
	Description                string
	PayeeName                  string
	PayeeImageURL              string
	PayerName                  string
	PayerImageURL              string
	TransferRequest            bool
	PaymentHash                string
	RedeemTxID                 string
	Destination                string
	PendingExpirationHeight    uint32
	PendingExpirationTimestamp int64
	PendingFull                bool
	Preimage                   string
	IsKeySend                  bool
	GroupKey                   string
	GroupName                  string

	//For closed channels
	ClosedChannelPoint      string
	ClosedChannelStatus     ChannelCloseStatus
	ClosedChannelTxID       string
	ClosedChannelRemoteTxID string
	ClosedChannelSweepTxID  string
}

PaymentInfo is the structure that holds the data for a payment in breez

type PaymentType

type PaymentType byte

PaymentType is the type of payment

type SwapAddressInfo

type SwapAddressInfo struct {
	LspID            string
	PaymentRequest   string
	Address          string
	CreatedTimestamp int64

	// Opening fee params
	MinMsat              uint64
	Proportional         uint32
	ValidUntil           string
	MaxIdleTime          uint32
	MaxClientToSelfDelay uint32
	Promise              string

	//client side data
	PaymentHash []byte
	Preimage    []byte
	PrivateKey  []byte
	PublicKey   []byte

	//tracked data
	ConfirmedTransactionIds []string
	ConfirmedAmount         int64
	InvoicedAmount          int64
	PaidAmount              int64
	LockHeight              uint32
	FundingTxID             string

	//address script
	Script []byte

	ErrorMessage    string
	SwapErrorReason int32
	EnteredMempool  bool

	//refund
	LastRefundTxID string
	NonBlocking    bool
}

SwapAddressInfo contains all the infromation regarding a submarine swap address.

func (*SwapAddressInfo) Confirmed

func (s *SwapAddressInfo) Confirmed() bool

Confirmed returns true if the transaction has confirmed in the past.

Jump to

Keyboard shortcuts

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