1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/** |
3
|
|
|
* This file is part of the ngutech/lightning-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\Lightning\Entity; |
10
|
|
|
|
11
|
|
|
use Daikon\Entity\Attribute; |
12
|
|
|
use Daikon\Entity\AttributeMap; |
13
|
|
|
use Daikon\Entity\Entity; |
14
|
|
|
use Daikon\Money\Entity\TransactionInterface; |
15
|
|
|
use Daikon\ValueObject\FloatValue; |
16
|
|
|
use Daikon\ValueObject\Text; |
17
|
|
|
use Daikon\ValueObject\Timestamp; |
|
|
|
|
18
|
|
|
use NGUtech\Bitcoin\ValueObject\Hash; |
19
|
|
|
use NGUtech\Bitcoin\ValueObject\Bitcoin; |
20
|
|
|
use NGUtech\Lightning\ValueObject\PaymentState; |
21
|
|
|
use NGUtech\Lightning\ValueObject\Request; |
22
|
|
|
|
23
|
|
|
final class LightningPayment extends Entity implements TransactionInterface |
24
|
|
|
{ |
25
|
|
|
public static function getAttributeMap(): AttributeMap |
26
|
|
|
{ |
27
|
|
|
return new AttributeMap([ |
28
|
|
|
Attribute::define('preimage', Hash::class), |
29
|
|
|
Attribute::define('preimageHash', Hash::class), |
30
|
|
|
Attribute::define('request', Request::class), |
31
|
|
|
Attribute::define('destination', Text::class), |
32
|
|
|
Attribute::define('amount', Bitcoin::class), |
33
|
|
|
Attribute::define('feeLimit', FloatValue::class), |
34
|
|
|
Attribute::define('feeEstimate', Bitcoin::class), |
35
|
|
|
Attribute::define('feeSettled', Bitcoin::class), |
36
|
|
|
Attribute::define('label', Text::class), |
37
|
|
|
Attribute::define('description', Text::class), |
38
|
|
|
Attribute::define('state', PaymentState::class), |
39
|
|
|
Attribute::define('createdAt', Timestamp::class), |
40
|
|
|
]); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function getIdentity(): Hash |
44
|
|
|
{ |
45
|
|
|
return $this->getPreimageHash(); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function getPreimage(): Hash |
49
|
|
|
{ |
50
|
|
|
return $this->get('preimage') ?? Hash::makeEmpty(); |
|
|
|
|
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function getPreimageHash(): Hash |
54
|
|
|
{ |
55
|
|
|
return $this->get('preimageHash') ?? Hash::makeEmpty(); |
|
|
|
|
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function getRequest(): Request |
59
|
|
|
{ |
60
|
|
|
return $this->get('request') ?? Request::makeEmpty(); |
|
|
|
|
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function getDestination(): Text |
64
|
|
|
{ |
65
|
|
|
return $this->get('destination') ?? Text::makeEmpty(); |
|
|
|
|
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function getAmount(): Bitcoin |
69
|
|
|
{ |
70
|
|
|
return $this->get('amount') ?? Bitcoin::makeEmpty(); |
|
|
|
|
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function getFeeLimit(): FloatValue |
74
|
|
|
{ |
75
|
|
|
return $this->get('feeLimit') ?? FloatValue::zero(); |
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function getFeeEstimate(): Bitcoin |
79
|
|
|
{ |
80
|
|
|
return $this->get('feeEstimate') ?? Bitcoin::makeEmpty(); |
|
|
|
|
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function getFeeSettled(): Bitcoin |
84
|
|
|
{ |
85
|
|
|
return $this->get('feeSettled') ?? Bitcoin::makeEmpty(); |
|
|
|
|
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function getFeeRefund(): Bitcoin |
89
|
|
|
{ |
90
|
|
|
return $this->getFeeEstimate()->subtract($this->getFeeSettled()); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function getLabel(): Text |
94
|
|
|
{ |
95
|
|
|
return $this->get('label') ?? Text::makeEmpty(); |
|
|
|
|
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
public function getDescription(): Text |
99
|
|
|
{ |
100
|
|
|
return $this->get('description') ?? Text::makeEmpty(); |
|
|
|
|
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function getState(): PaymentState |
104
|
|
|
{ |
105
|
|
|
return $this->get('state') ?? PaymentState::makeEmpty(); |
|
|
|
|
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
public function getCreatedAt(): Timestamp |
109
|
|
|
{ |
110
|
|
|
return $this->get('createdAt') ?? Timestamp::makeEmpty(); |
|
|
|
|
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths