transaction

package
v0.0.0-...-8d1acea Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TXInput

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

TXInput represents a transaction input

func NewTXInput

func NewTXInput(txId []byte, vout int, signature []byte, publicKey []byte) *TXInput

NewTXInput create a new TXInput

func (*TXInput) PubKey

func (ti *TXInput) PubKey() []byte

func (*TXInput) Signature

func (ti *TXInput) Signature() []byte

func (*TXInput) TxId

func (ti *TXInput) TxId() []byte

func (*TXInput) UsesKey

func (ti *TXInput) UsesKey(pubKeyHash []byte) bool

UsesKey checks whether the address initiated the transaction

func (*TXInput) Vout

func (ti *TXInput) Vout() int

type TXOutput

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

TXOutput represents a transaction output

func NewTXOutput

func NewTXOutput(value int, address string) *TXOutput

NewTXOutput create a new TXOutput

func (*TXOutput) IsLockedWithKey

func (to *TXOutput) IsLockedWithKey(pubKeyHash []byte) bool

IsLockedWithKey checks if the output can be used by the owner of the pubkey

func (*TXOutput) Lock

func (to *TXOutput) Lock(address []byte)

Lock signs the output

func (*TXOutput) PubKeyHash

func (to *TXOutput) PubKeyHash() []byte

func (*TXOutput) Value

func (to *TXOutput) Value() int

type TXOutputs

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

TXOutputs collects TXOutput

func DeserializeOutputs

func DeserializeOutputs(data []byte) TXOutputs

DeserializeOutputs deserializes TXOutputs

func (TXOutputs) Add

func (outs TXOutputs) Add(txOutput TXOutput)

Add adds TXOutput

func (*TXOutputs) Outputs

func (out *TXOutputs) Outputs() []TXOutput

func (TXOutputs) Serialize

func (outs TXOutputs) Serialize() []byte

Serialize serializes TXOutputs

type Transaction

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

func BuildTransaction

func BuildTransaction(inputs []TXInput, outputs []TXOutput) *Transaction

BuildTransaction creates a coinbase transaction

func DeserializeTransaction

func DeserializeTransaction(data []byte) Transaction

DeserializeTransaction deserializes a transaction

func NewCoinbaseTX

func NewCoinbaseTX(to, data string) *Transaction

NewCoinbaseTX creates a new coinbase transaction

func (*Transaction) Hash

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

Hash returns the hash of the Transaction

func (*Transaction) ID

func (t *Transaction) ID() []byte

func (*Transaction) IsCoinbase

func (t *Transaction) IsCoinbase() bool

IsCoinbase checks whether the transaction is coinbase

func (*Transaction) Serialize

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

Serialize returns a serialized Transaction

func (*Transaction) Sign

func (t *Transaction) Sign(privateKey ecdsa.PrivateKey, prevTxs map[string]Transaction)

Sign signs each input of a Transaction

func (*Transaction) String

func (t *Transaction) String() string

String returns a human-readable representation of a transaction

func (*Transaction) TrimmedCopy

func (t *Transaction) TrimmedCopy() Transaction

TrimmedCopy creates a trimmed copy of Transaction to be used in signing

func (*Transaction) Verify

func (t *Transaction) Verify(prevTxs map[string]Transaction) bool

Verify verifies signatures of Transaction inputs

func (*Transaction) Vin

func (t *Transaction) Vin() []TXInput

func (*Transaction) Vout

func (t *Transaction) Vout() []TXOutput

Jump to

Keyboard shortcuts

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