ttx

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: Apache-2.0 Imports: 35 Imported by: 5

Documentation

Overview

Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	// NonceSize is the default NonceSize
	NonceSize = 24
)
View Source
const (
	TokenNamespace = "tns"
)

Variables

View Source
var TxStatusMessage = driver.TxStatusMessage

TxStatusMessage maps TxStatus to string

Functions

func CompileServiceOptions added in v0.4.0

func CompileServiceOptions(opts ...token.ServiceOption) (*token.ServiceOptions, error)

func ExchangeRecipientIdentities

func ExchangeRecipientIdentities(context view.Context, walletID string, recipient view.Identity, opts ...token.ServiceOption) (view.Identity, view.Identity, error)

ExchangeRecipientIdentities executes the ExchangeRecipientIdentitiesView using by passed wallet id to derive the recipient identity to send to the passed recipient. The function returns, the recipient identity of the sender, the recipient identity of the recipient

func GetAuditorWallet added in v0.2.0

func GetAuditorWallet(sp token.ServiceProvider, opts ...token.ServiceOption) *token.AuditorWallet

GetAuditorWallet returns the wallet whose id is the passed id. If the passed id is empty, GetAuditorWallet has the same behaviour of MyAuditorWallet. It returns nil, if no wallet is found.

func GetIssuerWallet

func GetIssuerWallet(sp token.ServiceProvider, id string, opts ...token.ServiceOption) *token.IssuerWallet

GetIssuerWallet returns the issuer wallet whose id is the passed id. If the passed id is empty, GetIssuerWallet has the same behaviour of MyIssuerWallet. It returns nil, if no wallet is found.

func GetIssuerWalletForChannel

func GetIssuerWalletForChannel(sp token.ServiceProvider, channel, id string, opts ...token.ServiceOption) *token.IssuerWallet

GetIssuerWalletForChannel returns the issuer wallet whose id is the passed id for the passed channel. If the passed id is empty, GetIssuerWalletForChannel has the same behaviour of MyIssuerWallet. It returns nil, if no wallet is found.

func GetRandomBytes added in v0.4.0

func GetRandomBytes(len int) ([]byte, error)

GetRandomBytes returns len random looking bytes

func GetRandomNonce added in v0.4.0

func GetRandomNonce() ([]byte, error)

GetRandomNonce returns a random byte array of length NonceSize

func GetWallet

func GetWallet(sp token.ServiceProvider, id string, opts ...token.ServiceOption) *token.OwnerWallet

GetWallet returns the wallet whose id is the passed id. If the passed id is empty, GetWallet has the same behaviour of MyWallet. It returns nil, if no wallet is found.

func GetWalletForChannel

func GetWalletForChannel(sp token.ServiceProvider, channel, id string, opts ...token.ServiceOption) *token.OwnerWallet

GetWalletForChannel returns the wallet whose id is the passed id for the passed channel. If the passed id is empty, GetWalletForChannel has the same behaviour of MyWalletFromTx. It returns nil, if no wallet is found.

func IssueDistributionList added in v0.3.0

func IssueDistributionList(r *token.Request) []view.Identity

func Marshal

func Marshal(v interface{}) ([]byte, error)

func MarshalMeta

func MarshalMeta(v map[string][]byte) ([]byte, error)

func MyAuditorWallet

func MyAuditorWallet(sp token.ServiceProvider, opts ...token.ServiceOption) *token.AuditorWallet

MyAuditorWallet returns the default auditor wallet, nil if not found.

func MyIssuerWallet

func MyIssuerWallet(context view.Context, opts ...token.ServiceOption) *token.IssuerWallet

MyIssuerWallet returns the default issuer wallet, nil if not found

func MyWallet

MyWallet returns the default wallet, nil if not found.

func MyWalletFromTx

func MyWalletFromTx(sp token.ServiceProvider, tx *Transaction) *token.OwnerWallet

MyWalletFromTx returns the default wallet for the tuple (network, channel, namespace) as identified by the passed transaction. Returns nil if no wallet is found.

func NewCollectActionsResponderView

func NewCollectActionsResponderView(tx *Transaction, action *ActionTransfer) *collectActionsResponderView

NewCollectActionsResponderView returns an instance of the collectActionsResponderView. The view does the following: Sends back the transaction.

func NewCollectActionsView

func NewCollectActionsView(tx *Transaction, actions ...*ActionTransfer) *collectActionsView

NewCollectActionsView returns an instance of collectActionsView. The view does the following: For each action, the view contact the recipient by sending as first message the transaction. Then, the view waits for the answer and append it to the transaction.

func NewFinalityView

func NewFinalityView(tx *Transaction, opts ...TxOption) *finalityView

NewFinalityView returns an instance of the finalityView. The view does the following: It waits for the finality of the passed transaction. If the transaction is final, the vault is updated.

