boltz

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CompletedStatus = []string{
	InvoiceSettled.String(),
	TransactionClaimed.String(),
}
View Source
var FailedStatus = []string{
	SwapExpired.String(),
	InvoiceFailedToPay.String(),
	TransactionFailed.String(),
	TransactionRefunded.String(),
}

Functions

func CheckReverseSwapScript

func CheckReverseSwapScript(redeemScript, preimageHash []byte, claimKey *btcec.PrivateKey, timeoutBlockHeight uint32) error

func CheckSwapAddress

func CheckSwapAddress(chainParams *chaincfg.Params, address string, redeemScript []byte, isNested bool) error

func CheckSwapScript

func CheckSwapScript(redeemScript, preimageHash []byte, refundKey *btcec.PrivateKey, timeoutBlockHeight uint32) error

func ConstructTransaction

func ConstructTransaction(outputs []OutputDetails, outputAddress btcutil.Address, satPerVbyte int64) (*wire.MsgTx, error)

func NestedScriptHashAddress

func NestedScriptHashAddress(chainParams *chaincfg.Params, redeemScript []byte) (string, error)

func ScriptHashAddress

func ScriptHashAddress(chainParams *chaincfg.Params, redeemScript []byte) (string, error)

func SerializeTransaction

func SerializeTransaction(transaction *wire.MsgTx) (string, error)

func WitnessScriptHashAddress

func WitnessScriptHashAddress(chainParams *chaincfg.Params, redeemScript []byte) (string, error)

Types

type Boltz

type Boltz struct {
	URL string `long:"boltz.url" description:"URL endpoint of the Boltz API"`
	// contains filtered or unexported fields
}

func (*Boltz) BroadcastTransaction

func (boltz *Boltz) BroadcastTransaction(transactionHex string) (*BroadcastTransactionResponse, error)

func (*Boltz) CreateChannelCreation

func (boltz *Boltz) CreateChannelCreation(request CreateChannelCreationRequest) (response *CreateSwapResponse, err error)

func (*Boltz) CreateReverseSwap

func (boltz *Boltz) CreateReverseSwap(request CreateReverseSwapRequest) (*CreateReverseSwapResponse, error)

func (*Boltz) CreateSwap

func (boltz *Boltz) CreateSwap(request CreateSwapRequest) (*CreateSwapResponse, error)

func (*Boltz) GetFeeEstimation

func (boltz *Boltz) GetFeeEstimation() (*map[string]uint64, error)

func (*Boltz) GetNodes

func (boltz *Boltz) GetNodes() (*GetNodesResponse, error)

func (*Boltz) GetPairs

func (boltz *Boltz) GetPairs() (*GetPairsResponse, error)

func (*Boltz) GetSwapTransaction

func (boltz *Boltz) GetSwapTransaction(id string) (*GetSwapTransactionResponse, error)

func (*Boltz) GetVersion

func (boltz *Boltz) GetVersion() (*GetVersionResponse, error)

func (*Boltz) Init

func (boltz *Boltz) Init(symbol string)

func (*Boltz) SetInvoice

func (boltz *Boltz) SetInvoice(request SetInvoiceRequest) (*SetInvoiceResponse, error)

func (*Boltz) StreamSwapStatus

func (boltz *Boltz) StreamSwapStatus(id string, events chan *SwapStatusResponse, stopListening chan bool) error

func (*Boltz) SwapRates

func (boltz *Boltz) SwapRates(request SwapRatesRequest) (*SwapRatesResponse, error)

func (*Boltz) SwapStatus

func (boltz *Boltz) SwapStatus(id string) (*SwapStatusResponse, error)

type BroadcastTransactionRequest

type BroadcastTransactionRequest struct {
	Currency       string `json:"currency"`
	TransactionHex string `json:"transactionHex"`
}

type BroadcastTransactionResponse

type BroadcastTransactionResponse struct {
	TransactionId string `json:"transactionId"`

	Error string `json:"error"`
}

type Channel

type Channel struct {
	Auto             bool   `json:"auto"`
	Private          bool   `json:"private"`
	InboundLiquidity uint32 `json:"inboundLiquidity"`
}

type ChannelState

type ChannelState int
const (
	ChannelNone ChannelState = iota
	ChannelAccepted
	ChannelSettled
)

func ParseChannelState

func ParseChannelState(event string) ChannelState

func (ChannelState) String

func (event ChannelState) String() string

type CreateChannelCreationRequest

type CreateChannelCreationRequest struct {
	Type            string `json:"type"`
	PairId          string `json:"pairId"`
	OrderSide       string `json:"orderSide"`
	RefundPublicKey string `json:"refundPublicKey"`
	Invoice         string `json:"invoice"`
	PreimageHash    string `json:"preimageHash"`

	Channel Channel `json:"channel"`
}

type CreateReverseSwapRequest

type CreateReverseSwapRequest struct {
	Type           string `json:"type"`
	PairId         string `json:"pairId"`
	OrderSide      string `json:"orderSide"`
	InvoiceAmount  uint64 `json:"invoiceAmount"`
	PreimageHash   string `json:"preimageHash"`
	ClaimPublicKey string `json:"claimPublicKey"`
}

type CreateReverseSwapResponse

