transaction

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2020 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SCRIPT_SEPARATOR_HEX ...
	SCRIPT_SEPARATOR_HEX = "003b" // Unicode semi-colon character: ";"

	// SCRIPT_ITEM_SEPARATOR_HEX ...
	SCRIPT_ITEM_SEPARATOR_HEX = "002c" // Unicode comma character: ","
)

Separators should be used as their binary value, ie. passed through utils.Must(utils.FromHex()).

View Source
const (
	STATE   = "state"
	OPT_IN  = "opt-in"
	OPT_OUT = "opt-out"
)
View Source
const (
	// INFINITY ...
	INFINITY int = -1 // Any negative value would suit but -1 is our preferred choice
)

Variables

This section is empty.

Functions

func CheckScript

func CheckScript(ls LockingScript, us UnlockingScript) bool

CheckScript should return `true` to notify that it's a valid combination of transactions

It takes the opt-in's locking script and the other transaction's unlocking script and return a boolean.

func Checker

func Checker(item interface{}, value interface{}) bool

Checker is a function to be sent to concurrent.Slice.Check to compare the ID of both transactions. Item will be the original and Value will be either the new transaction we're trying to compare or its ID as a `Hash`.

func RebuildTransactionID

func RebuildTransactionID(forTx Transaction) (txID model.Hash, err error)

RebuildTransactionID ...

Types

type Contract

type Contract struct {
	TransactionType TransactionType `json:"type"`
	Channel         channel.Channel `json:"channel,omitempty"`
	Features        Features        `json:"features,omitempty"`
	Signatures      Signatures      `json:"signatures"`
}

Contract ...

type Features

type Features struct {
	Start       uint64               `json:"start"`
	End         int                  `json:"end"`    // Possible INFINITY
	MaxUse      int                  `json:"maxUse"` // Possible INFINITY
	Frequency   Frequency            `json:"freq,omitempty"`
	Destination features.Destination `json:"dest"`
}

Features ...

func (Features) GetByteArrayValues

func (f Features) GetByteArrayValues() (values [][]byte)

GetByteArrayValues ...

func (Features) HasStaticFeatures

func (f Features) HasStaticFeatures() bool

HasStaticFeatures ...

type Frequency

type Frequency struct {
	FirstPeriodID   uint64 `json:"firstPeriodId"`
	CycleLength     uint64 `json:"cycleLength"`
	UsePerCycle     int    `json:"usePerCycle"` // Possible INFINITY
	CurrentPeriodID uint64 `json:"currentPeriodId"`
}

Frequency ...

type LockingScript

type LockingScript struct {
	Version              model.Bits8             `json:"version"`
	BeneficiaryPublicKey crypto.PublicKey        `json:"beneficiaryPublicKey"`
	EmitterPublicKey     crypto.PublicKey        `json:"emitterPublicKey"`
	Permissions          permissions.Permissions `json:"permissions"`
}

LockingScript ...

func ToLockingScript

func ToLockingScript(s Script) (ls LockingScript, err error)

ToLockingScript ...

type Script

type Script model.Base64

Script ...

func BuildLocking

func BuildLocking(beneficiary crypto.PublicKey, emitter crypto.PublicKey, permissions permissions.Permissions) Script

BuildLocking creates the Script from the passed arguments.

It takes the users and the permissions as arguments and returns a Script object.

func BuildUnlocking

func BuildUnlocking(op operation.Operation, signedData []model.Signature, hashedFeatures model.Hash, timestamp uint64, rand int) Script

BuildUnlocking creates the Script from the passed arguments.

It takes the operation, an array of signed data, the hashed features, the timestamp and the transaction random number for identification as arguments and returns a Script object.

func ToScript

func ToScript(bytes []byte) Script

ToScript ...

func (Script) Base64

func (s Script) Base64() model.Base64

Base64 ...

func (Script) Bytes

func (s Script) Bytes() []byte

Bytes ...

func (*Script) GetPublicKeyValues

func (s *Script) GetPublicKeyValues() (beneficiaryPublicKey model.Key, emitterPublicKey model.Key, err error)

GetPublicKeyValues ...

func (Script) Parse

func (s Script) Parse() [][]byte

Parse ...

func (Script) String

func (s Script) String() string

String ...

type Signatures

type Signatures struct {
	Beneficiary model.Signature `json:"beneficiary,omitempty"`
	Emitter     model.Signature `json:"emitter,omitempty"`
}

Signatures ...

type Subchain

type Subchain struct {
	InitialTransactionID   model.Hash `json:"initialTransactionId"`
	LastStateTransactionID model.Hash `json:"lastStateTransactionId,omitempty"`
}

Subchain ...

type Transaction

type Transaction struct {
	TransactionID  model.Hash                     `json:"transactionId"`
	LastBlockID    model.Hash                     `json:"lastBlockId"`
	Subchain       Subchain                       `json:"subchain,omitempty"`
	Timestamp      uint64                         `json:"timestamp"`
	Contract       Contract                       `json:"contract"`
	Identification identification.Identifications `json:"identification,omitempty"`
	Script         Script                         `json:"script"`
	OblivionCode   string                         `json:"oblivionCode,omitempty"` // NB: this is the encrypted oblivion code
}

Transaction ...

func (*Transaction) CreateTransactionID

func (tx *Transaction) CreateTransactionID() error

CreateTransactionID ...

func (Transaction) Dump

func (tx Transaction) Dump()

Dump ...

func (Transaction) DumpByte

func (tx Transaction) DumpByte() ([]byte, error)

DumpByte ...

func (Transaction) GetByteArrayValues

func (tx Transaction) GetByteArrayValues() (values [][]byte)

GetByteArrayValues ...

func (*Transaction) IsEmpty

func (tx *Transaction) IsEmpty() bool

IsEmpty returns `true` if all its field are empty.

func (Transaction) IsFeeding

func (tx Transaction) IsFeeding() bool

IsFeeding ...

func (Transaction) IsOptOut

func (tx Transaction) IsOptOut() bool

IsOptOut ...

func (Transaction) IsSpending

func (tx Transaction) IsSpending() bool

IsSpending ...

func (Transaction) IsStatic

func (tx Transaction) IsStatic() bool

IsStatic ...

func (*Transaction) VerifyIdentification

func (tx *Transaction) VerifyIdentification(checker model.Ciphered, decompressedPublicKey model.Key) bool

VerifyIdentification helps verify that the transaction was correctly "signed".

It takes the data to check as well as the stakeholder's decompressed public key and returns a boolean.

type TransactionType

type TransactionType string

TransactionType ...

type Transactions

type Transactions []Transaction

Transactions ...

func (Transactions) Contains

func (t Transactions) Contains(item *Transaction) bool

Contains ...

func (*Transactions) Equals

func (t *Transactions) Equals(to *Transactions) bool

Equals ...

func (Transactions) Len

func (t Transactions) Len() int

func (Transactions) Less

func (t Transactions) Less(i, j int) bool

func (Transactions) Swap

func (t Transactions) Swap(i, j int)

type UnlockingScript

type UnlockingScript struct {
	Version        model.Bits8
	Operation      operation.Operation
	SignedData     []model.Signature
	HashedFeatures model.Hash
	Timestamp      uint64
	Random         int
}

UnlockingScript ...

func ToUnlockingScript

func ToUnlockingScript(s Script) (us UnlockingScript, err error)

ToUnlockingScript ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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