boltz

package
v2.3.5-0...-2fac4e2 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const AbsoluteFeeToleranceSat = 1500
View Source
const BitcoinBlockTime = float64(10)

Block times in minutes

View Source
const LiquidBlockTime = float64(1)
View Source
const RelativeFeeTolerance = Percentage(25)

Variables

View Source
var BtcSizes = TxSizes{}
View Source
var CompletedStatus = []string{
	InvoiceSettled.String(),
	TransactionClaimed.String(),
}
View Source
var ErrInvalidOnchainFee = errors.New("onchain fee way above expectation")
View Source
var ErrPartialSignaturesDisabled = errors.New("partial signatures are disabled")
View Source
var FailedStatus = []string{
	SwapExpired.String(),
	InvoiceFailedToPay.String(),
	TransactionFailed.String(),
	TransactionLockupFailed.String(),
	TransactionRefunded.String(),
}
View Source
var LiquidSizes = TxSizes{}
View Source
var MainNet = &Network{
	Btc:    &btc.MainNetParams,
	Liquid: &liquid.Liquid,
	Name:   "mainnet",
	DummyLockupAddress: map[Currency]string{
		CurrencyBtc:    "bc1p28f027j7nte0pprte30nz4qxx65uc3rur23pukjganmzfwejj5lqjq5lky",
		CurrencyLiquid: "lq1pqtfldcsfag6u5lv20f85zjp68x99er90jxlqv3yc3ucy9zd3tt0ndztxkr9jaxynl8l4hvsfch7slg7l52pfw49te3wrhwazr9lq9s6y2cgwtpn9wv7z",
	},
}
View Source
var (
	PairBtc = Pair{From: CurrencyBtc, To: CurrencyBtc}
)
View Source
var Regtest = &Network{
	Btc:    &btc.RegressionNetParams,
	Liquid: &liquid.Regtest,
	Name:   "regtest",
	DummyLockupAddress: map[Currency]string{
		CurrencyBtc:    "bcrt1pedm5v4z658f3ad4gyxmnren7gdnnqhm6pdtgheksfvm8f4k74uas7tz83f",
		CurrencyLiquid: "el1pqfg7mxz4cnpu8sj2pza285vh062eq0sxwt982nprnx0d975tvmzpdcqdwvpsds5q664fp90645wlze8544j8x59vzhhy6hylmad6ycjw07nsa6thmkz7",
	},
}
View Source
var Sizes = map[Currency]TxSizes{
	CurrencyBtc: {
		NormalClaim:   151,
		ReverseLockup: 154,
		ReverseClaim:  111,
	},
	CurrencyLiquid: {
		NormalClaim:   1337,
		ReverseLockup: 2503,
		ReverseClaim:  1309,
	},
}
View Source
var TestNet = &Network{
	Btc:    &btc.TestNet3Params,
	Liquid: &liquid.Testnet,
	Name:   "testnet",
	DummyLockupAddress: map[Currency]string{
		CurrencyBtc:    "tb1p5a2rc0hcuf8n2rssmfr9mqk08nlxzl9ngnlhj47gwegj7epjph5q9739y6",
		CurrencyLiquid: "tlq1pqghwg6s98dfhtrncxck6rl359eckxdwrk4680npy4m6q2lgud9y6p0w2jytj4akr2zhwze587d823zu5rg8vwfq0ehkk8c74lrvt77kmwqr5vwy7p47u",
	},
}

Functions

func BlocksToHours

func BlocksToHours(blockDelta uint32, currency Currency) float64

func CalculateInvoiceExpiry

func CalculateInvoiceExpiry(blockDelta uint32, currency Currency) int64

func CheckAmounts

func CheckAmounts(swapType SwapType, pair Pair, sendAmount uint64, receiveAmount uint64, serviceFee Percentage, estimations FeeEstimations, includeClaim bool) error

func ConstructTransaction

func ConstructTransaction(network *Network, currency Currency, outputs []OutputDetails, satPerVbyte float64, boltzApi *Api) (Transaction, Results, error)

func FindMagicRoutingHint

func FindMagicRoutingHint(invoice *zpay32.Invoice) *btcec.PublicKey

func FindPair

func FindPair[T any](pair Pair, nested map[Currency]map[Currency]T) (*T, error)

func GetBlockTime

func GetBlockTime(currency Currency) float64

func StripQuotes

func StripQuotes(text []byte) string

func ValidateAddress

func ValidateAddress(network *Network, rawAddress string, currency Currency) error