type CreateReverseSwapResponse struct {
	Id                 string `json:"id"`
	Invoice            string `json:"invoice"`
	OnchainAmount      uint64 `json:"onchainAmount"`
	RedeemScript       string `json:"redeemScript"`
	LockupAddress      string `json:"lockupAddress"`
	TimeoutBlockHeight uint32 `json:"TimeoutBlockHeight"`

	Error string `json:"error"`
}

type CreateSwapRequest

type CreateSwapRequest struct {
	Type            string `json:"type"`
	PairId          string `json:"pairId"`
	OrderSide       string `json:"orderSide"`
	RefundPublicKey string `json:"refundPublicKey"`
	Invoice         string `json:"invoice"`
	PreimageHash    string `json:"preimageHash"`
}

type CreateSwapResponse

type CreateSwapResponse struct {
	Id                 string `json:"id"`
	Bip21              string `json:"bip21"`
	Address            string `json:"address"`
	RedeemScript       string `json:"redeemScript"`
	AcceptZeroConf     bool   `json:"acceptZeroConf"`
	ExpectedAmount     uint64 `json:"expectedAmount"`
	TimeoutBlockHeight uint32 `json:"timeoutBlockHeight"`

	Error string `json:"error"`
}

type GetNodesResponse

type GetNodesResponse struct {
	Nodes map[string]struct {
		NodeKey string   `json:"nodeKey"`
		URIs    []string `json:"uris"`
	} `json:"nodes"`
}

type GetPairsResponse

type GetPairsResponse struct {
	Warnings []string `json:"warnings"`
	Pairs    map[string]struct {
		Rate   float32 `json:"rate"`
		Limits struct {
			Maximal uint64 `json:"maximal"`
			Minimal uint64 `json:"minimal"`
		} `json:"limits"`
		Fees struct {
			Percentage float32 `json:"percentage"`
			MinerFees  struct {
				BaseAsset  symbolMinerFees `json:"baseAsset"`
				QuoteAsset symbolMinerFees `json:"quoteAsset"`
			} `json:"minerFees"`
		} `json:"fees"`
	} `json:"pairs"`
}

type GetSwapTransactionRequest

type GetSwapTransactionRequest struct {
	Id string `json:"id"`
}

type GetSwapTransactionResponse

type GetSwapTransactionResponse struct {
	TransactionHex     string `json:"transactionHex"`
	TimeoutBlockHeight uint32 `json:"timeoutBlockHeight"`
	TimeoutEta         uint64 `json:"timeoutEta"`

	Error string `json:"error"`
}

type GetVersionResponse

type GetVersionResponse struct {
	Version string `json:"version"`
}

Types for Boltz API

type OutputDetails

type OutputDetails struct {
	LockupTransaction *btcutil.Tx
	Vout              uint32
	OutputType        OutputType

	RedeemScript []byte
	PrivateKey   *btcec.PrivateKey

	// Should be set to an empty array in case of a refund
	Preimage []byte

	// Can be zero in case of a claim transaction
	TimeoutBlockHeight uint32
}

type OutputType

type OutputType int
const (
	SegWit OutputType = iota
	Compatibility
	Legacy
)

type SetInvoiceRequest

type SetInvoiceRequest struct {
	Id      string `json:"id"`
	Invoice string `json:"invoice"`
}

type SetInvoiceResponse

type SetInvoiceResponse struct {
	Error string `json:"error"`
}

type SwapRatesRequest

type SwapRatesRequest struct {
	Id string `json:"id"`
}

type SwapRatesResponse

type SwapRatesResponse struct {
	OnchainAmount uint64 `json:"onchainAmount"`
	SubmarineSwap struct {
		InvoiceAmount uint64 `json:"invoiceAmount"`
	} `json:"submarineSwap"`

	Error string `json:"error"`
}

type SwapStatusRequest

type SwapStatusRequest struct {
	Id string `json:"id"`
}

type SwapStatusResponse

type SwapStatusResponse struct {
	Status  string `json:"status"`
	Channel struct {
		FundingTransactionId   string `json:"fundingTransactionId"`
		FundingTransactionVout uint32 `json:"fundingTransactionVout"`
	} `json:"channel"`
	Transaction struct {
		Id  string `json:"id"`
		Hex string `json:"hex"`
	} `json:"transaction"`

	Error string `json:"error"`
}

type SwapUpdateEvent

type SwapUpdateEvent int
const (
	SwapCreated SwapUpdateEvent = iota
	SwapExpired

	InvoiceSet
	InvoicePaid
	InvoicePending
	InvoiceSettled
	InvoiceFailedToPay

	ChannelCreated

	TransactionFailed
	TransactionMempool
	TransactionClaimed
	TransactionRefunded
	TransactionConfirmed
)

func ParseEvent

func ParseEvent(event string) SwapUpdateEvent

func (SwapUpdateEvent) IsCompletedStatus added in v1.2.3

func (event SwapUpdateEvent) IsCompletedStatus() bool

func (SwapUpdateEvent) IsFailedStatus added in v1.2.3

func (event SwapUpdateEvent) IsFailedStatus() bool

func (SwapUpdateEvent) String

func (event SwapUpdateEvent) String() string

Jump to

Keyboard shortcuts

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