server

package
v0.0.0-...-686de45 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2025 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeadlineContext = time.Second * 30
)

Variables

View Source
var (
	ALLOW_LOCAL_HOST = false

	CryptoDeadline        = time.Minute * 30
	MinForward            = types.Config.Forwarder.MinForward                             // Minimum amount to forward in SOL
	TransactionThreshold  = big.NewFloat(1 - types.Config.Forwarder.TransactionThreshold) // Threshold for transaction values
	IgnoreIotaTxThreshold = big.NewFloat(0.02)                                            // If the amount is 2% or less, ignore the transaction. This is to ignore bots.
)

Functions

func ParseJSON

func ParseJSON(r *http.Request, v interface{}) error

func SendJSON

func SendJSON(w http.ResponseWriter, v interface{})

func SendWebhook

func SendWebhook(uri string, v interface{})

Types

type Client

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

func NewClient

func NewClient(ctx context.Context) *Client

func (*Client) Close

func (c *Client) Close(ctx context.Context)

func (*Client) CreatePayment

func (c *Client) CreatePayment(w http.ResponseWriter, r *http.Request)

func (*Client) ForwardFunds

func (c *Client) ForwardFunds(ctx context.Context, pr *PaymentCreateResponse) error

func (*Client) HandleCreatePayment

func (c *Client) HandleCreatePayment(w http.ResponseWriter, r *http.Request, b *PaymentCreateBody)

func (*Client) HandleWebhookCall

func (c *Client) HandleWebhookCall(ctx context.Context, b *PaymentCreateBody, r *ws.LogResult, pr *PaymentCreateResponse) bool

func (*Client) Listen

func (c *Client) Listen()

func (Client) UpgradeWS

func (c Client) UpgradeWS(w http.ResponseWriter, r *http.Request) (*websocket.Conn, error)

UpgradeWS upgrades the connection to a websocket and runs KeepAlive operations

type PaymentCreateBody

type PaymentCreateBody struct {
	Amount      float64 `json:"amount"`
	CallbackURI string  `json:"callback_uri"`
}

type PaymentCreateResponse

type PaymentCreateResponse struct {
	Success bool    `json:"success"`
	ID      string  `json:"id"`
	Amount  float64 `json:"amount"`
	Address string  `json:"address"`
	QRCode  string  `json:"qrcode"`
	Expires uint64  `json:"expires"`
}

type WebhookResponse

type WebhookResponse struct {
	Success        bool    `json:"success" bson:"success"`
	ID             string  `json:"id" bson:"id"`
	Error          any     `json:"error" bson:"error"`
	DesiredAmount  float64 `json:"desired_amount" bson:"desired_amount"`
	AmountSent     float64 `json:"amount_sent" bson:"amount_sent"`
	TransactionID  string  `json:"transaction_id" bson:"transaction_id"`
	Address        string  `json:"address" bson:"address"`
	TimeSent       uint64  `json:"time_sent" bson:"time_sent"`
	PercentOfTotal float64 `json:"percent_of_total" bson:"percent_of_total"`
}

Jump to

Keyboard shortcuts

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