Documentation
¶
Index ¶
- Constants
- func ClaimKey(v []byte) string
- func CreateNonce() ([]byte, error)
- func ExchangeRecipientIdentities(context view.Context, walletID string, recipient view.Identity, ...) (view.Identity, view.Identity, error)
- func GetWallet(context view.Context, id string, opts ...token.ServiceOption) *token.OwnerWallet
- func IsScript(selector SelectFunction) iterators.Predicate[*token.UnspentToken]
- func LockKey(v []byte) string
- func LockValue(v []byte) []byte
- func NewAcceptView(tx *Transaction) view.View
- func NewCollectEndorsementsView(tx *Transaction) view.View
- func NewFinalityView(tx *Transaction, opts ...ttx.TxOption) view.View
- func NewOrderingAndFinalityView(tx *Transaction) view.View
- func NewOrderingAndFinalityWithTimeoutView(tx *Transaction, timeout time.Duration) view.View
- func NewReceiveTransactionView(network string) *receiveTransactionView
- func RespondExchangeRecipientIdentities(context view.Context) (view.Identity, view.Identity, error)
- func ScanForPreImage(sp token.ServiceProvider, image []byte, hashFunc crypto.Hash, ...) ([]byte, error)
- func SelectExpired(tok *token.UnspentToken, script *Script) (bool, error)
- func SelectNonExpired(tok *token.UnspentToken, script *Script) (bool, error)
- func WithHash(hash []byte) token.TransferOption
- func WithHashEncoding(encoding encoding.Encoding) token.TransferOption
- func WithHashFunc(hashFunc crypto.Hash) token.TransferOption
- func WithStartingTransaction(txID string) token.ServiceOption
- func WithStopOnLastTransaction() token.ServiceOption
- type Binder
- type ClaimSignature
- type ClaimSigner
- type ClaimVerifier
- type DistributeTermsView
- type ExpiredAndHashSelector
- type HashInfo
- type Input
- type Output
- type OutputStream
- type OwnerWallet
- func (w *OwnerWallet) DeleteClaimedSentTokens(context view.Context, opts ...token.ListTokensOption) error
- func (w *OwnerWallet) DeleteExpiredReceivedTokens(context view.Context, opts ...token.ListTokensOption) error
- func (w *OwnerWallet) GetExpiredByHash(ctx context.Context, hash []byte, opts ...token.ListTokensOption) (*token2.UnspentToken, error)
- func (w *OwnerWallet) GetExpiredReceivedTokenByHash(ctx context.Context, hash []byte, opts ...token.ListTokensOption) (*token2.UnspentToken, error)
- func (w *OwnerWallet) ListByPreImage(ctx context.Context, preImage []byte, opts ...token.ListTokensOption) (*token2.UnspentTokens, error)
- func (w *OwnerWallet) ListByPreImageIterator(ctx context.Context, preImage []byte, opts ...token.ListTokensOption) (iterators.Iterator[*token2.UnspentToken], error)
- func (w *OwnerWallet) ListExpired(ctx context.Context, opts ...token.ListTokensOption) (*token2.UnspentTokens, error)
- func (w *OwnerWallet) ListExpiredIterator(ctx context.Context, opts ...token.ListTokensOption) (iterators.Iterator[*token2.UnspentToken], error)
- func (w *OwnerWallet) ListExpiredReceivedTokens(ctx context.Context, opts ...token.ListTokensOption) (*token2.UnspentTokens, error)
- func (w *OwnerWallet) ListExpiredReceivedTokensIterator(ctx context.Context, opts ...token.ListTokensOption) (iterators.Iterator[*token2.UnspentToken], error)
- func (w *OwnerWallet) ListTokens(ctx context.Context, opts ...token.ListTokensOption) (*token2.UnspentTokens, error)
- func (w *OwnerWallet) ListTokensAsSender(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 PreImageSelector
- type QueryEngine
- type Script
- type ScriptAuth
- func (s *ScriptAuth) AmIAnAuditor() bool
- func (s *ScriptAuth) IsMine(ctx context.Context, tok *token3.Token) (string, []string, bool)
- func (s *ScriptAuth) Issued(ctx context.Context, issuer driver.Identity, tok *token3.Token) bool
- func (s *ScriptAuth) OwnerType(raw []byte) (driver.IdentityType, []byte, error)
- type SelectFunction
- type Terms
- type TokenVault
- type Transaction
- func NewAnonymousTransaction(sp view.Context, opts ...ttx.TxOption) (*Transaction, error)
- func NewTransaction(sp view.Context, signer view.Identity, opts ...ttx.TxOption) (*Transaction, error)
- func NewTransactionFromBytes(ctx view.Context, network, channel string, raw []byte) (*Transaction, error)
- func ReceiveTransaction(context view.Context) (*Transaction, error)
- func (t *Transaction) Claim(wallet *token.OwnerWallet, tok *token2.UnspentToken, preImage []byte, ...) error
- func (t *Transaction) Lock(ctx context.Context, wallet *token.OwnerWallet, sender view.Identity, ...) ([]byte, error)
- func (t *Transaction) Outputs() (*OutputStream, error)
- func (t *Transaction) Reclaim(wallet *token.OwnerWallet, tok *token2.UnspentToken, ...) error
- type Vault
- type Verifier
Constants ¶
const ( ClaimPreImage = "htlc.cpi" LockHash = "htlc.lh" )
const ( ScanForPreImageStartingTransaction = "htlc.ScanForPreImage.StartingTransaction" StopScanningOnLastTransaction = "htlc.ScanForPreImage.StopOnLastTransaction" True = "true" )
const ( ScriptType = driver.HTLCScriptIdentityType ScriptTypeString = driver.HTLCScriptIdentityTypeString // htlc script )
const TypeHTLCTerms = "htlc_terms"
TypeHTLCTerms is the envelope message-type discriminator for the HTLC Terms exchange. It lives with the htlc service rather than the generic session package.
Variables ¶
This section is empty.
Functions ¶
func CreateNonce ¶
CreateNonce generates a nonce using the common/crypto package
func ExchangeRecipientIdentities ¶
func ExchangeRecipientIdentities(context view.Context, walletID string, recipient view.Identity, opts ...token.ServiceOption) (view.Identity, view.Identity, error)
ExchangeRecipientIdentities executes the ttx ExchangeRecipientIdentitiesView
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 IsScript ¶
func IsScript(selector SelectFunction) iterators.Predicate[*token.UnspentToken]
func NewAcceptView ¶
func NewAcceptView(tx *Transaction) view.View
NewAcceptView returns an instance of the ttx acceptView struct
func NewCollectEndorsementsView ¶
func NewCollectEndorsementsView(tx *Transaction) view.View
NewCollectEndorsementsView returns an instance of the ttx collectEndorsementsView struct
func NewFinalityView ¶
func NewFinalityView(tx *Transaction, opts ...ttx.TxOption) view.View
NewFinalityView returns an instance of the ttx FinalityView
func NewOrderingAndFinalityView ¶
func NewOrderingAndFinalityView(tx *Transaction) view.View
NewOrderingAndFinalityView returns a new instance of the ttx orderingAndFinalityView struct
func NewOrderingAndFinalityWithTimeoutView ¶
func NewOrderingAndFinalityWithTimeoutView(tx *Transaction, timeout time.Duration) view.View
NewOrderingAndFinalityWithTimeoutView returns a new instance of the ttx orderingAndFinalityWithTimeoutView struct
func NewReceiveTransactionView ¶
func NewReceiveTransactionView(network string) *receiveTransactionView
NewReceiveTransactionView returns an instance of receiveTransactionView struct
func RespondExchangeRecipientIdentities ¶
RespondExchangeRecipientIdentities executes the ttx RespondExchangeRecipientIdentitiesView
func ScanForPreImage ¶
func ScanForPreImage(sp token.ServiceProvider, image []byte, hashFunc crypto.Hash, hashEncoding encoding.Encoding, timeout time.Duration, opts ...token.ServiceOption) ([]byte, error)
ScanForPreImage scans the ledger for a preimage of the passed image, taking into account the timeout
func SelectExpired ¶
func SelectExpired(tok *token.UnspentToken, script *Script) (bool, error)
SelectExpired selects expired htlc-tokens
func SelectNonExpired ¶
func SelectNonExpired(tok *token.UnspentToken, script *Script) (bool, error)
SelectNonExpired selects non-expired htlc-tokens
func WithHash ¶
func WithHash(hash []byte) token.TransferOption
WithHash sets a hash attribute to be used to customize the transfer command
func WithHashEncoding ¶
func WithHashEncoding(encoding encoding.Encoding) token.TransferOption
WithHashEncoding sets a hash encoding attribute to be used to customize the transfer command
func WithHashFunc ¶
func WithHashFunc(hashFunc crypto.Hash) token.TransferOption
WithHashFunc sets a hash function attribute to be used to customize the transfer command
func WithStartingTransaction ¶
func WithStartingTransaction(txID string) token.ServiceOption
WithStartingTransaction sets the network name
func WithStopOnLastTransaction ¶
func WithStopOnLastTransaction() token.ServiceOption
WithStopOnLastTransaction stops the scan when the last transaction is reached. When this is not set, the scan will wait until timeout or until the key is found.
Types ¶
type ClaimSignature ¶
ClaimSignature is the claim signature of an htlc script
type ClaimSigner ¶
ClaimSigner is the signer for the claim of an htlc script
type ClaimVerifier ¶
ClaimVerifier is the verifier of a ClaimSignature
func (*ClaimVerifier) Verify ¶
func (cv *ClaimVerifier) Verify(tokenRequestAndTxID, claimSignature []byte) error
Verify verifies that the passed signature is valid and that the contained preimage matches the hash info
type DistributeTermsView ¶
type DistributeTermsView struct {
// contains filtered or unexported fields
}
DistributeTermsView holds the terms and the recipient identity to be used by the view
func NewDistributeTermsView ¶
func NewDistributeTermsView(recipient view.Identity, terms *Terms) *DistributeTermsView
NewDistributeTermsView creates a view which distributes the terms to the recipient
type ExpiredAndHashSelector ¶
type ExpiredAndHashSelector struct {
Hash []byte
}
ExpiredAndHashSelector selects expired htlc-tokens with a specific hash
func (*ExpiredAndHashSelector) Select ¶
func (s *ExpiredAndHashSelector) Select(tok *token.UnspentToken, script *Script) (bool, error)
type HashInfo ¶
HashInfo contains the information regarding the hashing
type OutputStream ¶
type OutputStream struct {
*token.OutputStream
}
OutputStream models a stream over a set of outputs
func NewOutputStream ¶
func NewOutputStream(outputs *token.OutputStream) *OutputStream
NewOutputStream creates a new OutputStream for the passed outputs
func (*OutputStream) ByScript ¶
func (o *OutputStream) ByScript() *OutputStream
ByScript filters the OutputStream to only include outputs that are owned by an htlc script
func (*OutputStream) Filter ¶
func (o *OutputStream) Filter(f func(t *token.Output) bool) *OutputStream
Filter filters the OutputStream to only include outputs that match the passed predicate
func (*OutputStream) ScriptAt ¶
func (o *OutputStream) ScriptAt(i int) *Script
ScriptAt returns an htlc script that is the owner of the output at the passed index of the OutputStream
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) DeleteClaimedSentTokens ¶
func (w *OwnerWallet) DeleteClaimedSentTokens(context view.Context, opts ...token.ListTokensOption) error
DeleteClaimedSentTokens removes the claimed htlc-tokens whose sender id is in this wallet
func (*OwnerWallet) DeleteExpiredReceivedTokens ¶
func (w *OwnerWallet) DeleteExpiredReceivedTokens(context view.Context, opts ...token.ListTokensOption) error
DeleteExpiredReceivedTokens removes the expired htlc-tokens that have been reclaimed
func (*OwnerWallet) GetExpiredByHash ¶
func (w *OwnerWallet) GetExpiredByHash(ctx context.Context, hash []byte, opts ...token.ListTokensOption) (*token2.UnspentToken, error)
GetExpiredByHash returns the expired htlc-token whose sender id is in this wallet and whose hash is equal to the one passed as argument. It fails if no tokens are found or if more than one token is found.
func (*OwnerWallet) GetExpiredReceivedTokenByHash ¶
func (w *OwnerWallet) GetExpiredReceivedTokenByHash(ctx context.Context, hash []byte, opts ...token.ListTokensOption) (*token2.UnspentToken, error)
GetExpiredReceivedTokenByHash returns the expired htlc-token that matches the passed options, whose recipient belongs to this wallet, is expired, and hash the same hash. It fails if no tokens are found or if more than one token is found.
func (*OwnerWallet) ListByPreImage ¶
func (w *OwnerWallet) ListByPreImage(ctx context.Context, preImage []byte, opts ...token.ListTokensOption) (*token2.UnspentTokens, error)
ListByPreImage returns a list of tokens whose recipient is this wallet and with a matching preimage
func (*OwnerWallet) ListByPreImageIterator ¶
func (w *OwnerWallet) ListByPreImageIterator(ctx context.Context, preImage []byte, opts ...token.ListTokensOption) (iterators.Iterator[*token2.UnspentToken], error)
ListByPreImageIterator returns an iterator of tokens whose recipient is this wallet and with a matching preimage
func (*OwnerWallet) ListExpired ¶
func (w *OwnerWallet) ListExpired(ctx context.Context, opts ...token.ListTokensOption) (*token2.UnspentTokens, error)
ListExpired returns a list of expired htlc-tokens whose sender id is in this wallet
func (*OwnerWallet) ListExpiredIterator ¶
func (w *OwnerWallet) ListExpiredIterator(ctx context.Context, opts ...token.ListTokensOption) (iterators.Iterator[*token2.UnspentToken], error)
ListExpiredIterator returns an iterator of expired htlc-tokens whose sender id is in this wallet
func (*OwnerWallet) ListExpiredReceivedTokens ¶
func (w *OwnerWallet) ListExpiredReceivedTokens(ctx context.Context, opts ...token.ListTokensOption) (*token2.UnspentTokens, error)
ListExpiredReceivedTokens returns a list of tokens that matches the passed options, whose recipient belongs to this wallet, and are expired
func (*OwnerWallet) ListExpiredReceivedTokensIterator ¶
func (w *OwnerWallet) ListExpiredReceivedTokensIterator(ctx context.Context, opts ...token.ListTokensOption) (iterators.Iterator[*token2.UnspentToken], error)
ListExpiredReceivedTokensIterator returns an iterator of tokens that matches the passed options, whose recipient belongs to this wallet, and are expired
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) ListTokensAsSender ¶
func (w *OwnerWallet) ListTokensAsSender(ctx context.Context, opts ...token.ListTokensOption) (iterators.Iterator[*token2.UnspentToken], error)
ListTokensAsSender returns a list of non-expired htlc-tokens whose sender id is in this wallet
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 PreImageSelector ¶
type PreImageSelector struct {
// contains filtered or unexported fields
}
PreImageSelector selects htlc-tokens that match a given pre-image
func (*PreImageSelector) Filter ¶
func (f *PreImageSelector) Filter(tok *token.UnspentToken, script *Script) (bool, error)
type QueryEngine ¶
type Script ¶
type Script struct {
Sender view.Identity
Recipient view.Identity
Deadline time.Time
HashInfo HashInfo
}
Script contains the details of an htlc
type ScriptAuth ¶
type ScriptAuth struct {
WalletService driver.WalletService
}
ScriptAuth implements the Authorization interface for this script
func NewScriptAuth ¶
func NewScriptAuth(walletService driver.WalletService) *ScriptAuth
func (*ScriptAuth) AmIAnAuditor ¶
func (s *ScriptAuth) AmIAnAuditor() bool
AmIAnAuditor returns false for script ownership
func (*ScriptAuth) 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 (*ScriptAuth) OwnerType ¶
func (s *ScriptAuth) OwnerType(raw []byte) (driver.IdentityType, []byte, error)
type SelectFunction ¶
type SelectFunction = func(*token.UnspentToken, *Script) (bool, error)
SelectFunction is the prototype of a function to select pairs (token,script)
type Terms ¶
type Terms struct {
ReclamationDeadline time.Duration
TMSID1 token.TMSID
Type1 token2.Type
Amount1 uint64
TMSID2 token.TMSID
Type2 token2.Type
Amount2 uint64
}
Terms contains the details of the htlc to be examined
func ReceiveTerms ¶
ReceiveTerms runs the termsReceiverView and returns the received terms
type TokenVault ¶
type Transaction ¶
type Transaction struct {
*ttx.Transaction
Binder Binder
}
Transaction holds a ttx transaction
func NewAnonymousTransaction ¶
NewAnonymousTransaction returns a new anonymous token transaction customized with the passed opts
func NewTransaction ¶
func NewTransaction(sp view.Context, signer view.Identity, opts ...ttx.TxOption) (*Transaction, error)
NewTransaction returns a new token transaction customized with the passed opts that will be signed by the passed signer
func NewTransactionFromBytes ¶
func NewTransactionFromBytes(ctx view.Context, network, channel string, raw []byte) (*Transaction, error)
NewTransactionFromBytes returns a new transaction from the passed bytes
func ReceiveTransaction ¶
func ReceiveTransaction(context view.Context) (*Transaction, error)
ReceiveTransaction executes the receiveTransactionView and returns the received transaction
func (*Transaction) Claim ¶
func (t *Transaction) Claim(wallet *token.OwnerWallet, tok *token2.UnspentToken, preImage []byte, opts ...token.TransferOption) error
Claim appends a claim (transfer) action to the token request of the transaction
func (*Transaction) Lock ¶
func (t *Transaction) Lock(ctx context.Context, wallet *token.OwnerWallet, sender view.Identity, typ token2.Type, value uint64, recipient view.Identity, deadline time.Duration, opts ...token.TransferOption) ([]byte, error)
Lock appends a lock action to the token request of the transaction
func (*Transaction) Outputs ¶
func (t *Transaction) Outputs() (*OutputStream, error)
Outputs returns a new OutputStream of the transaction's outputs
func (*Transaction) Reclaim ¶
func (t *Transaction) Reclaim(wallet *token.OwnerWallet, tok *token2.UnspentToken, opts ...token.TransferOption) error
Reclaim appends a reclaim (transfer) action to the token request of the transaction
type Verifier ¶
type Verifier struct {
Recipient driver.Verifier
Sender driver.Verifier
Deadline time.Time
HashInfo HashInfo
// ClockFunc returns the current time used to evaluate the deadline.
// It defaults to time.Now when nil.
// Callers that have access to the Fabric block timestamp should inject it
// here to ensure deterministic, clock-skew-safe deadline enforcement.
ClockFunc func() time.Time
}
Verifier checks if an htlc script can be claimed or reclaimed