bridge

package
v0.0.0-...-b1bd2f5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// PaymentCannotResolveDestination is an error response
	PaymentCannotResolveDestination = &helpers.ErrorResponse{Code: "cannot_resolve_destination", Message: "Cannot resolve federated Stellar address.", Status: http.StatusBadRequest}
	// PaymentCannotUseMemo is an error response
	PaymentCannotUseMemo = &helpers.ErrorResponse{Code: "cannot_use_memo", Message: "Memo given in request but federation returned memo fields.", Status: http.StatusBadRequest}
	// PaymentSourceNotExist is an error response
	PaymentSourceNotExist = &helpers.ErrorResponse{Code: "source_not_exist", Message: "Source account does not exist.", Status: http.StatusBadRequest}
	// PaymentAssetCodeNotAllowed is an error response
	PaymentAssetCodeNotAllowed = &helpers.ErrorResponse{Code: "asset_code_not_allowed", Message: "Given asset_code not allowed.", Status: http.StatusBadRequest}

	// PaymentPending is an error response
	PaymentPending = &helpers.ErrorResponse{Code: "pending", Message: "Transaction pending. Repeat your request after given time.", Status: http.StatusAccepted}
	// PaymentDenied is an error response
	PaymentDenied = &helpers.ErrorResponse{Code: "denied", Message: "Transaction denied by destination.", Status: http.StatusForbidden}
)

Functions

func NewPaymentPendingError

func NewPaymentPendingError(seconds int) *helpers.ErrorResponse

NewPaymentPendingError creates a new PaymentPending error

Types

type AccountMergeOperationBody

type AccountMergeOperationBody struct {
	Source      *string
	Destination string
}

AccountMergeOperationBody represents account_merge operation

func (AccountMergeOperationBody) ToTransactionMutator

func (op AccountMergeOperationBody) ToTransactionMutator() b.TransactionMutator

ToTransactionMutator returns stellar/go TransactionMutator

func (AccountMergeOperationBody) Validate

func (op AccountMergeOperationBody) Validate() error

Validate validates if operation body is valid.

type AllowTrustOperationBody

type AllowTrustOperationBody struct {
	Source    *string
	AssetCode string `json:"asset_code"`
	Trustor   string
	Authorize bool
}

AllowTrustOperationBody represents allow_trust operation

func (AllowTrustOperationBody) ToTransactionMutator

func (op AllowTrustOperationBody) ToTransactionMutator() b.TransactionMutator

ToTransactionMutator returns stellar/go TransactionMutator

func (AllowTrustOperationBody) Validate

func (op AllowTrustOperationBody) Validate() error

Validate validates if operation body is valid.

type AuthorizeRequest

type AuthorizeRequest struct {
	AccountID string `form:"account_id" valid:"required,stellar_accountid"`
	AssetCode string `form:"asset_code" valid:"required,stellar_asset_code"`
}

AuthorizeRequest represents request made to /authorize endpoint of bridge server

func (AuthorizeRequest) Validate

func (r AuthorizeRequest) Validate(params ...interface{}) error

type BuilderRequest

type BuilderRequest struct {
	Source         string
	SequenceNumber string `json:"sequence_number"`
	Operations     []Operation
	Signers        []string
}

BuilderRequest represents request made to /builder endpoint of bridge server

func (BuilderRequest) Process

func (r BuilderRequest) Process() error

Process parses operations and creates OperationBody object for each operation

func (BuilderRequest) Validate

func (r BuilderRequest) Validate() error

Validate validates if the request is correct.

type BuilderResponse

type BuilderResponse struct {
	helpers.SuccessResponse
	TransactionEnvelope string `json:"transaction_envelope"`
}

BuilderResponse represents response returned by /builder endpoint of bridge server

func (*BuilderResponse) Marshal

func (response *BuilderResponse) Marshal() ([]byte, error)

Marshal marshals BuilderResponse

type ChangeTrustOperationBody

type ChangeTrustOperationBody struct {
	Source *string
	Asset  protocols.Asset
	// nil means max limit
	Limit *string
}

ChangeTrustOperationBody represents change_trust operation

func (ChangeTrustOperationBody) ToTransactionMutator

func (op ChangeTrustOperationBody) ToTransactionMutator() b.TransactionMutator

ToTransactionMutator returns go-stellar-base TransactionMutator

func (ChangeTrustOperationBody) Validate

func (op ChangeTrustOperationBody) Validate() error

Validate validates if operation body is valid.

type CreateAccountOperationBody

type CreateAccountOperationBody struct {
	Source          *string
	Destination     string
	StartingBalance string `json:"starting_balance"`
}

CreateAccountOperationBody represents create_account operation

func (CreateAccountOperationBody) ToTransactionMutator

func (op CreateAccountOperationBody) ToTransactionMutator() b.TransactionMutator

ToTransactionMutator returns go-stellar-base TransactionMutator

func (CreateAccountOperationBody) Validate

func (op CreateAccountOperationBody) Validate() error

