payreq

package
v0.0.0-...-38ff61f Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Btc represents the Bitcoin currency.
	Btc = Currency{
		Name:     "Bitcoin",
		Chaincfg: &chaincfg.MainNetParams,
	}

	// BtcTestnet represents the Bitcoin testnet currency.
	BtcTestnet = Currency{
		Name:     "Bitcoin Testnet",
		Chaincfg: &chaincfg.TestNet3Params,
	}

	// BtcSimnet represents the Bitcoin testnet currency.
	BtcSimnet = Currency{
		Name:     "Bitcoin Simnet",
		Chaincfg: &chaincfg.SimNetParams,
	}

	// Ltc represents the Litecoin currency.
	Ltc = Currency{
		Name:     "Litecoin",
		Chaincfg: liteCoinParams,
	}

	// LtcTestnet represents the Litecoin currency.
	LtcTestnet = Currency{
		Name:     "Litecoin Testnet",
		Chaincfg: liteCoinParamsTestnet,
	}

	// LtcSimnet represents the Litecoin currency.
	LtcSimnet = Currency{
		Name:     "Litecoin Simnet",
		Chaincfg: liteCoinParamsSimnet,
	}
)

RateMap contains exchange rates between Currencies.

Functions

func CreateP2SHAddress

func CreateP2SHAddress(c Currency, script []byte) (string, error)

CreateP2SHAddress returns a P2SH address as string given the currency and script.

func CreateP2SHP2WSHAddress

func CreateP2SHP2WSHAddress(c Currency, script []byte) (string, error)

CreateP2SHP2WSHAddress returns a P2SH nested P2WSH address as string given the currency and script.

func CreateSubmarineSwapScript

func CreateSubmarineSwapScript(inv PayReq, expires time.Duration, brokerKey, userKey *btcec.PublicKey) ([]byte, error)

CreateSubmarineSwapScript returns a Submarine Swap script from defined currency, invoice, expiration, broker and user key.

Types

type Currency

type Currency struct {
	Name     string
	Chaincfg *chaincfg.Params
}

Currency is a type representing a cryptocurrency. It has a name and parameters defining the chain of the cryptocurrency.

func GetCurrency

func GetCurrency(hrp string) (Currency, error)

GetCurrency returns the Currency for a Bech32 HRP.

func GetCurrencyFromInvoice

func GetCurrencyFromInvoice(bolt11 string) (Currency, error)

GetCurrencyFromInvoice returns the Currency of a Lightning network Bolt11 invoice without validating the checksum of the invoice.

type PayReq

type PayReq struct {
	Invoice     string
	Destination string
	Currency    Currency
	CreatedAt   time.Time
	Expiry      time.Duration
	Amount      uint64
	Description string
	PaymentHash []byte
}

PayReq is a type representing a swap payment request.

func DecodeInvoice

func DecodeInvoice(bolt11 string) (PayReq, error)

DecodeInvoice will return a PayReq given a Lightning network Bolt11 invoice.

Jump to

Keyboard shortcuts

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