Types

type Api

type Api struct {
	URL    string
	Client http.Client

	DisablePartialSignatures bool
}

func (*Api) AcceptChainSwapQuote

func (boltz *Api) AcceptChainSwapQuote(swapId string, quote *Quote) error

func (*Api) BroadcastTransaction

func (boltz *Api) BroadcastTransaction(currency Currency, txHex string) (string, error)

func (*Api) ClaimReverseSwap

func (boltz *Api) ClaimReverseSwap(swapId string, request *ClaimRequest) (*PartialSignature, error)

func (*Api) CreateChainSwap

func (boltz *Api) CreateChainSwap(request ChainRequest) (*ChainResponse, error)

func (*Api) CreateReverseSwap

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

func (*Api) CreateSwap

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

func (*Api) ExchangeChainSwapClaimSignature

func (boltz *Api) ExchangeChainSwapClaimSignature(swapId string, request *ChainSwapSigningRequest) (*PartialSignature, error)

func (*Api) FetchBolt12Invoice

func (boltz *Api) FetchBolt12Invoice(offer string, amountSat uint64) (string, error)

func (*Api) GetChainPairs

func (boltz *Api) GetChainPairs() (response ChainPairs, err error)

func (*Api) GetChainSwapClaimDetails

func (boltz *Api) GetChainSwapClaimDetails(swapId string) (*ChainSwapSigningDetails, error)

func (*Api) GetChainSwapQuote

func (boltz *Api) GetChainSwapQuote(swapId string) (*Quote, error)

func (*Api) GetChainSwapTransactions

func (boltz *Api) GetChainSwapTransactions(id string) (*GetChainSwapTransactionsResponse, error)

func (*Api) GetFeeEstimation

func (boltz *Api) GetFeeEstimation(currency Currency) (float64, error)

func (*Api) GetInvoiceAmount

func (boltz *Api) GetInvoiceAmount(swapId string) (*GetInvoiceAmountResponse, error)

func (*Api) GetNodes

func (boltz *Api) GetNodes() (Nodes, error)

func (*Api) GetPairs

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

func (*Api) GetReversePairs

func (boltz *Api) GetReversePairs() (response ReversePairs, err error)

func (*Api) GetReverseSwapBip21

func (boltz *Api) GetReverseSwapBip21(invoice string) (*ReverseBip21, error)

func (*Api) GetSubmarinePairs

func (boltz *Api) GetSubmarinePairs() (response SubmarinePairs, err error)

func (*Api) GetSwapClaimDetails

func (boltz *Api) GetSwapClaimDetails(swapId string) (*SwapClaimDetails, error)

func (*Api) GetSwapTransaction

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

func (*Api) GetTransaction

func (boltz *Api) GetTransaction(transactionId string, currency Currency) (string, error)

func (*Api) GetVersion

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

func (*Api) NewWebsocket

func (boltz *Api) NewWebsocket() *Websocket

func (*Api) RefundChainSwap

func (boltz *Api) RefundChainSwap(swapId string, request *RefundRequest) (*PartialSignature, error)

func (*Api) RefundSwap

func (boltz *Api) RefundSwap(swapId string, request *RefundRequest) (*PartialSignature, error)

func (*Api) SendSwapClaimSignature

func (boltz *Api) SendSwapClaimSignature(swapId string, signature *PartialSignature) error

func (*Api) SetInvoice

func (boltz *Api) SetInvoice(swapId string, invoice string) (*SetInvoiceResponse, error)

func (*Api) SwapStatus

func (boltz *Api) 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 BtcTransaction

type BtcTransaction struct {
	btcutil.Tx
}

func NewBtcTxFromHex

func NewBtcTxFromHex(hexString string) (*BtcTransaction, error)

func (*BtcTransaction) FindVout

func (transaction *BtcTransaction) FindVout(network *Network, addressToFind string) (uint32, uint64, error)

func (*BtcTransaction) Hash

func (transaction *BtcTransaction) Hash() string

func (*BtcTransaction) Serialize

func (transaction *BtcTransaction) Serialize() (string, error)

func (*BtcTransaction) VSize

func (transaction *BtcTransaction) VSize() uint64

func (*BtcTransaction) VoutValue

func (transaction *BtcTransaction) VoutValue(vout uint32) (uint64, error)

type ChainPair

