@@ -119,7 +119,8 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
119
119
{
120
120
tx.vout [0 ].nValue -= 1000000 ;
121
121
hash = tx.GetHash ();
122
- mempool.addUnchecked (hash, entry.Time (GetTime ()).FromTx (tx));
122
+ bool spendsCoinbase = (i == 0 ) ? true : false ; // only first tx spends coinbase
123
+ mempool.addUnchecked (hash, entry.Time (GetTime ()).SpendsCoinbase (spendsCoinbase).FromTx (tx));
123
124
tx.vin [0 ].prevout .hash = hash;
124
125
}
125
126
BOOST_CHECK (pblocktemplate = CreateNewBlock (chainparams, scriptPubKey));
@@ -139,7 +140,8 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
139
140
{
140
141
tx.vout [0 ].nValue -= 10000000 ;
141
142
hash = tx.GetHash ();
142
- mempool.addUnchecked (hash, entry.Time (GetTime ()).FromTx (tx));
143
+ bool spendsCoinbase = (i == 0 ) ? true : false ; // only first tx spends coinbase
144
+ mempool.addUnchecked (hash, entry.Time (GetTime ()).SpendsCoinbase (spendsCoinbase).FromTx (tx));
143
145
tx.vin [0 ].prevout .hash = hash;
144
146
}
145
147
BOOST_CHECK (pblocktemplate = CreateNewBlock (chainparams, scriptPubKey));
@@ -158,15 +160,15 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
158
160
tx.vin [0 ].prevout .hash = txFirst[1 ]->GetHash ();
159
161
tx.vout [0 ].nValue = 4900000000LL ;
160
162
hash = tx.GetHash ();
161
- mempool.addUnchecked (hash, entry.Time (GetTime ()).FromTx (tx));
163
+ mempool.addUnchecked (hash, entry.Time (GetTime ()).SpendsCoinbase ( true ). FromTx (tx));
162
164
tx.vin [0 ].prevout .hash = hash;
163
165
tx.vin .resize (2 );
164
166
tx.vin [1 ].scriptSig = CScript () << OP_1;
165
167
tx.vin [1 ].prevout .hash = txFirst[0 ]->GetHash ();
166
168
tx.vin [1 ].prevout .n = 0 ;
167
169
tx.vout [0 ].nValue = 5900000000LL ;
168
170
hash = tx.GetHash ();
169
- mempool.addUnchecked (hash, entry.Time (GetTime ()).FromTx (tx));
171
+ mempool.addUnchecked (hash, entry.Time (GetTime ()).SpendsCoinbase ( true ). FromTx (tx));
170
172
BOOST_CHECK (pblocktemplate = CreateNewBlock (chainparams, scriptPubKey));
171
173
delete pblocktemplate;
172
174
mempool.clear ();
@@ -177,7 +179,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
177
179
tx.vin [0 ].scriptSig = CScript () << OP_0 << OP_1;
178
180
tx.vout [0 ].nValue = 0 ;
179
181
hash = tx.GetHash ();
180
- mempool.addUnchecked (hash, entry.Time (GetTime ()).FromTx (tx));
182
+ mempool.addUnchecked (hash, entry.Time (GetTime ()).SpendsCoinbase ( false ). FromTx (tx));
181
183
BOOST_CHECK (pblocktemplate = CreateNewBlock (chainparams, scriptPubKey));
182
184
delete pblocktemplate;
183
185
mempool.clear ();
@@ -190,12 +192,12 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
190
192
script = CScript () << OP_0;
191
193
tx.vout [0 ].scriptPubKey = GetScriptForDestination (CScriptID (script));
192
194
hash = tx.GetHash ();
193
- mempool.addUnchecked (hash, entry.Time (GetTime ()).FromTx (tx));
195
+ mempool.addUnchecked (hash, entry.Time (GetTime ()).SpendsCoinbase ( true ). FromTx (tx));
194
196
tx.vin [0 ].prevout .hash = hash;
195
197
tx.vin [0 ].scriptSig = CScript () << (std::vector<unsigned char >)script;
196
198
tx.vout [0 ].nValue -= 1000000 ;
197
199
hash = tx.GetHash ();
198
- mempool.addUnchecked (hash, entry.Time (GetTime ()).FromTx (tx));
200
+ mempool.addUnchecked (hash, entry.Time (GetTime ()).SpendsCoinbase ( false ). FromTx (tx));
199
201
BOOST_CHECK (pblocktemplate = CreateNewBlock (chainparams, scriptPubKey));
200
202
delete pblocktemplate;
201
203
mempool.clear ();
@@ -206,10 +208,10 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
206
208
tx.vout [0 ].nValue = 4900000000LL ;
207
209
tx.vout [0 ].scriptPubKey = CScript () << OP_1;
208
210
hash = tx.GetHash ();
209
- mempool.addUnchecked (hash, entry.Time (GetTime ()).FromTx (tx));
211
+ mempool.addUnchecked (hash, entry.Time (GetTime ()).SpendsCoinbase ( true ). FromTx (tx));
210
212
tx.vout [0 ].scriptPubKey = CScript () << OP_2;
211
213
hash = tx.GetHash ();
212
- mempool.addUnchecked (hash, entry.Time (GetTime ()).FromTx (tx));
214
+ mempool.addUnchecked (hash, entry.Time (GetTime ()).SpendsCoinbase ( true ). FromTx (tx));
213
215
BOOST_CHECK (pblocktemplate = CreateNewBlock (chainparams, scriptPubKey));
214
216
delete pblocktemplate;
215
217
mempool.clear ();
@@ -235,7 +237,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
235
237
tx.vout [0 ].scriptPubKey = CScript () << OP_1;
236
238
tx.nLockTime = chainActive.Tip ()->nHeight +1 ;
237
239
hash = tx.GetHash ();
238
- mempool.addUnchecked (hash, entry.Time (GetTime ()).FromTx (tx));
240
+ mempool.addUnchecked (hash, entry.Time (GetTime ()).SpendsCoinbase ( true ). FromTx (tx));
239
241
BOOST_CHECK (!CheckFinalTx (tx, LOCKTIME_MEDIAN_TIME_PAST));
240
242
241
243
// time locked
@@ -249,7 +251,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
249
251
tx2.vout [0 ].scriptPubKey = CScript () << OP_1;
250
252
tx2.nLockTime = chainActive.Tip ()->GetMedianTimePast ()+1 ;
251
253
hash = tx2.GetHash ();
252
- mempool.addUnchecked (hash, entry.Time (GetTime ()).FromTx (tx2));
254
+ mempool.addUnchecked (hash, entry.Time (GetTime ()).SpendsCoinbase ( true ). FromTx (tx2));
253
255
BOOST_CHECK (!CheckFinalTx (tx2, LOCKTIME_MEDIAN_TIME_PAST));
254
256
255
257
BOOST_CHECK (pblocktemplate = CreateNewBlock (chainparams, scriptPubKey));
0 commit comments