sdcgo

package module
v0.0.0-...-4d6a0de Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2020 License: MIT Imports: 3 Imported by: 0

README

sdc-go

Build Status Coverage Status GoDoc License

💰 A simple digial coin implementation in golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serialize

func Serialize(input interface{}) ([]byte, error)

Serialize serializes the input into bytes.

Types

type Block

type Block struct {
	TimeStamp     int64
	Transactions  []*Transaction
	PrevBlockHash []byte
	Hash          []byte
	Nonce         int
}

Block is a block in a blockchain.

func DeserializeBlock

func DeserializeBlock(b []byte) (*Block, error)

DeserializeBlock deserializes the given bytes into a block.

func NewBlock

func NewBlock(transactions []*Transaction, prevBlockHash []byte) *Block

NewBlock creates a new block.

func (*Block) Serialize

func (b *Block) Serialize() ([]byte, error)

Serialize serializes the block.

type TXInput

type TXInput struct {
	Txid      []byte
	Vout      int
	ScriptSig string
}

TXInput is the input of a transaction.

func (*TXInput) CanUnlockOutputWith

func (in *TXInput) CanUnlockOutputWith(unlockingData string) bool

CanUnlockOutputWith checks whether the input can unlock the output.

type TXOutput

type TXOutput struct {
	Value        int
	ScriptPubKey string
}

TXOutput is the output of a transaction.

func (*TXOutput) CanBeUnlockedWith

func (out *TXOutput) CanBeUnlockedWith(unlockingData string) bool

CanBeUnlockedWith checks whether the output can be unlocked.

type Transaction

type Transaction struct {
	ID   []byte
	Vin  []TXInput
	Vout []TXOutput
}

Transaction is a transaction in the chain.

Jump to

Keyboard shortcuts

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