rfq

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const Kind = "rfq"

Kind identifies this message kind

Variables

This section is empty.

Functions

func ValidNext added in v0.11.0

func ValidNext() []string

ValidNext returns the valid message kinds that can follow a RFQ.

Types

type ClaimsSet

type ClaimsSet []string

ClaimsSet is a set of claims

func (ClaimsSet) Scrub

func (c ClaimsSet) Scrub(salt string, privateData *PrivateData) (string, error)

Scrub extracts claims from the payin method and replaces it with a hash

type CreateOption

type CreateOption func(*createOptions)

CreateOption is a function type used to apply options to RFQ creation.

func Claims

func Claims(claims []string) CreateOption

Claims can be passed to Create to provide claims if required by the offering.

func CreatedAt

func CreatedAt(t time.Time) CreateOption

CreatedAt can be passed to Create to provide a custom created at time.

func ExternalID

func ExternalID(externalID string) CreateOption

ExternalID can be passed to Create to provide a custom external id.

func ID

func ID(id string) CreateOption

ID can be passed to Create to provide a custom id.

type Data

type Data struct {
	OfferingID string               `json:"offeringId"`
	Payin      ScrubbedPayinMethod  `json:"payin"`
	Payout     ScrubbedPayoutMethod `json:"payout"`
	ClaimsHash string               `json:"claimsHash,omitempty"`
}

Data encapsulates the data content of a request for quote.

type PayinMethod

type PayinMethod struct {
	Amount         string               `json:"amount"`
	Kind           string               `json:"kind"`
	PaymentDetails PaymentMethodDetails `json:"paymentDetails"`
}

PayinMethod is used to create the payin method for an RFQ

func Payin

func Payin(amount, kind string, opts ...PaymentMethodOption) PayinMethod

Payin can be passed to Create to provide a payin method.

func (*PayinMethod) Scrub

func (p *PayinMethod) Scrub(salt string, privateData *PrivateData) (ScrubbedPayinMethod, error)

Scrub extracts the private data from the payin method and replaces it with a hash

type PaymentMethodDetails

type PaymentMethodDetails map[string]any

PaymentMethodDetails is a map populated with the required payment details specified by an offering

type PaymentMethodOption

type PaymentMethodOption func(*paymentMethodOptions)

PaymentMethodOption is a function type used to apply options to payment methods.

func PaymentDetails

func PaymentDetails(details map[string]any) PaymentMethodOption

PaymentDetails can be passed to Payin or Payout to provide arbitrary payment details.

type PayoutMethod

type PayoutMethod struct {
	Kind           string               `json:"kind"`
	PaymentDetails PaymentMethodDetails `json:"paymentDetails"`
}

PayoutMethod is used to create the payout method for an RFQ

func Payout

func Payout(kind string, opts ...PaymentMethodOption) PayoutMethod

Payout can be passed to Create to provide a payout method.

func (*PayoutMethod) Scrub

func (p *PayoutMethod) Scrub(salt string, privateData *PrivateData) (ScrubbedPayoutMethod, error)

Scrub extracts the private data from the payout method and replaces it with a hash

type PrivateData

type PrivateData struct {
	Salt   string                `json:"salt,omitempty"`
	Claims []string              `json:"claims,omitempty"`
	Payin  PrivatePaymentDetails `json:"payin,omitempty"`
	Payout PrivatePaymentDetails `json:"payout,omitempty"`
}

PrivateData contains data which can be detached from the payload without disrupting integrity.

func (PrivateData) IsZero

func (p PrivateData) IsZero() bool

IsZero checks if struct is empty

type PrivatePaymentDetails

type PrivatePaymentDetails struct {
	PaymentDetails PaymentMethodDetails `json:"paymentDetails,omitempty"`
}

PrivatePaymentDetails contains the private payment details. used in PrivateData

type RFQ

type RFQ struct {
	Metadata    message.Metadata `json:"metadata,omitempty"`
	Data        Data             `json:"data,omitempty"`
	PrivateData *PrivateData     `json:"privateData,omitempty"`
	Signature   string           `json:"signature,omitempty"`
}

RFQ represents a request for quote message within the exchange.

func Create

func Create(fromDID did.BearerDID, to, offeringID string, payin PayinMethod, payout PayoutMethod, opts ...CreateOption) (RFQ, error)

Create creates an RFQ

An RFQ is a resource created by a customer of the PFI to request a quote

func Parse added in v0.10.0

func Parse(data []byte, privateDataStrict bool) (RFQ, error)

Parse validates, parses input data into an RFQ, and verifies the signature and private data.

func (RFQ) Digest

func (r RFQ) Digest() ([]byte, error)

Digest computes a hash of the rfq

func (RFQ) GetKind added in v0.13.0

func (r RFQ) GetKind() string

GetKind returns the kind of message

func (RFQ) GetMetadata added in v0.13.0

func (r RFQ) GetMetadata() message.Metadata

GetMetadata returns the metadata of the message

func (RFQ) GetValidNext added in v0.13.0

func (r RFQ) GetValidNext() []string

GetValidNext returns the valid message kinds that can follow a RFQ.

func (*RFQ) UnmarshalJSON

func (r *RFQ) UnmarshalJSON(data []byte) error

UnmarshalJSON validates and unmarshals the input data into an RFQ.

func (*RFQ) Verify added in v0.8.0

func (r *RFQ) Verify(privateDataStrict bool) error

Verify verifies the signature and private data hashes of the RFQ.

type ScrubbedPayinMethod

type ScrubbedPayinMethod struct {
	Amount             string `json:"amount"`
	Kind               string `json:"kind"`
	PaymentDetailsHash string `json:"paymentDetailsHash,omitempty"`
}

ScrubbedPayinMethod represents the chosen method for the pay-in

type ScrubbedPayoutMethod

type ScrubbedPayoutMethod struct {
	Kind               string `json:"kind"`
	PaymentDetailsHash string `json:"paymentDetailsHash,omitempty"`
}

ScrubbedPayoutMethod represents the chosen method for the pay-out

Jump to

Keyboard shortcuts

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