money

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: AGPL-3.0 Imports: 19 Imported by: 12

Documentation

Index

Constants

View Source
const (
	PayloadTypeTransfer = "trans"
	PayloadTypeSplit    = "split"
	PayloadTypeTransDC  = "transDC"
	PayloadTypeSwapDC   = "swapDC"
	PayloadTypeLock     = "lock"
	PayloadTypeUnlock   = "unlock"
)
View Source
const (
	UnitIDLength   = UnitPartLength + TypePartLength
	UnitPartLength = 32
	TypePartLength = 1
)
View Source
const DefaultSystemIdentifier types.SystemID = 0x00000001

Variables

View Source
var (
	// The ID of the dust collector money supply
	DustCollectorMoneySupplyID = NewBillID(nil, nil)

	// Dust collector predicate
	DustCollectorPredicate = templates.NewP2pkh256BytesFromKeyHash(abHasher.Sum256([]byte("dust collector")))
)
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 (
	ErrInvalidDataType  = errors.New("invalid data type")
	ErrInvalidBillValue = errors.New("transaction value must be equal to bill value")
)
View Source
var (
	ErrTxNil                       = errors.New("tx is nil")
	ErrTxAttrNil                   = errors.New("tx attributes is nil")
	ErrBillNil                     = errors.New("bill is nil")
	ErrBillLocked                  = errors.New("bill is already locked")
	ErrTargetSystemIdentifierEmpty = errors.New("TargetSystemIdentifier is empty")
	ErrTargetRecordIDEmpty         = errors.New("TargetRecordID is empty")
	ErrAdditionTimeInvalid         = errors.New("EarliestAdditionTime 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 (
	ErrBillUnlocked = errors.New("bill is already unlocked")
)
View Source
var ErrInvalidLockStatus = errors.New("invalid lock status: expected non-zero value, got zero value")

Functions

func HashForIDCalculation

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

func NewBillID

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

func NewFeeCreditRecordID

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

func NewTxSystem

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

func NewUnitData

func NewUnitData(unitID types.UnitID) (state.UnitData, error)

Types

type BillData

type BillData struct {
	V        uint64      `json:"value,string"`      // The monetary value of this bill
	T        uint64      `json:"lastUpdate,string"` // The round number of the last transaction with the bill
	Backlink types.Bytes `json:"backlink"`          // Backlink (256-bit hash)
	Locked   uint64      `json:"locked,string"`     // locked status of the bill, non-zero value means locked
	// contains filtered or unexported fields
}

func (*BillData) Copy

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

func (*BillData) IsLocked

func (b *BillData) IsLocked() bool

func (*BillData) SummaryValueInput

func (b *BillData) SummaryValueInput() uint64

func (*BillData) Write

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

type DustCollector

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

func NewDustCollector

func NewDustCollector(s *state.State) *DustCollector

func (*DustCollector) AddDustBill

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

func (*DustCollector) GetDustBills

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

func (*DustCollector) RemoveDustBills

func (d *DustCollector) RemoveDustBills(blockNumber uint64)

type LockAttributes

type LockAttributes struct {
	LockStatus uint64 // status of the lock, non-zero value means locked
	Backlink   []byte
	// contains filtered or unexported fields
}

type Module

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

func NewMoneyModule

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

func (*Module) BeginBlockFuncs

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

func (*Module) EndBlockFuncs

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

func (*Module) TxExecutors

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

type Option

type Option func(*Options)

func WithFeeCalculator

func WithFeeCalculator(calc fc.FeeCalculator) Option

func WithHashAlgorithm

func WithHashAlgorithm(hashAlgorithm crypto.Hash) Option

func WithPredicateExecutor added in v0.4.0

func WithPredicateExecutor(exec PredicateExecutor) Option

WithPredicateExecutor allows to replace the default predicate executor function. Should be used by tests only.

func WithState

func WithState(s *state.State) Option

func WithSystemDescriptionRecords

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

func WithSystemIdentifier

func WithSystemIdentifier(systemIdentifier types.SystemID) Option

func WithTrustBase

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

type Options

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

type PredicateExecutor added in v0.4.0

type PredicateExecutor func(ctx context.Context, predicate types.PredicateBytes, args []byte, txo *types.TransactionOrder, env predicates.TxContext) (bool, error)

type SplitAttributes

type SplitAttributes struct {
	TargetUnits    []*TargetUnit
	RemainingValue uint64
	Backlink       []byte
	// contains filtered or unexported fields
}

type SwapDCAttributes

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

type TargetUnit

type TargetUnit struct {
	Amount         uint64
	OwnerCondition []byte
	// contains filtered or unexported fields
}

type TransferAttributes

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

type TransferDCAttributes

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

type UnlockAttributes

type UnlockAttributes struct {
	Backlink []byte
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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