transaction

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	ChainID ChainID
}

func NewBuilder

func NewBuilder(chainID ChainID) *Builder

func (*Builder) NewTransaction

func (b *Builder) NewTransaction(data DataInterface) (Interface, error)

type BuyCoinData

type BuyCoinData struct {
	CoinToBuy          Coin
	ValueToBuy         *big.Int
	CoinToSell         Coin
	MaximumValueToSell *big.Int
}

Transaction for buy a coin paying another coin (owned by sender). CoinToBuy - Symbol of a coin to get. ValueToBuy - Amount of CoinToBuy to get. CoinToSell - Symbol of a coin to give. MaximumValueToSell - Maximum value of coins to sell.

func NewBuyCoinData

func NewBuyCoinData() *BuyCoinData

func (*BuyCoinData) SetCoinToBuy

func (d *BuyCoinData) SetCoinToBuy(symbol string) *BuyCoinData

func (*BuyCoinData) SetCoinToSell

func (d *BuyCoinData) SetCoinToSell(symbol string) *BuyCoinData

func (*BuyCoinData) SetMaximumValueToSell

func (d *BuyCoinData) SetMaximumValueToSell(value *big.Int) *BuyCoinData

func (*BuyCoinData) SetValueToBuy

func (d *BuyCoinData) SetValueToBuy(value *big.Int) *BuyCoinData

type ChainID

type ChainID byte
const (
	MainNetChainID ChainID
	TestNetChainID
)

type Check

type Check struct {
	*CheckData
	// contains filtered or unexported fields
}

func (*Check) Encode

func (check *Check) Encode() (string, error)

func (*Check) SetPassphrase

func (check *Check) SetPassphrase(passphrase string) CheckInterface

Set secret phrase which you will pass to receiver of the check

func (*Check) Sign

func (check *Check) Sign(prKey string) (Signed, error)

Sign Check

type CheckAddress

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

func NewCheckAddress

func NewCheckAddress(address string, passphrase string) (*CheckAddress, error)

func (*CheckAddress) Proof

func (check *CheckAddress) Proof() (string, error)

Proof Check

type CheckData

type CheckData struct {
	Nonce    []byte
	ChainID  ChainID
	DueBlock uint64
	Coin     Coin
	Value    *big.Int
	GasCoin  Coin
	Lock     *big.Int
	V        *big.Int
	R        *big.Int
	S        *big.Int
}

Issue a check that will later be redeemed by the person of your choice.

func DecodeCheck

func DecodeCheck(rawCheck string) (*CheckData, error)

Prepare check string and convert to data

func (*CheckData) PublicKey

func (check *CheckData) PublicKey() (string, error)

func (*CheckData) Sender

func (check *CheckData) Sender() (string, error)

func (*CheckData) String

func (check *CheckData) String() string

type CheckInterface

type CheckInterface interface {
	SetPassphrase(passphrase string) CheckInterface
	Sign(prKey string) (Signed, error)
}

func NewCheck

func NewCheck(nonce uint64, chainID ChainID, dueBlock uint64, coin string, value *big.Int, gasCoin string) CheckInterface

Create Check Nonce - unique "id" of the check. Coin Symbol - symbol of coin. Value - amount of coins. Due Block - defines last block height in which the check can be used.

type Coin

type Coin [10]byte

func (Coin) String

func (c Coin) String() string

type CreateCoinData

type CreateCoinData struct {
	Name                 string
	Symbol               Coin
	InitialAmount        *big.Int
	InitialReserve       *big.Int
	ConstantReserveRatio uint
	MaxSupply            *big.Int
}

Transaction for creating new coin in a system. Name - Name of a coin. Arbitrary string up to 64 letters length. Symbol - Symbol of a coin. Must be unique, alphabetic, uppercase, 3 to 10 symbols length. InitialAmount - Amount of coins to issue. Issued coins will be available to sender account. InitialReserve - Initial reserve in BIP's. ConstantReserveRatio - CRR, uint, should be from 10 to 100.

func NewCreateCoinData

func NewCreateCoinData() *CreateCoinData

func (*CreateCoinData) SetConstantReserveRatio

func (d *CreateCoinData) SetConstantReserveRatio(ratio uint) *CreateCoinData

func (*CreateCoinData) SetInitialAmount

func (d *CreateCoinData) SetInitialAmount(value *big.Int) *CreateCoinData

func (*CreateCoinData) SetInitialReserve

func (d *CreateCoinData) SetInitialReserve(value *big.Int) *CreateCoinData

func (*CreateCoinData) SetMaxSupply

func (d *CreateCoinData) SetMaxSupply(maxSupply *big.Int) *CreateCoinData

func (*CreateCoinData) SetName

func (d *CreateCoinData) SetName(name string) *CreateCoinData

func (*CreateCoinData) SetSymbol

