transaction

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// encoded public key length 0x21 || encoded public key (33 bytes) || OP_CHECKSIG(0xac)
	PublickKeyScriptLen = 35

	// signature length(0x40) || 64 bytes signature
	SignatureScriptLen = 65

	// 1byte m || 3 encoded public keys with leading 0x40 (34 bytes * 3) ||
	// 1byte n + 1byte OP_CHECKMULTISIG
	// FIXME: if want to support 1/2 multisig
	MinMultisigCodeLen = 105
)

Variables

This section is empty.

Functions

func IsValidAttributeType

func IsValidAttributeType(usage TransactionAttributeUsage) bool

func ParseMultisigTransactionCode

func ParseMultisigTransactionCode(code []byte) []common.Uint160

Types

type BalanceTxInput

type BalanceTxInput struct {
	AssetID     common.Uint256
	Value       common.Fixed64
	ProgramHash common.Uint160
}

func (*BalanceTxInput) Deserialize

func (bi *BalanceTxInput) Deserialize(r io.Reader) error

func (*BalanceTxInput) Serialize

func (bi *BalanceTxInput) Serialize(w io.Writer)

type ILedgerStore

type ILedgerStore interface {
	GetTransaction(hash Uint256) (*Transaction, error)
	GetQuantityIssued(AssetId Uint256) (Fixed64, error)
}
var TxStore ILedgerStore

type Payload

type Payload interface {
	Data(version byte) []byte
	Serialize(w io.Writer, version byte) error

	Deserialize(r io.Reader, version byte) error
}

type Transaction

type Transaction struct {
	TxType         TransactionType
	PayloadVersion byte
	Payload        Payload
	Attributes     []*TxAttribute
	UTXOInputs     []*UTXOTxInput
	BalanceInputs  []*BalanceTxInput
	Outputs        []*TxOutput
	Programs       []*program.Program

	AssetOutputs      map[common.Uint256][]*TxOutput
	AssetInputAmount  map[common.Uint256]common.Fixed64
	AssetOutputAmount map[common.Uint256]common.Fixed64
	// contains filtered or unexported fields
}

func NewBookKeeperTransaction

func NewBookKeeperTransaction(pubKey *crypto.PubKey, isAdd bool, cert []byte, issuer *crypto.PubKey) (*Transaction, error)

func NewDataFileTransaction

func NewDataFileTransaction(path string, fileName string, note string, issuer *crypto.PubKey) (*Transaction, error)

func NewDeployTransaction

func NewDeployTransaction(fc *code.FunctionCode, programHash common.Uint160, name, codeversion, author, email, desp string, language types.LangType) (*Transaction, error)

initial a new transaction with publish payload

func NewInvokeTransaction

func NewInvokeTransaction(fc []byte, codeHash common.Uint160, programhash common.Uint160) (*Transaction, error)

initial a new transaction with invoke payload

func NewIssueAssetTransaction

func NewIssueAssetTransaction(outputs []*TxOutput) (*Transaction, error)

func NewLockAssetTransaction

func NewLockAssetTransaction(programHash common.Uint160, assetID common.Uint256, amount common.Fixed64, height uint32) (*Transaction, error)

func NewPrivacyPayloadTransaction

func NewPrivacyPayloadTransaction(fromPrivKey []byte, fromPubkey *crypto.PubKey, toPubkey *crypto.PubKey, payloadType payload.EncryptedPayloadType, data []byte) (*Transaction, error)

func NewRecordTransaction

func NewRecordTransaction(recordType string, recordData []byte) (*Transaction, error)

initial a new transaction with record payload

func NewRegisterAssetTransaction

func NewRegisterAssetTransaction(asset *asset.Asset, amount common.Fixed64, issuer *crypto.PubKey, controller common.Uint160) (*Transaction, error)

func NewTransferAssetTransaction

func NewTransferAssetTransaction(inputs []*UTXOTxInput, outputs []*TxOutput) (*Transaction, error)

func (*Transaction) AppendNewSignature

func (tx *Transaction) AppendNewSignature(sig []byte) error

func (*Transaction) Deserialize

func (tx *Transaction) Deserialize(r io.Reader) error

deserialize the Transaction

func (*Transaction) DeserializeUnsigned

func (tx *Transaction) DeserializeUnsigned(r io.Reader) error

func (*Transaction) DeserializeUnsignedWithoutType

func (tx *Transaction) DeserializeUnsignedWithoutType(r io.Reader) error

func (*Transaction) GenerateAssetMaps

func (tx *Transaction) GenerateAssetMaps()

func (*Transaction) GetMergedAssetIDValueFromOutputs

func (tx *Transaction) GetMergedAssetIDValueFromOutputs() TransactionResult

func (*Transaction) GetMergedAssetIDValueFromReference

func (tx *Transaction) GetMergedAssetIDValueFromReference() (TransactionResult, error)

func (*Transaction) GetMessage

func (tx *Transaction) GetMessage() []byte