type ChainPair struct {
	Hash   string  `json:"hash"`
	Rate   float64 `json:"rate"`
	Limits struct {
		Minimal               uint64 `json:"minimal"`
		Maximal               uint64 `json:"maximal"`
		MaximalZeroConfAmount uint64 `json:"maximalZeroConf"`
	} `json:"limits"`
	Fees struct {
		Percentage float64 `json:"percentage"`
		MinerFees  struct {
			Server uint64 `json:"server"`
			User   struct {
				Claim  uint64 `json:"claim"`
				Lockup uint64 `json:"lockup"`
			} `json:"user"`
		} `json:"minerFees"`
	} `json:"fees"`
}

type ChainPairs

type ChainPairs map[Currency]map[Currency]ChainPair

type ChainRequest

type ChainRequest struct {
	From             Currency  `json:"from"`
	To               Currency  `json:"to"`
	PreimageHash     HexString `json:"preimageHash"`
	ClaimPublicKey   HexString `json:"claimPublicKey,omitempty"`
	RefundPublicKey  HexString `json:"refundPublicKey,omitempty"`
	UserLockAmount   uint64    `json:"userLockAmount,omitempty"`
	ServerLockAmount uint64    `json:"serverLockAmount,omitempty"`
	PairHash         string    `json:"pairHash,omitempty"`
	ReferralId       string    `json:"referralId,omitempty"`
}

type ChainResponse

type ChainResponse struct {
	Id            string         `json:"id"`
	ClaimDetails  *ChainSwapData `json:"claimDetails,omitempty"`
	LockupDetails *ChainSwapData `json:"lockupDetails,omitempty"`

	Error string `json:"error"`
}

type ChainSwapData

type ChainSwapData struct {
	SwapTree           *SerializedTree `json:"swapTree,omitempty"`
	LockupAddress      string          `json:"lockupAddress"`
	ServerPublicKey    HexString       `json:"serverPublicKey,omitempty"`
	TimeoutBlockHeight uint32          `json:"timeoutBlockHeight"`
	Amount             uint64          `json:"amount"`
	BlindingKey        HexString       `json:"blindingKey,omitempty"`
	Bip21              string          `json:"bip21,omitempty"`
}

type ChainSwapSigningDetails

type ChainSwapSigningDetails struct {
	PubNonce        HexString `json:"pubNonce"`
	TransactionHash HexString `json:"transactionHash"`
	PublicKey       HexString `json:"publicKey"`

	Error string `json:"error"`
}

type ChainSwapSigningRequest

type ChainSwapSigningRequest struct {
	Preimage  HexString         `json:"preimage"`
	Signature *PartialSignature `json:"signature"`
	ToSign    *ClaimRequest     `json:"toSign"`

	Error string `json:"error"`
}

type ChainSwapTransaction

type ChainSwapTransaction struct {
	Transaction struct {
		Id  string `json:"id"`
		Hex string `json:"hex"`
	} `json:"transaction"`
}

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 ClaimRequest

type ClaimRequest struct {
	Preimage    HexString `json:"preimage"`
	PubNonce    HexString `json:"pubNonce"`
	Transaction string    `json:"transaction"`
	Index       int       `json:"index"`
}

type CreateReverseSwapRequest

type CreateReverseSwapRequest struct {
	From             Currency  `json:"from"`
	To               Currency  `json:"to"`
	PreimageHash     HexString `json:"preimageHash"`
	ClaimPublicKey   HexString `json:"claimPublicKey"`
	InvoiceAmount    uint64    `json:"invoiceAmount,omitempty"`
	OnchainAmount    uint64    `json:"onchainAmount,omitempty"`
	PairHash         string    `json:"pairHash,omitempty"`
	ReferralId       string    `json:"referralId"`
	Address          string    `json:"address,omitempty"`
	AddressSignature HexString `json:"addressSignature,omitempty"`
	Description      string    `json:"description,omitempty"`
	DescriptionHash  HexString `json:"descriptionHash,omitempty"`
	InvoiceExpiry    uint64    `json:"invoiceExpiry,omitempty"`

	Error string `json:"error"`
}

type CreateReverseSwapResponse

type CreateReverseSwapResponse struct {
	Id                 string          `json:"id"`
	Invoice            string          `json:"invoice"`
	SwapTree           *SerializedTree `json:"swapTree"`
	RefundPublicKey    HexString       `json:"refundPublicKey"`
	LockupAddress      string          `json:"lockupAddress"`
	TimeoutBlockHeight uint32          `json:"timeoutBlockHeight"`
	OnchainAmount      uint64          `json:"onchainAmount"`
	BlindingKey        HexString       `json:"blindingKey"`

	Error string `json:"error"`
}

