transaction

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2019 License: MIT Imports: 11 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          [10]byte
	ValueToBuy         *big.Int
	CoinToSell         [10]byte
	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 = iota + 1
	TestNetChainID
)

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 CreateCoinData

type CreateCoinData struct {
	Name                 string
	Symbol               [10]byte
	InitialAmount        *big.Int
	InitialReserve       *big.Int
	ConstantReserveRatio uint
}

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 NOAH'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) 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
}

type DataInterface

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

type DeclareCandidacyData

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

Transaction for declaring new validator candidacy. Address - Address of candidate in NOAH 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 DelegateData

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

Transaction for delegating funds to validator. PubKey - Public key of a validator. Coin - Symbol of coin to stake. Stake - 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) SetStake

func (d *DelegateData) SetStake(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 Fee

type Fee uint

type Interface

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

type IssueCheck

type IssueCheck struct {
	*IssueCheckData
	// contains filtered or unexported fields
}

func (*IssueCheck) Encode

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

func (*IssueCheck) SetPassphrase

func (check *IssueCheck) SetPassphrase(passphrase string) IssueCheckInterface

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

func (*IssueCheck) Sign

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

Sign Issue Check

type IssueCheckData

type IssueCheckData struct {
	Nonce    []byte
	ChainID  ChainID
	DueBlock uint64
	Coin     [10]byte
	Value    *big.Int
	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 DecodeIssueCheck

func DecodeIssueCheck(check string) (*IssueCheckData, error)

Prepare check string and convert to data

type IssueCheckInterface

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

func NewIssueCheck

func NewIssueCheck(nonce uint64, chainID ChainID, dueBlock uint64, coin string, value *big.Int) IssueCheckInterface

Create Issue 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 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        [10]byte
	CoinToBuy         [10]byte
	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        [10]byte
	ValueToSell       *big.Int
	CoinToBuy         [10]byte
	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  [10]byte
	To    [20]byte
	Value *big.Int
}

Transaction for sending arbitrary coin. Coin - Symbol of a coin. To - Recipient address in NOAH 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 SignatureType

type SignatureType byte

type Signed

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

type SignedTransaction

type SignedTransaction interface {
	Encode() (string, error)
	Fee() *big.Int
	Hash() (string, error)
	Data() DataInterface
	Signature() (*Signature, error)
	SenderAddress() (string, error)
	PublicKey() (string, error)
}

func Decode

func Decode(tx string) (SignedTransaction, error)

Decode transaction

type Transaction

type Transaction struct {
	Nonce         uint64
	ChainID       ChainID
	GasPrice      uint8
	GasCoin       [10]byte
	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   [10]byte
	Value  *big.Int
}

Transaction for unbonding funds from validator's stake. PubKey - Public key of a validator. Coin - Symbol of coin to stake. Stake - 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