func (*Transaction) GetOutputHashes

func (tx *Transaction) GetOutputHashes() ([]common.Uint160, error)

func (*Transaction) GetProgramHashes

func (tx *Transaction) GetProgramHashes() ([]common.Uint160, error)

func (*Transaction) GetPrograms

func (tx *Transaction) GetPrograms() []*program.Program

func (*Transaction) GetReference

func (tx *Transaction) GetReference() (map[*UTXOTxInput]*TxOutput, error)

func (*Transaction) GetTransactionResults

func (tx *Transaction) GetTransactionResults() (TransactionResult, error)

func (*Transaction) Hash

func (tx *Transaction) Hash() common.Uint256

func (*Transaction) ParseTransactionCode

func (tx *Transaction) ParseTransactionCode() []common.Uint160

func (*Transaction) ParseTransactionSig

func (tx *Transaction) ParseTransactionSig() (havesig, needsig int, err error)

func (*Transaction) Serialize

func (tx *Transaction) Serialize(w io.Writer) error

Serialize the Transaction

func (*Transaction) SerializeUnsigned

func (tx *Transaction) SerializeUnsigned(w io.Writer) error

Serialize the Transaction data without contracts

func (*Transaction) SetHash

func (tx *Transaction) SetHash(hash common.Uint256)

func (*Transaction) SetPrograms

func (tx *Transaction) SetPrograms(programs []*program.Program)

func (*Transaction) ToArray

func (tx *Transaction) ToArray() []byte

func (*Transaction) Type

func (tx *Transaction) Type() common.InventoryType

func (*Transaction) Verify

func (tx *Transaction) Verify() error

type TransactionAttributeUsage

type TransactionAttributeUsage byte
const (
	Nonce          TransactionAttributeUsage = 0x00
	Script         TransactionAttributeUsage = 0x20
	DescriptionUrl TransactionAttributeUsage = 0x81
	Description    TransactionAttributeUsage = 0x90
)

type TransactionPool

type TransactionPool interface {

	//  add a transaction to the pool.
	Add(*Transaction) error

	//returns all transactions that were in the pool.
	Dump() ([]*Transaction, error)
}

type TransactionResult

type TransactionResult map[common.Uint256]common.Fixed64

type TransactionType

type TransactionType byte
const (
	BookKeeping    TransactionType = 0x00
	IssueAsset     TransactionType = 0x01
	BookKeeper     TransactionType = 0x02
	LockAsset      TransactionType = 0x03
	PrivacyPayload TransactionType = 0x20
	RegisterAsset  TransactionType = 0x40
	TransferAsset  TransactionType = 0x80
	Record         TransactionType = 0x81
	DeployCode     TransactionType = 0xd0
	InvokeCode     TransactionType = 0xd1
	DataFile       TransactionType = 0x12
)

type TxAttribute

type TxAttribute struct {
	Usage TransactionAttributeUsage
	Data  []byte
	Size  uint32
}

func NewTxAttribute

func NewTxAttribute(u TransactionAttributeUsage, data []byte) TxAttribute

func (*TxAttribute) Deserialize

func (tx *TxAttribute) Deserialize(r io.Reader) error

func (*TxAttribute) GetSize

func (tx *TxAttribute) GetSize() uint32

func (*TxAttribute) Serialize

func (tx *TxAttribute) Serialize(w io.Writer) error

func (*TxAttribute) ToArray

func (tx *TxAttribute) ToArray() []byte

type TxOutput

type TxOutput struct {
	AssetID     common.Uint256
	Value       common.Fixed64
	ProgramHash common.Uint160
}

func (*TxOutput) Deserialize

func (o *TxOutput) Deserialize(r io.Reader)

func (*TxOutput) Serialize

func (o *TxOutput) Serialize(w io.Writer)

func (*TxOutput) ToArray

func (ui *TxOutput) ToArray() []byte

type UTXOTxInput

type UTXOTxInput struct {
	ReferTxID common.Uint256

	//the index of transcation
	ReferTxOutputIndex uint16
}

func (*UTXOTxInput) Deserialize

func (ui *UTXOTxInput) Deserialize(r io.Reader) error

func (*UTXOTxInput) Equals

func (ui *UTXOTxInput) Equals(other *UTXOTxInput) bool

func (*UTXOTxInput) Serialize

func (ui *UTXOTxInput) Serialize(w io.Writer)

func (*UTXOTxInput) ToArray

func (ui *UTXOTxInput) ToArray() []byte

func (*UTXOTxInput) ToString

func (ui *UTXOTxInput) ToString() string

type UTXOUnspent

type UTXOUnspent struct {
	Txid  common.Uint256
	Index uint32
	Value common.Fixed64
}

func (*UTXOUnspent) Deserialize

func (uu *UTXOUnspent) Deserialize(r io.Reader) error

func (*UTXOUnspent) Serialize

func (uu *UTXOUnspent) Serialize(w io.Writer)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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