type CreateSwapRequest

type CreateSwapRequest struct {
	From            Currency  `json:"from"`
	To              Currency  `json:"to"`
	PairHash        string    `json:"pairHash,omitempty"`
	RefundPublicKey HexString `json:"refundPublicKey"`
	Invoice         string    `json:"invoice,omitempty"`
	ReferralId      string    `json:"referralId"`
	PreimageHash    HexString `json:"preimageHash,omitempty"`

	Error string `json:"error"`
}

type CreateSwapResponse

type CreateSwapResponse struct {
	Id                 string          `json:"id"`
	Bip21              string          `json:"bip21"`
	Address            string          `json:"address"`
	SwapTree           *SerializedTree `json:"swapTree"`
	ClaimPublicKey     HexString       `json:"claimPublicKey"`
	TimeoutBlockHeight uint32          `json:"timeoutBlockHeight"`
	AcceptZeroConf     bool            `json:"acceptZeroConf"`
	ExpectedAmount     uint64          `json:"expectedAmount"`
	BlindingKey        HexString       `json:"blindingKey"`

	Error string `json:"error"`
}

type Currency

type Currency string
const (
	CurrencyBtc       Currency = "BTC"
	CurrencyLiquid    Currency = "L-BTC"
	CurrencyRootstock Currency = "RBTC"
)

func GetAddressCurrency

func GetAddressCurrency(network *Network, address string) (Currency, error)

func ParseCurrency

func ParseCurrency(currency string) (Currency, error)

func TransactionCurrency

func TransactionCurrency(transaction Transaction) Currency

func (*Currency) UnmarshalText

func (currency *Currency) UnmarshalText(data []byte) (err error)

type Error

type Error error

type ErrorMessage

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

type FeeEstimations

type FeeEstimations map[Currency]float64

type GetChainSwapTransactionsResponse

type GetChainSwapTransactionsResponse struct {
	UserLock   *ChainSwapTransaction `json:"userLock"`
	ServerLock *ChainSwapTransaction `json:"serverLock"`

	Error string `json:"error"`
}

type GetInvoiceAmountResponse

type GetInvoiceAmountResponse struct {
	InvoiceAmount uint64 `json:"invoiceAmount"`
	Error         string `json:"error"`
}

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 GetTransactionRequest

type GetTransactionRequest struct {
	Currency      string `json:"currency"`
	TransactionId string `json:"transactionId"`

	Error string `json:"error"`
}

type GetTransactionResponse

type GetTransactionResponse struct {
	Hex string `json:"hex"`

	Error string `json:"error"`
}

type GetVersionResponse

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

Types for Boltz API

type HexString

type HexString []byte

func (HexString) MarshalText

func (s HexString) MarshalText() ([]byte, error)

func (*HexString) UnmarshalText

func (s *HexString) UnmarshalText(data []byte) (err error)

type LiquidTransaction

type LiquidTransaction struct {
	liquidtx.Transaction
	OurOutputBlindingKey *btcec.PrivateKey
}

func NewLiquidTxFromHex

func NewLiquidTxFromHex(hexString string, ourOutputBlindingKey *btcec.PrivateKey) (*LiquidTransaction, error)

func (*LiquidTransaction) FindVout

func (transaction *LiquidTransaction) FindVout(network *Network, addressToFind string) (uint32, uint64, error)

func (*LiquidTransaction) Hash

func (transaction *LiquidTransaction) Hash() string

func (*LiquidTransaction) Serialize

func (transaction *LiquidTransaction) Serialize() (string, error)

func (*LiquidTransaction) VSize

func (transaction *LiquidTransaction) VSize() uint64

func (*LiquidTransaction) VoutValue

func (transaction *LiquidTransaction) VoutValue(vout uint32) (uint64, error)

type MusigSession

type MusigSession struct {
	*musig2.Session
	// contains filtered or unexported fields
}

func NewSigningSession

func NewSigningSession(tree *SwapTree) (*MusigSession, error)

func (*MusigSession) Finalize

func (session *MusigSession) Finalize(transaction Transaction, outputs []OutputDetails, network *Network, boltzSignature *PartialSignature) (err error)

func (*MusigSession) Sign

func (session *MusigSession) Sign(hash []byte, boltzNonce []byte) (*PartialSignature, error)

type Network

