core

package
v0.0.0-...-497026d Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EncryptionAlgoName string = "secp256k1"
	FamilyVersion      string = "0.1"
)

Internal Constants

View Source
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.

View Source
const (
	AddressLength   = 70
	NamespaceLength = 6
)

address related constants used by various payloads

View Source
const (
	AddressNotFound int = 404
)

Various codes go here

Variables

View Source
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

func CheckLength(address string) string

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

func FamilyName(sourceAccount, payloadType string) string

FamilyName returns family name from source account and payload type

func GetBankAuthTools

func GetBankAuthTools() (bankPubKey sgn.PublicKey, signer *sgn.Signer)

GetBankAuthTools returns bank public key and signer object

func HashIt

func HashIt(p []byte) []byte

HashIt hash. Note: code taken from doSHA512 in signing

func HexdigestB

func HexdigestB(p []byte) string

HexdigestB mimics hexdigest() in python's hashlib

func HexdigestStr

func HexdigestStr(str string) string

HexdigestStr for strings

func Namespace

func Namespace(familyName string) string

Namespace for state addresses

func RuleFunctions

func RuleFunctions() map[string]govaluate.ExpressionFunction

RuleFunctions the functions allowable in rule expressions

func SubmitStateReq

func SubmitStateReq(address string) ([]string, [][]byte)

SubmitStateReq to rest api

func SubmitTx

func SubmitTx(tx *tpr.Transaction) map[string]interface{}

SubmitTx for submitting transaction through restful API

func VerifyPermission

func VerifyPermission(familyName string, pubKey []byte) bool

VerifyPermission verify that initiator is permitted to transact in this transaction family

func VerifySignature

func VerifySignature(pl, signature, pubKey []byte) bool

VerifySignature signature is that of pl using pubKey

Types

type ARule

type ARule struct {
	Rule     string `json:"rule"`
	RuleHash string `json:"rulehash"`
}

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 NewRule

func NewRule(r string, ruleHash string) ARule

NewRule constructs new rule

func SortConflicts

func SortConflicts(m map[string][]ARule) []ARule

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?)

func (*ARule) Evaluate

func (r *ARule) Evaluate(m map[string]interface{}) interface{}

Evaluate the rule for the given parameters. Currently returns "nil" (yes, string) or output from rule function(s)

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

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

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

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

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

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

Apply remove a transactor from a group of transactors

func (*PayloadRemoveInitiatorFromGroup) WrapInTx

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

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

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

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

func (*PayloadSetPendingTx) Apply

func (*PayloadSetPendingTx) Apply(pl []byte, context *processor.Context) error

Apply applier for making a transaction pending

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

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

Jump to

Keyboard shortcuts

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