service

package
v0.0.0-...-7107d2d Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KeyEvent - event name for key
	KeyEvent = "key"
	// BatchExecuteEvent - event name for batch execute
	BatchExecuteEvent = "batchExecute"
)

Variables

This section is empty.

Functions

func AsBytes

func AsBytes(args []string) [][]byte

AsBytes converts a slice of strings to a slice of byte slices.

func ConvertPrivateKeyToBase58Check

func ConvertPrivateKeyToBase58Check(privateKey ed25519.PrivateKey) string

ConvertPrivateKeyToBase58Check - use privateKey with standard encoded type - Base58Check

func ConvertPublicKeyToBase58

func ConvertPublicKeyToBase58(publicKey ed25519.PublicKey) string

ConvertPublicKeyToBase58 - use publicKey with standard encoded type - Base58

func ConvertSignatureToBase58

func ConvertSignatureToBase58(publicKey []byte) string

ConvertSignatureToBase58 - use signature with standard encoded type - Base58

func EncodedPrivKeyToEd25519

func EncodedPrivKeyToEd25519(secretKey string) (ed25519.PrivateKey, ed25519.PublicKey, error)

EncodedPrivKeyToEd25519 - get private key type Ed25519 by encoded private key in string secretKey string - private key in base58check, base58 or hex

func GenerateMessage

func GenerateMessage(validatorPublicKeys []string, channelID string, chaincodeName string, methodName string, args []string) string

GenerateMessage - generate message for sign

func GeneratePrivateAndPublicKey

func GeneratePrivateAndPublicKey() (ed25519.PublicKey, ed25519.PrivateKey, error)

GeneratePrivateAndPublicKey - generate private and public key

func GeneratePrivateKey

func GeneratePrivateKey() (string, error)

GeneratePrivateKey - generate private key

func GetAddress

func GetAddress(secretKey string) (string, error)

GetAddress - get address by encoded string in standard encoded for project is 'base58.Check' secretKey string - private key in base58check, or hex or base58

func GetAddressByPublicKey

func GetAddressByPublicKey(publicKey ed25519.PublicKey) (string, error)

GetAddressByPublicKey - get address by encoded string in standard encoded for project is 'base58.Check' secretKey string - private key in base58check, or hex or base58

func GetBase58PubKey

func GetBase58PubKey(secretKey string) (string, error)

GetBase58PubKey returns base58-encoded pubkey. secretKey string - private key in base58check, or hex or base58

func GetNonce

func GetNonce() string

GetNonce - get nonce for transaction

func GetNonceInt64

func GetNonceInt64() int64

GetNonceInt64 - get nonce for transaction

func GetPrivateKeySKFromBase58

func GetPrivateKeySKFromBase58(secretKey string) (ed25519.PrivateKey, ed25519.PublicKey, error)

GetPrivateKeySKFromBase58 - get private key type Ed25519 by string - Base58 encoded private key secretKey string - private key in Base58

func GetPrivateKeySKFromBase58Check

func GetPrivateKeySKFromBase58Check(secretKey string) (ed25519.PrivateKey, ed25519.PublicKey, error)

GetPrivateKeySKFromBase58Check - get private key type Ed25519 by string - Base58Check encoded private key secretKey string - private key in Base58Check

func GetPrivateKeySKFromHex

func GetPrivateKeySKFromHex(secretKey string) (ed25519.PrivateKey, ed25519.PublicKey, error)

GetPrivateKeySKFromHex - get private key type Ed25519 by string - hex encoded private key secretKey string - private key in hex

func NowMillisecond

func NowMillisecond() int64

NowMillisecond returns current time in milliseconds

func Sign

func Sign(privateKey ed25519.PrivateKey, publicKey ed25519.PublicKey, channel string, chaincode string, methodName string, args []string) ([]string, string, error)

Sign - sign message by private key

func SignACL

func SignACL(signerInfoArray []SignerInfo, methodName string, address string, reason string, reasonId string, newPkey string) ([]string, string, error)

SignACL - sign message by private key

func SignMessage

func SignMessage(signerInfo SignerInfo, result []string) ([]byte, [32]byte, error)

SignMessage - sign message by private key

Types

type HLFClient

type HLFClient struct {
	NotifierChaincodeEvents map[string]<-chan *fab.CCEvent

	ContextOptions []fabsdk.ContextOption
	// contains filtered or unexported fields
}

HLFClient - Hyperledger Fabric client

func NewHLFClient

func NewHLFClient(connectionConfigPath string, username string, organization string, vaultConfig *VaultConfig) (*HLFClient, error)

NewHLFClient - create new HLFClient instance

func (*HLFClient) AddAfterInvokeHandler

func (hlf *HLFClient) AddAfterInvokeHandler(afterInvokeHandler HlfAfterInvokeHandler)

AddAfterInvokeHandler - add after invoke handler

func (*HLFClient) AddBeforeInvokeHandler

func (hlf *HLFClient) AddBeforeInvokeHandler(beforeInvokeHandler HlfBeforeInvokeHandler)

AddBeforeInvokeHandler - add before invoke handler

func (*HLFClient) AddChannel

func (hlf *HLFClient) AddChannel(channelID string, events ...string) error

AddChannel - add channel to hlf client

func (*HLFClient) AddFabsdk

func (hlf *HLFClient) AddFabsdk(configProvider core2.ConfigProvider, opts ...fabsdk.Option) error

AddFabsdk - add fabsdk to hlf client

func (*HLFClient) ChaincodeVersion

func (hlf *HLFClient) ChaincodeVersion(chaincode string, peer string) (string, error)

ChaincodeVersion - only for admin user, get version for chaincode, firstly try to get version for 1.4, secondly try to get for 2.3 lifecycle

