ncoin_wallet

package module
v0.0.0-...-fc0402f Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2018 License: MIT Imports: 14 Imported by: 2

README

Documentation

Index

Constants

View Source
const REDIS_PATH = "localhost"
View Source
const REDIS_PORT = "6379"
View Source
const SEED_SIZE = 512 //bytes
View Source
const WALLET_FOLDER = ".ncoin"

Variables

This section is empty.

Functions

func BlockFromJson

func BlockFromJson(r []byte) (b block, e error)

func CalculateMerkleRoot

func CalculateMerkleRoot(hashList []string) (root string)

Types

type Blockchain

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

Blockchain struct contains all blockchain blocks and reference to last block

func (*Blockchain) AddBlock

func (b *Blockchain) AddBlock(n block)

AddBlock function appends new block to the blockchain and reference that block as lastBlock.

func (*Blockchain) GetMerkleTreeRoot

func (b *Blockchain) GetMerkleTreeRoot() (hash string)

GetMerkleTreeRoot function iterates over whole blockchain blocks and generates its hash. Then combines that hash and returns the root of blcks hash Merkle Tree.

func (*Blockchain) Load

func (b *Blockchain) Load()

func (*Blockchain) Store

func (b *Blockchain) Store()

type Transaction

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

Transaction struct contains all the attributes necessary for one transaction of the blockchain.

func NewTransaction

func NewTransaction(addressTo uint64, addressFrom uint64, quantity float64, fee float64) Transaction

NewTransaction its a constructor for a new Transaction struct, receive all the attribute of the Transaction except the sign

func TransactionFromJson

func TransactionFromJson(r []byte) (t *Transaction, e error)

func (*Transaction) AddressFrom

func (t *Transaction) AddressFrom() uint64

AddressFrom its the getter for the addressFrom attribute

func (*Transaction) AddressTo

func (t *Transaction) AddressTo() uint64

AddressTo its the getter for the addressTo attribute

func (*Transaction) CalculateHash

func (t *Transaction) CalculateHash() string

func (*Transaction) CheckHash

func (t *Transaction) CheckHash(inputHash string) bool

func (*Transaction) Fee

func (t *Transaction) Fee() float64

Fee its the getter for the Fee attribute

func (*Transaction) GetSign

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

GetSign its the getter for the sign attribute

func (*Transaction) Quantity

func (t *Transaction) Quantity() float64

Quantity its the getter for the quantity attribute

func (*Transaction) Sign

func (t *Transaction) Sign(privateKey *rsa.PrivateKey) (e error)

func (*Transaction) Stringify

func (t *Transaction) Stringify() (s string)

Stringify return the Transaction in string format

func (*Transaction) ToJson

func (t *Transaction) ToJson() ([]byte, error)

func (*Transaction) Verify

func (t *Transaction) Verify(publicKey *rsa.PublicKey) error

Verify verify the sign of the transaction with the parameter publicKey *rsa.PublicKey. Return a err if somewhat goes wrong or nil if all it`s ok.

type Wallet

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

Cartera

func NewWallet

func NewWallet() (w *Wallet, e error)

func (*Wallet) Address

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

Devuelve la dirección de la cartera.

func (*Wallet) Balance

func (w *Wallet) Balance() float64

Devuelve el saldo de la cartera.

func (*Wallet) PrivateKey

func (w *Wallet) PrivateKey() *rsa.PrivateKey

Devuelve la private_key de la cartera.

func (*Wallet) PublicKey

func (w *Wallet) PublicKey() *rsa.PublicKey

func (*Wallet) SendTransaction

func (w *Wallet) SendTransaction(amount float64, address uint64)

Envía la cantidad de NCoin indicada a la dirección indicada. Requiere candidad y dirección como parámetros .

func (*Wallet) SetAddress

func (w *Wallet) SetAddress(address []byte)

func (*Wallet) SetBalance

func (w *Wallet) SetBalance(balance float64)

func (*Wallet) SetPrivateKey

func (w *Wallet) SetPrivateKey(privateKey *rsa.PrivateKey)

func (*Wallet) SetPublicKey

func (w *Wallet) SetPublicKey(publicKey *rsa.PublicKey)

func (*Wallet) Unlock

func (w *Wallet) Unlock(pk uint64)

Desbloquea la wallet, requiere una private_key como parametro.

Directories

Path Synopsis
cmd
cli

Jump to

Keyboard shortcuts

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