func NewFinalityWithOpts added in v0.4.0

func NewFinalityWithOpts(opts ...TxOption) *finalityView

func NewOrderingAndFinalityView

func NewOrderingAndFinalityView(tx *Transaction) *orderingAndFinalityView

NewOrderingAndFinalityView returns a new instance of the orderingAndFinalityView struct. The view does the following: 1. It broadcasts the token transaction to the proper backend. 2. It waits for finality of the token transaction by listening to delivery events from one of the Fabric peer nodes trusted by the FSC node.

func NewOrderingAndFinalityWithTimeoutView

func NewOrderingAndFinalityWithTimeoutView(tx *Transaction, timeout time.Duration) *orderingAndFinalityView

NewOrderingAndFinalityWithTimeoutView returns a new instance of the orderingAndFinalityView struct. The view does the following: 1. It broadcasts the token transaction to the proper backend. 2. It waits for finality of the token transaction.

func NewOrderingView

func NewOrderingView(tx *Transaction, opts ...TxOption) *orderingView

NewOrderingView returns a new instance of the orderingView struct. The view does the following: 1. It broadcasts the token transaction to the proper backend.

func NewOrderingViewWithOpts added in v0.4.0

func NewOrderingViewWithOpts(opts ...TxOption) *orderingView

func ReadMessage added in v0.4.0

func ReadMessage(session view.Session, timeout time.Duration) ([]byte, error)

func ReceiveAction

func ReceiveAction(context view.Context) (*Transaction, *ActionTransfer, error)

ReceiveAction runs the receiveActionsView. The view does the following: It receives the transaction, the collection of actions, and the requested action.

func RecipientDataBytes added in v0.3.0

func RecipientDataBytes(r *token.RecipientData) ([]byte, error)

func RecipientDataFromBytes added in v0.3.0

func RecipientDataFromBytes(raw []byte) (*token.RecipientData, error)

func RequestRecipientIdentity

func RequestRecipientIdentity(context view.Context, recipient view.Identity, opts ...token.ServiceOption) (view.Identity, error)

RequestRecipientIdentity executes the RequestRecipientIdentityView. The sender contacts the recipient's FSC node identified via the passed view identity. The sender gets back the identity the recipient wants to use to assign ownership of tokens.

func RequestWithdrawal added in v0.3.0

func RequestWithdrawal(context view.Context, issuer view.Identity, wallet string, tokenType token2.Type, amount uint64, notAnonymous bool, opts ...token.ServiceOption) (view.Identity, view.Session, error)

RequestWithdrawal runs RequestWithdrawalView with the passed arguments. The view will generate a recipient identity and pass it to the issuer.

func RequestWithdrawalForRecipient added in v0.3.0

func RequestWithdrawalForRecipient(context view.Context, issuer view.Identity, wallet string, tokenType token2.Type, amount uint64, notAnonymous bool, recipientData *RecipientData, opts ...token.ServiceOption) (view.Identity, view.Session, error)

RequestWithdrawalForRecipient runs RequestWithdrawalView with the passed arguments. The view will send the passed recipient data to the issuer.

func RespondExchangeRecipientIdentities

func RespondExchangeRecipientIdentities(context view.Context) (view.Identity, view.Identity, error)

RespondExchangeRecipientIdentities executes the RespondExchangeRecipientIdentitiesView. The recipient sends back the identity to receive ownership of tokens. The identity is taken from the default wallet

func RespondRequestRecipientIdentity

func RespondRequestRecipientIdentity(context view.Context) (view.Identity, error)

RespondRequestRecipientIdentity executes the RespondRequestRecipientIdentityView. The recipient sends back the identity to receive ownership of tokens. The identity is taken from the default wallet. If the wallet is not found, an error is returned.

func RespondRequestRecipientIdentityUsingWallet

func RespondRequestRecipientIdentityUsingWallet(context view.Context, wallet string) (view.Identity, error)

RespondRequestRecipientIdentityUsingWallet executes the RespondRequestRecipientIdentityView. The recipient sends back the identity to receive ownership of tokens. The identity is taken from the passed wallet. If the wallet is not found, an error is returned. If the wallet is the empty string, the identity is taken from the default wallet.

func RunView

func RunView(context view.Context, view view.View, opts ...view.RunViewOption)

RunView runs passed view within the passed Context and using the passed options in a separate goroutine

func StoreTransactionRecords

func StoreTransactionRecords(context view.Context, tx *Transaction) error

StoreTransactionRecords stores the transaction records extracted from the passed transaction to the token transaction db

func TransferDistributionList added in v0.3.0

func TransferDistributionList(r *token.Request) []view.Identity

func Unmarshal

func Unmarshal(data []byte, v interface{}) error

func UnmarshalMeta

func UnmarshalMeta(raw []byte) (map[string][]byte, error)

