Documentation ¶
Index ¶
- Constants
- type TXInput
- type TXOutput
- type TXOutputs
- type Transaction
- func (tx *Transaction) Hash() []byte
- func (tx Transaction) IsCoinbase() bool
- func (tx *Transaction) Serialize() []byte
- func (tx *Transaction) Sign(privKey ecdsa.PrivateKey, prevTXs map[string]Transaction) error
- func (tx Transaction) String() string
- func (tx *Transaction) TrimmedCopy() Transaction
- func (tx *Transaction) Verify(prevTXs map[string]Transaction) bool
Constants ¶
const (
Subsidy = 10
)
Exported constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TXOutput ¶
TXOutput represents a transaction output
func NewTXOutput ¶
NewTXOutput create a new TXOutput
func (*TXOutput) IsLockedWithKey ¶
IsLockedWithKey checks if the output can be used by the owner of the pubkey
type TXOutputs ¶
type TXOutputs struct {
Outputs []TXOutput
}
TXOutputs collects TXOutput
func DeserializeOutputs ¶
DeserializeOutputs deserializes TXOutputs
type Transaction ¶
Transaction represents a Bitcoin-like 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 NewUTXOTransaction ¶
func NewUTXOTransaction(acc int, validOutputs map[string][]int, to string, amount int, addrFrom []byte) (*Transaction, error)
NewUTXOTransaction creates a new transaction from the passed transaction inputs
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() []byte
Hash calculates the hash of the transaction and returns it as a byte array
func (Transaction) IsCoinbase ¶
func (tx Transaction) IsCoinbase() bool
IsCoinbase checks whether the transaction is coinbase
func (*Transaction) Serialize ¶
func (tx *Transaction) Serialize() []byte
Serialize sets ID of a transaction
func (*Transaction) Sign ¶
func (tx *Transaction) Sign(privKey ecdsa.PrivateKey, prevTXs map[string]Transaction) error
Sign signs each input of a Transaction
func (Transaction) String ¶
func (tx Transaction) String() string
String returns a human-readable representation of a transaction
func (*Transaction) TrimmedCopy ¶
func (tx *Transaction) TrimmedCopy() Transaction
TrimmedCopy creates a trimmed copy of Transaction to be used in signing
func (*Transaction) Verify ¶
func (tx *Transaction) Verify(prevTXs map[string]Transaction) bool
Verify verifies signatures of Transaction inputs