swap

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCodeInvalidSwapRequest = iota
	ErrCodeRejectedSwapRequest
	ErrCodeFailedToComplete
	ErrCodeInvalidTransaction
	ErrCodeBadPricingSwapRequest
	ErrCodeAborted
	ErrCodeFailedToBroadcast
)

Variables

This section is empty.

Functions

func Accept

func Accept(opts AcceptOpts) (string, []byte, error)

Accept takes a AcceptOpts and returns the id of the SwapAccept entity and its serialized version

func Complete

func Complete(opts CompleteOpts) (string, []byte, error)

Complete takes a CompleteOpts and returns the id of the SwapComplete entity and its serialized version

func Fail

func Fail(opts FailOpts) (string, []byte, error)

func FailV1 added in v1.0.0

func FailV1(opts FailOpts) (string, []byte, error)

func Request

func Request(opts RequestOpts) ([]byte, error)

Request takes a RequestOpts struct and returns a serialized protobuf message.

func ValidateCompletePset

func ValidateCompletePset(opts ValidateCompletePsetOpts) error

ValidateCompletePset takes a VerifyCompeltePsetOpts and returns whether the final signed pset matches the original SwapRequest message

Types

type AcceptOpts

type AcceptOpts struct {
	Message            []byte
	Transaction        string
	InputBlindingKeys  map[string][]byte
	OutputBlindingKeys map[string][]byte
	UnblindedInputs    []UnblindedInput
}

AcceptOpts is the struct given to Accept method

type CompleteOpts

type CompleteOpts struct {
	Message     []byte
	Transaction string
}

CompleteOpts is the struct given to the Complete method

type FailOpts

type FailOpts struct {
	MessageID string
	ErrCode   int
}

type RequestOpts

type RequestOpts struct {
	Id                 string
	AssetToSend        string
	AmountToSend       uint64
	AssetToReceive     string
	AmountToReceive    uint64
	Transaction        string
	InputBlindingKeys  map[string][]byte
	OutputBlindingKeys map[string][]byte
	UnblindedInputs    []UnblindedInput
	// Fee asset and amount are not (de)serialized, they're used only to check
	// that the amounts of the swap request match those of the PSETv2 tx.
	FeeAsset  string
	FeeAmount uint64
}

RequestOpts is the struct to be given to the Request method

type UnblindedInput added in v1.0.0

type UnblindedInput struct {
	Index         uint32
	Asset         string
	Amount        uint64
	AssetBlinder  string
	AmountBlinder string
}

type ValidateCompletePsetOpts

type ValidateCompletePsetOpts struct {
	PsetBase64         string
	InputBlindingKeys  map[string][]byte
	OutputBlindingKeys map[string][]byte
	SwapRequest        *tdexv1.SwapRequest
}

ValidateCompletePsetOpts is the struct given to the ValidateCompletePset method

Jump to

Keyboard shortcuts

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