transactions

package
v0.0.0-...-f432f55 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2018 License: GPL-3.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCurrentTimeWithOffset

func GetCurrentTimeWithOffset(offset int64) uint32

GetCurrentTimeWithOffset returns the current blockchain time with an offset

Types

type Asset

type Asset interface {
	IsValid() (bool, error)
	// contains filtered or unexported methods
}

Asset is asset data that can be attached to a transaction

type CastVoteAsset

type CastVoteAsset struct {
	// Votes is a slice of the public keys of the delegates to vote for
	Votes [][]byte
	// Unvotes is a slice of the public keys of the delegates to remove votes from
	Unvotes [][]byte
}

CastVoteAsset is the asset needed for a TransactionTypeVote The maximum number of votes is 33

func (*CastVoteAsset) IsValid

func (c *CastVoteAsset) IsValid() (bool, error)

IsValid returns whether the asset is valid

func (*CastVoteAsset) MarshalJSON

func (c *CastVoteAsset) MarshalJSON() ([]byte, error)

MarshalJSON marshals the asset to the lisk JSON format

type CreateDappAsset

type CreateDappAsset struct {
	// Dapp is the dapp that should be registered
	Dapp *Dapp
}

CreateDappAsset is the asset needed for a TransactionTypeDappRegistration

type Dapp

type Dapp struct {
	Name        string
	Link        string
	Type        string
	Category    string
	Description string
	Tags        []string
	Icon        string
}

Dapp represents a Dapp on the Lisk blockchain

type DataAsset

type DataAsset string

DataAsset is an asset that is used to attach data to a normal transaction

func (DataAsset) IsValid

func (a DataAsset) IsValid() (bool, error)

IsValid returns whether the asset is valid

func (DataAsset) MarshalJSON

func (a DataAsset) MarshalJSON() ([]byte, error)

MarshalJSON marshals the asset to the lisk JSON format

type RegisterDelegateAsset

type RegisterDelegateAsset struct {
	// Username is the username for the delegate
	Username string
	// PublicKey is the public key of the delegate
	PublicKey []byte
}

RegisterDelegateAsset is the asset needed for a TransactionTypeDelegateRegistration

func (*RegisterDelegateAsset) IsValid

func (r *RegisterDelegateAsset) IsValid() (bool, error)

IsValid returns whether the asset is valid

func (*RegisterDelegateAsset) MarshalJSON

func (r *RegisterDelegateAsset) MarshalJSON() ([]byte, error)

MarshalJSON marshals the asset to the lisk JSON format

type RegisterMultisignatureAccountAsset

type RegisterMultisignatureAccountAsset struct {
	// Min is the minimum number of signatures that is required for a transaction
	Min byte `json:"min"`
	// Lifetime is the lifetime of the transaction in which it can be signed
	Lifetime byte `json:"lifetime"`
	// AddKeys is a slice of keys to add to the multisignature wallet
	AddKeys [][]byte `json:"_"`
	// AddKeys is a slice of keys to remove from the multisignature wallet
	RemoveKeys [][]byte `json:"_"`
}

RegisterMultisignatureAccountAsset is the asset needed for a TransactionTypeMultisignatureRegistration

func (*RegisterMultisignatureAccountAsset) IsValid

IsValid returns whether the asset is valid

func (*RegisterMultisignatureAccountAsset) MarshalJSON

func (r *RegisterMultisignatureAccountAsset) MarshalJSON() ([]byte, error)

MarshalJSON marshals the asset to the lisk JSON format

type RegisterSecondSignatureAsset

type RegisterSecondSignatureAsset struct {
	// PublicKey is the public key for the second secret
	PublicKey []byte
}

RegisterSecondSignatureAsset is the asset needed for a TransactionTypeSecondSecretRegistration

func (*RegisterSecondSignatureAsset) IsValid

func (r *RegisterSecondSignatureAsset) IsValid() (bool, error)

IsValid returns whether the asset is valid

func (*RegisterSecondSignatureAsset) MarshalJSON

func (r *RegisterSecondSignatureAsset) MarshalJSON() ([]byte, error)

MarshalJSON marshals the asset to the lisk JSON format

type Transaction

type Transaction struct {
	Type                          TransactionType
	Amount                        uint64
	RecipientID                   string
	Timestamp                     uint32
	Asset                         Asset
	SenderPublicKey               []byte
	TransactionRequesterPublicKey []byte
	// contains filtered or unexported fields
}

Transaction represents a lisk network transaction

func NewMultisignatureRegistrationTransaction

func NewMultisignatureRegistrationTransaction(recipientID string, secret string, secondSecret string, timeOffset int64,
	addKeys [][]byte, removeKeys [][]byte, Lifetime byte, min byte) (
	*Transaction, error)