func (d *CreateCoinData) SetSymbol(symbol string) *CreateCoinData

type CreateMultisigData

type CreateMultisigData struct {
	Threshold uint
	Weights   []uint
	Addresses [][20]byte
}

func NewCreateMultisigData

func NewCreateMultisigData() *CreateMultisigData

func (*CreateMultisigData) AddSigData

func (d *CreateMultisigData) AddSigData(address string, weight uint) (*CreateMultisigData, error)

func (*CreateMultisigData) AddressBytes

func (d *CreateMultisigData) AddressBytes() [20]byte

func (*CreateMultisigData) AddressString

func (d *CreateMultisigData) AddressString() string

func (*CreateMultisigData) MustAddSigData

func (d *CreateMultisigData) MustAddSigData(address string, weight uint) *CreateMultisigData

func (*CreateMultisigData) SetThreshold

func (d *CreateMultisigData) SetThreshold(threshold uint) *CreateMultisigData

type DataInterface

type DataInterface interface {
	// contains filtered or unexported methods
}

type DeclareCandidacyData

type DeclareCandidacyData struct {
	Address    [20]byte
	PubKey     []byte
	Commission uint
	Coin       Coin
	Stake      *big.Int
}

Transaction for declaring new validator candidacy. Address - Address of candidate in Minter Network. This address would be able to control candidate. Also all rewards will be sent to this address. PubKey - Public key of a validator. Commission - Commission (from 0 to 100) from rewards which delegators will pay to validator. Coin - Symbol of coin to stake. Stake - Amount of coins to stake.

func NewDeclareCandidacyData

func NewDeclareCandidacyData() *DeclareCandidacyData

func (*DeclareCandidacyData) MustSetAddress

func (d *DeclareCandidacyData) MustSetAddress(address string) *DeclareCandidacyData

func (*DeclareCandidacyData) MustSetPubKey

func (d *DeclareCandidacyData) MustSetPubKey(key string) *DeclareCandidacyData

func (*DeclareCandidacyData) SetAddress

func (d *DeclareCandidacyData) SetAddress(address string) (*DeclareCandidacyData, error)

func (*DeclareCandidacyData) SetCoin

func (d *DeclareCandidacyData) SetCoin(symbol string) *DeclareCandidacyData

func (*DeclareCandidacyData) SetCommission

func (d *DeclareCandidacyData) SetCommission(value uint) *DeclareCandidacyData

func (*DeclareCandidacyData) SetPubKey

func (d *DeclareCandidacyData) SetPubKey(key string) (*DeclareCandidacyData, error)

func (*DeclareCandidacyData) SetStake

func (d *DeclareCandidacyData) SetStake(value *big.Int) *DeclareCandidacyData
type DeepLink struct {
	Type    Type
	Data    []byte
	Payload []byte

	Nonce    *uint // optional
	GasPrice *uint // optional
	GasCoin  *Coin // optional
}
func NewDeepLink(data DataInterface) (*DeepLink, error)
func (d *DeepLink) CreateLink(pass string) (string, error)

func (*DeepLink) Encode

func (d *DeepLink) Encode() (string, error)

func (*DeepLink) SetGasCoin

func (d *DeepLink) SetGasCoin(symbol string) *DeepLink

func (*DeepLink) SetPayload

func (d *DeepLink) SetPayload(payload []byte) *DeepLink

type DelegateData

type DelegateData struct {
	PubKey []byte
	Coin   Coin
	Value  *big.Int
}

Transaction for delegating funds to validator. PubKey - Public key of a validator. Coin - Symbol of coin to stake. Value - Amount of coins to stake.

func NewDelegateData

func NewDelegateData() *DelegateData

func (*DelegateData) MustSetPubKey

func (d *DelegateData) MustSetPubKey(key string) *DelegateData

func (*DelegateData) SetCoin

func (d *DelegateData) SetCoin(symbol string) *DelegateData

func (*DelegateData) SetPubKey

func (d *DelegateData) SetPubKey(key string) (*DelegateData, error)

func (*DelegateData) SetValue

func (d *DelegateData) SetValue(value *big.Int) *DelegateData

type EditCandidateData

type EditCandidateData struct {
	PubKey        []byte
	RewardAddress [20]byte
	OwnerAddress  [20]byte
}

Transaction for editing existing candidate.

func NewEditCandidateData

func NewEditCandidateData() *EditCandidateData

func (*EditCandidateData) MustSetOwnerAddress

func (d *EditCandidateData) MustSetOwnerAddress(address string) *EditCandidateData

func (*EditCandidateData) MustSetPubKey

func (d *EditCandidateData) MustSetPubKey(key string) *EditCandidateData

func (*EditCandidateData) MustSetRewardAddress

func (d *EditCandidateData) MustSetRewardAddress(address string) *EditCandidateData

