Overview

Namespaces

  • Liberty
  • None

Classes

  • Liberty\BigInteger
  • Liberty\Block
  • Liberty\Blockchain
  • Liberty\Collection
  • Liberty\CollectionFileList
  • Liberty\File
  • Liberty\Folder
  • Liberty\INI
  • Liberty\LECDSA
  • Liberty\Onecrypt
  • Liberty\SSV
  • Liberty\Text
  • Liberty\Transaction
  • Liberty\Wallet
  • Liberty\WebPeer

Functions

  • __autoload
  • Overview
  • Namespace
  • Class
 1: <?php
 2: 
 3: namespace Liberty;
 4: 
 5: use Liberty\LECDSA;
 6: use Liberty\Transaction;
 7: use Exception;
 8: 
 9: /**
10:  * Liberty Block Class
11:  *
12:  * @category  Cryptocurrency
13:  * @package   Liberty
14:  * @license   http://www.opensource.org/licenses/mit-license.php MIT License
15:  * @version   1.0.0
16:  * @since     2018-01-16
17:  * @author    Liberty Group <cryptolibertygroup@gmail.com>
18:  */
19: 
20: 
21: class Block {
22: 
23:     public $index;
24:     
25:     public $sender;
26:     public $receiver;
27:     public $amount;
28:     public $fee;
29: 
30:     public $time;
31:     public $signature;
32:     public $previousHash;
33:     
34: 
35: 
36:     public function __construct($index, $sender, $receiver, $amount, $fee, $time, $signature, $previousHash)
37:     {
38:         $this->index = $index;
39:         
40:         $this->sender = $sender;
41:         $this->receiver = $receiver;
42:         $this->amount = $amount;
43:         $this->fee = $fee;
44:         $this->time = $time;
45:         $this->signature = $signature;
46: 
47:         $this->previousHash = $previousHash;
48: 
49:         /*
50:         if(! Transaction::verify($sender, $receiver, $amount, $fee, $time, $signature) ) {
51:             throw new Exception("Invalid Signature");
52:         }
53:         */
54:     }
55: 
56: 
57: 
58:     public function hash()
59:     {
60:         $ec = new LECDSA();
61:         $hash = hash("sha256", $this->index . $this->sender . $this->receiver . $this->amount . $this->fee . 
62:                         $this->time . $this->signature . $this->previousHash);
63:         return $ec->base58_encode($hash);
64:     }
65:     
66: 
67: 
68:     public function block()
69:     {
70:         $block = $this->index . " ";
71:         $block .= $this->sender . " ";
72:         $block .= $this->receiver . " ";
73:         $block .= $this->amount . " ";
74:         $block .= $this->fee . " ";
75:         $block .= $this->time . " ";
76:         $block .= $this->signature . " ";
77:         $block .= $this->previousHash . " ";
78:         $block .= $this->hash();
79:         return $block;
80:     }
81: 
82: }
83: 
84: ?>
API documentation generated by ApiGen