type Network struct {
	Btc                *btc.Params
	Liquid             *liquid.Network
	Name               string
	DummyLockupAddress map[Currency]string
}

func ParseChain

func ParseChain(network string) (*Network, error)

type NodeInfo

type NodeInfo struct {
	PublicKey string   `json:"publicKey"`
	Uris      []string `json:"uris"`
}

type Nodes

type Nodes = map[string]map[string]NodeInfo

type OutputDetails

type OutputDetails struct {
	LockupTransaction Transaction
	Vout              uint32
	// the absolute fee to pay for this output
	Fee uint64

	// which address to use as the destination for the output
	Address string

	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

	// taproot only
	SwapTree    *SwapTree
	Cooperative bool
	// swap tree of server lockup transaction, required when cooperatively claiming a chain swap
	RefundSwapTree *SwapTree

	SwapId   string
	SwapType SwapType
}

func (*OutputDetails) IsRefund

func (output *OutputDetails) IsRefund() bool

type OutputResult

type OutputResult struct {
	Err error
	Fee uint64
}

type Pair

type Pair struct {
	From Currency
	To   Currency
}

func (Pair) String

func (p Pair) String() string

type PartialSignature

type PartialSignature struct {
	PubNonce         HexString `json:"pubNonce"`
	PartialSignature HexString `json:"partialSignature"`

	Error string `json:"error"`
}

type Percentage

type Percentage float64

func (Percentage) Calculate

func (p Percentage) Calculate(value uint64) uint64

func (Percentage) Ratio

func (p Percentage) Ratio() float64

func (Percentage) String

func (p Percentage) String() string

func (*Percentage) UnmarshalJSON

func (p *Percentage) UnmarshalJSON(text []byte) error

type Quote

type Quote struct {
	ResponseError
	Amount uint64 `json:"amount"`
}

type RefundRequest

type RefundRequest struct {
	PubNonce    HexString `json:"pubNonce"`
	Transaction string    `json:"transaction"`
	Index       int       `json:"index"`
}

type ResponseError

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

func (ResponseError) ApiError

func (response ResponseError) ApiError(err error) error

type Results

type Results map[string]OutputResult

func (Results) SetErr

func (results Results) SetErr(id string, err error)

type ReverseBip21

type ReverseBip21 struct {
	Bip21     string    `json:"bip21"`
	Signature HexString `json:"signature"`

	Error string `json:"error"`
}

type ReversePair

type ReversePair struct {
	Hash   string  `json:"hash"`
	Rate   float64 `json:"rate"`
	Limits struct {
		Minimal uint64 `json:"minimal"`
		Maximal uint64 `json:"maximal"`
	} `json:"limits"`
	Fees struct {
		Percentage float64 `json:"percentage"`
		MinerFees  struct {
			Lockup uint64 `json:"lockup"`
			Claim  uint64 `json:"claim"`
		} `json:"minerFees"`
	} `json:"fees"`
}

type ReversePairs

type ReversePairs map[Currency]map[Currency]ReversePair

type SerializedLeaf

type SerializedLeaf struct {
	Version txscript.TapscriptLeafVersion `json:"version"`
	Output  HexString                     `json:"output"`
}

func (*SerializedLeaf) Deserialize

func (leaf *SerializedLeaf) Deserialize() TapLeaf

type SerializedTree

type SerializedTree struct {
	ClaimLeaf  SerializedLeaf `json:"claimLeaf"`
	RefundLeaf SerializedLeaf `json:"refundLeaf"`
}

func (*SerializedTree) Deserialize

func (tree *SerializedTree) Deserialize() *SwapTree

type SetInvoiceRequest

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

type SetInvoiceResponse

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

type SubmarinePair

type SubmarinePair struct {
	Hash   string  `json:"hash"`
	Rate   float64 `json:"rate"`
	Limits struct {
		Minimal               uint64 `json:"minimal"`
		Maximal               uint64 `json:"maximal"`
		MaximalZeroConfAmount uint64 `json:"maximalZeroConf"`
	} `json:"limits"`
	Fees struct {
		Percentage float64 `json:"percentage"`
		MinerFees  uint64  `json:"minerFees"`
	} `json:"fees"`
}

type SubmarinePairs

type SubmarinePairs map[Currency]map[Currency]SubmarinePair

type SwapClaimDetails

type SwapClaimDetails struct {
	PubNonce        HexString `json:"pubNonce"`
	TransactionHash HexString `json:"transactionHash"`
	Preimage        HexString `json:"preimage"`
	PublicKey       HexString `json:"publicKey"`

	Error string `json:"error"`
}

