Documentation
¶
Index ¶
- Constants
- Variables
- func CheckLength(address string) string
- func CreateTransaction(pl *c.SignedPayload, familyName string, inputs []string, outputs []string, ...) *tpr.Transaction
- func FamilyName(sourceAccount, payloadType string) string
- func GetBankAuthTools() (bankPubKey sgn.PublicKey, signer *sgn.Signer)
- func HashIt(p []byte) []byte
- func HexdigestB(p []byte) string
- func HexdigestStr(str string) string
- func Namespace(familyName string) string
- func RuleFunctions() map[string]govaluate.ExpressionFunction
- func SubmitStateReq(address string) ([]string, [][]byte)
- func SubmitTx(tx *tpr.Transaction) map[string]interface{}
- func VerifyPermission(familyName string, pubKey []byte) bool
- func VerifySignature(pl, signature, pubKey []byte) bool
- type ARule
- type ErrorBody
- type PagingBody
- type PayloadAddInitiatorToGroup
- type PayloadAddSigTx
- type PayloadClosePendingTx
- type PayloadDeleteInitiatorPubKeys
- type PayloadDeleteInitiatorRule
- type PayloadListInitiatorGroups
- type PayloadListInitiatorPubKeys
- type PayloadListInitiatorRules
- type PayloadListPendingTx
- type PayloadListRecipient
- type PayloadQueryAuth
- type PayloadRemoveInitiatorFromGroup
- type PayloadRemoveRecipient
- type PayloadSetInitiatorPubKeys
- type PayloadSetInitiatorRule
- type PayloadSetPendingTx
- type PayloadSetRecipient
- type PendingTxSigsInfo
- type StateRespBody
- type StatusRespBody
Constants ¶
const ( EncryptionAlgoName string = "secp256k1" FamilyVersion string = "0.1" )
Internal Constants
const ( RecipientPermissionTag string = "" InitiatorPermissionTag string = "" )
Permission tags used in transaction family names. With these sys admin can configure role level permissions as opposed to account level only. Important Note: as of this version, they must remain empty strings.
const ( AddressLength = 70 NamespaceLength = 6 )
address related constants used by various payloads
const (
AddressNotFound int = 404
)
Various codes go here
Variables ¶
var PayloadRegistry = map[string]reflect.Type{ "set_initiator_rule": reflect.TypeOf(&PayloadSetInitiatorRule{}), "delete_initiator_rule": reflect.TypeOf(&PayloadDeleteInitiatorRule{}), "list_initiator_rules": reflect.TypeOf(&PayloadListInitiatorRules{}), "add_initiator_to_group": reflect.TypeOf(&PayloadAddInitiatorToGroup{}), "remove_initiator_from_group": reflect.TypeOf(&PayloadRemoveInitiatorFromGroup{}), "list_initiator_groups": reflect.TypeOf(&PayloadListInitiatorGroups{}), "set_initiator_pub_keys": reflect.TypeOf(&PayloadSetInitiatorPubKeys{}), "delete_initiator_pub_keys": reflect.TypeOf(&PayloadDeleteInitiatorPubKeys{}), "list_initiator_pub_keys": reflect.TypeOf(&PayloadListInitiatorPubKeys{}), "query_auth": reflect.TypeOf(&PayloadQueryAuth{}), "set_pending_tx": reflect.TypeOf(&PayloadSetPendingTx{}), "close_pending_tx": reflect.TypeOf(&PayloadClosePendingTx{}), "add_sig_tx": reflect.TypeOf(&PayloadAddSigTx{}), "list_pending_tx": reflect.TypeOf(&PayloadListPendingTx{}), "set_recipient": reflect.TypeOf(&PayloadSetRecipient{}), "remove_recipient": reflect.TypeOf(&PayloadRemoveRecipient{}), "list_recipient": reflect.TypeOf(&PayloadListRecipient{}), "set_account_level_rule": reflect.TypeOf(&PayloadSetInitiatorRule{}), "delete_account_level_rule": reflect.TypeOf(&PayloadDeleteInitiatorRule{}), "list_account_level_rules": reflect.TypeOf(&PayloadListInitiatorRules{}), }
PayloadRegistry map strings to payload types
Functions ¶
func CheckLength ¶
CheckLength the length required by sawtooth
func CreateTransaction ¶
func CreateTransaction(pl *c.SignedPayload, familyName string, inputs []string, outputs []string, dependencies []string) *tpr.Transaction
CreateTransaction build a sawtooth transaction
func FamilyName ¶
FamilyName returns family name from source account and payload type
func GetBankAuthTools ¶
GetBankAuthTools returns bank public key and signer object
func HexdigestB ¶
HexdigestB mimics hexdigest() in python's hashlib
func RuleFunctions ¶
func RuleFunctions() map[string]govaluate.ExpressionFunction
RuleFunctions the functions allowable in rule expressions
func SubmitStateReq ¶
SubmitStateReq to rest api
func SubmitTx ¶
func SubmitTx(tx *tpr.Transaction) map[string]interface{}
SubmitTx for submitting transaction through restful API
func VerifyPermission ¶
VerifyPermission verify that initiator is permitted to transact in this transaction family
func VerifySignature ¶
VerifySignature signature is that of pl using pubKey
Types ¶
type ARule ¶
ARule structure for storing rules. rules are required to be ternary expressions. Rule must be a ternary expression that returns output from NofM() in RuleFunctions() or "nil"
func SortConflicts ¶
SortConflicts takes group rules and individual rules, for example, and overrule the group rule when conflict is detected. In general, rules in second array overrule those in first. Problem: how to detect conflicting rules? one idea: rules concerning the exact same quantities and only those (for example, initiator and amount and nothing else) should be solved for conflicts (using SAT?)
type ErrorBody ¶
type ErrorBody struct {
Code int `json:"Code"`
Title string `json:"Title"`
Message string `json:"Message"`
}
ErrorBody structure for errors
type PagingBody ¶
type PagingBody struct {
Start string `json:"Start"` // address of first block on page
Limit int `json:"Limit"` // what we retrieved
NextPosision string `json:"NextPosition"` // address of block at top of next page
Next string `json:"Next"` // link to next
}
PagingBody if response broken into pages
type PayloadAddInitiatorToGroup ¶
type PayloadAddInitiatorToGroup c.PayloadAddInitiatorToGroup
PayloadAddInitiatorToGroup assign individual initiator or group to a (larger) group
func (*PayloadAddInitiatorToGroup) Apply ¶
func (*PayloadAddInitiatorToGroup) Apply(pl []byte, context *processor.Context) error
Apply add a transactor to a group of transactors
func (*PayloadAddInitiatorToGroup) WrapInTx ¶
func (*PayloadAddInitiatorToGroup) WrapInTx(pl *c.SignedPayload) *transaction_pb2.Transaction
WrapInTx SignedPayload with PayloadAddInitiatorToGroup to submit to validator
type PayloadAddSigTx ¶
type PayloadAddSigTx c.PayloadAddSigTx
PayloadAddSigTx to add a sig to a pending tx requiring multi sigs
func (*PayloadAddSigTx) Apply ¶
func (*PayloadAddSigTx) Apply(pl []byte, context *processor.Context) error
Apply applier for adding signatures to a pending transaction
func (*PayloadAddSigTx) Handle ¶
func (*PayloadAddSigTx) Handle(pl []byte) map[string]interface{}
Handle add sig tx. Note: add sig tx is a state changing request. Unlike other state changing requests however which just have to make sure the transaction was committed (through SubmitTx), add sig tx needs to know if all sigs have been obtained. Since the Apply() method invoked from the validator has to return error only, I added a Handle() method which checks to see if more sigs are still needed after this sig has been added
func (*PayloadAddSigTx) WrapInTx ¶
func (*PayloadAddSigTx) WrapInTx(pl *c.SignedPayload) *transaction_pb2.Transaction
WrapInTx signedPayload with PayloadAddSigTx to submit to validator
type PayloadClosePendingTx ¶
type PayloadClosePendingTx c.PayloadClosePendingTx
PayloadClosePendingTx to cancel a tx pending while sigs are collected
func (*PayloadClosePendingTx) Apply ¶
func (*PayloadClosePendingTx) Apply(pl []byte, context *processor.Context) error
Apply applier for closing a pending transaction. typical scenario is cancellation of the transaction
func (*PayloadClosePendingTx) WrapInTx ¶
func (*PayloadClosePendingTx) WrapInTx(pl *c.SignedPayload) *transaction_pb2.Transaction
WrapInTx signedPayload with payloadClosePendingTx to submit to validator
type PayloadDeleteInitiatorPubKeys ¶
type PayloadDeleteInitiatorPubKeys c.PayloadDeleteInitiatorPubKeys
PayloadDeleteInitiatorPubKeys remove public key that was attached to initiator
func (*PayloadDeleteInitiatorPubKeys) Apply ¶
func (*PayloadDeleteInitiatorPubKeys) Apply(pl []byte, context *processor.Context) error
Apply delete public keys for transactor
func (*PayloadDeleteInitiatorPubKeys) WrapInTx ¶
func (*PayloadDeleteInitiatorPubKeys) WrapInTx(pl *c.SignedPayload) *transaction_pb2.Transaction
WrapInTx SignedPayload with PayloadDeleteInitiatorPubKeys to submit to validator
type PayloadDeleteInitiatorRule ¶
type PayloadDeleteInitiatorRule c.PayloadDeleteInitiatorRule
PayloadDeleteInitiatorRule delete rule that applies to individual intiator or group
func (*PayloadDeleteInitiatorRule) Apply ¶
func (*PayloadDeleteInitiatorRule) Apply(pl []byte, context *processor.Context) error
Apply applier for deleting new account rules
func (*PayloadDeleteInitiatorRule) WrapInTx ¶
func (*PayloadDeleteInitiatorRule) WrapInTx(pl *c.SignedPayload) *transaction_pb2.Transaction
WrapInTx SignedPayload with PayloadDeleteInitiatorRule to submit to validator
type PayloadListInitiatorGroups ¶
type PayloadListInitiatorGroups c.PayloadListInitiatorGroups
PayloadListInitiatorGroups list all groups that this initiator belongs to
func (*PayloadListInitiatorGroups) Handle ¶
func (*PayloadListInitiatorGroups) Handle(pl []byte) map[string]interface{}
Handle for listing of initiator and recipient specific rules
type PayloadListInitiatorPubKeys ¶
type PayloadListInitiatorPubKeys c.PayloadListInitiatorPubKeys
PayloadListInitiatorPubKeys list all keys that were assigned to this (individual) initiator
func (*PayloadListInitiatorPubKeys) Handle ¶
func (*PayloadListInitiatorPubKeys) Handle(pl []byte) map[string]interface{}
Handle for listing of initiator and recipient specific rules
type PayloadListInitiatorRules ¶
type PayloadListInitiatorRules c.PayloadListInitiatorRules
PayloadListInitiatorRules list rules that apply to individual intiator or group
func (*PayloadListInitiatorRules) Handle ¶
func (*PayloadListInitiatorRules) Handle(pl []byte) map[string]interface{}
Handle for listing of initiator and recipient specific rules
type PayloadListPendingTx ¶
type PayloadListPendingTx c.PayloadListPendingTx
PayloadListPendingTx for listing all pending tx requiring an initiator's sig
func (*PayloadListPendingTx) Handle ¶
func (*PayloadListPendingTx) Handle(pl []byte) map[string]interface{}
Handle return all payloads of all pending transactions awaiting payload.Initiator's signature
type PayloadListRecipient ¶
type PayloadListRecipient c.PayloadListRecipient
PayloadListRecipient methods implementation
func (*PayloadListRecipient) Handle ¶
func (*PayloadListRecipient) Handle(pl []byte) map[string]interface{}
Handle list all state information about this recipient
type PayloadQueryAuth ¶
type PayloadQueryAuth c.PayloadQueryAuth
PayloadQueryAuth for querying the system about allowing a banking transaction to go through
func (*PayloadQueryAuth) Handle ¶
func (*PayloadQueryAuth) Handle(pl []byte) map[string]interface{}
Handle to handle authorisation queries payloads
type PayloadRemoveInitiatorFromGroup ¶
type PayloadRemoveInitiatorFromGroup c.PayloadRemoveInitiatorFromGroup
PayloadRemoveInitiatorFromGroup remove initiator from group
func (*PayloadRemoveInitiatorFromGroup) Apply ¶
func (*PayloadRemoveInitiatorFromGroup) Apply(pl []byte, context *processor.Context) error
Apply remove a transactor from a group of transactors
func (*PayloadRemoveInitiatorFromGroup) WrapInTx ¶
func (*PayloadRemoveInitiatorFromGroup) WrapInTx(pl *c.SignedPayload) *transaction_pb2.Transaction
WrapInTx SignedPayload with PayloadRemoveInitiatorFromGroup to submit to validator
type PayloadRemoveRecipient ¶
type PayloadRemoveRecipient c.PayloadRemoveRecipient
PayloadRemoveRecipient methods implementation
func (*PayloadRemoveRecipient) Apply ¶
func (*PayloadRemoveRecipient) Apply(pl []byte, context *processor.Context) error
Apply remove account details for recipient
func (*PayloadRemoveRecipient) WrapInTx ¶
func (*PayloadRemoveRecipient) WrapInTx(pl *c.SignedPayload) *transaction_pb2.Transaction
WrapInTx wrap SignedPayload with PayloadRemoveRecipient payload in a sawtooth transaction
type PayloadSetInitiatorPubKeys ¶
type PayloadSetInitiatorPubKeys c.PayloadSetInitiatorPubKeys
PayloadSetInitiatorPubKeys assign public key(s) to (individual) initiator
func (*PayloadSetInitiatorPubKeys) Apply ¶
func (*PayloadSetInitiatorPubKeys) Apply(pl []byte, context *processor.Context) error
Apply set the public keys for a given transactor, typically one for every channel
func (*PayloadSetInitiatorPubKeys) WrapInTx ¶
func (*PayloadSetInitiatorPubKeys) WrapInTx(pl *c.SignedPayload) *transaction_pb2.Transaction
WrapInTx SignedPayload with PayloadSetInitiatorPubKeys to submit to validator
type PayloadSetInitiatorRule ¶
type PayloadSetInitiatorRule c.PayloadSetInitiatorRule
PayloadSetInitiatorRule setting rules that apply to individual intiator or group
func (*PayloadSetInitiatorRule) Apply ¶
func (*PayloadSetInitiatorRule) Apply(pl []byte, context *processor.Context) error
Apply applier for setting new account rules
func (*PayloadSetInitiatorRule) WrapInTx ¶
func (*PayloadSetInitiatorRule) WrapInTx(pl *c.SignedPayload) *transaction_pb2.Transaction
WrapInTx SignedPayload with PayloadSetInitiatorRule to submit to validator
type PayloadSetPendingTx ¶
type PayloadSetPendingTx struct {
SourceAccount string
BankTransaction []byte // the bank transaction that requires multi sigs
AuthorisedSigs []string // List of pools (comma-separated lists) of authorised signers from the multisig rules that were triggered by this transaction
RequiredMinSigs []int // list of minimum required sigs: so, RequiredMinSigs[0] applies to the signers in AuthorisedSigs[0], a string with Transactor{} ID's separated by commas
TransactionID string
Initiator string // this is the initiator who initiated the query that resulted in this pending tx
}
PayloadSetPendingTx payload to set pending transaction and signature info. Note: this one is only defined here and not in ../common because a client never initiates a set pending tx
type PayloadSetRecipient ¶
type PayloadSetRecipient c.PayloadSetRecipient
PayloadSetRecipient methods implementation
func (*PayloadSetRecipient) Apply ¶
func (*PayloadSetRecipient) Apply(pl []byte, context *processor.Context) error
Apply tie recipient to specific accounts
func (*PayloadSetRecipient) WrapInTx ¶
func (*PayloadSetRecipient) WrapInTx(pl *c.SignedPayload) *transaction_pb2.Transaction
WrapInTx wrap SignedPayload with PayloadSetRecipient payload in a sawtooth transaction
type PendingTxSigsInfo ¶
type PendingTxSigsInfo struct {
AuthorisedSigs []map[string]bool // one map per rule triggered. value true means signer signed
RequiredMinSigs []int
}
PendingTxSigsInfo convenient structure to store required sigs info in the state
type StateRespBody ¶
type StateRespBody struct {
Data []map[string]interface{} `json:"Data"`
Link string `json:"Link"`
Head string `json:"Head"`
Paging PagingBody `json:"Paging"`
Error ErrorBody `json:"Error"`
}
StateRespBody struct for state query response body
type StatusRespBody ¶
type StatusRespBody struct {
Data []map[string]interface{} `json:"data"`
Link string `json:"link"`
}
StatusRespBody for status response body