Validate validates if operation body is valid.

type InflationOperationBody

type InflationOperationBody struct {
	Source *string
}

InflationOperationBody represents inflation operation

func (InflationOperationBody) ToTransactionMutator

func (op InflationOperationBody) ToTransactionMutator() b.TransactionMutator

ToTransactionMutator returns go-stellar-base TransactionMutator

func (InflationOperationBody) Validate

func (op InflationOperationBody) Validate() error

Validate validates if operation body is valid.

type ManageDataOperationBody

type ManageDataOperationBody struct {
	Source *string
	Name   string
	Data   string
}

ManageDataOperationBody represents manage_data operation

func (ManageDataOperationBody) ToTransactionMutator

func (op ManageDataOperationBody) ToTransactionMutator() b.TransactionMutator

ToTransactionMutator returns go-stellar-base TransactionMutator

func (ManageDataOperationBody) Validate

func (op ManageDataOperationBody) Validate() error

Validate validates if operation body is valid.

type ManageOfferOperationBody

type ManageOfferOperationBody struct {
	PassiveOffer bool `json:"-"`
	Source       *string
	Selling      protocols.Asset
	Buying       protocols.Asset
	Amount       string
	Price        string
	OfferID      *string `json:"offer_id"`
}

ManageOfferOperationBody represents manage_offer operation

func (ManageOfferOperationBody) ToTransactionMutator

func (op ManageOfferOperationBody) ToTransactionMutator() b.TransactionMutator

ToTransactionMutator returns go-stellar-base TransactionMutator

func (ManageOfferOperationBody) Validate

func (op ManageOfferOperationBody) Validate() error

Validate validates if operation body is valid.

type Operation

type Operation struct {
	Type    OperationType
	RawBody json.RawMessage `json:"body"` // Delay parsing until we know operation type
	Body    OperationBody   `json:"-"`    // Created during processing stage
}

Operation struct contains operation type and body

type OperationBody

type OperationBody interface {
	ToTransactionMutator() b.TransactionMutator
	Validate() error
}

OperationBody interface is a common interface for builder operations

type OperationType

type OperationType string

OperationType is the type of operation

const (
	// OperationTypeCreateAccount represents create_account operation
	OperationTypeCreateAccount OperationType = "create_account"
	// OperationTypePayment represents payment operation
	OperationTypePayment OperationType = "payment"
	// OperationTypePathPayment represents path_payment operation
	OperationTypePathPayment OperationType = "path_payment"
	// OperationTypeManageOffer represents manage_offer operation
	OperationTypeManageOffer OperationType = "manage_offer"
	// OperationTypeCreatePassiveOffer represents create_passive_offer operation
	OperationTypeCreatePassiveOffer OperationType = "create_passive_offer"
	// OperationTypeSetOptions represents set_options operation
	OperationTypeSetOptions OperationType = "set_options"
	// OperationTypeChangeTrust represents change_trust operation
	OperationTypeChangeTrust OperationType = "change_trust"
	// OperationTypeAllowTrust represents allow_trust operation
	OperationTypeAllowTrust OperationType = "allow_trust"
	// OperationTypeAccountMerge represents account_merge operation
	OperationTypeAccountMerge OperationType = "account_merge"
	// OperationTypeInflation represents inflation operation
	OperationTypeInflation OperationType = "inflation"
	// OperationTypeManageData represents manage_data operation
	OperationTypeManageData OperationType = "manage_data"
)

type PathPaymentOperationBody

type PathPaymentOperationBody struct {
	Source *string

	SendMax   string          `json:"send_max"`
	SendAsset protocols.Asset `json:"send_asset"`

	Destination       string
	DestinationAmount string          `json:"destination_amount"`
	DestinationAsset  protocols.Asset `json:"destination_asset"`

	Path []protocols.Asset
}

PathPaymentOperationBody represents path_payment operation

func (*PathPaymentOperationBody) FromRequestSpecial

func (op *PathPaymentOperationBody) FromRequestSpecial(r *http.Request, destination interface{}) error

ToValuesSpecial converts special values from http.Request to struct

func (PathPaymentOperationBody) ToTransactionMutator

func (op PathPaymentOperationBody) ToTransactionMutator() b.TransactionMutator

ToTransactionMutator returns go-stellar-base TransactionMutator

func (PathPaymentOperationBody) ToValuesSpecial

func (op PathPaymentOperationBody) ToValuesSpecial(values url.Values)

ToValuesSpecial adds special values (not easily convertable) to given url.Values

func (PathPaymentOperationBody) Validate

func (op PathPaymentOperationBody) Validate() error

Validate validates if operation body is valid.

type PaymentOperationBody

type PaymentOperationBody struct {
	Source      *string
	Destination string
	Amount      string
	Asset       protocols.Asset
}

PaymentOperationBody represents payment operation

func (PaymentOperationBody) ToTransactionMutator

func (op PaymentOperationBody) ToTransactionMutator() b.TransactionMutator

