abchainTx

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ADDRESS_VERSION  = 1
	ADDRESS_CRC_LEN  = 4
	ADDRESS_HASH_LEN = 20
)
View Source
const (
	AddressRequirePartByteSize = ADDRESS_HASH_LEN + ADDRESS_VERSION
	AddressVerifyCodeSize      = ADDRESS_CRC_LEN
)

Variables

This section is empty.

Functions

func DecodeProto

func DecodeProto(arg []byte, m proto.Message) error

func DefaultNetworkName

func DefaultNetworkName() string

func EncodeProto

func EncodeProto(m proto.Message) []byte

func GenerateNonce

func GenerateNonce() []byte

func GetAddrCheckSum

func GetAddrCheckSum(rb []byte) ([AddressVerifyCodeSize]byte, error)

func GetHashOfRawTx

func GetHashOfRawTx(header []byte, msg []byte, method string) []byte

func NewTxBuilder

func NewTxBuilder(ccname string, nonce []byte, method string, msg proto.Message) (*baseBuilder, error)

func NewTxBuilder2

func NewTxBuilder2(ccname string, nonce []byte) (b *baseBuilder, err error)

func NewTxBuilderWithTimeLock

func NewTxBuilderWithTimeLock(ccname string, nonce []byte, t time.Time) (b *baseBuilder, err error)

func NewTxMaker

func NewTxMaker(args [][]byte) *baseMaker

func NormalizeHash

func NormalizeHash(h []byte) []byte

func SetAddressInterfaceImpl

func SetAddressInterfaceImpl(impl AddressInterface)

SetAddressInterfaceImpl set impl nil to restore v1

func UseNetwork

func UseNetwork(i uint8)

Types

type AddrCredentialBuilder

type AddrCredentialBuilder interface {
	AddSignature(sign *pb.Signature)
}

type AddrCredentials

type AddrCredentials interface {
	Verify(addr Address) error
	CredCount() int
	// GetCredPubkey(addr Address) *crypto.PublicKey
	// ListCredPubkeys() []*crypto.PublicKey
	GetCredPubkey(addr Address) crypto.Verifier
	ListCredPubkeys() []crypto.Verifier
}

func NewAddrCredential

func NewAddrCredential(hash []byte, addrc []*pb.TxCredential_AddrCredentials_User) (ret AddrCredentials, e error)

type Address

type Address struct {
	Version   int32
	NetworkId uint8
	Hash      []byte
}

func NewAddress

func NewAddress(pub abcrypto.Verifier) (*Address, error)

func NewAddressFromHash

func NewAddressFromHash(h []byte) *Address

func NewAddressFromPBMessage

func NewAddressFromPBMessage(addrProto *pb.TxAddr) (*Address, error)

func NewAddressFromPrivateKey

func NewAddressFromPrivateKey(priv abcrypto.Signer) (*Address, error)

func NewAddressFromString

func NewAddressFromString(addressStr string) (*Address, error)

func (*Address) Dump

func (addr *Address) Dump() string

func (*Address) Internal

func (addr *Address) Internal() []byte

func (*Address) IsEqual

func (addr *Address) IsEqual(otherAddr *Address) bool

func (*Address) IsExternal

func (addr *Address) IsExternal() bool

func (*Address) PBMessage

func (addr *Address) PBMessage() *pb.TxAddr

func (*Address) Serialize

func (addr *Address) Serialize() []byte

func (*Address) ToString

func (addr *Address) ToString() string

type AddressHelper

type AddressHelper map[uint8]string
var AddrHelper AddressHelper = map[uint8]string{
	1: "ABCHAIN",
	4: "VCTMAINNET",
}

type AddressInterface

type AddressInterface interface {
	NewAddressFromString(addressStr string) (*Address, error)
	Serialize(addr *Address) []byte
}

AddressInterface interface

type AddressInterfaceV1

type AddressInterfaceV1 struct{}

AddressInterfaceV1 struct

func (AddressInterfaceV1) NewAddressFromString

func (m AddressInterfaceV1) NewAddressFromString(addressStr string) (*Address, error)

NewAddressFromString for AddressInterfaceV1

func (AddressInterfaceV1) Serialize

func (m AddressInterfaceV1) Serialize(addr *Address) []byte

Serialize for AddressInterfaceV1

type Builder

type Builder interface {
	TxMaker
	GetNonce() []byte
	GetHash() []byte
}

type DataCredentials

type DataCredentials interface {
	GetValue(string) interface{}
}

type DataCredentialsBuilder

type DataCredentialsBuilder interface {
	AddString(string, string)
	AddInteger(string, int32)
	AddBytes(string, []byte)
}

type Flags

type Flags uint32

Flags for txoption

func TxFlag_Timelock

func TxFlag_Timelock() Flags

TxFlag_Timelock indicate the expried time in header is obliged to be considered

func (Flags) And

func (f Flags) And(fanother Flags) Flags

And @Flags

func (Flags) IsTimeLock

func (f Flags) IsTimeLock() bool

IsTimeLock @Flags

func (Flags) U

func (f Flags) U() uint32

U @Flags

type Parser

type Parser interface {
	GetCCname() string
	GetNonce() []byte
	GetFlags() Flags
	GetTxTime() time.Time
	GetAddrCredential() AddrCredentials
	GetDataCredential() DataCredentials
	//an optional index can passed to fetch a message pushed in stack
	//no argument or 0 fetch the current message
	GetMessage(...int) proto.Message
	PushMsg(proto.Message)
	PopMsg() proto.Message

	//is alias of PushMsg now (backward compatibility)
	UpdateMsg(proto.Message)
}

Parser ...

func ParseTx

func ParseTx(msg proto.Message, method string, args [][]byte) (Parser, error)

ParseTx ...

type TxArgParser

type TxArgParser interface {
	Msg() proto.Message
	Detail(proto.Message) interface{}
}

a parser which can handle the arguments of a transaction with purposed format in hyperledger project

type TxMaker

type TxMaker interface {
	GetCredBuilder() AddrCredentialBuilder
	GetDataCredBuilder() DataCredentialsBuilder
	GenArguments() ([][]byte, error)
	GenArgumentsWithoutCred() ([][]byte, error)
	GenHash(string) []byte
}

Jump to

Keyboard shortcuts

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