func (*EditCandidateData) SetOwnerAddress

func (d *EditCandidateData) SetOwnerAddress(address string) (*EditCandidateData, error)

func (*EditCandidateData) SetPubKey

func (d *EditCandidateData) SetPubKey(key string) (*EditCandidateData, error)

func (*EditCandidateData) SetRewardAddress

func (d *EditCandidateData) SetRewardAddress(address string) (*EditCandidateData, error)

type EncodeInterface

type EncodeInterface interface {
	Encode() (string, error)
}

type Interface

type Interface interface {
	EncodeInterface

	SetSignatureType(signatureType SignatureType) Interface
	SetMultiSignatureType() Interface

	SetNonce(nonce uint64) Interface
	SetGasCoin(name string) Interface
	SetGasPrice(price uint8) Interface
	SetPayload(payload []byte) Interface
	SetServiceData(serviceData []byte) Interface
	Sign(prKey string, multisigPrKeys ...string) (SignedTransaction, error)
	// contains filtered or unexported methods
}

type MultisendData

type MultisendData struct {
	List []MultisendDataItem
}

Transaction for sending coins to multiple addresses.

func NewMultisendData

func NewMultisendData() *MultisendData

func (*MultisendData) AddItem

func (d *MultisendData) AddItem(item MultisendDataItem) *MultisendData

type MultisendDataItem

type MultisendDataItem SendData

func NewMultisendDataItem

func NewMultisendDataItem() *MultisendDataItem

func (*MultisendDataItem) MustSetTo

func (d *MultisendDataItem) MustSetTo(address string) *MultisendDataItem

func (*MultisendDataItem) SetCoin

func (d *MultisendDataItem) SetCoin(symbol string) *MultisendDataItem

func (*MultisendDataItem) SetTo

func (d *MultisendDataItem) SetTo(address string) (*MultisendDataItem, error)

func (*MultisendDataItem) SetValue

func (d *MultisendDataItem) SetValue(value *big.Int) *MultisendDataItem

type RedeemCheckData

type RedeemCheckData struct {
	RawCheck []byte
	Proof    [65]byte
}

Transaction for redeeming a check. RawCheck - Raw check received from sender. Proof - Proof of owning a check. Note that maximum GasPrice is limited to 1 to prevent fraud, because GasPrice is set by redeem tx sender but commission is charded from check issuer.

func NewRedeemCheckData

func NewRedeemCheckData() *RedeemCheckData

func (*RedeemCheckData) MustSetProof

func (d *RedeemCheckData) MustSetProof(proof string) *RedeemCheckData

func (*RedeemCheckData) MustSetRawCheck

func (d *RedeemCheckData) MustSetRawCheck(raw string) *RedeemCheckData

func (*RedeemCheckData) SetProof

func (d *RedeemCheckData) SetProof(proof string) (*RedeemCheckData, error)

func (*RedeemCheckData) SetRawCheck

func (d *RedeemCheckData) SetRawCheck(raw string) (*RedeemCheckData, error)

type SellAllCoinData

type SellAllCoinData struct {
	CoinToSell        Coin
	CoinToBuy         Coin
	MinimumValueToBuy *big.Int
}

Transaction for selling one coin (owned by sender) in favour of another coin in a system. CoinToSell - Symbol of a coin to give. ValueToSell - Amount of CoinToSell to give. CoinToBuy - Symbol of a coin to get. MinimumValueToBuy - Minimum value of coins to get.

func NewSellAllCoinData

func NewSellAllCoinData() *SellAllCoinData

func (*SellAllCoinData) SetCoinToBuy

func (d *SellAllCoinData) SetCoinToBuy(symbol string) *SellAllCoinData

func (*SellAllCoinData) SetCoinToSell

func (d *SellAllCoinData) SetCoinToSell(symbol string) *SellAllCoinData

func (*SellAllCoinData) SetMinimumValueToBuy

func (d *SellAllCoinData) SetMinimumValueToBuy(value *big.Int) *SellAllCoinData

type SellCoinData

type SellCoinData struct {
	CoinToSell        Coin
	ValueToSell       *big.Int
	CoinToBuy         Coin
	MinimumValueToBuy *big.Int
}

Transaction for selling one coin (owned by sender) in favour of another coin in a system. CoinToSell - Symbol of a coin to give. ValueToSell - Amount of CoinToSell to give. CoinToBuy - Symbol of a coin to get. MinimumValueToBuy - Minimum value of coins to get.

func NewSellCoinData

func NewSellCoinData() *SellCoinData

func (*SellCoinData) SetCoinToBuy

func (d *SellCoinData) SetCoinToBuy(symbol string) *SellCoinData

func (*SellCoinData) SetCoinToSell

func (d *SellCoinData) SetCoinToSell(symbol string) *SellCoinData

