@@ -35,31 +35,27 @@ var UtxoValidationRules = []common.UtxoValidationRuleFunc{
35
35
}
36
36
37
37
// UtxoValidateTimeToLive ensures that the current tip slot is not after the specified TTL value
38
- func UtxoValidateTimeToLive (tx common.Transaction , ls common.LedgerState , ts common.TipState , pp common.ProtocolParameters ) error {
39
- tip , err := ts .Tip ()
40
- if err != nil {
41
- return err
42
- }
38
+ func UtxoValidateTimeToLive (tx common.Transaction , slot uint64 , ls common.LedgerState , pp common.ProtocolParameters ) error {
43
39
ttl := tx .TTL ()
44
- if ttl == 0 || ttl >= tip . Point . Slot {
40
+ if ttl == 0 || ttl >= slot {
45
41
return nil
46
42
}
47
43
return ExpiredUtxoError {
48
44
Ttl : ttl ,
49
- Slot : tip . Point . Slot ,
45
+ Slot : slot ,
50
46
}
51
47
}
52
48
53
49
// UtxoValidateInputSetEmptyUtxo ensures that the input set is not empty
54
- func UtxoValidateInputSetEmptyUtxo (tx common.Transaction , ls common. LedgerState , ts common.TipState , pp common.ProtocolParameters ) error {
50
+ func UtxoValidateInputSetEmptyUtxo (tx common.Transaction , slot uint64 , ls common.LedgerState , pp common.ProtocolParameters ) error {
55
51
if len (tx .Inputs ()) > 0 {
56
52
return nil
57
53
}
58
54
return InputSetEmptyUtxoError {}
59
55
}
60
56
61
57
// UtxoValidateFeeTooSmallUtxo ensures that the fee is at least the calculated minimum
62
- func UtxoValidateFeeTooSmallUtxo (tx common.Transaction , ls common. LedgerState , ts common.TipState , pp common.ProtocolParameters ) error {
58
+ func UtxoValidateFeeTooSmallUtxo (tx common.Transaction , slot uint64 , ls common.LedgerState , pp common.ProtocolParameters ) error {
63
59
minFee , err := MinFeeTx (tx , pp )
64
60
if err != nil {
65
61
return err
@@ -74,7 +70,7 @@ func UtxoValidateFeeTooSmallUtxo(tx common.Transaction, ls common.LedgerState, t
74
70
}
75
71
76
72
// UtxoValidateBadInputsUtxo ensures that all inputs are present in the ledger state (have not been spent)
77
- func UtxoValidateBadInputsUtxo (tx common.Transaction , ls common. LedgerState , ts common.TipState , pp common.ProtocolParameters ) error {
73
+ func UtxoValidateBadInputsUtxo (tx common.Transaction , slot uint64 , ls common.LedgerState , pp common.ProtocolParameters ) error {
78
74
var badInputs []common.TransactionInput
79
75
for _ , tmpInput := range tx .Inputs () {
80
76
_ , err := ls .UtxoById (tmpInput )
@@ -91,7 +87,7 @@ func UtxoValidateBadInputsUtxo(tx common.Transaction, ls common.LedgerState, ts
91
87
}
92
88
93
89
// UtxoValidateWrongNetwork ensures that all output addresses use the correct network ID
94
- func UtxoValidateWrongNetwork (tx common.Transaction , ls common. LedgerState , ts common.TipState , pp common.ProtocolParameters ) error {
90
+ func UtxoValidateWrongNetwork (tx common.Transaction , slot uint64 , ls common.LedgerState , pp common.ProtocolParameters ) error {
95
91
networkId := ls .NetworkId ()
96
92
var badAddrs []common.Address
97
93
for _ , tmpOutput := range tx .Outputs () {
@@ -111,7 +107,7 @@ func UtxoValidateWrongNetwork(tx common.Transaction, ls common.LedgerState, ts c
111
107
}
112
108
113
109
// UtxoValidateWrongNetworkWithdrawal ensures that all withdrawal addresses use the correct network ID
114
- func UtxoValidateWrongNetworkWithdrawal (tx common.Transaction , ls common. LedgerState , ts common.TipState , pp common.ProtocolParameters ) error {
110
+ func UtxoValidateWrongNetworkWithdrawal (tx common.Transaction , slot uint64 , ls common.LedgerState , pp common.ProtocolParameters ) error {
115
111
networkId := ls .NetworkId ()
116
112
var badAddrs []common.Address
117
113
for addr := range tx .Withdrawals () {
@@ -130,7 +126,7 @@ func UtxoValidateWrongNetworkWithdrawal(tx common.Transaction, ls common.LedgerS
130
126
}
131
127
132
128
// UtxoValidateValueNotConservedUtxo ensures that the consumed value equals the produced value
133
- func UtxoValidateValueNotConservedUtxo (tx common.Transaction , ls common. LedgerState , ts common.TipState , pp common.ProtocolParameters ) error {
129
+ func UtxoValidateValueNotConservedUtxo (tx common.Transaction , slot uint64 , ls common.LedgerState , pp common.ProtocolParameters ) error {
134
130
// Calculate consumed value
135
131
// consumed = value from input(s) + withdrawals + refunds(?)
136
132
var consumedValue uint64
@@ -162,7 +158,7 @@ func UtxoValidateValueNotConservedUtxo(tx common.Transaction, ls common.LedgerSt
162
158
}
163
159
164
160
// UtxoValidateOutputTooSmallUtxo ensures that outputs have at least the minimum value
165
- func UtxoValidateOutputTooSmallUtxo (tx common.Transaction , ls common. LedgerState , ts common.TipState , pp common.ProtocolParameters ) error {
161
+ func UtxoValidateOutputTooSmallUtxo (tx common.Transaction , slot uint64 , ls common.LedgerState , pp common.ProtocolParameters ) error {
166
162
minCoin , err := MinCoinTxOut (tx , pp )
167
163
if err != nil {
168
164
return err
@@ -182,7 +178,7 @@ func UtxoValidateOutputTooSmallUtxo(tx common.Transaction, ls common.LedgerState
182
178
}
183
179
184
180
// UtxoValidateOutputBootAddrAttrsTooBig ensures that bootstrap (Byron) addresses don't have attributes that are too large
185
- func UtxoValidateOutputBootAddrAttrsTooBig (tx common.Transaction , ls common. LedgerState , ts common.TipState , pp common.ProtocolParameters ) error {
181
+ func UtxoValidateOutputBootAddrAttrsTooBig (tx common.Transaction , slot uint64 , ls common.LedgerState , pp common.ProtocolParameters ) error {
186
182
var badOutputs []common.TransactionOutput
187
183
for _ , tmpOutput := range tx .Outputs () {
188
184
addr := tmpOutput .Address ()
@@ -208,7 +204,7 @@ func UtxoValidateOutputBootAddrAttrsTooBig(tx common.Transaction, ls common.Ledg
208
204
}
209
205
210
206
// UtxoValidateMaxTxSizeUtxo ensures that a transaction does not exceed the max size
211
- func UtxoValidateMaxTxSizeUtxo (tx common.Transaction , ls common. LedgerState , ts common.TipState , pp common.ProtocolParameters ) error {
207
+ func UtxoValidateMaxTxSizeUtxo (tx common.Transaction , slot uint64 , ls common.LedgerState , pp common.ProtocolParameters ) error {
212
208
tmpTx , ok := tx .(* ShelleyTransaction )
213
209
if ! ok {
214
210
return fmt .Errorf ("transaction is not expected type" )
0 commit comments