bridge

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2018 License: Apache-2.0, BSD-2-Clause-Views, MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AllowTrustMalformed is an error response
	AllowTrustMalformed = &protocols.ErrorResponse{Code: "allow_trust_malformed", Message: "Asset name is malformed.", Status: http.StatusBadRequest}
	// AllowTrustNoTrustline is an error response
	AllowTrustNoTrustline = &protocols.ErrorResponse{Code: "allow_trust_no_trustline", Message: "Trustor does not have a trustline yet.", Status: http.StatusBadRequest}
	// AllowTrustTrustNotRequired is an error response
	AllowTrustTrustNotRequired = &protocols.ErrorResponse{Code: "allow_trust_trust_not_required", Message: "Authorizing account does not require allowing trust. Set AUTH_REQUIRED_FLAG on your account to use this feature.", Status: http.StatusBadRequest}
	// AllowTrustCantRevoke is an error response
	AllowTrustCantRevoke = &protocols.ErrorResponse{Code: "allow_trust_cant_revoke", Message: "Authorizing account has AUTH_REVOCABLE_FLAG set. Can't revoke the trustline.", Status: http.StatusBadRequest}
)
View Source
var (
	// TransactionBadSequence is an error response
	TransactionBadSequence = &protocols.ErrorResponse{Code: "transaction_bad_seq", Message: "Bad Sequence. Please, try again.", Status: http.StatusBadRequest}
	// TransactionBadAuth is an error response
	TransactionBadAuth = &protocols.ErrorResponse{Code: "transaction_bad_auth", Message: "Invalid network or too few signatures.", Status: http.StatusBadRequest}
	// TransactionInsufficientBalance is an error response
	TransactionInsufficientBalance = &protocols.ErrorResponse{Code: "transaction_insufficient_balance", Message: "Transaction fee would bring account below reserve.", Status: http.StatusBadRequest}
	// TransactionNoAccount is an error response
	TransactionNoAccount = &protocols.ErrorResponse{Code: "transaction_no_account", Message: "Source account not found.", Status: http.StatusBadRequest}
	// TransactionInsufficientFee is an error response
	TransactionInsufficientFee = &protocols.ErrorResponse{Code: "transaction_insufficient_fee", Message: "Transaction fee is too small.", Status: http.StatusBadRequest}
	// TransactionBadAuthExtra is an error response
	TransactionBadAuthExtra = &protocols.ErrorResponse{Code: "transaction_bad_auth_extra", Message: "Unused signatures attached to transaction.", Status: http.StatusBadRequest}
)
View Source
var (

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

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

	// PaymentMalformed is an error response
	PaymentMalformed = &protocols.ErrorResponse{Code: "payment_malformed", Message: "Operation is malformed.", Status: http.StatusBadRequest}
	// PaymentUnderfunded is an error response
	PaymentUnderfunded = &protocols.ErrorResponse{Code: "payment_underfunded", Message: "Not enough funds to send this transaction.", Status: http.StatusBadRequest}
	// PaymentSrcNoTrust is an error response
	PaymentSrcNoTrust = &protocols.ErrorResponse{Code: "payment_src_no_trust", Message: "No trustline on source account.", Status: http.StatusBadRequest}
	// PaymentSrcNotAuthorized is an error response
	PaymentSrcNotAuthorized = &protocols.ErrorResponse{Code: "payment_src_not_authorized", Message: "Source not authorized to transfer.", Status: http.StatusBadRequest}
	// PaymentNoDestination is an error response
	PaymentNoDestination = &protocols.ErrorResponse{Code: "payment_no_destination", Message: "Destination account does not exist.", Status: http.StatusBadRequest}
	// PaymentNoTrust is an error response
	PaymentNoTrust = &protocols.ErrorResponse{Code: "payment_no_trust", Message: "Destination missing a trust line for asset.", Status: http.StatusBadRequest}
	// PaymentNotAuthorized is an error response
	PaymentNotAuthorized = &protocols.ErrorResponse{Code: "payment_not_authorized", Message: "Destination not authorized to trust asset. It needs to be allowed first by using /authorize endpoint.", Status: http.StatusBadRequest}
	// PaymentLineFull is an error response
	PaymentLineFull = &protocols.ErrorResponse{Code: "payment_line_full", Message: "Sending this payment would make a destination go above their limit.", Status: http.StatusBadRequest}
	// PaymentNoIssuer is an error response
	PaymentNoIssuer = &protocols.ErrorResponse{Code: "payment_no_issuer", Message: "Missing issuer on asset.", Status: http.StatusBadRequest}
	// PaymentTooFewOffers is an error response
	PaymentTooFewOffers = &protocols.ErrorResponse{Code: "payment_too_few_offers", Message: "Not enough offers to satisfy path.", Status: http.StatusBadRequest}
	// PaymentOfferCrossSelf is an error response
	PaymentOfferCrossSelf = &protocols.ErrorResponse{Code: "payment_offer_cross_self", Message: "would cross one of its own offers.", Status: http.StatusBadRequest}
	// PaymentOverSendmax is an error response
	PaymentOverSendmax = &protocols.ErrorResponse{Code: "payment_over_sendmax", Message: "Could not satisfy sendmax.", Status: http.StatusBadRequest}
)