func WithRecipientData added in v0.4.0

func WithRecipientData(recipientData *RecipientData) token.ServiceOption

WithRecipientData is used to add a RecipientData to the service options

func WithType

func WithType(tokenType token2.Type) token.ListTokensOption

WithType returns a list token option that filter by the passed token type. If the passed token type is the empty string, all token types are selected.

Types

type AcceptView added in v0.4.0

type AcceptView struct {
	// contains filtered or unexported fields
}

func NewAcceptView

func NewAcceptView(tx *Transaction, opts ...EndorsementsOpt) *AcceptView

func (*AcceptView) Call added in v0.4.0

func (s *AcceptView) Call(context view.Context) (interface{}, error)

type ActionTransfer

type ActionTransfer struct {
	// From is the sender
	From view.Identity
	// Type of tokens to transfer
	Type token2.Type
	// Amount to transfer
	Amount uint64
	// Recipient is the recipient of the transfer
	Recipient view.Identity
}

ActionTransfer describe a transfer operation

type Actions

type Actions struct {
	Transfers []*ActionTransfer
}

type AuditApproveView

type AuditApproveView struct {
	// contains filtered or unexported fields
}

func NewAuditApproveView

func NewAuditApproveView(w *token.AuditorWallet, tx *Transaction) *AuditApproveView

func (*AuditApproveView) Call

func (a *AuditApproveView) Call(context view.Context) (interface{}, error)

type AuditingViewInitiator

type AuditingViewInitiator struct {
	// contains filtered or unexported fields
}

func (*AuditingViewInitiator) Call

func (a *AuditingViewInitiator) Call(context view.Context) (interface{}, error)

type CheckService added in v0.4.0

type CheckService interface {
	Check(context context.Context) ([]string, error)
}

type CheckServiceProvider added in v0.4.0

type CheckServiceProvider interface {
	CheckService(id token.TMSID, adb *ttxdb.DB, tdb *tokens.Tokens) (CheckService, error)
}

type CollectEndorsementsView added in v0.3.0

type CollectEndorsementsView struct {
	Opts *EndorsementsOpts
	// contains filtered or unexported fields
}

func NewCollectEndorsementsView

func NewCollectEndorsementsView(tx *Transaction, opts ...EndorsementsOpt) *CollectEndorsementsView

NewCollectEndorsementsView returns an instance of the CollectEndorsementsView struct. This view does the following: 1. It collects all the required signatures to authorize any issue and transfer operation contained in the token transaction. 2. It invokes the Token Chaincode to collect endorsements on the Token Request and prepare the relative transaction. 3. Before completing, all recipients receive the approved transaction. Depending on the token driver implementation, the recipient's signature might or might not be needed to make the token transaction valid.

func (*CollectEndorsementsView) Call added in v0.3.0

func (c *CollectEndorsementsView) Call(context view.Context) (interface{}, error)

Call executes the view. This view does the following: 1. It collects all the required signatures to authorize any issue and transfer operation contained in the token transaction. 2. It invokes the Token Chaincode to collect endorsements on the Token Request and prepare the relative transaction. 3. Before completing, all recipients receive the approved transaction. Depending on the token driver implementation, the recipient's signature might or might not be needed to make the token transaction valid.

type DB added in v0.4.0

type DB struct {
	// contains filtered or unexported fields
}

DB is the interface for the owner service

func Get added in v0.4.0

Get returns the DB instance for the passed TMS

func New added in v0.4.0

New returns the DB instance for the passed TMS

func (*DB) Append added in v0.4.0

func (a *DB) Append(tx *Transaction) error

Append adds the passed transaction to the database

func (*DB) AppendTransactionEndorseAck added in v0.4.0

func (a *DB) AppendTransactionEndorseAck(txID string, id view.Identity, sigma []byte) error

func (*DB) Check added in v0.4.0

func (a *DB) Check(context context.Context) ([]string, error)

func (*DB) GetStatus added in v0.4.0

func (a *DB) GetStatus(txID string) (TxStatus, string, error)

GetStatus return the status of the given transaction id. It returns an error if no transaction with that id is found

func (*DB) GetTokenRequest added in v0.4.0

func (a *DB) GetTokenRequest(txID string) ([]byte, error)

GetTokenRequest returns the token request bound to the passed transaction id, if available.

func (*DB) GetTransactionEndorsementAcks added in v0.4.0

func (a *DB) GetTransactionEndorsementAcks(id string) (map[string][]byte, error)

func (*DB) SetStatus added in v0.4.0

func (a *DB) SetStatus(ctx context.Context, txID string, status driver.TxStatus, message string) error

SetStatus sets the status of the audit records with the passed transaction id to the passed status

type DBProvider added in v0.4.0

type DBProvider interface {
	DBByTMSId(id token.TMSID) (*ttxdb.DB, error)
}

