Documentation
¶
Index ¶
- func GetWallet(context view.Context, id string, opts ...token.ServiceOption) *token.OwnerWallet
- func NewFinalityView(tx *Transaction, opts ...ttx.TxOption) view.View
- func RequestRecipientIdentity(context view.Context, parties []token.Identity, opts ...token.ServiceOption) (token.Identity, error)
- type EscrowAuth
- func (s *EscrowAuth) AmIAnAuditor() bool
- func (s *EscrowAuth) IsMine(ctx context.Context, tok *token3.Token) (string, []string, bool)
- func (s *EscrowAuth) Issued(ctx context.Context, issuer driver.Identity, tok *token3.Token) bool
- func (s *EscrowAuth) OwnerType(raw []byte) (driver.IdentityType, []byte, error)
- type OwnerWallet
- func (w *OwnerWallet) ListTokens(ctx context.Context, opts ...token.ListTokensOption) (*token2.UnspentTokens, error)
- func (w *OwnerWallet) ListTokensAsEscrow(ctx context.Context, opts ...token.ListTokensOption) (iterators.Iterator[*token2.UnspentToken], error)
- func (w *OwnerWallet) ListTokensIterator(ctx context.Context, opts ...token.ListTokensOption) (iterators.Iterator[*token2.UnspentToken], error)
- type QueryEngine
- type ReceiveSpendRequestView
- type ReceiveSpendTxView
- type RequestSpendView
- type SpendRequest
- type SpendResponse
- type TokenVault
- type Transaction
- type Vault
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetWallet ¶
func GetWallet(context view.Context, id string, opts ...token.ServiceOption) *token.OwnerWallet
GetWallet returns the wallet whose id is the passed id
func NewFinalityView ¶
func NewFinalityView(tx *Transaction, opts ...ttx.TxOption) view.View
func RequestRecipientIdentity ¶
func RequestRecipientIdentity(context view.Context, parties []token.Identity, opts ...token.ServiceOption) (token.Identity, error)
RequestRecipientIdentity requests the recipient identity for the given parties. It returns a multisig identity. All the parties are notified about the participants in the multisig identity.
Types ¶
type EscrowAuth ¶
type EscrowAuth struct {
WalletService driver.WalletService
}
EscrowAuth implements the Authorization interface for this script
func NewEscrowAuth ¶
func NewEscrowAuth(walletService driver.WalletService) *EscrowAuth
func (*EscrowAuth) AmIAnAuditor ¶
func (s *EscrowAuth) AmIAnAuditor() bool
AmIAnAuditor returns false for script ownership
func (*EscrowAuth) IsMine ¶
IsMine returns true if either the sender or the recipient is in one of the owner wallets. It returns an empty wallet id.
func (*EscrowAuth) OwnerType ¶
func (s *EscrowAuth) OwnerType(raw []byte) (driver.IdentityType, []byte, error)
type OwnerWallet ¶
type OwnerWallet struct {
// contains filtered or unexported fields
}
OwnerWallet is a combination of a wallet and a query service
func Wallet ¶
func Wallet(context view.Context, wallet *token.OwnerWallet) *OwnerWallet
Wallet returns an OwnerWallet which contains a wallet and a query service
func (*OwnerWallet) ListTokens ¶
func (w *OwnerWallet) ListTokens(ctx context.Context, opts ...token.ListTokensOption) (*token2.UnspentTokens, error)
ListTokens returns a list of tokens that matches the passed options and whose recipient belongs to this wallet
func (*OwnerWallet) ListTokensAsEscrow ¶
func (w *OwnerWallet) ListTokensAsEscrow(ctx context.Context, opts ...token.ListTokensOption) (iterators.Iterator[*token2.UnspentToken], error)
ListTokensAsEscrow returns a list of tokens which are co-owned by OwnerWallet
func (*OwnerWallet) ListTokensIterator ¶
func (w *OwnerWallet) ListTokensIterator(ctx context.Context, opts ...token.ListTokensOption) (iterators.Iterator[*token2.UnspentToken], error)
ListTokensIterator returns an iterator of tokens that matches the passed options and whose recipient belongs to this wallet
type QueryEngine ¶
type ReceiveSpendRequestView ¶
type ReceiveSpendRequestView struct{}
ReceiveSpendRequestView receives a SpendRequest from the context's session.
func NewReceiveSpendRequestView ¶
func NewReceiveSpendRequestView() *ReceiveSpendRequestView
type ReceiveSpendTxView ¶
type ReceiveSpendTxView struct {
// contains filtered or unexported fields
}
ReceiveSpendTxView is the co-owner's view: it ACKs the SpendRequest and returns the assembled transaction received from the initiator without endorsing it. The caller is responsible for inspecting the transaction (e.g. confirming it consumes the expected token and does not include other tokens owned by this node) and, if the checks pass, running ttx.NewEndorseView(tx) to produce the signature.
Splitting receive from endorse lets the application decide which business-logic checks to apply rather than baking a fixed policy into the library.
func NewReceiveSpendTxView ¶
func NewReceiveSpendTxView(request *SpendRequest) *ReceiveSpendTxView
NewReceiveSpendTxView returns a new ReceiveSpendTxView for the given request.
func (*ReceiveSpendTxView) Call ¶
func (a *ReceiveSpendTxView) Call(context view.Context) (any, error)
Call implements view.View. It sends the SpendResponse ACK, receives the assembled transaction, and returns it without endorsing. Endorsement is the caller's responsibility once any business-logic checks pass.
type RequestSpendView ¶
type RequestSpendView struct {
// contains filtered or unexported fields
}
RequestSpendView sends a SpendRequest to all parties and waits for their responses
func NewRequestSpendView ¶
func NewRequestSpendView(unspentToken *token.UnspentToken, opts ...token2.ServiceOption) *RequestSpendView
func (*RequestSpendView) WithTimeout ¶
func (c *RequestSpendView) WithTimeout(timeout time.Duration) *RequestSpendView
type SpendRequest ¶
type SpendRequest struct {
Token *token.UnspentToken
}
SpendRequest is the request to spend a token
func ReceiveSpendRequest ¶
func (*SpendRequest) Bytes ¶
func (r *SpendRequest) Bytes() ([]byte, error)
func (*SpendRequest) String ¶
func (r *SpendRequest) String() string
type SpendResponse ¶
type SpendResponse struct {
Err error
}
SpendResponse is the response to a SpendRequest
type TokenVault ¶
type Transaction ¶
type Transaction struct {
*ttx.Transaction
}
Transaction wraps a ttx.Transaction to provide a more user-friendly API for multisig transactions.
func ReceiveSpendTx ¶
func ReceiveSpendTx(context view.Context, request *SpendRequest) (*Transaction, error)
ReceiveSpendTx is a convenience wrapper that runs ReceiveSpendTxView and returns the unsigned spend transaction so the caller can inspect it before deciding whether to endorse.
func Wrap ¶
func Wrap(tx *ttx.Transaction) *Transaction
Wrap wraps a ttx.Transaction to provide a more user-friendly API for multisig transactions.
func (*Transaction) Lock ¶
func (t *Transaction) Lock(senderWallet *token2.OwnerWallet, tokenType token.Type, amount uint64, recipient token2.Identity, opts ...token2.TransferOption) error
Lock locks the given amount of tokens of the given type in the sender's wallet and transfers them to the recipient.
func (*Transaction) Spend ¶
func (t *Transaction) Spend(senderWallet *token2.OwnerWallet, at *token.UnspentToken, recipient token2.Identity, opts ...token2.TransferOption) error
Spend spends the given token.