Functions

func ErrorFromHorizonResponse

func ErrorFromHorizonResponse(response horizon.SubmitTransactionResponse) *protocols.ErrorResponse

ErrorFromHorizonResponse checks if horizon.SubmitTransactionResponse is an error response and creates ErrorResponse for it

func NewPaymentPendingError

func NewPaymentPendingError(seconds int) *protocols.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 `name:"account_id" required:""`
	AssetCode string `name:"asset_code" required:""`

	protocols.FormRequest
}

AuthorizeRequest represents request made to /authorize endpoint of bridge server

func (*AuthorizeRequest) FromRequest

func (request *AuthorizeRequest) FromRequest(r *http.Request) error

FromRequest will populate request fields using http.Request.

func (*AuthorizeRequest) ToValues

func (request *AuthorizeRequest) ToValues() url.Values

ToValues will create url.Values from request.

func (*AuthorizeRequest) Validate

func (request *AuthorizeRequest) Validate(allowedAssets []config.Asset, issuingAccountID string) error

Validate validates if request fields are valid. Useful when checking if a request is correct.

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 {
	protocols.SuccessResponse
	TransactionEnvelope string `json:"transaction_envelope"`
}

BuilderResponse represents response returned by /builder endpoint of bridge server

func (*BuilderResponse) Marshal

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

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) ToTransactionMutator

func (op PathPaymentOperationBody) ToTransactionMutator() b.TransactionMutator

ToTransactionMutator returns go-stellar-base TransactionMutator

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 `name:"id"`
	// Source account secret
	Source string `name:"source"`
	// Sender address (like alice*stellar.org)
	Sender string `name:"sender"`
	// Destination address (like bob*stellar.org)
	Destination string `name:"destination"`
	// ForwardDestination
	ForwardDestination *protocols.ForwardDestination `name:"forward_destination"`
	// Memo type
	MemoType string `name:"memo_type"`
	// Memo value
	Memo string `name:"memo"`
	// Amount destination should receive
	Amount string `name:"amount" required:""`
	// Code of the asset destination should receive
	AssetCode string `name:"asset_code"`
	// Issuer of the asset destination should receive
	AssetIssuer string `name:"asset_issuer"`
	// Only for path_payment
	SendMax string `name:"send_max"`
	// Only for path_payment
	SendAssetCode string `name:"send_asset_code"`
	// Only for path_payment
	SendAssetIssuer string `name:"send_asset_issuer"`
	// path[n][asset_code] path[n][asset_issuer]
	Path []protocols.Asset `name:"path"`
	// Determined whether to use compliance protocol or to send a simple payment.
	UseCompliance bool `name:"use_compliance"`
	// Extra memo. If set, UseCompliance value will be ignored and it will use compliance.
	ExtraMemo string `name:"extra_memo"`

	protocols.FormRequest
}

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

func (*PaymentRequest) FromRequest

func (request *PaymentRequest) FromRequest(r *http.Request) error

FromRequest will populate request fields using http.Request.

func (*PaymentRequest) ToComplianceSendRequest

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

ToComplianceSendRequest transforms PaymentRequest to callback.SendRequest

func (*PaymentRequest) ToValues

func (request *PaymentRequest) ToValues() url.Values

ToValues will create url.Values from request.

func (*PaymentRequest) Validate

func (request *PaymentRequest) Validate() error

Validate validates if request fields are valid. Useful when checking if a request is correct.

type ReprocessRequest

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

	protocols.FormRequest
}

ReprocessRequest represents request made to /reprocess endpoint of bridge server

func (*ReprocessRequest) FromRequest

func (request *ReprocessRequest) FromRequest(r *http.Request) error

FromRequest will populate request fields using http.Request.

func (*ReprocessRequest) ToValues

func (request *ReprocessRequest) ToValues() url.Values

ToValues will create url.Values from request.

func (*ReprocessRequest) Validate

func (request *ReprocessRequest) Validate() error

Validate validates if request fields are valid. Useful when checking if a request is correct.

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

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