func (*HLFClient) ChaincodeVersion14

func (hlf *HLFClient) ChaincodeVersion14(client *resmgmt.Client, chaincode string, peer string) (string, error)

ChaincodeVersion14 - only for admin user, get version for chaincode for 1.4 hlf

func (*HLFClient) ChaincodeVersion23Lifecycle

func (hlf *HLFClient) ChaincodeVersion23Lifecycle(client *resmgmt.Client, chaincode string, peer string) (string, error)

ChaincodeVersion23Lifecycle - only for admin user, get version for Committed chaincode for 2.3 hlf - lifecycle

func (*HLFClient) GetBlockchainInfo

func (hlf *HLFClient) GetBlockchainInfo(channelID string, peer string) (*fab.BlockchainInfoResponse, error)

GetBlockchainInfo queries and return information about ledger (height, current block hash, and previous block hash) from peer.

func (*HLFClient) GetCCEventNotifier

func (hlf *HLFClient) GetCCEventNotifier(client *channel.Client, chaincodeName string, event string) (<-chan *fab.CCEvent, error)

GetCCEventNotifier - get notifier for chaincode event

func (*HLFClient) GetTransactionByID

func (hlf *HLFClient) GetTransactionByID(channelID string, transactionID string, peer string) (*peer.ProcessedTransaction, error)

GetTransactionByID - return transaction by id from peer

func (*HLFClient) Invoke

func (hlf *HLFClient) Invoke(channelID string, chaincodeName string, methodName string, methodArgs []string, noBatch bool, peers ...string) (*channel.Response, error)

Invoke - method to sign arguments and send invoke request to hlf channelID string - channel name for invoke chaincodeName string - chaincode name for invoke methodName string - chaincode method name for invoke methodArgs []string - noBatch bool - if wait batchTransaction set 'true' peers string - target peer for invoke, if empty use default peer count by policy

func (*HLFClient) InvokeWithPublicAndPrivateKey

func (hlf *HLFClient) InvokeWithPublicAndPrivateKey(privateKey ed25519.PrivateKey, publicKey ed25519.PublicKey, channelID string, chaincodeName string, methodName string, methodArgs []string, noBatch bool, peers string) (*channel.Response, error)

InvokeWithPublicAndPrivateKey - method to sign arguments and send invoke request to hlf privateKey string - private key in ed25519 publicKey string - private key in ed25519 channelID string - channel name for invoke chaincodeName string - chaincode name for invoke methodName string - chaincode method name for invoke methodArgs []string - noBatch bool - if wait batchTransaction set 'true' peers string - peer0.atomyze

func (*HLFClient) InvokeWithSecretKey

func (hlf *HLFClient) InvokeWithSecretKey(channelID string, chaincodeName string, methodName string, methodArgs []string, secretKey string, noBatch bool, peers string) (*channel.Response, error)

InvokeWithSecretKey - method to sign arguments and send invoke request to hlf methodArgs []string - secretKey string - private key ed25519 - in base58check, or hex or base58 chaincodeName string - chaincode name for invoke methodName string - chaincode method name for invoke noBatch bool - if wait batchTransaction set 'true' peers string - peer0.atomyze

func (*HLFClient) Query

func (hlf *HLFClient) Query(
	channelID string, chaincodeName string, methodName string, methodArgs []string,
) (*channel.Response, error)

Query - method to send query request to hlf

func (*HLFClient) QueryBlock

func (hlf *HLFClient) QueryBlock(channelID string, blockID string, endpoints string) (*common.Block, error)

QueryBlock - return block by id from peer

func (*HLFClient) QueryBlockByTxID

func (hlf *HLFClient) QueryBlockByTxID(channelID string, transactionId string, peer string) (*common.Block, error)

QueryBlockByTxID - return block by transaction id

func (*HLFClient) Request

func (hlf *HLFClient) Request(
	methodArgs []string, chaincodeName string, methodName string, noBatch bool,
	client *channel.Client,
	requestFunc func(channel.Request, ...channel.RequestOption) (channel.Response, error),
	options ...channel.RequestOption,
) (*channel.Response, error)

Request - method to send request to hlf

func (*HLFClient) SignArgs

func (hlf *HLFClient) SignArgs(channelID string, chaincodeName string, methodName string, methodArgs []string, privateKey ed25519.PrivateKey, publicKey ed25519.PublicKey) ([]string, error)

SignArgs - sign arguments for invoke

type HlfAfterInvokeHandler

type HlfAfterInvokeHandler func(beforeInvokeData interface{}, r *channel.Response, invokeErr error, channelID string, chaincodeName string, methodName string, methodArgs []string, noBatch bool, peers ...string) error

HlfAfterInvokeHandler - handler after invoke

type HlfBeforeInvokeHandler

type HlfBeforeInvokeHandler func(channelID string, chaincodeName string, methodName string, methodArgs []string, noBatch bool, peers ...string) (interface{}, error)

HlfBeforeInvokeHandler - handler before invoke

type SignerInfo

type SignerInfo struct {
	PrivateKey ed25519.PrivateKey
	PublicKey  ed25519.PublicKey
}

SignerInfo - struct for sign message

type VaultConfig

type VaultConfig struct {
	Token string `mapstructure:"token,omitempty"`
	Path  string `mapstructure:"path,omitempty"`

	Address      string `mapstructure:"address,omitempty"`
	UserCertName string `mapstructure:"user_cert_name,omitempty"`
	UserOrgMspID string `mapstructure:"user_org_msp_id,omitempty"`
}

VaultConfig - config for vault

Jump to

Keyboard shortcuts

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