money

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: AGPL-3.0 Imports: 17 Imported by: 11

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 // The monetary value of this bill
	T        uint64 // The round number of the last transaction with the bill
	Backlink []byte // Backlink (256-bit hash)
	Locked   uint64 // 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) (m *Module, err 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 gocrypto.Hash) Option

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]crypto.Verifier) Option

type Options

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

func DefaultOptions

func DefaultOptions() *Options

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