NewMultisignatureRegistrationTransaction creates a new transaction to create/update multisignature accounts and signs it using the given secrets. The second secret is optional and only required for lisk wallets with a second signature. The keys are binary representations of the public keys of the relevant delegates. Lifetime is the pending transaction lifetime. Min is the minimum number of signatures required.

func NewSecondSignatureTransaction

func NewSecondSignatureTransaction(
	recipientID string, secret string, newSecondSecret string, timeOffset int64) (
	*Transaction, error)

NewSecondSignatureTransaction creates a new transaction to create a second signature and signs it using the given secrets.

func NewTransaction

func NewTransaction(recipientID string, amount uint64, secret string, secondSecret string, timeOffset int64) (
	*Transaction, error)

NewTransaction creates a new value transfer transaction and signs it using the given secrets. The second secret is optional and only required for lisk wallets with a second signature.

func NewTransactionWithData

func NewTransactionWithData(
	recipientID string, amount uint64, secret string, secondSecret string, timeOffset int64, data interface{}) (
	*Transaction, error)

NewTransactionWithData creates a new value transfer transaction with data and signs it using the given secrets. The second secret is optional and only required for lisk wallets with a second signature. Data can be a string or byte slice with a maximum length of 64 bytes.

func NewVoteTransaction

func NewVoteTransaction(recipientID string, secret string, secondSecret string, timeOffset int64,
	votes [][]byte, unvotes [][]byte) (
	*Transaction, error)

NewVoteTransaction creates a new vote transaction and signs it using the given secrets. The second secret is optional and only required for lisk wallets with a second signature. The votes and unvotes are binary representations of the public keys of the relevant delegates.

func (*Transaction) Fee

func (t *Transaction) Fee() (uint32, error)

Fee returns the calculated fee of the transaction

func (*Transaction) Hash

func (t *Transaction) Hash() ([]byte, error)

Hash returns the SHA256 hash of the transaction bytes

func (*Transaction) ID

func (t *Transaction) ID() (string, error)

ID returns the ID of the transaction

func (*Transaction) IsValid

func (t *Transaction) IsValid() (bool, error)

IsValid returns whether the transaction is valid

func (*Transaction) MarshalJSON

func (t *Transaction) MarshalJSON() ([]byte, error)

MarshalJSON converts the transaction to a JSON payload that can be sent to the node

func (*Transaction) SecondSign

func (t *Transaction) SecondSign(privateKey []byte) error

SecondSign adds a second signature to the transaction using the given privateKey. This has to be redone when any fields of the transaction are changed.

func (*Transaction) Serialize

func (t *Transaction) Serialize() ([]byte, error)

Serialize serializes the transaction in the binary format used

func (*Transaction) Sign

func (t *Transaction) Sign(privateKey []byte) error

Sign signs the transaction with the given privateKey. This has to be redone when any fields of the transaction are changed.

type TransactionType

type TransactionType byte

TransactionType represents a transaction type and specifies the associated action

const (
	// TransactionTypeNormal is used to transfer Lisk
	TransactionTypeNormal TransactionType = 0

	// TransactionTypeSecondSecretRegistration is used to register a second secret
	TransactionTypeSecondSecretRegistration TransactionType = 1

	// TransactionTypeDelegateRegistration is used to register a delegate
	TransactionTypeDelegateRegistration TransactionType = 2

	// TransactionTypeVote is used to change vote for delegates
	TransactionTypeVote TransactionType = 3

	// TransactionTypeMultisignatureRegistration is used to register and modify a multisignature wallet
	TransactionTypeMultisignatureRegistration TransactionType = 4

	// TransactionTypeDappRegistration is used to register a DApp
	TransactionTypeDappRegistration TransactionType = 5

	// TransactionTypeTransferInSidechain is used to transfer lisk into a sidechain
	TransactionTypeTransferInSidechain TransactionType = 6

	// TransactionTypeTransferOutSidechain is used to transfer lisk out of a sidechain
	TransactionTypeTransferOutSidechain TransactionType = 7
)

type TransferInDappAsset

type TransferInDappAsset struct {
	// DappID is the ID of the DApp to transfer lisk in
	DappID string `json:"dappId"`
}

TransferInDappAsset is the asset needed for a TransactionTypeTransferInSidechain

type TransferOutDappAsset

type TransferOutDappAsset struct {
	// DappID is the ID of the DApp to transfer lisk out of
	DappID string `json:"dappId"`
	// TransactionID is the ID of the withdrawal transaction on the sidechain
	TransactionID string `json:"transactionId"`
}

TransferOutDappAsset is the asset needed for a TransactionTypeTransferOutSidechain

Jump to

Keyboard shortcuts

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