ToTransactionMutator returns go-stellar-base TransactionMutator

func (PaymentOperationBody) Validate

func (op PaymentOperationBody) Validate() error

Validate validates if operation body is valid.

type PaymentRequest

type PaymentRequest struct {
	// Payment ID
	ID string `form:"id" valid:"optional"`
	// Source account secret
	Source string `form:"source" valid:"optional,stellar_seed"`
	// Sender address (like alice*stellar.org)
	Sender string `form:"sender" valid:"optional,stellar_address"`
	// Destination address (like bob*stellar.org)
	Destination string `form:"destination" valid:"optional,stellar_destination"`
	// ForwardDestination
	ForwardDestination *protocols.ForwardDestination `form:"forward_destination" valid:"-"`
	// Memo type
	MemoType string `form:"memo_type" valid:"optional"`
	// Memo value
	Memo string `form:"memo" valid:"optional"`
	// Amount destination should receive
	Amount string `form:"amount" valid:"required,stellar_amount"`
	// Code of the asset destination should receive
	AssetCode string `form:"asset_code" valid:"optional,stellar_asset_code"`
	// Issuer of the asset destination should receive
	AssetIssuer string `form:"asset_issuer" valid:"optional,stellar_accountid"`
	// Only for path_payment
	SendMax string `form:"send_max" valid:"optional,stellar_amount"`
	// Only for path_payment
	SendAssetCode string `form:"send_asset_code" valid:"optional,stellar_asset_code"`
	// Only for path_payment
	SendAssetIssuer string `form:"send_asset_issuer" valid:"optional,stellar_accountid"`
	// path[n][asset_code] path[n][asset_issuer]
	Path []protocols.Asset `form:"path" valid:"optional"`
	// Determined whether to use compliance protocol or to send a simple payment.
	UseCompliance bool `form:"use_compliance" valid:"-"`
	// Extra memo. If set, UseCompliance value will be ignored and it will use compliance.
	ExtraMemo string `form:"extra_memo" valid:"-"`
}

PaymentRequest represents request made to /payment endpoint of the bridge server

func (*PaymentRequest) FromRequestSpecial

func (request *PaymentRequest) FromRequestSpecial(r *http.Request, destination interface{}) error

ToValuesSpecial converts special values from http.Request to struct

func (*PaymentRequest) ToComplianceSendRequest

func (request *PaymentRequest) ToComplianceSendRequest() *complianceServer.SendRequest

ToComplianceSendRequest transforms PaymentRequest to complianceServer.SendRequest

func (PaymentRequest) ToValuesSpecial

func (request PaymentRequest) ToValuesSpecial(values url.Values)

ToValuesSpecial adds special values (not easily convertable) to given url.Values

func (*PaymentRequest) Validate

func (request *PaymentRequest) Validate(params ...interface{}) error

Validate is additional validation method to validate special fields.

type ReprocessRequest

type ReprocessRequest struct {
	OperationID string `form:"operation_id" valid:"required"`
	// Force is required for reprocessing successful payments. Please use with caution!
	Force bool `form:"force" valid:"-"`
}

ReprocessRequest represents request made to /reprocess endpoint of bridge server

func (ReprocessRequest) Validate

func (r ReprocessRequest) Validate(params ...interface{}) error

type ReprocessResponse

type ReprocessResponse struct {
	Status  string `json:"status"`
	Message string `json:"message,omitempty"`
}

ReprocessResponse represents a response returned by /reprocess endpoint

func (ReprocessResponse) HTTPStatus

func (r ReprocessResponse) HTTPStatus() int

func (ReprocessResponse) Marshal

func (r ReprocessResponse) Marshal() ([]byte, error)

type SetOptionsOperationBody

type SetOptionsOperationBody struct {
	Source          *string
	InflationDest   *string           `json:"inflation_dest"`
	SetFlags        *[]int            `json:"set_flags"`
	ClearFlags      *[]int            `json:"clear_flags"`
	MasterWeight    *uint32           `json:"master_weight"`
	LowThreshold    *uint32           `json:"low_threshold"`
	MediumThreshold *uint32           `json:"medium_threshold"`
	HighThreshold   *uint32           `json:"high_threshold"`
	HomeDomain      *string           `json:"home_domain"`
	Signer          *SetOptionsSigner `json:"signer"`
}

SetOptionsOperationBody represents set_options operation

func (SetOptionsOperationBody) ToTransactionMutator

func (op SetOptionsOperationBody) ToTransactionMutator() b.TransactionMutator

ToTransactionMutator returns go-stellar-base TransactionMutator

func (SetOptionsOperationBody) Validate

func (op SetOptionsOperationBody) Validate() error

Validate validates if operation body is valid.

type SetOptionsSigner

type SetOptionsSigner struct {
	PublicKey string `json:"public_key"`
	Weight    uint32 `json:"weight"`
}

SetOptionsSigner is a struct that representing signer in SetOptions operation body

Jump to

Keyboard shortcuts

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