payment

package
v0.0.0-...-e9c30ff Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Amount

type Amount struct {
	*big.Int
}

func NewAmount

func NewAmount(numbersToAdd ...*big.Int) Amount

func NewAmountFromAPIString

func NewAmountFromAPIString(s string) (Amount, error)

func NewAmountFromDecimal

func NewAmountFromDecimal(d decimal.Decimal) Amount

func (Amount) Decimal

func (a Amount) Decimal() decimal.Decimal

func (Amount) SerializeForAPI

func (a Amount) SerializeForAPI() string

type MulticurrencyPaymentData

type MulticurrencyPaymentData struct {
	Currency        nanswapclient.Ticker
	PaymentAddress  string
	ExpectedAmounts []Amount
	OrderID         string
}

type PaymentAccountPool

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

func New

func New(log *log.Logger, statsClient *statsd.Client, w *wallet.Wallet, repAddress string, modLogWebhook api.WebhookClient,
	dustThreshold Amount, defaultCollectorAccountAddress string, nanswapClient *nanswapclient.Client) *PaymentAccountPool

func (*PaymentAccountPool) AwaitConclusionOfInFlightPayments

func (p *PaymentAccountPool) AwaitConclusionOfInFlightPayments(collectorAccount string)

func (*PaymentAccountPool) DefaultCollectorAccountAddress

func (p *PaymentAccountPool) DefaultCollectorAccountAddress() string

func (*PaymentAccountPool) ReceiveMulticurrencyPayment

func (p *PaymentAccountPool) ReceiveMulticurrencyPayment(ctx context.Context, expectedAmounts []Amount, extraCurrencies []nanswapclient.Ticker, swapTimeout time.Duration) (PaymentReceiver, error)

func (*PaymentAccountPool) ReceivePayment

func (p *PaymentAccountPool) ReceivePayment() (PaymentReceiver, error)

func (*PaymentAccountPool) ReceivePaymentIntoCollectorAccount

func (p *PaymentAccountPool) ReceivePaymentIntoCollectorAccount(collectorAccountAddress string) (PaymentReceiver, error)

func (*PaymentAccountPool) RequestAccount

func (p *PaymentAccountPool) RequestAccount() (*wallet.Account, error)

func (*PaymentAccountPool) ReturnAccount

func (p *PaymentAccountPool) ReturnAccount(account *wallet.Account)

func (*PaymentAccountPool) SetMulticurrencyPaymentsEnabled

func (p *PaymentAccountPool) SetMulticurrencyPaymentsEnabled(enabled bool)

func (*PaymentAccountPool) Worker

func (p *PaymentAccountPool) Worker(ctx context.Context, interval time.Duration) error

type PaymentReceivedEventArgs

type PaymentReceivedEventArgs struct {
	Amount         Amount
	SenderAmount   Amount // the amount as "seen" by the sender in SenderCurrency units, before swap/conversion
	SenderCurrency nanswapclient.Ticker
	From           string
	Balance        Amount
	BlockHash      string
}

PaymentReceivedEventArgs contains the data associated with the event that is fired when a payment is received

type PaymentReceiver

type PaymentReceiver interface {
	Address() string
	MulticurrencyPaymentData() []MulticurrencyPaymentData
	PaymentReceived() event.Event[PaymentReceivedEventArgs]
	MulticurrencyPaymentDataAvailable() event.Event[[]MulticurrencyPaymentData]

	// ReceivableBalance may block for a significant amount of time when receiving multicurrency payments
	// (refactor the Nanswap order fetching code in processPaymentsToAccount to fix this)
	ReceivableBalance() Amount

	// Revert should be called when one wants to return anything that was received.
	// Does not terminate the payment flow (to do so, call Close)
	Revert(refundAddress string) error

	// Close must be called to terminate the payment flow, asynchronously sending the funds in the payment account to the collector account for this flow.
	// It returns a channel that closes when the funds are done being sent to the collector account
	Close() <-chan struct{}
}

PaymentReceiver represents a payment flow (one monitored account)

Jump to

Keyboard shortcuts

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