func (*SellCoinData) SetMinimumValueToBuy

func (d *SellCoinData) SetMinimumValueToBuy(value *big.Int) *SellCoinData

func (*SellCoinData) SetValueToSell

func (d *SellCoinData) SetValueToSell(value *big.Int) *SellCoinData

type SendData

type SendData struct {
	Coin  Coin
	To    [20]byte
	Value *big.Int
}

Transaction for sending arbitrary coin. Coin - Symbol of a coin. To - Recipient address in Minter Network. Value - Amount of Coin to send.

func NewSendData

func NewSendData() *SendData

func (*SendData) MustSetTo

func (d *SendData) MustSetTo(address string) *SendData

func (*SendData) SetCoin

func (d *SendData) SetCoin(symbol string) *SendData

func (*SendData) SetTo

func (d *SendData) SetTo(address string) (*SendData, error)

func (*SendData) SetValue

func (d *SendData) SetValue(value *big.Int) *SendData

type SetCandidateOffData

type SetCandidateOffData struct {
	PubKey []byte
}

Transaction for turning candidate off. This transaction should be sent from address which is set in the "Declare candidacy transaction". PubKey - Public key of a validator.

func NewSetCandidateOffData

func NewSetCandidateOffData() *SetCandidateOffData

func (*SetCandidateOffData) MustSetPubKey

func (d *SetCandidateOffData) MustSetPubKey(key string) *SetCandidateOffData

func (*SetCandidateOffData) SetPubKey

func (d *SetCandidateOffData) SetPubKey(key string) (*SetCandidateOffData, error)

type SetCandidateOnData

type SetCandidateOnData struct {
	PubKey []byte
}

Transaction for turning candidate on. This transaction should be sent from address which is set in the "Declare candidacy transaction". PubKey - Public key of a validator.

func NewSetCandidateOnData

func NewSetCandidateOnData() *SetCandidateOnData

func (*SetCandidateOnData) MustSetPubKey

func (d *SetCandidateOnData) MustSetPubKey(key string) *SetCandidateOnData

func (*SetCandidateOnData) SetPubKey

func (d *SetCandidateOnData) SetPubKey(key string) (*SetCandidateOnData, error)

type Signature

type Signature struct {
	V *big.Int
	R *big.Int
	S *big.Int
}

type SignatureMulti

type SignatureMulti struct {
	Multisig   [20]byte
	Signatures []*Signature
}

type SignatureType

type SignatureType byte
const (
	SignatureTypeSingle SignatureType
	SignatureTypeMulti
)

type Signed

type Signed interface {
	Encode() (string, error)
}

type SignedTransaction

type SignedTransaction interface {
	EncodeInterface
	GetTransaction() *Transaction
	Fee() *big.Int
	Hash() (string, error)
	Data() DataInterface
	Signature() (signatureInterface, error)
	AddSignature(signatures ...[]byte) (SignedTransaction, error)
	SignatureData() []byte
	SimpleSignatureData() ([]byte, error)
	SenderAddress() (string, error)
	Sign(prKey string, multisigPrKeys ...string) (SignedTransaction, error)
}

func Decode

func Decode(tx string) (SignedTransaction, error)

Decode transaction

type Transaction

type Transaction struct {
	Nonce         uint64
	ChainID       ChainID
	GasPrice      uint8
	GasCoin       Coin
	Type          Type
	Data          []byte
	Payload       []byte
	ServiceData   []byte
	SignatureType SignatureType
	SignatureData []byte
}

func (*Transaction) Encode

func (tx *Transaction) Encode() (string, error)

type Type

type Type byte
const (
	TypeSend Type = iota + 1
	TypeSellCoin
	TypeSellAllCoin
	TypeBuyCoin
	TypeCreateCoin
	TypeDeclareCandidacy
	TypeDelegate
	TypeUnbond
	TypeRedeemCheck
	TypeSetCandidateOnline
	TypeSetCandidateOffline
	TypeCreateMultisig
	TypeMultisend
	TypeEditCandidate
)

type UnbondData

type UnbondData struct {
	PubKey []byte
	Coin   Coin
	Value  *big.Int
}

Transaction for unbonding funds from validator's stake. PubKey - Public key of a validator. Coin - Symbol of coin to stake. Value - Amount of coins to stake.

func NewUnbondData

func NewUnbondData() *UnbondData

func (*UnbondData) MustSetPubKey

func (d *UnbondData) MustSetPubKey(key string) *UnbondData

func (*UnbondData) SetCoin

func (d *UnbondData) SetCoin(symbol string) *UnbondData

func (*UnbondData) SetPubKey

func (d *UnbondData) SetPubKey(key string) (*UnbondData, error)

func (*UnbondData) SetValue

func (d *UnbondData) SetValue(value *big.Int) *UnbondData

Jump to

Keyboard shortcuts

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