money

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: AGPL-3.0, ISC Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeTransferOrder   = "TransferOrder"
	TypeTransferDCOrder = "TransferDCOrder"
	TypeSplitOrder      = "SplitOrder"
	TypeSwapOrder       = "SwapOrder"
)

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")
)
View Source
var (
	ErrInvalidBillValue = errors.New("transaction value must be equal to bill value")

	// swap tx specific validity conditions
	ErrSwapInvalidTargetValue        = errors.New("target value of the bill must be equal to the sum of the target values of succeeded payments in swap transaction")
	ErrSwapInsufficientDCMoneySupply = errors.New("insufficient DC-money supply")
	ErrSwapBillAlreadyExists         = errors.New("swapped bill id already exists")
	ErrSwapInvalidBillIdentifiers    = errors.New("all bill identifiers in dust transfer orders must exist in transaction bill identifiers")
	ErrSwapInvalidBillId             = errors.New("bill id is not properly computed")
	ErrSwapDustTransfersInvalidOrder = errors.New("transfer orders are not listed in strictly increasing order of bill identifiers")
	ErrSwapInvalidNonce              = errors.New("dust transfer orders do not contain proper nonce")
	ErrSwapInvalidTargetBearer       = errors.New("dust transfer orders do not contain proper target bearer")
	ErrInvalidProofType              = errors.New("invalid proof type")
)
View Source
var File_money_tx_proto protoreflect.FileDescriptor
View Source
var (
	SchemeOpts = &allMoneySchemeOptions{}
)

Functions

func NewMoneyTx

func NewMoneyTx(systemID []byte, tx *txsystem.Transaction) (txsystem.GenericTransaction, error)

NewMoneyTx creates a new wrapper, returns an error if unknown transaction type is given as argument.

func NewMoneyTxSystem

func NewMoneyTxSystem(hashAlgorithm crypto.Hash, initialBill *InitialBill, dcMoneyAmount uint64, customOpts ...Option) (*moneyTxSystem, 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) AddToHasher

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

func (*BillData) Value

func (b *BillData) Value() rma.SummaryValue

type InitialBill

type InitialBill struct {
	ID    *uint256.Int
	Value uint64
	Owner rma.Predicate
}

type Option

type Option func(*Options)

type Options

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

type Split

type Split interface {
	txsystem.GenericTransaction
	Amount() uint64
	TargetBearer() []byte
	RemainingValue() uint64
	Backlink() []byte
	HashForIdCalculation(hashFunc crypto.Hash) []byte // Returns hash value for the sameShardId function
}

type SplitOrder

type SplitOrder struct {
	Amount         uint64 `protobuf:"varint,1,opt,name=amount,proto3" json:"amount,omitempty"`
	TargetBearer   []byte `protobuf:"bytes,2,opt,name=target_bearer,json=targetBearer,proto3" json:"target_bearer,omitempty"`
	RemainingValue uint64 `protobuf:"varint,3,opt,name=remaining_value,json=remainingValue,proto3" json:"remaining_value,omitempty"`
	Backlink       []byte `protobuf:"bytes,4,opt,name=backlink,proto3" json:"backlink,omitempty"`
	// contains filtered or unexported fields
}

func (*SplitOrder) Descriptor deprecated

func (*SplitOrder) Descriptor() ([]byte, []int)

Deprecated: Use SplitOrder.ProtoReflect.Descriptor instead.

func (*SplitOrder) GetAmount

func (x *SplitOrder) GetAmount() uint64
func (x *SplitOrder) GetBacklink() []byte

func (*SplitOrder) GetRemainingValue

func (x *SplitOrder) GetRemainingValue() uint64

func (*SplitOrder) GetTargetBearer

func (x *SplitOrder) GetTargetBearer() []byte

func (*SplitOrder) ProtoMessage

func (*SplitOrder) ProtoMessage()

func (*SplitOrder) ProtoReflect

func (x *SplitOrder) ProtoReflect() protoreflect.Message

func (*SplitOrder) Reset

func (x *SplitOrder) Reset()

func (*SplitOrder) String

func (x *SplitOrder) String() string

type Swap

type Swap interface {
	txsystem.GenericTransaction
	OwnerCondition() []byte
	BillIdentifiers() []*uint256.Int
	DCTransfers() []TransferDC
	Proofs() []*block.BlockProof
	TargetValue() uint64
}

type SwapOrder

type SwapOrder struct {
	OwnerCondition  []byte                  `protobuf:"bytes,1,opt,name=owner_condition,json=ownerCondition,proto3" json:"owner_condition,omitempty"`
	BillIdentifiers [][]byte                `protobuf:"bytes,2,rep,name=bill_identifiers,json=billIdentifiers,proto3" json:"bill_identifiers,omitempty"`
	DcTransfers     []*txsystem.Transaction `protobuf:"bytes,3,rep,name=dc_transfers,json=dcTransfers,proto3" json:"dc_transfers,omitempty"`
	Proofs          []*block.BlockProof     `protobuf:"bytes,4,rep,name=proofs,proto3" json:"proofs,omitempty"`
	TargetValue     uint64                  `protobuf:"varint,5,opt,name=target_value,json=targetValue,proto3" json:"target_value,omitempty"`
	// contains filtered or unexported fields
}

