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(sp view2.ServiceProvider, id string, opts ...token.ServiceOption) *token.OwnerWallet
- 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) view.View
- func NewFinalityWithTimeoutView(tx *Transaction, timeout time.Duration) 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(ctx view.Context, 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
- type ClaimSignature
- type ClaimSigner
- type ClaimVerifier
- type DistributeTermsView
- type FilteredIterator
- 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) ListByPreImage(preImage []byte, opts ...token.ListTokensOption) (*token2.UnspentTokens, error)
- func (w *OwnerWallet) ListByPreImageIterator(preImage []byte, opts ...token.ListTokensOption) (*FilteredIterator, error)
- func (w *OwnerWallet) ListExpired(opts ...token.ListTokensOption) (*token2.UnspentTokens, error)
- func (w *OwnerWallet) ListExpiredIterator(opts ...token.ListTokensOption) (*FilteredIterator, error)
- func (w *OwnerWallet) ListExpiredReceivedTokens(opts ...token.ListTokensOption) (*token2.UnspentTokens, error)
- func (w *OwnerWallet) ListExpiredReceivedTokensIterator(opts ...token.ListTokensOption) (*FilteredIterator, error)
- func (w *OwnerWallet) ListTokens(opts ...token.ListTokensOption) (*token2.UnspentTokens, error)
- func (w *OwnerWallet) ListTokensAsSender(opts ...token.ListTokensOption) (*FilteredIterator, error)
- func (w *OwnerWallet) ListTokensIterator(opts ...token.ListTokensOption) (*FilteredIterator, error)
- type PreImageSelector
- type QueryEngine
- type Script
- type ScriptOwnership
- type SelectFunction
- type Terms
- 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(wallet *token.OwnerWallet, sender view.Identity, typ string, value uint64, ...) ([]byte, error)
- func (t *Transaction) Outputs() (*OutputStream, error)
- func (t *Transaction) Reclaim(wallet *token.OwnerWallet, tok *token2.UnspentToken) error
- type Verifier
Constants ¶
const ( ClaimPreImage = "htlc.cpi" LockHash = "htlc.lh" )
const (
ScanForPreImageStartingTransaction = "htlc.ScanForPreImage.StartingTransaction"
)
const (
ScriptType = "htlc" // htlc script
)
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(sp view2.ServiceProvider, id string, opts ...token.ServiceOption) *token.OwnerWallet
GetWallet returns the wallet whose id is the passed id
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) view.View
NewFinalityView returns an instance of the ttx FinalityView
func NewFinalityWithTimeoutView ¶
func NewFinalityWithTimeoutView(tx *Transaction, timeout time.Duration) view.View
NewFinalityWithTimeoutView returns an instance of the ttx FinalityView with timeout
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(ctx view.Context, 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
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 FilteredIterator ¶
type FilteredIterator struct {
// contains filtered or unexported fields
}
func (*FilteredIterator) Close ¶
func (f *FilteredIterator) Close()
func (*FilteredIterator) Next ¶
func (f *FilteredIterator) Next() (*token2.UnspentToken, 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(sp view2.ServiceProvider, 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) ListByPreImage ¶
func (w *OwnerWallet) ListByPreImage(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(preImage []byte, opts ...token.ListTokensOption) (*FilteredIterator, error)
ListByPreImageIterator returns an iterator of tokens whose recipient is this wallet and with a matching preimage
func (*OwnerWallet) ListExpired ¶
func (w *OwnerWallet) ListExpired(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(opts ...token.ListTokensOption) (*FilteredIterator, error)
ListExpiredIterator returns a iterator of expired htlc-tokens whose sender id is in this wallet
func (*OwnerWallet) ListExpiredReceivedTokens ¶
func (w *OwnerWallet) ListExpiredReceivedTokens(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(opts ...token.ListTokensOption) (*FilteredIterator, 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(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(opts ...token.ListTokensOption) (*FilteredIterator, error)
ListTokensAsSender returns a list of non-expired htlc-tokens whose sender id is in this wallet
func (*OwnerWallet) ListTokensIterator ¶
func (w *OwnerWallet) ListTokensIterator(opts ...token.ListTokensOption) (*FilteredIterator, 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 QueryEngine interface { // UnspentTokensIteratorBy returns an iterator over all unspent tokens by type and id. Type can be empty UnspentTokensIteratorBy(id, typ string) (driver.UnspentTokensIterator, error) }
type Script ¶
type Script struct { Sender view.Identity Recipient view.Identity Deadline time.Time HashInfo HashInfo }
Script contains the details of an htlc
type ScriptOwnership ¶
type ScriptOwnership struct{}
ScriptOwnership implements the Ownership interface for scripts
func (*ScriptOwnership) AmIAnAuditor ¶
func (s *ScriptOwnership) AmIAnAuditor(tms *token.ManagementService) bool
AmIAnAuditor returns false for script ownership
func (*ScriptOwnership) IsMine ¶
func (s *ScriptOwnership) IsMine(tms *token.ManagementService, tok *token3.Token) ([]string, bool)
IsMine returns true if one is either a sender or a recipient of an htlc script
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 string Amount1 uint64 TMSID2 token.TMSID Type2 string Amount2 uint64 }
Terms contains the details of the htlc to be examined
func ReceiveTerms ¶
ReceiveTerms runs the termsReceiverView and returns the received terms
type Transaction ¶
type Transaction struct {
*ttx.Transaction
}
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) error
Claim appends a claim (transfer) action to the token request of the transaction
func (*Transaction) Lock ¶
func (t *Transaction) Lock(wallet *token.OwnerWallet, sender view.Identity, typ string, 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) error
Reclaim appends a reclaim (transfer) action to the token request of the transaction