compliance

package
v0.0.0-...-5c63435 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Nonce       string `json:"nonce"`
	Transaction `json:"transaction"`
	Operations  []Operation `json:"operations"`
}

Attachment represents preimage object of compliance protocol in Stellar attachment convention

func (*Attachment) GenerateNonce

func (attachment *Attachment) GenerateNonce()

GenerateNonce generates a nonce and assigns it to `Nonce` field. It does not have to be crypto random. We just want two attachments always have a different hashes.

func (*Attachment) Hash

func (attachment *Attachment) Hash() ([32]byte, error)

Hash returns sha-256 hash of the JSON marshalled attachment.

func (*Attachment) Marshal

func (attachment *Attachment) Marshal() ([]byte, error)

Marshal marshals Attachment

type AuthData

type AuthData struct {
	// The stellar address of the customer that is initiating the send.
	Sender string `json:"sender" valid:"required,stellar_address"`
	// If the caller needs the recipient's AML info in order to send the payment.
	NeedInfo bool `json:"need_info" valid:"-"`
	// The transaction that the sender would like to send in XDR format. This transaction is unsigned.
	Tx string `json:"tx" valid:"required,base64"`
	// The full text of the attachment the hash of this attachment is included in the transaction.
	AttachmentJSON string `json:"attachment" valid:"required,json"`
}

AuthData represents how AuthRequest.Data field looks like.

func (AuthData) Attachment

func (d AuthData) Attachment() (attachment Attachment, err error)

Attachment returns attachment from the the object.

func (AuthData) AttachmentPreimageHash

func (d AuthData) AttachmentPreimageHash() [32]byte

AttachmentPreimageHash returns sha-256 hash of memo preimage.

func (*AuthData) Marshal

func (d *AuthData) Marshal() ([]byte, error)

Marshal marshals Attachment

func (AuthData) Validate

func (d AuthData) Validate() error

Validate checks if fields are of required form:

  • `Sender` field is valid address
  • `Tx` is valid and it's memo_hash equals sha256 hash of attachment preimage
  • `Attachment` is valid JSON

type AuthRequest

type AuthRequest struct {
	// Marshalled AuthData JSON object (because of the attached signature, json can be marshalled to infinite number of valid JSON strings)
	DataJSON string `name:"data" valid:"required,json"`
	// Signature of sending FI
	Signature string `name:"sig" valid:"required,base64"`
}

AuthRequest represents auth request sent to compliance server

func (*AuthRequest) Data

func (r *AuthRequest) Data() (data AuthData, err error)

Data returns AuthData from the request.

func (*AuthRequest) Populate

func (r *AuthRequest) Populate(request *http.Request) *AuthRequest

func (*AuthRequest) ToURLValues

func (r *AuthRequest) ToURLValues() url.Values

ToURLValues returns AuthData encoded as url.Values.

func (*AuthRequest) Validate

func (r *AuthRequest) Validate() error

Validate is using govalidator to check if fields are valid and also runs Validate method on authData. This method only performs data validation. You should also call VerifySignature to confirm that signature is valid.

func (*AuthRequest) VerifySignature

func (r *AuthRequest) VerifySignature(sender string) error

VerifySignature verifies if signature is valid. It makes a network connection to sender server in order to obtain stellar.toml file and signing key.

type AuthResponse

type AuthResponse struct {
	// If this FI is willing to share AML information or not. {ok, denied, pending, error}
	InfoStatus AuthStatus `json:"info_status"`
	// If this FI is willing to accept this transaction. {ok, denied, pending, error}
	TxStatus AuthStatus `json:"tx_status"`
	// (only present if info_status is ok) JSON of the recipient's AML information. in the Stellar attachment convention
	DestInfo string `json:"dest_info,omitempty"`
	// (only present if info_status or tx_status is pending) Estimated number of seconds till the sender can check back for a change in status. The sender should just resubmit this request after the given number of seconds.
	Pending int `json:"pending,omitempty"`
	// (only present if info_status or tx_status is error)
	Error string `json:"error,omitempty"`
}

AuthResponse represents response sent by auth server

func (*AuthResponse) Marshal

func (r *AuthResponse) Marshal() ([]byte, error)

Marshal marshals Attachment

type AuthStatus

type AuthStatus string

AuthStatus represents auth status returned by Auth Server

