money

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PayloadTypeTransfer = "trans"
	PayloadTypeSplit    = "split"
	PayloadTypeTransDC  = "transDC"
	PayloadTypeSwapDC   = "swapDC"
)
View Source
const (
	UnitIDLength   = UnitPartLength + TypePartLength
	UnitPartLength = 32
	TypePartLength = 1
)

Variables

View Source
var (
	ErrInitialBillIsNil                  = errors.New("initial bill may not be nil")
	ErrInvalidInitialBillID              = errors.New("initial bill ID may not be equal to the DC money supply ID")
	ErrUndefinedSystemDescriptionRecords = errors.New("undefined system description records")
	ErrNilFeeCreditBill                  = errors.New("fee credit bill is nil in system description record")
	ErrInvalidFeeCreditBillID            = errors.New("fee credit bill may not be equal to the DC money supply ID and initial bill ID")
)
View Source
var (
	ErrReclaimFCInvalidTargetUnit         = errors.New("invalid target unit")
	ErrReclaimFCInvalidTxFee              = errors.New("the transaction fees cannot exceed the transferred value")
	ErrReclaimFCInvalidTargetUnitBacklink = errors.New("invalid target unit backlink")
)
View Source
var (
	ErrInvalidBillValue       = errors.New("transaction value must be equal to bill value")
	ErrSplitBillZeroAmount    = errors.New("when splitting a bill the value assigned to the new bill must be greater than zero")
	ErrSplitBillZeroRemainder = errors.New("when splitting a bill the remaining value of the bill must be greater than zero")
	ErrInvalidDataType        = errors.New("invalid data type")
)
View Source
var (
	ErrTxNil                       = errors.New("tx is nil")
	ErrBillNil                     = errors.New("bill is nil")
	ErrTargetSystemIdentifierEmpty = errors.New("TargetSystemIdentifier is empty")
	ErrTargetRecordIDEmpty         = errors.New("TargetRecordID is empty")
	ErrAdditionTimeInvalid         = errors.New("EarliestAdditonTime is greater than LatestAdditionTime")
	ErrRecordIDExists              = errors.New("fee tx cannot contain fee credit reference")
	ErrFeeProofExists              = errors.New("fee tx cannot contain fee authorization proof")
	ErrInvalidFCValue              = errors.New("the amount to transfer cannot exceed the value of the bill")
	ErrInvalidFeeValue             = errors.New("the transaction max fee cannot exceed the transferred amount")
	ErrInvalidBacklink             = errors.New("the transaction backlink is not equal to unit backlink")
)
View Source
var (
	BillUnitType            = []byte{0x00}
	FeeCreditRecordUnitType = []byte{0x0f}
)
View Source
var DefaultSystemIdentifier = []byte{0, 0, 0, 0}

Functions

func HashForIDCalculation added in v0.2.0

func HashForIDCalculation(idBytes []byte, attr []byte, timeout uint64, hashFunc crypto.Hash) []byte

func NewBillID added in v0.2.0

func NewBillID(shardPart []byte, unitPart []byte) types.UnitID

func NewFeeCreditRecordID added in v0.2.0

func NewFeeCreditRecordID(shardPart []byte, unitPart []byte) types.UnitID

func NewTxSystem added in v0.2.0

func NewTxSystem(opts ...Option) (*txsystem.GenericTxSystem, error)

Types

type BillData

type BillData struct {
	V        uint64 // The monetary value of this bill
	T        uint64 // The round number of the last transaction with the bill
	Backlink []byte // Backlink (256-bit hash)
}

func (*BillData) Copy added in v0.2.0

func (b *BillData) Copy() state.UnitData

func (*BillData) SummaryValueInput added in v0.2.0

func (b *BillData) SummaryValueInput() uint64

func (*BillData) Write added in v0.2.0

func (b *BillData) Write(hasher hash.Hash)

type DustCollector added in v0.2.0

type DustCollector struct {
	// contains filtered or unexported fields
}

func NewDustCollector added in v0.2.0

func NewDustCollector(s *state.State) *DustCollector

func (*DustCollector) AddDustBill added in v0.2.0

func (d *DustCollector) AddDustBill(id types.UnitID, currentBlockNumber uint64)

func (*DustCollector) GetDustBills added in v0.2.0

func (d *DustCollector) GetDustBills(blockNumber uint64) []types.UnitID

func (*DustCollector) RemoveDustBills added in v0.2.0

func (d *DustCollector) RemoveDustBills(blockNumber uint64)

type InitialBill

type InitialBill struct {
	ID    types.UnitID
	Value uint64
	Owner state.Predicate
}

type Module added in v0.2.0

type Module struct {
	// contains filtered or unexported fields
}

func NewMoneyModule added in v0.2.0

func NewMoneyModule(options *Options) (m *Module, err error)

func (*Module) BeginBlockFuncs added in v0.2.0

func (m *Module) BeginBlockFuncs() []func(blockNr uint64) error

func (*Module) EndBlockFuncs added in v0.2.0

func (m *Module) EndBlockFuncs() []func(blockNumber uint64) error

func (*Module) GenericTransactionValidator added in v0.2.0

func (m *Module) GenericTransactionValidator() txsystem.GenericTransactionValidator

func (*Module) TxExecutors added in v0.2.0

func (m *Module) TxExecutors() map[string]txsystem.TxExecutor

type Option

type Option func(*Options)

func WithDCMoneyAmount added in v0.2.0

func WithDCMoneyAmount(a uint64) Option

func WithFeeCalculator added in v0.2.0

func WithFeeCalculator(calc fc.FeeCalculator) Option

func WithHashAlgorithm added in v0.2.0

func WithHashAlgorithm(hashAlgorithm gocrypto.Hash) Option

func WithInitialBill added in v0.2.0

func WithInitialBill(bill *InitialBill) Option

func WithState added in v0.2.0

func WithState(s *state.State) Option

func WithSystemDescriptionRecords added in v0.2.0

func WithSystemDescriptionRecords(records []*genesis.SystemDescriptionRecord) Option

func WithSystemIdentifier added in v0.2.0

func WithSystemIdentifier(systemIdentifier []byte) Option

func WithTrustBase added in v0.2.0

func WithTrustBase(trust map[string]crypto.Verifier) Option

type Options

type Options struct {
	// contains filtered or unexported fields
}

func DefaultOptions added in v0.2.0

func DefaultOptions() *Options

type SplitAttributes added in v0.2.0

type SplitAttributes struct {
	Amount         uint64
	TargetBearer   []byte
	RemainingValue uint64
	Backlink       []byte
	// contains filtered or unexported fields
}

type SwapDCAttributes added in v0.2.0

type SwapDCAttributes struct {
	OwnerCondition   []byte
	DcTransfers      []*types.TransactionRecord
	DcTransferProofs []*types.TxProof
	TargetValue      uint64 // value added to target bill
	// contains filtered or unexported fields
}

type TransferAttributes added in v0.2.0

type TransferAttributes struct {
	NewBearer   []byte
	TargetValue uint64
	Backlink    []byte
	// contains filtered or unexported fields
}

type TransferDCAttributes added in v0.2.0

type TransferDCAttributes struct {
	Value              uint64
	TargetUnitID       []byte
	TargetUnitBacklink []byte
	Backlink           []byte
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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