crypto

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DHASH

func DHASH(data []byte) [32]byte

Types

type NodeID

type NodeID [32]byte

func (NodeID) IsEmpty

func (n NodeID) IsEmpty() bool

IsEmpty check script is empty

type TransactionInput

type TransactionInput struct {
	// The previous output transaction reference, as an OutPoint structure
	PreviousOutput TransactionInputOutpoint `json:"previous_output"`
	// Transaction version as defined by the sender. Intended for "replacement" of transactions when information is
	// updated before inclusion into a block.
	Sequence      uint32 `json:"sequence"`
	Script        []byte `json:"signature_script"`     // Computational Script for confirming transaction authorization
	PublicKey     []byte `json:"public_key,omitempty"` // Public Key for verify signature when to work with wallet
	WalletAddress []byte `json:"wallet_address,omitempty"`
}

func (*TransactionInput) MarshalJSON

func (ti *TransactionInput) MarshalJSON() ([]byte, error)

func (*TransactionInput) UnmarshalJSON

func (ti *TransactionInput) UnmarshalJSON(data []byte) error

UnmarshalJSON custom json convert

type TransactionInputOutpoint

type TransactionInputOutpoint struct {
	Hash    [32]byte `json:"hash"`  // The hash of the referenced transaction
	Index   uint32   `json:"index"` // The index of the specific output in the transaction. The first output is 0, etc.
	Value   uint64   `json:"value"` // Transaction Value
	Address string
}

func (*TransactionInputOutpoint) MarshalJSON

func (tio *TransactionInputOutpoint) MarshalJSON() ([]byte, error)

MarshalJSON custom json convert

func (TransactionInputOutpoint) ToBytes

func (tio TransactionInputOutpoint) ToBytes() []byte

ToBytes convert TransactionInputOutpoint to bytes slice

func (*TransactionInputOutpoint) UnmarshalJSON

func (tio *TransactionInputOutpoint) UnmarshalJSON(data []byte) error

UnmarshalJSON custom json convert

type TransactionOutput

type TransactionOutput struct {
	Index         uint32 `json:"index"`
	Value         uint64 `json:"value"`     // Transaction Value
	Script        []byte `json:"pk_script"` // Usually contains the public key as a script setting up conditions to claim this output.
	Payload       []byte `json:"payload"`
	WalletAddress []byte `json:"wallet_address,omitempty"`
	NodeID        NodeID `json:"node_id"` // usually contains the public key of node for request to be part of commission
}

func (*TransactionOutput) MarshalJSON

func (to *TransactionOutput) MarshalJSON() ([]byte, error)

MarshalJSON custom json convert

func (*TransactionOutput) UnmarshalJSON

func (to *TransactionOutput) UnmarshalJSON(data []byte) error

UnmarshalJSON custom json convert

type Tx

type Tx struct {
	Hash     [32]byte            `json:"hash"`
	Version  uint32              `json:"version"`
	LockTime uint32              `json:"lock_time"`
	Inputs   []TransactionInput  `json:"tx_in"`
	Outputs  []TransactionOutput `json:"tx_out"`
}

func NewTransaction

func NewTransaction(unspents []*TransactionInputOutpoint, toAddresses map[string]uint64, changeAddress string, commission uint64) (*Tx, error)

func (*Tx) GenerateHash

func (tx *Tx) GenerateHash() [32]byte

GenerateHash return generated hash

func (*Tx) MarshalJSON

func (tx *Tx) MarshalJSON() ([]byte, error)

func (*Tx) MsgForSign

func (tx *Tx) MsgForSign(hash [32]byte, index uint32) []byte

MsgForSign return msg for sign

func (*Tx) UnmarshalJSON

func (tx *Tx) UnmarshalJSON(data []byte) error

UnmarshalJSON custom json convert

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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