plisio

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 14 Imported by: 0

README

plisio-go

A zero-dependency, idiomatic Go client for the Plisio cryptocurrency payment gateway API.

Install

go get github.com/obeliskdev/plisio-go

Quick start

package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/obeliskdev/plisio-go"
)

func main() {
	client := plisio.NewClient(os.Getenv("PLISIO_KEY")) // your SECRET_KEY

	inv, err := client.CreateInvoice(context.Background(),
		plisio.WithOrderName("order-1"),
		plisio.WithOrderNumber(1001),
		plisio.WithSourceAmount(20, plisio.USD), // 20 USD, converted to crypto
		plisio.WithAllowedCurrencies(plisio.BTC, plisio.ETH, plisio.USDT_TRX),
		plisio.WithCallbackURL("https://example.com/plisio/callback?json=true"),
		plisio.WithExpireMin(30),
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println("Pay at:", inv.InvoiceURL)
}
Handling callbacks

Append ?json=true to your callback URL, then validate and parse each POST:

func handler(w http.ResponseWriter, r *http.Request) {
	body, _ := io.ReadAll(r.Body)
	cb, err := client.ParseCallback(body)
	if err != nil {
		http.Error(w, "invalid", http.StatusUnprocessableEntity)
		return
	}
	if cb.Status == plisio.StatusCompleted {
		// fulfill the order for cb.OrderNumber
	}
	w.WriteHeader(http.StatusOK)
}
Amounts and numbers

Plisio does not guarantee a consistent JSON type for monetary fields, so every amount/rate is returned as plisio.Number:

f, _ := cb.Amount.Float64() // as float
s := cb.Amount.String()     // exact text, no precision loss
if cb.Amount.IsNull() { ... }

Endpoints

Method Description
GetBalance Cryptocurrency balance
GetCurrencies Supported cryptocurrencies
CreateInvoice Create a payment invoice
GetCommission Estimate commission + network fee
Withdraw Send crypto (single or mass cash-out)
GetFee Estimate network fee
GetFeePlan Available fee plans
GetOperations List transactions (paginated, filterable)
GetOperation Transaction details
ValidateCallback / ParseCallback Verify webhook signatures

License

MIT

Documentation

Overview

Package plisio is a Go client for the Plisio cryptocurrency payment gateway API (https://plisio.net).

Create a Client with your Plisio SECRET_KEY, then call endpoint methods. All methods take a context.Context and return the unwrapped data payload. Monetary values are returned as Number, which safely handles Plisio's inconsistent JSON typing (string, float, int, or null) without losing precision.

client := plisio.NewClient(os.Getenv("PLISIO_KEY"))
inv, err := client.CreateInvoice(ctx,
	plisio.WithOrderName("order-1"),
	plisio.WithOrderNumber(1001),
	plisio.WithAmount(0.5),
)

To receive invoice updates, point Plisio at a callback URL with "?json=true" appended and validate each POST with Client.ParseCallback.

Example
package main

import (
	"fmt"

	"github.com/obeliskdev/plisio-go"
)

func main() {
	c := plisio.NewClient("SECRET_KEY")
	_ = c
	fmt.Println("client created")
}
Output:
client created

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrInvalidCallback = errors.New("plisio: invalid callback verify_hash")

ErrInvalidCallback is returned by ParseCallback when the verify_hash does not match, meaning the payload did not come from Plisio or was tampered with.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	HTTPStatus int    // HTTP status code (e.g. 400, 401, 422, 500)
	Name       string // data.name, e.g. "Bad Request"
	Message    string // data.message, human-readable explanation
	Code       int    // data.code, Plisio's internal error code
}

APIError is an error returned by the Plisio API. It captures the error envelope's fields plus the HTTP status code of the response.

func (*APIError) Error

func (e *APIError) Error() string

type Balance

type Balance struct {
	Currency      CryptoCurrency `json:"psys_cid"`
	Balance       Number         `json:"balance"`
	LockedBalance Number         `json:"lockedBalance"`
}

Balance is the balance of a single cryptocurrency in your Plisio account.

type Callback

type Callback struct {
	TxnID           string          `json:"txn_id"`
	Status          OperationStatus `json:"status"`
	Amount          Number          `json:"amount"`
	Currency        string          `json:"currency"`
	OrderNumber     string          `json:"order_number"`
	OrderName       string          `json:"order_name"`
	Confirmations   Number          `json:"confirmations"`
	SourceCurrency  string          `json:"source_currency"`
	SourceAmount    Number          `json:"source_amount"`
	InvoiceTotalSum Number          `json:"invoice_total_sum"`
	VerifyHash      string          `json:"verify_hash"`
}

Callback is the decoded invoice-update callback Plisio POSTs to your callback URL. Only the commonly-used fields are typed; Amount is Number.

type Client

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

Client is a Plisio API client. Create one with NewClient. It is safe for concurrent use.

func NewClient

func NewClient(apiKey string, opts ...ClientOption) *Client

NewClient returns a Client authenticated with apiKey (your Plisio SECRET_KEY). Behaviour can be customized with ClientOptions.

func (*Client) CreateInvoice

func (c *Client) CreateInvoice(ctx context.Context, opts ...InvoiceOption) (*Invoice, error)

CreateInvoice creates a new payment invoice.

Example
package main

import (
	"context"
	"fmt"

	"github.com/obeliskdev/plisio-go"
)

func main() {
	c := plisio.NewClient("SECRET_KEY")
	inv, err := c.CreateInvoice(context.Background(),
		plisio.WithOrderName("order-1"),
		plisio.WithOrderNumber(1001),
		plisio.WithSourceAmount(20, plisio.USD),
		plisio.WithAllowedCurrencies(plisio.BTC, plisio.ETH, plisio.USDT_TRX),
		plisio.WithCallbackURL("https://example.com/plisio/callback?json=true"),
		plisio.WithExpireMin(30),
	)
	if err != nil {
		// handle *plisio.APIError
		return
	}
	fmt.Println(inv.InvoiceURL)
}

func (*Client) GetBalance

func (c *Client) GetBalance(ctx context.Context, currency CryptoCurrency) (*Balance, error)

GetBalance returns the balance for the given cryptocurrency.

func (*Client) GetCommission

func (c *Client) GetCommission(ctx context.Context, currency CryptoCurrency, opts ...CommissionOption) (*Commission, error)

GetCommission estimates the Plisio commission and network fee.

func (*Client) GetCurrencies

func (c *Client) GetCurrencies(ctx context.Context, fiat ...FiatCurrency) ([]Currency, error)

GetCurrencies lists supported cryptocurrencies. If a fiat currency is given, rates are returned relative to it; otherwise USD is used.

func (*Client) GetFee

func (c *Client) GetFee(ctx context.Context, currency CryptoCurrency, addresses []string, amounts []float64, feePlan ...PlanName) (*Fee, error)

GetFee estimates the network fee for sending amounts to addresses.

func (*Client) GetFeePlan

func (c *Client) GetFeePlan(ctx context.Context, currency CryptoCurrency) (json.RawMessage, error)

GetFeePlan returns the available fee plans for a currency. The shape varies per currency, so the raw JSON is returned.

func (*Client) GetOperation

func (c *Client) GetOperation(ctx context.Context, id string) (*Operation, error)

GetOperation returns the details of a single operation by id.

func (*Client) GetOperations

func (c *Client) GetOperations(ctx context.Context, opts ...OperationsOption) (*Operations, error)

GetOperations lists operations with optional pagination and filters.

func (*Client) ParseCallback

func (c *Client) ParseCallback(body []byte) (*Callback, error)

ParseCallback validates the callback and, if authentic, decodes it into a Callback. It returns ErrInvalidCallback when validation fails.

func (*Client) ValidateCallback

func (c *Client) ValidateCallback(body []byte) bool

ValidateCallback reports whether body is an authentic Plisio callback. It recomputes the HMAC-SHA1 verify_hash over the key-sorted JSON (excluding verify_hash) and compares it in constant time.

Use the "?json=true" query param on your callback URL so Plisio sends JSON (this is the documented scheme for non-PHP integrations).

func (*Client) Withdraw

func (c *Client) Withdraw(ctx context.Context, currency CryptoCurrency, opts ...WithdrawOption) (*Withdraw, error)

Withdraw sends cryptocurrency to one or more addresses.

type ClientOption

type ClientOption func(*Client)

ClientOption configures a Client. Options are applied in order; later options win if they set the same field.

func WithBaseURL

func WithBaseURL(u string) ClientOption

WithBaseURL overrides the API base URL (mainly for testing). A trailing slash is added if missing.

func WithHTTPClient

func WithHTTPClient(hc *http.Client) ClientOption

WithHTTPClient sets the underlying *http.Client used for all requests. Use it to supply custom transports, proxies, or instrumentation.

func WithTimeout

func WithTimeout(d time.Duration) ClientOption

WithTimeout sets the http.Client timeout. It clones the current http.Client before setting Timeout, so a client shared via WithHTTPClient is never mutated. If WithHTTPClient is also given, the option applied last wins.

func WithUserAgent

func WithUserAgent(ua string) ClientOption

WithUserAgent sets a User-Agent header sent with every request.

type Commission

type Commission struct {
	Commission       Number      `json:"commission"`
	Fee              Number      `json:"fee"`
	MaxAmount        Number      `json:"maxAmount"`
	Plan             PlanName    `json:"plan"`
	UseWallet        Number      `json:"useWallet"`
	UseWalletBalance Number      `json:"useWalletBalance"`
	Errors           Number      `json:"errors"`
	CustomFeeRate    Number      `json:"customFeeRate"`
	Custom           CustomRange `json:"custom"`
}

Commission estimates the Plisio commission and network fee for a withdrawal.

type CommissionOption

type CommissionOption func(*commissionParams)

CommissionOption configures a GetCommission call.

func WithCommissionAddresses

func WithCommissionAddresses(addrs ...string) CommissionOption

WithCommissionAddresses sets the destination address(es) to estimate for.

func WithCommissionAmounts

func WithCommissionAmounts(amounts ...float64) CommissionOption

WithCommissionAmounts sets the amount(s) to estimate for.

func WithCommissionFeePlan

func WithCommissionFeePlan(n PlanName) CommissionOption

WithCommissionFeePlan selects the fee plan to estimate.

func WithCommissionType

func WithCommissionType(t OperationType) CommissionOption

WithCommissionType sets the operation type to estimate for.

func WithCustomFeeRate

func WithCustomFeeRate(rate int) CommissionOption

WithCustomFeeRate sets a custom fee rate to estimate (with PlanCustom).

type CryptoCurrency

type CryptoCurrency string

CryptoCurrency is a cryptocurrency identifier (the "ID" column of Plisio's supported cryptocurrencies, sent as psys_cid / cid).

const (
	BTC      CryptoCurrency = "BTC"
	ETH      CryptoCurrency = "ETH"
	LTC      CryptoCurrency = "LTC"
	DASH     CryptoCurrency = "DASH"
	ZEC      CryptoCurrency = "ZEC"
	DOGE     CryptoCurrency = "DOGE"
	BCH      CryptoCurrency = "BCH"
	XMR      CryptoCurrency = "XMR"
	USDT     CryptoCurrency = "USDT"
	SHIB     CryptoCurrency = "SHIB"
	USDC     CryptoCurrency = "USDC"
	TRX      CryptoCurrency = "TRX"
	USDT_TRX CryptoCurrency = "USDT_TRX"
	BNB      CryptoCurrency = "BNB"
	USDT_BSC CryptoCurrency = "USDT_BSC"
	BUSD     CryptoCurrency = "BUSD"
	ETC      CryptoCurrency = "ETC"
	TZEC     CryptoCurrency = "TZEC"
	BTT_TRX  CryptoCurrency = "BTT_TRX"
	TUSD     CryptoCurrency = "TUSD"
)

type Currency

type Currency struct {
	Name                        string         `json:"name"`
	Currency                    CryptoCurrency `json:"currency"`
	Icon                        string         `json:"icon"`
	RateUSD                     Number         `json:"rate_usd"`
	PriceUSD                    Number         `json:"price_usd"`
	Precision                   Number         `json:"precision"`
	Fiat                        FiatCurrency   `json:"fiat"`
	FiatRate                    Number         `json:"fiat_rate"`
	MinSumIn                    Number         `json:"min_sum_in"`
	InvoiceCommissionPercentage Number         `json:"invoice_commission_percentage"`
	Hidden                      Number         `json:"hidden"`
	Maintenance                 bool           `json:"maintenance"`
}

Currency describes a cryptocurrency supported by Plisio. Numeric fields are Number because Plisio returns them inconsistently (string vs number).

func (*Currency) UnmarshalJSON

func (c *Currency) UnmarshalJSON(b []byte) error

UnmarshalJSON handles Plisio returning the currency id under either "currency" or "cid".

type CustomRange

type CustomRange struct {
	Min     Number `json:"min"`
	Max     Number `json:"max"`
	Default Number `json:"default"`
	Borders Number `json:"borders"`
	Unit    string `json:"unit"`
}

CustomRange describes the allowed range for a custom fee.

type Fee

type Fee struct {
	Fee      Number         `json:"fee"`
	Currency CryptoCurrency `json:"psys_cid"`
	Plan     PlanName       `json:"plan"`
}

Fee is the estimated network fee for a withdrawal.

type FiatCurrency

type FiatCurrency string

FiatCurrency is a fiat currency code (e.g. USD). Plisio supports 167; the constants cover the common ones but any code may be used.

const (
	USD FiatCurrency = "USD"
	EUR FiatCurrency = "EUR"
	AUD FiatCurrency = "AUD"
)

type Invoice

type Invoice struct {
	TxnID                 string `json:"txn_id"`
	InvoiceURL            string `json:"invoice_url"`
	Amount                Number `json:"amount"`
	PendingAmount         Number `json:"pending_amount"`
	WalletHash            string `json:"wallet_hash"`
	PsysCid               string `json:"psys_cid"`
	Currency              string `json:"currency"`
	Status                string `json:"status"`
	SourceCurrency        string `json:"source_currency"`
	SourceRate            string `json:"source_rate"`
	ExpireUtc             string `json:"expire_utc"`
	ExpectedConfirmations string `json:"expected_confirmations"`
	QrCode                string `json:"qr_code"`
	VerifyHash            string `json:"verify_hash"`
	InvoiceCommission     Number `json:"invoice_commission"`
	InvoiceSum            Number `json:"invoice_sum"`
	InvoiceTotalSum       Number `json:"invoice_total_sum"`
}

Invoice is a Plisio payment invoice. The broad set of fields is returned only for white-label shops; otherwise only TxnID, InvoiceURL and InvoiceTotalSum are populated. Monetary fields are Number.

type InvoiceOption

type InvoiceOption func(*invoiceParams)

InvoiceOption configures a CreateInvoice call.

func WithAllowedCurrencies

func WithAllowedCurrencies(cc ...CryptoCurrency) InvoiceOption

WithAllowedCurrencies restricts which cryptocurrencies the buyer may pay with (comma-separated psys_cids).

func WithAmount

func WithAmount(f float64) InvoiceOption

WithAmount sets the invoice amount in cryptocurrency. Mutually exclusive with WithSourceAmount. Amounts are rendered to at most 8 decimal places; values smaller than 1e-8 become "0".

func WithCallbackURL

func WithCallbackURL(s string) InvoiceOption

WithCallbackURL sets the URL that receives invoice status POST updates. Append "?json=true" for non-PHP integrations (see ValidateCallback).

func WithCurrency

func WithCurrency(c CryptoCurrency) InvoiceOption

WithCurrency selects the cryptocurrency the invoice is paid in. If unset, Plisio picks one of the active currencies from your API settings.

func WithDescription

func WithDescription(s string) InvoiceOption

WithDescription sets the invoice description.

func WithEmail

func WithEmail(s string) InvoiceOption

WithEmail pre-fills the buyer email so Plisio skips asking for it.

func WithExpireMin

func WithExpireMin(n int) InvoiceOption

WithExpireMin sets how many minutes until the invoice expires.

func WithFailCallbackURL

func WithFailCallbackURL(s string) InvoiceOption

WithFailCallbackURL sets the URL notified when the invoice fails.

func WithFailInvoiceURL

func WithFailInvoiceURL(s string) InvoiceOption

WithFailInvoiceURL sets the "To the site" link on an unpaid invoice.

func WithLanguage

func WithLanguage(s string) InvoiceOption

WithLanguage sets the invoice language (only "en_US" is supported).

func WithOrderName

func WithOrderName(s string) InvoiceOption

WithOrderName sets the merchant internal order name (required by Plisio).

func WithOrderNumber

func WithOrderNumber(n int) InvoiceOption

WithOrderNumber sets the unique merchant order number (required by Plisio).

func WithPlugin

func WithPlugin(s string) InvoiceOption

WithPlugin is Plisio's internal integration-plugin identifier.

func WithRedirectToInvoice

func WithRedirectToInvoice(b bool) InvoiceOption

WithRedirectToInvoice redirects the user to Plisio's invoice page instead of returning JSON (not for white-label shops).

func WithReturnExisting

func WithReturnExisting(b bool) InvoiceOption

WithReturnExisting returns the existing invoice instead of an error when one already exists for the order.

func WithSourceAmount

func WithSourceAmount(f float64, fiat FiatCurrency) InvoiceOption

WithSourceAmount sets the invoice amount in a fiat currency; Plisio converts it to crypto. Mutually exclusive with WithAmount. Amounts are rendered to at most 8 decimal places; values smaller than 1e-8 become "0".

func WithSuccessCallbackURL

func WithSuccessCallbackURL(s string) InvoiceOption

WithSuccessCallbackURL sets the URL notified when the invoice succeeds.

func WithSuccessInvoiceURL

func WithSuccessInvoiceURL(s string) InvoiceOption

WithSuccessInvoiceURL sets the "To the site" link on a paid invoice.

func WithVersion

func WithVersion(s string) InvoiceOption

WithVersion is Plisio's internal integration-plugin version.

type Number

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

Number is a numeric value returned by the Plisio API.

Plisio does not guarantee a consistent JSON type for monetary fields: the same field may arrive as a JSON string ("1.5"), a float (1.5), an int (1), or null. Number preserves the exact textual form and converts on demand, so no precision is ever lost and decoding never fails on a type mismatch.

func (Number) Float64

func (n Number) Float64() (float64, error)

Float64 parses the value as a float64.

func (Number) Int64

func (n Number) Int64() (int64, error)

Int64 parses the value as an int64.

func (Number) IsNull

func (n Number) IsNull() bool

IsNull reports whether the value was absent or JSON null.

func (Number) MarshalJSON

func (n Number) MarshalJSON() ([]byte, error)

MarshalJSON emits the number in its raw form (or null when unset/empty, consistent with IsNull).

func (Number) String

func (n Number) String() string

String returns the exact textual form, preserving full precision. It returns "" for a null value.

func (*Number) UnmarshalJSON

func (n *Number) UnmarshalJSON(b []byte) error

UnmarshalJSON accepts a JSON string, number, or null.

type Operation

type Operation struct {
	UserID           Number            `json:"user_id"`
	ShopID           string            `json:"shop_id"`
	Type             OperationType     `json:"type"`
	Status           OperationStatus   `json:"status"`
	PendingSum       Number            `json:"pending_sum"`
	Currency         CryptoCurrency    `json:"psys_cid"`
	SourceCurrency   FiatCurrency      `json:"source_currency"`
	SourceRate       Number            `json:"source_rate"`
	Confirmations    Number            `json:"confirmations"`
	Fee              Number            `json:"fee"`
	WalletHash       string            `json:"wallet_hash"`
	SendMany         map[string]Number `json:"sendmany"`
	Params           OperationParams   `json:"params"`
	ExpireAtUTC      Number            `json:"expire_at_utc"`
	CreatedAtUTC     Number            `json:"created_at_utc"`
	Amount           Number            `json:"amount"`
	Sum              Number            `json:"sum"`
	Commission       Number            `json:"commission"`
	TxURL            Strings           `json:"tx_url"`
	TxID             []string          `json:"tx_id"`
	ID               string            `json:"id"`
	ActualSum        Number            `json:"actual_sum"`
	ActualCommission Number            `json:"actual_commission"`
	ActualFee        Number            `json:"actual_fee"`
	ActualInvoiceSum Number            `json:"actual_invoice_sum"`
	Tx               []OperationTx     `json:"tx"`
	StatusCode       Number            `json:"status_code"`
	ParentID         string            `json:"parent_id"`
	ChildIDs         []string          `json:"child_ids"`
}

Operation is a Plisio transaction/invoice. Fields are populated depending on the operation type and whether white-label is active. All numerics are Number to survive Plisio's inconsistent typing.

type OperationParams

type OperationParams struct {
	OrderNumber    string         `json:"order_number"`
	OrderName      string         `json:"order_name"`
	SourceAmount   Number         `json:"source_amount"`
	SourceCurrency FiatCurrency   `json:"source_currency"`
	Currency       CryptoCurrency `json:"currency"`
	Amount         Number         `json:"amount"`
	SourceRate     Number         `json:"source_rate"`
	Email          string         `json:"email"`
	USDRate        Number         `json:"usd_rate"`
}

OperationParams holds the original request parameters of an operation.

type OperationStatus

type OperationStatus string

OperationStatus is the lifecycle status of an invoice or operation.

const (
	StatusNew                OperationStatus = "new"
	StatusPending            OperationStatus = "pending"
	StatusPendingInternal    OperationStatus = "pending internal"
	StatusExpired            OperationStatus = "expired"
	StatusCompleted          OperationStatus = "completed"
	StatusMismatch           OperationStatus = "mismatch"
	StatusError              OperationStatus = "error"
	StatusCancelled          OperationStatus = "cancelled"
	StatusCancelledDuplicate OperationStatus = "cancelled duplicate"
)

type OperationTx

type OperationTx struct {
	TxID          string   `json:"txid"`
	Block         Number   `json:"block"`
	Confirmations Number   `json:"confirmations"`
	Value         Number   `json:"value"`
	Processed     bool     `json:"processed"`
	FailRetry     Number   `json:"failRetry"`
	FeeRate       Number   `json:"feeRate"`
	FeeRateUnit   string   `json:"feeRateUnit"`
	URL           string   `json:"url"`
	WalletHash    []string `json:"wallet_hash"`
}

OperationTx is a single on-chain transaction belonging to an operation.

type OperationType

type OperationType string

OperationType is the kind of an operation.

const (
	OpCashIn      OperationType = "cash_in"
	OpCashOut     OperationType = "cash_out"
	OpMassCashOut OperationType = "mass_cash_out"
	OpInvoice     OperationType = "invoice"
	OpPayIn       OperationType = "pay_in"
)

type Operations

type Operations struct {
	Operations []Operation                  `json:"operations"`
	Links      map[string]map[string]string `json:"_links"`
	Meta       map[string]Number            `json:"_meta"`
}

Operations is a paginated list of operations with HATEOAS links and meta.

type OperationsOption

type OperationsOption func(*operationsParams)

OperationsOption configures a GetOperations call.

func WithLimit

func WithLimit(n int) OperationsOption

WithLimit sets the page size.

func WithOperationCurrency

func WithOperationCurrency(c CryptoCurrency) OperationsOption

WithOperationCurrency filters by cryptocurrency.

func WithPage

func WithPage(n int) OperationsOption

WithPage sets the page number.

func WithSearch

func WithSearch(s string) OperationsOption

WithSearch searches by txid, order number, or customer email.

func WithShopID

func WithShopID(id string) OperationsOption

WithShopID filters operations by shop.

func WithStatus

func WithStatus(s OperationStatus) OperationsOption

WithStatus filters by operation status.

func WithType

func WithType(t OperationType) OperationsOption

WithType filters by operation type.

type PlanName

type PlanName string

PlanName is a Plisio fee plan.

const (
	PlanEconomy  PlanName = "economy"
	PlanNormal   PlanName = "normal"
	PlanPriority PlanName = "priority"
	PlanCustom   PlanName = "custom"
)

type Strings

type Strings []string

Strings accepts either a single JSON string or an array of strings and always exposes a slice. Plisio returns tx_url in both forms.

func (*Strings) UnmarshalJSON

func (s *Strings) UnmarshalJSON(b []byte) error

UnmarshalJSON decodes a single JSON string, an array of strings, or null.

type Withdraw

type Withdraw struct {
	Type           OperationType     `json:"type"`
	Status         string            `json:"status"`
	Currency       CryptoCurrency    `json:"psys_cid"`
	SourceCurrency FiatCurrency      `json:"source_currency"`
	SourceRate     Number            `json:"source_rate"`
	Fee            Number            `json:"fee"`
	WalletHash     string            `json:"wallet_hash"`
	SendMany       map[string]Number `json:"sendmany"`
	Amount         Number            `json:"amount"`
	TxURL          string            `json:"tx_url"`
	TxID           []string          `json:"tx_id"`
	ID             string            `json:"id"`
}

Withdraw is the result of a cash-out operation.

type WithdrawOption

type WithdrawOption func(*withdrawParams)

WithdrawOption configures a Withdraw call.

func WithAmounts

func WithAmounts(amounts ...float64) WithdrawOption

WithAmounts sets the amount(s) to send, one per WithTo address. Amounts are rendered to at most 8 decimal places; values smaller than 1e-8 become "0".

func WithFeePlan

func WithFeePlan(n PlanName) WithdrawOption

WithFeePlan selects a Plisio fee plan.

func WithFeeRate

func WithFeeRate(f float64) WithdrawOption

WithFeeRate sets a custom fee rate (only with PlanCustom).

func WithTo

func WithTo(addrs ...string) WithdrawOption

WithTo sets the destination address(es). Multiple addresses create a mass cash-out (must match the count of WithAmounts).

func WithWithdrawType

func WithWithdrawType(t OperationType) WithdrawOption

WithWithdrawType sets the operation type (cash_out or mass_cash_out).

Jump to

Keyboard shortcuts

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