func (*SwapOrder) Descriptor deprecated

func (*SwapOrder) Descriptor() ([]byte, []int)

Deprecated: Use SwapOrder.ProtoReflect.Descriptor instead.

func (*SwapOrder) GetBillIdentifiers

func (x *SwapOrder) GetBillIdentifiers() [][]byte

func (*SwapOrder) GetDcTransfers

func (x *SwapOrder) GetDcTransfers() []*txsystem.Transaction

func (*SwapOrder) GetOwnerCondition

func (x *SwapOrder) GetOwnerCondition() []byte

func (*SwapOrder) GetProofs

func (x *SwapOrder) GetProofs() []*block.BlockProof

func (*SwapOrder) GetTargetValue

func (x *SwapOrder) GetTargetValue() uint64

func (*SwapOrder) ProtoMessage

func (*SwapOrder) ProtoMessage()

func (*SwapOrder) ProtoReflect

func (x *SwapOrder) ProtoReflect() protoreflect.Message

func (*SwapOrder) Reset

func (x *SwapOrder) Reset()

func (*SwapOrder) String

func (x *SwapOrder) String() string

type Transfer

type Transfer interface {
	txsystem.GenericTransaction
	NewBearer() []byte
	TargetValue() uint64
	Backlink() []byte
}

type TransferDC

type TransferDC interface {
	txsystem.GenericTransaction
	Nonce() []byte
	TargetBearer() []byte
	TargetValue() uint64
	Backlink() []byte
}

type TransferDCOrder

type TransferDCOrder struct {
	Nonce        []byte `protobuf:"bytes,1,opt,name=nonce,proto3" json:"nonce,omitempty"`
	TargetBearer []byte `protobuf:"bytes,2,opt,name=target_bearer,json=targetBearer,proto3" json:"target_bearer,omitempty"`
	TargetValue  uint64 `protobuf:"varint,3,opt,name=target_value,json=targetValue,proto3" json:"target_value,omitempty"`
	Backlink     []byte `protobuf:"bytes,4,opt,name=backlink,proto3" json:"backlink,omitempty"`
	// contains filtered or unexported fields
}

func (*TransferDCOrder) Descriptor deprecated

func (*TransferDCOrder) Descriptor() ([]byte, []int)

Deprecated: Use TransferDCOrder.ProtoReflect.Descriptor instead.

func (x *TransferDCOrder) GetBacklink() []byte

func (*TransferDCOrder) GetNonce

func (x *TransferDCOrder) GetNonce() []byte

func (*TransferDCOrder) GetTargetBearer

func (x *TransferDCOrder) GetTargetBearer() []byte

func (*TransferDCOrder) GetTargetValue

func (x *TransferDCOrder) GetTargetValue() uint64

func (*TransferDCOrder) ProtoMessage

func (*TransferDCOrder) ProtoMessage()

func (*TransferDCOrder) ProtoReflect

func (x *TransferDCOrder) ProtoReflect() protoreflect.Message

func (*TransferDCOrder) Reset

func (x *TransferDCOrder) Reset()

func (*TransferDCOrder) String

func (x *TransferDCOrder) String() string

type TransferOrder

type TransferOrder struct {
	NewBearer   []byte `protobuf:"bytes,1,opt,name=new_bearer,json=newBearer,proto3" json:"new_bearer,omitempty"`
	TargetValue uint64 `protobuf:"varint,2,opt,name=target_value,json=targetValue,proto3" json:"target_value,omitempty"`
	Backlink    []byte `protobuf:"bytes,3,opt,name=backlink,proto3" json:"backlink,omitempty"`
	// contains filtered or unexported fields
}

func (*TransferOrder) Descriptor deprecated

func (*TransferOrder) Descriptor() ([]byte, []int)

Deprecated: Use TransferOrder.ProtoReflect.Descriptor instead.

func (x *TransferOrder) GetBacklink() []byte

func (*TransferOrder) GetNewBearer

func (x *TransferOrder) GetNewBearer() []byte

func (*TransferOrder) GetTargetValue

func (x *TransferOrder) GetTargetValue() uint64

func (*TransferOrder) ProtoMessage

func (*TransferOrder) ProtoMessage()

func (*TransferOrder) ProtoReflect

func (x *TransferOrder) ProtoReflect() protoreflect.Message

func (*TransferOrder) Reset

func (x *TransferOrder) Reset()

func (*TransferOrder) String

func (x *TransferOrder) String() string

Jump to

Keyboard shortcuts

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