type SwapStatusResponse

type SwapStatusResponse struct {
	Status           string `json:"status"`
	ZeroConfRejected bool   `json:"zeroConfRejected"`
	Transaction      struct {
		Id  string `json:"id"`
		Hex string `json:"hex"`
	} `json:"transaction"`

	Error string `json:"error"`
}

type SwapTree

type SwapTree struct {
	ClaimLeaf  TapLeaf
	RefundLeaf TapLeaf
	// contains filtered or unexported fields
}

func (*SwapTree) Address

func (tree *SwapTree) Address(network *Network, blindingPubKey *btcec.PublicKey) (string, error)

func (*SwapTree) Check

func (tree *SwapTree) Check(
	swapType SwapType,
	timeoutBlockHeight uint32,
	preimageHash []byte,
) error

func (*SwapTree) CheckAddress

func (tree *SwapTree) CheckAddress(expected string, network *Network, blindingPubKey *btcec.PublicKey) error

func (*SwapTree) GetControlBlock

func (tree *SwapTree) GetControlBlock(isRefund bool) ([]byte, error)

func (*SwapTree) GetLeaf

func (tree *SwapTree) GetLeaf(isRefund bool) TapLeaf

func (*SwapTree) GetLeafHash

func (tree *SwapTree) GetLeafHash(isRefund bool) chainhash.Hash

func (*SwapTree) Init

func (tree *SwapTree) Init(
	isLiquid bool,
	isClaim bool,
	ourKey *btcec.PrivateKey,
	boltzKey *btcec.PublicKey,
) error

func (*SwapTree) PubKey

func (tree *SwapTree) PubKey() *btcec.PublicKey

func (*SwapTree) Serialize

func (tree *SwapTree) Serialize() *SerializedTree

type SwapType

type SwapType string
const (
	NormalSwap  SwapType = "submarine"
	ReverseSwap SwapType = "reverse"
	ChainSwap   SwapType = "chain"
)

func ParseSwapType

func ParseSwapType(swapType string) (SwapType, error)

type SwapUpdate

type SwapUpdate struct {
	SwapStatusResponse `mapstructure:",squash"`
	Id                 string `json:"id"`
}

type SwapUpdateEvent

type SwapUpdateEvent int
const (
	SwapCreated SwapUpdateEvent = iota
	SwapExpired

	InvoiceSet
	InvoicePaid
	InvoicePending
	InvoiceSettled
	InvoiceFailedToPay

	ChannelCreated

	TransactionFailed
	TransactionMempool
	TransactionClaimed
	TransactionRefunded
	TransactionConfirmed
	TransactionLockupFailed
	TransactionClaimPending

	TransactionServerMempoool
	TransactionServerConfirmed

	TransactionDirect
	TransactionDirectMempool
)

func ParseEvent

func ParseEvent(event string) SwapUpdateEvent

func (SwapUpdateEvent) IsCompletedStatus

func (event SwapUpdateEvent) IsCompletedStatus() bool

func (SwapUpdateEvent) IsFailedStatus

func (event SwapUpdateEvent) IsFailedStatus() bool

func (SwapUpdateEvent) String

func (event SwapUpdateEvent) String() string

type TapLeaf

type TapLeaf = txscript.TapLeaf

type Transaction

type Transaction interface {
	Hash() string
	Serialize() (string, error)
	VSize() uint64
	FindVout(network *Network, address string) (uint32, uint64, error)
	VoutValue(vout uint32) (uint64, error)
}

func NewTxFromHex

func NewTxFromHex(currency Currency, hexString string, ourOutputBlindingKey *btcec.PrivateKey) (Transaction, error)

type TxSizes

type TxSizes struct {
	NormalClaim   uint64
	ReverseLockup uint64
	ReverseClaim  uint64
}

type Websocket

type Websocket struct {
	Updates chan SwapUpdate
	// contains filtered or unexported fields
}

func (*Websocket) Close

func (boltz *Websocket) Close() error

func (*Websocket) Connect

func (boltz *Websocket) Connect() error

func (*Websocket) Reconnect

func (boltz *Websocket) Reconnect() error

func (*Websocket) Subscribe

func (boltz *Websocket) Subscribe(swapIds []string) error

func (*Websocket) Unsubscribe

func (boltz *Websocket) Unsubscribe(swapId string)

Jump to

Keyboard shortcuts

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