const (
	// AuthStatusOk is returned when authentication was successful
	AuthStatusOk AuthStatus = "ok"
	// AuthStatusPending is returned when authentication is pending
	AuthStatusPending AuthStatus = "pending"
	// AuthStatusDenied is returned when authentication was denied
	AuthStatusDenied AuthStatus = "denied"
	// AuthStatusError is returned when there was an error
	AuthStatusError AuthStatus = "error"
)

type Operation

type Operation struct {
	// Overriddes Transaction field for this operation
	SenderInfo map[string]string `json:"sender_info"`
	// Overriddes Transaction field for this operation
	Route Route `json:"route"`
	// Overriddes Transaction field for this operation
	Note string `json:"note"`
}

Operation represents a single operation object in Stellar attachment

type Route

type Route string

Route allows unmarshalling both integer and string types into string

func (*Route) UnmarshalJSON

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

type SenderInfo

type SenderInfo struct {
	FirstName   string `json:"first_name,omitempty"`
	MiddleName  string `json:"middle_name,omitempty"`
	LastName    string `json:"last_name,omitempty"`
	Address     string `json:"address,omitempty"`
	City        string `json:"city,omitempty"`
	Province    string `json:"province,omitempty"`
	PostalCode  string `json:"postal_code,omitempty"`
	Country     string `json:"country,omitempty"`
	Email       string `json:"email,omitempty"`
	Phone       string `json:"phone,omitempty"`
	DateOfBirth string `json:"date_of_birth,omitempty"`
	CompanyName string `json:"company_name,omitempty"`
}

SenderInfo is a helper structure with standardized fields that contains information about the sender. Use Map() method to transform it to map[string]string used in Transaction and Operation structs.

func (SenderInfo) Map

func (senderInfo SenderInfo) Map() (map[string]string, error)

Map transforms SenderInfo to map[string]string for embedding in Transaction/Operation struct.

type Transaction

type Transaction struct {
	SenderInfo map[string]string `json:"sender_info"`
	Route      Route             `json:"route"`
	Note       string            `json:"note"`
	Extra      string            `json:"extra"`
}

Transaction represents transaction field in Stellar attachment

type TransactionStatus

type TransactionStatus string

TransactionStatus is the status string returned be tx_status endpoint

const (
	// TransactionStatusUnknown is a value of `status` field for the
	// tx_status endpoint response. It represents that the
	// institution is not aware of the transaction
	TransactionStatusUnknown TransactionStatus = "unknown"

	// TransactionStatusApproved is a value of `status` field for the
	// tx_status endpoint response. It represents that the
	// payment was approved by the receiving FI but the Stellar
	// transaction hasn't been received yet
	TransactionStatusApproved TransactionStatus = "approved"

	// TransactionStatusNotApproved is a value of `status` field for the
	// tx_status endpoint response. It represents that the
	// Stellar transaction was found but it was never approved
	// by the receiving FI.
	TransactionStatusNotApproved TransactionStatus = "not_approved"

	// TransactionStatusPending is a value of `status` field for the
	// tx_status endpoint response. It represents that the
	// payment was received and being processed
	TransactionStatusPending TransactionStatus = "pending"

	// TransactionStatusFailed is a value of `status` field for the
	// tx_status endpoint response. It represents that the
	// payment was failed and could not be deposited
	TransactionStatusFailed TransactionStatus = "failed"

	// TransactionStatusRefunded is a value of `status` field for the
	// tx_status endpoint response. It represents that the
	// payment was sent back to sending FI
	TransactionStatusRefunded TransactionStatus = "refunded"

	// TransactionStatusClaimable is a value of `status` field for the
	// tx_status endpoint response. It represents that the
	// cash is ready to be picked up at specified locations.
	// Mostly used for cash pickup
	TransactionStatusClaimable TransactionStatus = "claimable"

	// TransactionStatusDelivered is a value of `status` field for the
	// tx_status endpoint response. It represents that the
	// payment has been delivered to the recepient
	TransactionStatusDelivered TransactionStatus = "delivered"
)

type TransactionStatusResponse

type TransactionStatusResponse struct {
	Status   TransactionStatus `json:"status"`
	RecvCode string            `json:"recv_code,omitempty"`
	RefundTx string            `json:"refund_tx,omitempty"`
	Msg      string            `json:"msg,omitempty"`
}

TransactionStatusResponse represents a response from the tx_status endpoint

Jump to

Keyboard shortcuts

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