compliance

package
v0.0.29 Latest Latest
Warning

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

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

Documentation

Overview

Package compliance contains message structures required to implement compliance protocol.

You can check compliance protocol doc here: https://www.stellar.org/developers/learn/integration-guides/compliance-protocol.html

Sending a payment

When you want to send payment using compliance protocol you need to send additional `sender` and `extra_memo` fields to the `/payment` endpoint.

Stellar    Bridge                            Compliance                             Acme Bank
   |          |                                    |                                    |
   |          |      compliance.HandlerSend()      |                                    |
   |          |               /send                |                                    |
   |          |       compliance.SendRequest       |                                    |
   |          □----------------------------------->□~~~ - Builds transaction            |
   |          □                                    □    - Gets AuthServer from          |
   |          □                                    □      stellar.toml file             |
   |          □                                    □    - Sends request to receiver     |
   |          □                                    □      AuthServer                    |
   |          □                                    □                                    |
   |          □                                    □       compliance.AuthRequest       □
   |          □                                    □----------------------------------->□~~~ - Performs KYC
   |          □                                    □                                    □    - Saves the memo preimage
   |          □                                    □       compliance.AuthResponse      □
   |          □      compliance.SendResponse       □<-----------------------------------□
   |          □<-----------------------------------□                                    |
   |          □~~~ - Signs the transaction         |                                    |
   |          □      returned by compliance        |                                    |
   |          □      server                        |                                    |
   |          □    - Submits a transaction to      |                                    |
   |          □      the Stellar network           |                                    |
   |<---------□                                    |                                    |
   |          |                                    |                                    |

Receiving a payment

When you want to use compliance protocol when receiving payments...

Stellar    Bridge                            Compliance                             Acme Bank
   |          |                                    |                                    |
   |          |                                    |        compliance.AuthRequest      □
   |          |                                    □<-----------------------------------□~~~ - Other organization sends
   |          |                                    □~~~ - You perform KYC               □      request to your AuthServer
   |          |                                    □    - You save the memo preimage    □
   |          |                                    □                                    □
   |          |                                    □      compliance.AuthResponse       □
   |          |                                    □----------------------------------->□
   |          |                                    |                                    |
   |--------->□~~~ - If you respond with           |                                    |
   |          □      AUTH_STATUS_OK to AuthRequest |                                    |
   |          □      transaction will be sent      |                                    |
   |          □    - Payment is received           |                                    |
   |          □      by payment listener           |                                    |
   |          □                                    |                                    |
   |          □    compliance.HandlerReceive()     |                                    |
   |          □            /receive                |                                    |
   |          □     compliance.ReceiveRequest      |                                    |
   |          □----------------------------------->□~~~ - Compliance server will load   |
   |          □                                    □      memo preimage that was saved  |
   |          □                                    □      earlier                       |
   |          □                                    □                                    |
   |          □    compliance.ReceiveResponse      □                                    |
   |          □<-----------------------------------□                                    |
   |          □                                    |                                    |
   |          □~~~ - Bridge server will send       |                                    |
   |          □      a receive callback with       |                                    |
   |          □      `extra_memo` preimage         |                                    |
   |          □                                    |                                    |
   |          |                                    |                                    |

Index

Constants

This section is empty.

Variables

View Source
var (

	// TransactionNotFoundError is an error response
	TransactionNotFoundError = &protocols.ErrorResponse{Code: "transaction_not_found", Message: "Transaction not found.", Status: http.StatusNotFound}

	// CannotResolveDestination is an error response
	CannotResolveDestination = &protocols.ErrorResponse{Code: "cannot_resolve_destination", Message: "Cannot resolve federated Stellar address.", Status: http.StatusBadRequest}
	// AuthServerNotDefined is an error response
	AuthServerNotDefined = &protocols.ErrorResponse{Code: "auth_server_not_defined", Message: "No AUTH_SERVER defined in stellar.toml file.", Status: http.StatusBadRequest}
)

Functions

This section is empty.

Types

type CallbackResponse added in v0.0.28

type CallbackResponse struct {
	// Estimated number of seconds till the sender can check back for a change in status.
	Pending int    `json:"pending"`
	Error   string `json:"error"`
}

CallbackResponse is a response from Sanctions and AskUser callbacks when they return 202 Accepted or 400 Bad Requests statuses

type FetchInfoRequest

type FetchInfoRequest struct {
	Address string `name:"address" required:""`
	// contains filtered or unexported fields
}

FetchInfoRequest represents a request sent to fetch_info callback

func (*FetchInfoRequest) FromRequest

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

FromRequest will populate request fields using http.Request.

func (*FetchInfoRequest) ToValues

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

ToValues will create url.Values from request.

type FetchInfoResponse

type FetchInfoResponse struct {
	Name        string `json:"name"`
	Address     string `json:"address"`
	DateOfBirth string `json:"date_of_birth"`
}

FetchInfoResponse represents a response returned by fetch_info callback

type ReceiveRequest

type ReceiveRequest struct {
	Memo string `name:"memo" required:""`
	// contains filtered or unexported fields
}

ReceiveRequest represents request sent to /receive endpoint of compliance server

func (*ReceiveRequest) FromRequest

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

FromRequest will populate request fields using http.Request.

func (*ReceiveRequest) ToValues

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

ToValues will create url.Values from request.

func (*ReceiveRequest) Validate

func (request *ReceiveRequest) Validate() error

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

type ReceiveResponse

type ReceiveResponse struct {
	protocols.SuccessResponse
	// The AuthData hash of this memo.
	Data string `json:"data"`
}

ReceiveResponse represents response returned by /receive endpoint

func (*ReceiveResponse) Marshal

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

Marshal marshals ReceiveResponse

type SendRequest

type SendRequest struct {
	// Source account ID
	Source string `name:"source" required:""`
	// Sender address (like alice*stellar.org)
	Sender string `name:"sender" required:""`
	// Destination address (like bob*stellar.org)
	Destination string `name:"destination" required:""`
	// Amount destination should receive
	Amount string `name:"amount" required:""`
	// Code of the asset destination should receive
	AssetCode string `name:"asset_code" required:""`
	// Issuer of the asset destination should receive
	AssetIssuer string `name:"asset_issuer" required:""`
	// 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"`
	// Extra memo
	ExtraMemo string `name:"extra_memo"`

	protocols.FormRequest
}

SendRequest represents request sent to /send endpoint of compliance server

func (*SendRequest) FromRequest

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

FromRequest will populate request fields using http.Request.

func (*SendRequest) ToValues

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

ToValues will create url.Values from request.

func (*SendRequest) Validate

func (request *SendRequest) Validate() error

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

type SendResponse

type SendResponse struct {
	protocols.SuccessResponse
	proto.AuthResponse `json:"auth_response"`
	// xdr.Transaction base64-encoded. Sequence number of this transaction will be equal 0.
	TransactionXdr string `json:"transaction_xdr,omitempty"`
}

SendResponse represents response returned by /send endpoint

func (*SendResponse) Marshal

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

Marshal marshals SendResponse

Jump to

Keyboard shortcuts

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