type EndorseView added in v0.3.0

type EndorseView struct {
	// contains filtered or unexported fields
}

func NewEndorseView

func NewEndorseView(tx *Transaction) *EndorseView

NewEndorseView returns an instance of the endorseView. The view does the following: 1. Wait for signature requests. 2. Upon receiving a signature request, it validates the request and send back the requested signature. 3. After, it waits to receive the Transaction. The Transaction is validated and stored locally to be processed at time of committing. 4. It sends back an ack.

func (*EndorseView) Call added in v0.3.0

func (s *EndorseView) Call(context view.Context) (interface{}, error)

Call executes the view. The view does the following: 1. Wait for signature requests. 2. Upon receiving a signature request, it validates the request and send back the requested signature. 3. After, it waits to receive the Transaction. The Transaction is validated and stored locally to be processed at time of committing. 4. It sends back an ack.

type EndorsementsOpt added in v0.3.0

type EndorsementsOpt func(*EndorsementsOpts) error

EndorsementsOpt is a function that configures a EndorsementsOpts

func WithExternalWalletSigner added in v0.3.0

func WithExternalWalletSigner(walletID string, ews ExternalWalletSigner) EndorsementsOpt

func WithSkipApproval added in v0.3.0

func WithSkipApproval() EndorsementsOpt

WithSkipApproval to skip approval

func WithSkipAuditing added in v0.3.0

func WithSkipAuditing() EndorsementsOpt

WithSkipAuditing to skip auditing

func WithSkipDistributeEnv added in v0.4.0

func WithSkipDistributeEnv() EndorsementsOpt

WithSkipDistributeEnv to skip approval

type EndorsementsOpts added in v0.3.0

type EndorsementsOpts struct {
	// SkipAuditing set it to true to skip the auditing phase
	SkipAuditing bool
	// SkipApproval set it to true to skip the approval phase
	SkipApproval bool
	// SkipDistributeEnv set it to true to skip the distribution phase
	SkipDistributeEnv bool
	// External Signers
	ExternalWalletSigners map[string]ExternalWalletSigner
}

EndorsementsOpts is used to configure the CollectEndorsementsView

func CompileCollectEndorsementsOpts added in v0.3.0

func CompileCollectEndorsementsOpts(opts ...EndorsementsOpt) (*EndorsementsOpts, error)

CompileCollectEndorsementsOpts compiles the given list of ServiceOption

func (*EndorsementsOpts) ExternalWalletSigner added in v0.3.0

func (o *EndorsementsOpts) ExternalWalletSigner(id string) ExternalWalletSigner

type ExchangeRecipientIdentitiesView

type ExchangeRecipientIdentitiesView struct {
	TMSID  token.TMSID
	Wallet string
	Other  view.Identity
}

func (*ExchangeRecipientIdentitiesView) Call

func (f *ExchangeRecipientIdentitiesView) Call(context view.Context) (interface{}, error)

type ExchangeRecipientRequest

type ExchangeRecipientRequest struct {
	TMSID         token.TMSID
	WalletID      []byte
	RecipientData *RecipientData
}

func (*ExchangeRecipientRequest) Bytes

func (r *ExchangeRecipientRequest) Bytes() ([]byte, error)

func (*ExchangeRecipientRequest) FromBytes

func (r *ExchangeRecipientRequest) FromBytes(raw []byte) error

type ExternalWalletSigner added in v0.3.0

type ExternalWalletSigner interface {
	Sign(party view.Identity, message []byte) ([]byte, error)
	Done() error
}

type GetNetworkFunc added in v0.4.0

type GetNetworkFunc = func(network string, channel string) (*network.Network, error)

type LocalBidirectionalChannel

type LocalBidirectionalChannel struct {
	// contains filtered or unexported fields
}

