payments

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: Unlicense Imports: 3 Imported by: 0

Documentation

Overview

Package payments provides an abstraction above the implementation for handling Lightning Network payments and storing pending payments awaiting session keys.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PayChan added in v0.1.16

type PayChan chan *Payment

PayChan is a channel for sending and receiving payments between the LN interface and the Engine.

func (PayChan) Receive added in v0.1.16

func (pc PayChan) Receive() <-chan *Payment

Receive waits on receiving a Payment on a PayChan.

func (PayChan) Send added in v0.1.16

func (pc PayChan) Send(amount lnwire.MilliSatoshi,
	id nonce.ID, preimage sha256.Hash) (confirmChan chan bool)

Send a payment on the PayChan.

type Payment

type Payment struct {

	// ID is the unique identifier that will be used internally also for the session
	// when the session onion arrives.
	ID nonce.ID

	// Preimage is the hash of the pair of secret keys that proves a session key set
	// should be tied to the provided secret keys for decrypting onions for this
	// session.
	Preimage sha256.Hash

	// Amount in millisatoshi that have been received over LN.
	Amount lnwire.MilliSatoshi

	// ConfirmChan signals from the LN server to the Engine that the payment is
	// complete, and if available the session can now be spent from.
	ConfirmChan chan bool
}

Payment is the essential details of a payment and the method to wait for full confirmation.

type PendingPayments

type PendingPayments []*Payment

PendingPayments is a slice of Payments used to store the queue of payments awaiting sessions.

func (PendingPayments) Add

func (p PendingPayments) Add(np *Payment) (pp PendingPayments)

Add a new payment to the PendingPayments and return the mutated slice.

func (PendingPayments) Delete

func (p PendingPayments) Delete(preimage sha256.Hash) (pp PendingPayments)

Delete a pending payment and return the mutated slice with the item matching the preimage removed.

func (PendingPayments) Find

func (p PendingPayments) Find(id nonce.ID) (pp *Payment)

Find the pending payment with the matching nonce.ID (internal reference).

func (PendingPayments) FindPreimage

func (p PendingPayments) FindPreimage(pi sha256.Hash) (pp *Payment)

FindPreimage searches for a match for the preimage hash, as would be needed after receiving the preimage in the payment the session's keys derive the preimage for this search.

Jump to

Keyboard shortcuts

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