Documentation ¶
Index ¶
- Constants
- func DecryptMessageWithPrivateKey(privateKey *rsa.PrivateKey, encrypted []byte) []byte
- func EncryptMessageWithPublicKey(publicKey *rsa.PublicKey, message string) []byte
- func GenDigest(hash hash.Hash, message []byte) []byte
- func GenerateHashForKey(label string) hash.Hash
- func GeneratePubPrivKeyPair() (*rsa.PrivateKey, *rsa.PublicKey)
- func GetHashOfPublicKey(pid *PublicIdentity) string
- func GetKeyForBook(publicKey *rsa.PublicKey) string
- func VerifySingature(senderPubKey *rsa.PublicKey, message []byte, sig []byte) bool
- func VerifyTxSig(fromPid PublicIdentity, tx Transaction, txSig []byte) bool
- type BalanceBook
- func (bb *BalanceBook) BuildBalanceBook(chain p2.Blockchain, fromHeight int32)
- func (bb *BalanceBook) CheckAmountPromisedByOne(pid PublicIdentity) float64
- func (bb *BalanceBook) GetBalanceFromKey(PublicKeyHashStr string) float64
- func (bb *BalanceBook) GetBalanceFromPublicKey(publicKey *rsa.PublicKey) float64
- func (bb *BalanceBook) GetKey(publicKey *rsa.PublicKey) string
- func (bb *BalanceBook) PutTxInPromised(tx Transaction)
- func (bb *BalanceBook) Show() string
- func (bb *BalanceBook) ShowPromised() string
- func (bb *BalanceBook) TransferPromisesMade(btx BorrowingTransaction)
- func (bb *BalanceBook) UpdateABalanceBookForTx(tx Transaction)
- func (bb *BalanceBook) UpdateABalanceInBook(PublicKeyHashStr string, updateBalanceBy float64)
- func (bb *BalanceBook) UpdateABalanceInPromised(tx Transaction, btx BorrowingTransaction)
- type BlockChainHolders
- type BorrowingTransaction
- type BorrowingTransactions
- type ClientId
- type Identity
- type PublicIdentity
- type Transaction
- type TransactionBeat
- type TransactionPool
- func (txp *TransactionPool) AddPoolToTransactionPool(recvTxp TransactionPool)
- func (txp *TransactionPool) AddToTransactionPool(tx Transaction)
- func (txp *TransactionPool) DeleteFromTransactionPool(txid string)
- func (txp *TransactionPool) GetTransactionPoolJsonObj() TransactionPoolJson
- func (txp *TransactionPool) ReadFromTransactionPool(n int) map[string]Transaction
- func (txp *TransactionPool) Show() string
- type TransactionPoolJson
- type Wallet
Constants ¶
View Source
const TOKENUNIT = "pingala"
Variables ¶
This section is empty.
Functions ¶
func DecryptMessageWithPrivateKey ¶
func DecryptMessageWithPrivateKey(privateKey *rsa.PrivateKey, encrypted []byte) []byte
func GenerateHashForKey ¶
generateHashForKey func creates a hash for id
func GeneratePubPrivKeyPair ¶
func GeneratePubPrivKeyPair() (*rsa.PrivateKey, *rsa.PublicKey)
generatePubPrivKeyPair func creates key pair pub - priv
func GetKeyForBook ¶
func VerifySingature ¶
func VerifyTxSig ¶
func VerifyTxSig(fromPid PublicIdentity, tx Transaction, txSig []byte) bool
Types ¶
type BalanceBook ¶
type BalanceBook struct { Book p1.MerklePatriciaTrie //key - hashOfPubKey and Value - balance // key - Requirement transaction id -||- value - BorrowingTransaction Promised map[string]BorrowingTransaction // contains filtered or unexported fields }
func NewBalanceBook ¶
func NewBalanceBook() BalanceBook
func (*BalanceBook) BuildBalanceBook ¶
func (bb *BalanceBook) BuildBalanceBook(chain p2.Blockchain, fromHeight int32)
func (*BalanceBook) CheckAmountPromisedByOne ¶
func (bb *BalanceBook) CheckAmountPromisedByOne(pid PublicIdentity) float64
func (*BalanceBook) GetBalanceFromKey ¶
func (bb *BalanceBook) GetBalanceFromKey(PublicKeyHashStr string) float64
func (*BalanceBook) GetBalanceFromPublicKey ¶
func (bb *BalanceBook) GetBalanceFromPublicKey(publicKey *rsa.PublicKey) float64
func (*BalanceBook) GetKey ¶
func (bb *BalanceBook) GetKey(publicKey *rsa.PublicKey) string
GetKey func takes in PublicKey and returns Key for Book
func (*BalanceBook) PutTxInPromised ¶
func (bb *BalanceBook) PutTxInPromised(tx Transaction)
func (*BalanceBook) Show ¶
func (bb *BalanceBook) Show() string
func (*BalanceBook) ShowPromised ¶
func (bb *BalanceBook) ShowPromised() string
func (*BalanceBook) TransferPromisesMade ¶
func (bb *BalanceBook) TransferPromisesMade(btx BorrowingTransaction)
func (*BalanceBook) UpdateABalanceBookForTx ¶
func (bb *BalanceBook) UpdateABalanceBookForTx(tx Transaction)
func (*BalanceBook) UpdateABalanceInBook ¶
func (bb *BalanceBook) UpdateABalanceInBook(PublicKeyHashStr string, updateBalanceBy float64)
func (*BalanceBook) UpdateABalanceInPromised ¶
func (bb *BalanceBook) UpdateABalanceInPromised(tx Transaction, btx BorrowingTransaction)
type BlockChainHolders ¶
type BlockChainHolders struct { Holders map[string]PublicIdentity // contains filtered or unexported fields }
func NewBlockChainHolders ¶
func NewBlockChainHolders() BlockChainHolders
func (*BlockChainHolders) AddBlockChainHolder ¶
func (BCH *BlockChainHolders) AddBlockChainHolder(addr string, pid PublicIdentity)
func (*BlockChainHolders) DeleteBlockChainHolder ¶
func (BCH *BlockChainHolders) DeleteBlockChainHolder(addr string)
func (*BlockChainHolders) Show ¶
func (BCH *BlockChainHolders) Show() string
type BorrowingTransaction ¶
type BorrowingTransaction struct { BorrowingTxId string `json:"borrowingtxid"` BorrowingTx Transaction `json:"borrowingtx"` PromisesMade []Transaction `json:"promisesmade"` // key - transaction id (Lending) // todo todo -- changed from map to array PromisedValue float64 `json:"promisedvalue"` }
func NewBorrowingTransaction ¶
func NewBorrowingTransaction(tx Transaction) BorrowingTransaction
func (*BorrowingTransaction) CheckForEnoughPromises ¶
func (btx *BorrowingTransaction) CheckForEnoughPromises() bool
func (*BorrowingTransaction) EncodeTojsonString ¶
func (btx *BorrowingTransaction) EncodeTojsonString() string
type BorrowingTransactions ¶
type BorrowingTransactions struct { BorrowingTxs map[string]Transaction // key - BorrowingTxId value - txJson Borrower map[string]string //json of pid of borrower }
func BuildBorrowingTransactions ¶
func BuildBorrowingTransactions(chains []p2.Blockchain) BorrowingTransactions
func NewBorrowingTransactions ¶
func NewBorrowingTransactions() BorrowingTransactions
type ClientId ¶
type ClientId struct { PrivateKey *rsa.PrivateKey `json:"privateKey"` PublicKey *rsa.PublicKey `json:"publicKey"` //HashForKey hash.Hash Label string `json:"label"` }
func ExistingClientId ¶
func JsonToClientId ¶
func NewClientId ¶
func (*ClientId) ClientIdToJsonByteArray ¶
func (*ClientId) GenSignature ¶
func (*ClientId) GetMyPublicIdentity ¶
func (id *ClientId) GetMyPublicIdentity() PublicIdentity
type Identity ¶
type Identity struct { PublicKey *rsa.PublicKey `json:"publicKey"` //HashForKey hash.Hash Label string `json:"label"` // contains filtered or unexported fields }
func NewIdentity ¶
func (*Identity) GenSignature ¶
func (*Identity) GetMyPrivateKey ¶
func (id *Identity) GetMyPrivateKey() *rsa.PrivateKey
func (*Identity) GetMyPublicIdentity ¶
func (id *Identity) GetMyPublicIdentity() PublicIdentity
type PublicIdentity ¶
type PublicIdentity struct { PublicKey *rsa.PublicKey `json:"publicKey"` //HashForKey hash.Hash `json="hashForKey"` Label string `json:"label"` }
func JsonToPublicIdentity ¶
func JsonToPublicIdentity(str string) PublicIdentity
func (*PublicIdentity) PublicIdentityToJson ¶
func (pid *PublicIdentity) PublicIdentityToJson() string
type Transaction ¶
type Transaction struct { Id string `json:"id"` From PublicIdentity `json:"from"` To PublicIdentity `json:"to"` //if To is empty then its a borrowing tx ToTxId string `json:"toTxId"` Tokens float64 `json:"tokens"` Fees float64 `json:"fees"` TxType string `json:"txtype"` Timestamp time.Time `json:"timestamp"` }
func JsonToTransaction ¶
func JsonToTransaction(txJson string) Transaction
func NewTransaction ¶
func NewTransaction(from PublicIdentity, to PublicIdentity, toTxId string, tokens float64, fees float64, txType string) Transaction
func (*Transaction) CreateTxSig ¶
func (tx *Transaction) CreateTxSig(fromCid ClientId) []byte
func (*Transaction) CreateTxSigForMiner ¶
func (tx *Transaction) CreateTxSigForMiner(fromId Identity) []byte
func (*Transaction) Show ¶
func (tx *Transaction) Show() string
func (*Transaction) TransactionToJson ¶
func (tx *Transaction) TransactionToJson() string
func (*Transaction) TransactionToJsonByteArray ¶
func (tx *Transaction) TransactionToJsonByteArray() []byte
type TransactionBeat ¶
type TransactionBeat struct { Tx Transaction FromPid PublicIdentity TxSig []byte Hops int }
func DecodeToTransactionBeat ¶
func DecodeToTransactionBeat(transactionBeatJson []byte) TransactionBeat
DecodeToHeartBeatData func decodes json string to HeartBeatData
func NewTransactionBeat ¶
func NewTransactionBeat(tx Transaction, fromPid PublicIdentity, fromSig []byte) TransactionBeat
func PrepareTransactionBeat ¶
func PrepareTransactionBeat(tx Transaction, cid ClientId) TransactionBeat
func (*TransactionBeat) EncodeToJson ¶
func (data *TransactionBeat) EncodeToJson() string
EncodeToJson func encodes HeartBeatData to json string
func (*TransactionBeat) EncodeToJsonByteArray ¶
func (data *TransactionBeat) EncodeToJsonByteArray() []byte
EncodeToJson func encodes HeartBeatData to json byte array
func (*TransactionBeat) VerifyTxSigInTxBeat ¶
func (data *TransactionBeat) VerifyTxSigInTxBeat() bool
type TransactionPool ¶
type TransactionPool struct { Pool map[string]Transaction `json:"pool"` Confirmed map[string]bool `json:"confirmed"` // contains filtered or unexported fields }
this is for mining
func NewTransactionPool ¶
func NewTransactionPool() TransactionPool
func (*TransactionPool) AddPoolToTransactionPool ¶
func (txp *TransactionPool) AddPoolToTransactionPool(recvTxp TransactionPool)
func (*TransactionPool) AddToTransactionPool ¶
func (txp *TransactionPool) AddToTransactionPool(tx Transaction)
func (*TransactionPool) DeleteFromTransactionPool ¶
func (txp *TransactionPool) DeleteFromTransactionPool(txid string)
func (*TransactionPool) GetTransactionPoolJsonObj ¶
func (txp *TransactionPool) GetTransactionPoolJsonObj() TransactionPoolJson
Copy func returns a copy of the peerMap
func (*TransactionPool) ReadFromTransactionPool ¶
func (txp *TransactionPool) ReadFromTransactionPool(n int) map[string]Transaction
func (*TransactionPool) Show ¶
func (txp *TransactionPool) Show() string
type TransactionPoolJson ¶
type TransactionPoolJson struct {
Pool map[string]Transaction `json:"pool"`
}
func DecodeJsonToTransactionPoolJson ¶
func DecodeJsonToTransactionPoolJson(jsonStr string) TransactionPoolJson
func (*TransactionPoolJson) EncodeToJsonTransactionPoolJson ¶
func (txpj *TransactionPoolJson) EncodeToJsonTransactionPoolJson() string
Click to show internal directories.
Click to hide internal directories.