LocalBidirectionalChannel is a bidirectional channel that is used to simulate a session between two views (let's call them L and R) running in the same process.

func NewLocalBidirectionalChannel

func NewLocalBidirectionalChannel(caller string, contextID string, endpoint string, pkid []byte) (*LocalBidirectionalChannel, error)

NewLocalBidirectionalChannel creates a new bidirectional channel

func (*LocalBidirectionalChannel) LeftSession

func (c *LocalBidirectionalChannel) LeftSession() view.Session

LeftSession returns the session from the L to R

func (*LocalBidirectionalChannel) RightSession

func (c *LocalBidirectionalChannel) RightSession() view.Session

RightSession returns the session from the R to L

type Manager added in v0.4.0

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles the databases

func NewManager added in v0.4.0

func NewManager(
	np NetworkProvider,
	tmsProvider TMSProvider,
	ttxDBProvider DBProvider,
	tokensBProvider TokensProvider,
	tracerProvider trace.TracerProvider,
	CheckServiceProvider CheckServiceProvider,
) *Manager

NewManager creates a new DB manager.

func (*Manager) DB added in v0.4.0

func (m *Manager) DB(tmsID token.TMSID) (*DB, error)

DB returns the DB for the given TMS

func (*Manager) RestoreTMS added in v0.4.0

func (m *Manager) RestoreTMS(tmsID token.TMSID) error

RestoreTMS restores the ttxdb corresponding to the passed TMS ID.

type Metrics added in v0.3.0

type Metrics struct {
	EndorsedTransactions      metrics.Counter
	AuditApprovedTransactions metrics.Counter
	AcceptedTransactions      metrics.Counter
}

func GetMetrics added in v0.3.0

func GetMetrics(sp token.ServiceProvider) *Metrics

func NewMetrics added in v0.3.0

func NewMetrics(p metrics.Provider) *Metrics

type NetworkProvider added in v0.4.0

type NetworkProvider interface {
	GetNetwork(network string, channel string) (*network.Network, error)
}

type Payload

type Payload struct {
	TxID      network.TxID
	ID        string
	Network   string
	Channel   string
	Namespace string
	Signer    view.Identity
	Transient network.TransientMap

	TokenRequest *token.Request
	Envelope     *network.Envelope
}

type QueryTransactionsParams added in v0.4.0

type QueryTransactionsParams = ttxdb.QueryTransactionsParams

type ReceiveTransactionView added in v0.3.0

type ReceiveTransactionView struct {
	// contains filtered or unexported fields
}

func NewReceiveTransactionView

func NewReceiveTransactionView(network string) *ReceiveTransactionView

func (*ReceiveTransactionView) Call added in v0.3.0

func (f *ReceiveTransactionView) Call(context view.Context) (interface{}, error)

type ReceiveWithdrawalRequestView added in v0.3.0

type ReceiveWithdrawalRequestView struct{}

ReceiveWithdrawalRequestView this is the view used by the issuer to receive a withdrawal request

func NewReceiveIssuanceRequestView added in v0.3.0

func NewReceiveIssuanceRequestView() *ReceiveWithdrawalRequestView

func (*ReceiveWithdrawalRequestView) Call added in v0.3.0

func (r *ReceiveWithdrawalRequestView) Call(context view.Context) (interface{}, error)

type RecipientData

type RecipientData = token.RecipientData

type RecipientRequest

type RecipientRequest struct {
	TMSID         token.TMSID
	WalletID      []byte
	RecipientData *RecipientData
}

func (*RecipientRequest) Bytes

func (r *RecipientRequest) Bytes() ([]byte, error)

func (*RecipientRequest) FromBytes

func (r *RecipientRequest) FromBytes(raw []byte) error

type RegisterAuditorView

type RegisterAuditorView struct {
	TMSID     token.TMSID
	AuditView view.View
}

func NewRegisterAuditorView

func NewRegisterAuditorView(auditView view.View, opts ...token.ServiceOption) *RegisterAuditorView

func (*RegisterAuditorView) Call

func (r *RegisterAuditorView) Call(context view.Context) (interface{}, error)

type RequestRecipientIdentityView

type RequestRecipientIdentityView struct {
	TMSID              token.TMSID
	Other              view.Identity
	OtherRecipientData *RecipientData
}

func (*RequestRecipientIdentityView) Call

func (f *RequestRecipientIdentityView) Call(context view.Context) (interface{}, error)

type RequestWithdrawalView added in v0.3.0

type RequestWithdrawalView struct {
	Issuer       view.Identity
	TokenType    token2.Type
	Amount       uint64
	TMSID        token.TMSID
	Wallet       string
	NotAnonymous bool

	RecipientData *RecipientData
}

RequestWithdrawalView is the initiator view to request an issuer the issuance of tokens. The view prepares an instance of WithdrawalRequest and send it to the issuer.

func NewRequestWithdrawalView added in v0.3.0

func NewRequestWithdrawalView(issuer view.Identity, tokenType token2.Type, amount uint64, notAnonymous bool) *RequestWithdrawalView

func (*RequestWithdrawalView) Call added in v0.3.0

func (r *RequestWithdrawalView) Call(context view.Context) (interface{}, error)

func (*RequestWithdrawalView) WithRecipientData added in v0.4.0

func (r *RequestWithdrawalView) WithRecipientData(data *RecipientData) *RequestWithdrawalView

WithRecipientData sets the recipient data to use

func (*RequestWithdrawalView) WithTMSID added in v0.3.0

WithTMSID sets the TMS ID to be used

func (*RequestWithdrawalView) WithWallet added in v0.3.0

func (r *RequestWithdrawalView) WithWallet(wallet string) *RequestWithdrawalView

WithWallet sets the wallet to use to retrieve a recipient identity if it has not been passed already

type RespondExchangeRecipientIdentitiesView

type RespondExchangeRecipientIdentitiesView struct {
	Wallet string
}

func (*RespondExchangeRecipientIdentitiesView) Call

func (s *RespondExchangeRecipientIdentitiesView) Call(context view.Context) (interface{}, error)

type RespondRequestRecipientIdentityView

type RespondRequestRecipientIdentityView struct {
	Wallet string
}

func (*RespondRequestRecipientIdentityView) Call

func (s *RespondRequestRecipientIdentityView) Call(context view.Context) (interface{}, error)

type SignatureRequest added in v0.3.0

type SignatureRequest struct {
	TX      []byte
	Request []byte
	TxID    []byte
	Signer  view.Identity
}

func (*SignatureRequest) MessageToSign added in v0.3.0

func (sr *SignatureRequest) MessageToSign() []byte

type SignerProvider added in v0.3.0

type SignerProvider interface {
	GetSigner(party view.Identity) (token.Signer, error)
}

type StreamExternalWalletMsg added in v0.3.0

type StreamExternalWalletMsg struct {
	// Type is the type of this message
	Type StreamExternalWalletMsgType
	// Raw will be interpreted following Type
	Raw []byte
}

StreamExternalWalletMsg is the root message that the remote wallet and the ttx package exchange.

func NewStreamExternalWalletMsg added in v0.3.0

func NewStreamExternalWalletMsg(Type StreamExternalWalletMsgType, v interface{}) (*StreamExternalWalletMsg, error)

NewStreamExternalWalletMsg creates a new root message for the given type and value

type StreamExternalWalletMsgType added in v0.3.0

type StreamExternalWalletMsgType = int
const (
	SigRequest StreamExternalWalletMsgType
	SignResponse
	Done
)

type StreamExternalWalletSignRequest added in v0.3.0

type StreamExternalWalletSignRequest struct {
	Party   view.Identity
	Message []byte
}

StreamExternalWalletSignRequest is a message to request a signature

type StreamExternalWalletSignResponse added in v0.3.0

type StreamExternalWalletSignResponse struct {
	Sigma []byte
}

StreamExternalWalletSignResponse is a message to respond to a request of signature

type StreamExternalWalletSignerClient added in v0.3.0

type StreamExternalWalletSignerClient struct {
	// contains filtered or unexported fields
}

StreamExternalWalletSignerClient is the signer client executed where the token-sdk is in execution

func NewStreamExternalWalletSignerClient added in v0.3.0

func NewStreamExternalWalletSignerClient(sp SignerProvider, stream view2.Stream, _ int) *StreamExternalWalletSignerClient

func NewStreamExternalWalletSignerClientWithTimeout added in v0.4.0

func NewStreamExternalWalletSignerClientWithTimeout(sp SignerProvider, stream view2.Stream, timeout time.Duration) *StreamExternalWalletSignerClient

func (*StreamExternalWalletSignerClient) Respond added in v0.3.0

type StreamExternalWalletSignerServer added in v0.3.0

type StreamExternalWalletSignerServer struct {
	// contains filtered or unexported fields
}

StreamExternalWalletSignerServer is the signer server executed by the remote wallet

func NewStreamExternalWalletSignerServer added in v0.3.0

func NewStreamExternalWalletSignerServer(stream view2.Stream) *StreamExternalWalletSignerServer

func (*StreamExternalWalletSignerServer) Done added in v0.3.0

func (*StreamExternalWalletSignerServer) Sign added in v0.3.0

func (s *StreamExternalWalletSignerServer) Sign(party view.Identity, message []byte) ([]byte, error)

type TMSProvider added in v0.4.0

type TMSProvider interface {
	GetManagementService(opts ...token.ServiceOption) (*token.ManagementService, error)
}

type TokenTransactionDB added in v0.3.0

type TokenTransactionDB interface {
	GetTokenRequest(txID string) ([]byte, error)
	GetTransactionEndorsementAcks(id string) (map[string][]byte, error)
}

type TokensProvider added in v0.4.0

type TokensProvider interface {
	Tokens(tmsID token.TMSID) (*tokens.Tokens, error)
}

type Transaction

type Transaction struct {
	*Payload

	TMS             *token.ManagementService
	NetworkProvider GetNetworkFunc
	Opts            *TxOptions
	Context         context.Context
}

func NewAnonymousTransaction

func NewAnonymousTransaction(context view.Context, opts ...TxOption) (*Transaction, error)

NewAnonymousTransaction returns a new anonymous token transaction customized with the passed opts

func NewTransaction

func NewTransaction(context view.Context, signer view.Identity, opts ...TxOption) (*Transaction, error)

NewTransaction returns a new token transaction customized with the passed opts that will be signed by the passed signer. A valid signer is a signer that the target network recognizes as so. For example, in case of fabric, the signer must be a valid fabric identity. If the passed signer is nil, then the default identity is used.

func NewTransactionFromBytes

func NewTransactionFromBytes(context view.Context, raw []byte) (*Transaction, error)

func ReceiveTransaction

func ReceiveTransaction(context view.Context, opts ...TxOption) (*Transaction, error)

func (*Transaction) ApplicationMetadata

func (t *Transaction) ApplicationMetadata(k string) []byte

func (*Transaction) Bytes

func (t *Transaction) Bytes(eIDs ...string) ([]byte, error)

Bytes returns the serialized version of the transaction. If eIDs is not nil, then metadata is filtered by the passed eIDs.

func (*Transaction) Channel

func (t *Transaction) Channel() string

func (*Transaction) CloseSelector added in v0.4.0

func (t *Transaction) CloseSelector() error

func (*Transaction) ID

func (t *Transaction) ID() string

ID returns the ID of this transaction. It is equal to the underlying transaction's ID.

func (*Transaction) Inputs

func (t *Transaction) Inputs() (*token.InputStream, error)

func (*Transaction) InputsAndOutputs added in v0.3.0

func (t *Transaction) InputsAndOutputs() (*token.InputStream, *token.OutputStream, error)

func (*Transaction) IsValid

func (t *Transaction) IsValid() error

IsValid checks that the transaction is well-formed. This means checking that the embedded TokenRequest is valid.

func (*Transaction) Issue

func (t *Transaction) Issue(wallet *token.IssuerWallet, receiver view.Identity, typ token2.Type, q uint64, opts ...token.IssueOption) error

Issue appends a new Issue operation to the TokenRequest inside this transaction

func (*Transaction) MarshallToAudit

func (t *Transaction) MarshallToAudit() ([]byte, error)

func (*Transaction) Namespace

func (t *Transaction) Namespace() string

func (*Transaction) Network

func (t *Transaction) Network() string

func (*Transaction) NetworkTxID added in v0.4.0

func (t *Transaction) NetworkTxID() network.TxID

func (*Transaction) Outputs

func (t *Transaction) Outputs() (*token.OutputStream, error)

func (*Transaction) Redeem

func (t *Transaction) Redeem(wallet *token.OwnerWallet, typ token2.Type, value uint64, opts ...token.TransferOption) error

func (*Transaction) Release

func (t *Transaction) Release()

func (*Transaction) Request

func (t *Transaction) Request() *token.Request

func (*Transaction) Selector

func (t *Transaction) Selector() (token.Selector, error)

Selector returns the default token selector for this transaction

func (*Transaction) SetApplicationMetadata

func (t *Transaction) SetApplicationMetadata(k string, v []byte)

func (*Transaction) TMSID added in v0.3.0

func (t *Transaction) TMSID() token.TMSID

func (*Transaction) TokenService

func (t *Transaction) TokenService() *token.ManagementService

func (*Transaction) Transfer

func (t *Transaction) Transfer(wallet *token.OwnerWallet, typ token2.Type, values []uint64, owners []view.Identity, opts ...token.TransferOption) error

Transfer appends a new Transfer operation to the TokenRequest inside this transaction

type TransactionInfo

type TransactionInfo struct {
	// EndorsementAcks contains the endorsement ACKs received at time of dissemination.
	EndorsementAcks map[string][]byte
	// ApplicationMetadata contains the application metadata
	ApplicationMetadata map[string][]byte

	TokenRequest []byte
}

TransactionInfo contains the transaction info.

type TransactionInfoProvider

type TransactionInfoProvider struct {
	// contains filtered or unexported fields
}

TransactionInfoProvider allows the retrieval of the transaction info

func (*TransactionInfoProvider) TransactionInfo

func (a *TransactionInfoProvider) TransactionInfo(txID string) (*TransactionInfo, error)

TransactionInfo returns the transaction info for the given transaction ID.

type TransactionSer

type TransactionSer struct {
	Nonce        []byte
	Creator      []byte
	ID           string
	Network      string
	Channel      string
	Namespace    string
	Signer       []byte
	Transient    []byte
	TokenRequest []byte
	Envelope     []byte
}

type TxAuditor added in v0.4.0

type TxAuditor struct {
	// contains filtered or unexported fields
}

func (*TxAuditor) Audit added in v0.4.0

func (*TxAuditor) Check added in v0.4.0

func (a *TxAuditor) Check(context context.Context) ([]string, error)

func (*TxAuditor) GetTokenRequest added in v0.4.0

func (a *TxAuditor) GetTokenRequest(txID string) ([]byte, error)

func (*TxAuditor) NewHoldingsFilter added in v0.4.0

func (a *TxAuditor) NewHoldingsFilter() *auditdb.HoldingsFilter

NewHoldingsFilter returns a programmable filter over the holdings owned by enrollment IDs.

func (*TxAuditor) NewPaymentsFilter added in v0.4.0

func (a *TxAuditor) NewPaymentsFilter() *auditdb.PaymentsFilter

NewPaymentsFilter returns a programmable filter over the payments sent or received by enrollment IDs.

func (*TxAuditor) Release added in v0.4.0

func (a *TxAuditor) Release(tx *Transaction)

Release unlocks the passed enrollment IDs.

func (*TxAuditor) SetStatus added in v0.4.0

func (a *TxAuditor) SetStatus(ctx context.Context, txID string, status driver.TxStatus, message string) error

SetStatus sets the status of the audit records with the passed transaction id to the passed status

func (*TxAuditor) Transactions added in v0.4.0

Transactions returns an iterator of transaction records filtered by the given params.

func (*TxAuditor) Validate added in v0.4.0

func (a *TxAuditor) Validate(tx *Transaction) error

type TxOption

type TxOption func(*TxOptions) error

func WithAuditor

func WithAuditor(auditor view.Identity) TxOption

func WithChannel

func WithChannel(channel string) TxOption

func WithNamespace

func WithNamespace(namespace string) TxOption

func WithNetwork

func WithNetwork(network string) TxOption

func WithNetworkTxID added in v0.4.0

func WithNetworkTxID(id network.TxID) TxOption

func WithNoCachingRequest added in v0.4.0

func WithNoCachingRequest() TxOption

WithNoCachingRequest is used to tell the ordering view to not cache the token request

func WithNoTransactionVerification added in v0.3.0

func WithNoTransactionVerification() TxOption

func WithTMS

func WithTMS(network, channel, namespace string) TxOption

WithTMS filters by network, channel and namespace. Each of them can be empty

func WithTMSID

func WithTMSID(id token.TMSID) TxOption

WithTMSID filters by TMS identifier

func WithTimeout added in v0.4.0

func WithTimeout(timeout time.Duration) TxOption

func WithTransactions added in v0.4.0

func WithTransactions(tx *Transaction) TxOption

func WithTxID added in v0.4.0

func WithTxID(txID string) TxOption

type TxOptions

type TxOptions struct {
	Auditor                   view.Identity
	TMSID                     token.TMSID
	NoTransactionVerification bool
	Timeout                   time.Duration
	TxID                      string
	Transaction               *Transaction
	NetworkTxID               network.TxID
	NoCachingRequest          bool
}

type TxOwner added in v0.4.0

type TxOwner struct {
	// contains filtered or unexported fields
}

func NewOwner

NewOwner returns a new owner service.

func (*TxOwner) Append added in v0.4.0

func (a *TxOwner) Append(tx *Transaction) error

Append adds a new transaction to the token transaction database.

func (*TxOwner) Check added in v0.4.0

func (a *TxOwner) Check(context context.Context) ([]string, error)

func (*TxOwner) GetStatus added in v0.4.0

func (a *TxOwner) GetStatus(txID string) (TxStatus, string, error)

GetStatus return the status of the given transaction id. It returns an error if no transaction with that id is found

func (*TxOwner) GetTokenRequest added in v0.4.0

func (a *TxOwner) GetTokenRequest(txID string) ([]byte, error)

func (*TxOwner) SetStatus added in v0.4.0

func (a *TxOwner) SetStatus(ctx context.Context, txID string, status driver.TxStatus, message string) error

SetStatus sets the status of the audit records with the passed transaction id to the passed status

func (*TxOwner) TransactionInfo added in v0.4.0

func (a *TxOwner) TransactionInfo(txID string) (*TransactionInfo, error)

TransactionInfo returns the transaction info for the given transaction ID.

func (*TxOwner) Transactions added in v0.4.0

func (a *TxOwner) Transactions(params QueryTransactionsParams) (driver.TransactionIterator, error)

Transactions returns an iterators of transaction records filtered by the given params.

type TxStatus

type TxStatus = driver.TxStatus

TxStatus is the status of a transaction

const (
	// Unknown is the status of a transaction that is unknown
	Unknown TxStatus = driver.Unknown
	// Pending is the status of a transaction that has been submitted to the ledger
	Pending TxStatus = driver.Pending
	// Confirmed is the status of a transaction that has been confirmed by the ledger
	Confirmed TxStatus = driver.Confirmed
	// Deleted is the status of a transaction that has been deleted due to a failure to commit
	Deleted TxStatus = driver.Deleted
)

type WithdrawalRequest added in v0.3.0

type WithdrawalRequest struct {
	TMSID         token.TMSID
	RecipientData RecipientData
	TokenType     token2.Type
	Amount        uint64
	NotAnonymous  bool
}

func ReceiveWithdrawalRequest added in v0.3.0

func ReceiveWithdrawalRequest(context view.Context) (*WithdrawalRequest, error)

Jump to

Keyboard shortcuts

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