models

package
v0.0.0-...-2d974e4 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckSum

func CheckSum(payload []byte) []byte

func HashPubKey

func HashPubKey(pubkey []byte) []byte

func NewKeyPair

func NewKeyPair() (*ecdsa.PrivateKey, []byte)

Types

type BlockModel

type BlockModel struct {
	gorm.Model
	Timestamp    int64
	Transactions []*TransactionModel `gorm:"foreignkey:BlockID"`
	Hash         string              `gorm:"type:varchar(32)"`
	Prev         uint
	PrevHash     string `gorm:"type:varchar(32)"`
	Iterations   int
}

func (*BlockModel) GetHash

func (b *BlockModel) GetHash() []byte

func (*BlockModel) GetPrevHash

func (b *BlockModel) GetPrevHash() []byte

func (*BlockModel) HashTransactions

func (b *BlockModel) HashTransactions() []byte

func (*BlockModel) LoadTransactions

func (b *BlockModel) LoadTransactions(db *gorm.DB) []*TransactionModel

func (*BlockModel) Save

func (b *BlockModel) Save(db *gorm.DB, odb *gorm.DB)

func (*BlockModel) SetHash

func (b *BlockModel) SetHash()

type TXInput

type TXInput struct {
	TxID      string `gorm:"primary_key"`
	OtxID     string
	Vout      int
	Signature string
	PubKey    string
}

func (*TXInput) CanUnlockOutput

func (itx *TXInput) CanUnlockOutput(hash []byte) bool

func (*TXInput) GetKey

func (itx *TXInput) GetKey() []byte

func (*TXInput) GetOTXID

func (itx *TXInput) GetOTXID() []byte

func (*TXInput) GetPubKeyHashed

func (itx *TXInput) GetPubKeyHashed() []byte

func (*TXInput) GetSignature

func (itx *TXInput) GetSignature() []byte

func (*TXInput) GetTXID

func (itx *TXInput) GetTXID() []byte

type TXOutput

type TXOutput struct {
	gorm.Model
	TxID       string
	Value      int
	PubKeyHash string
}

func (*TXOutput) CanBeUnlocked

func (otx *TXOutput) CanBeUnlocked(PubKeyHash []byte) bool

func (*TXOutput) Display

func (otx *TXOutput) Display()

func (*TXOutput) GetKey

func (otx *TXOutput) GetKey() []byte

func (*TXOutput) GetTXID

func (otx *TXOutput) GetTXID() []byte

func (*TXOutput) Lock

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

type TransactionModel

type TransactionModel struct {
	BlockID uint       `gorm:"foreign_key"`
	Txid    string     `gorm:"primary_key"`
	Vin     []TXInput  `gorm:"foreignkey:TxID"`
	Vout    []TXOutput `gorm:"foreignkey:TxID"`
}

func (*TransactionModel) GetTXID

func (tx *TransactionModel) GetTXID() []byte

func (*TransactionModel) GetTrimmedTransaction

func (tx *TransactionModel) GetTrimmedTransaction() *TransactionModel

func (*TransactionModel) IsCoinbase

func (tx *TransactionModel) IsCoinbase() bool

func (*TransactionModel) LoadData

func (tx *TransactionModel) LoadData(db *gorm.DB) error

func (*TransactionModel) SetID

func (tx *TransactionModel) SetID()

func (*TransactionModel) Sign

func (tx *TransactionModel) Sign(privKey *ecdsa.PrivateKey, prevTransactions map[string]*TransactionModel)

func (*TransactionModel) Verify

func (tx *TransactionModel) Verify(prevTransactions map[string]*TransactionModel) bool

type Wallet

type Wallet struct {
	gorm.Model
	PrivateKey string
	PublicKey  string
}

func NewWallet

func NewWallet() *Wallet

func (*Wallet) Display

func (w *Wallet) Display()

func (Wallet) GetAddress

func (w Wallet) GetAddress() []byte

func (*Wallet) GetEcdsaPrivateKey

func (w *Wallet) GetEcdsaPrivateKey() *ecdsa.PrivateKey

func (*Wallet) GetKey

func (w *Wallet) GetKey() []byte

func (*Wallet) GetPubKeyHashed

func (w *Wallet) GetPubKeyHashed() []byte

type Wallets

type Wallets struct {
	List map[string]*Wallet
}

func GetWallets

func GetWallets(db *gorm.DB) *Wallets

func (*Wallets) Display

func (ws *Wallets) Display()

func (*Wallets) GetWallet

func (ws *Wallets) GetWallet(address string) *Wallet

func (*Wallets) Load

func (ws *Wallets) Load(db *gorm.DB) error

func (*Wallets) Save

func (ws *Wallets) Save(db *gorm.DB) error

Jump to

Keyboard shortcuts

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