1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/** |
3
|
|
|
* This file is part of the ngutech/bitcoin-interop project. |
4
|
|
|
* |
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
6
|
|
|
* file that was distributed with this source code. |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace NGUtech\Bitcoin\Entity; |
10
|
|
|
|
11
|
|
|
use Daikon\Entity\Attribute; |
12
|
|
|
use Daikon\Entity\AttributeMap; |
13
|
|
|
use Daikon\Entity\Entity; |
14
|
|
|
use Daikon\ValueObject\Natural; |
15
|
|
|
use Daikon\ValueObject\Timestamp; |
16
|
|
|
use NGUtech\Bitcoin\ValueObject\Hash; |
17
|
|
|
use NGUtech\Bitcoin\ValueObject\HashList; |
18
|
|
|
|
19
|
|
|
final class BitcoinBlock extends Entity |
20
|
|
|
{ |
21
|
|
|
public static function getAttributeMap(): AttributeMap |
22
|
|
|
{ |
23
|
|
|
return new AttributeMap([ |
24
|
|
|
Attribute::define('hash', Hash::class), |
25
|
|
|
Attribute::define('merkleRoot', Hash::class), |
26
|
|
|
Attribute::define('confirmations', Natural::class), |
27
|
|
|
Attribute::define('transactions', HashList::class), |
28
|
|
|
Attribute::define('height', Natural::class), |
29
|
|
|
Attribute::define('timestamp', Timestamp::class) |
30
|
|
|
]); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function getIdentity(): Hash |
34
|
|
|
{ |
35
|
|
|
return $this->getHash(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function getHash(): Hash |
39
|
|
|
{ |
40
|
|
|
return $this->get('hash') ?? Hash::makeEmpty(); |
|
|
|
|
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function getMerkleRoot(): Hash |
44
|
|
|
{ |
45
|
|
|
return $this->get('merkleRoot') ?? Hash::makeEmpty(); |
|
|
|
|
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function getConfirmations(): Natural |
49
|
|
|
{ |
50
|
|
|
return $this->get('confirmations') ?? Natural::makeEmpty(); |
|
|
|
|
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function getTransactions(): HashList |
54
|
|
|
{ |
55
|
|
|
return $this->get('transactions') ?? HashList::makeEmpty(); |
|
|
|
|
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function getHeight(): Natural |
59
|
|
|
{ |
60
|
|
|
return $this->get('height') ?? Natural::makeEmpty(); |
|
|
|
|
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function getTimestamp(): Timestamp |
64
|
|
|
{ |
65
|
|
|
return $this->get('timestamp') ?? Timestamp::makeEmpty(); |
|
|
|
|
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|