Skip to content

Commit 3671be2

Browse files
committed
fix false negative case for MINT transactions
See the newly added unit test case for this issue. Currently there are 151 unit tests.
1 parent 2653647 commit 3671be2

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/localvalidator.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,10 @@ export class LocalValidator implements SlpValidator {
282282
}
283283
} catch (_) {}
284284
}
285-
if (this.cachedValidations[txid].parents.length !== 1) {
285+
if (this.cachedValidations[txid].parents.length < 1) {
286286
this.cachedValidations[txid].validity = false;
287287
this.cachedValidations[txid].waiting = false;
288-
this.cachedValidations[txid].invalidReason = "MINT transaction must have 1 valid baton parent.";
288+
this.cachedValidations[txid].invalidReason = "MINT transaction must have at least 1 candidate baton parent input.";
289289
return this.cachedValidations[txid].validity!;
290290
}
291291
}
@@ -342,10 +342,14 @@ export class LocalValidator implements SlpValidator {
342342
// Set validity validation-cache for parents, and handle MINT condition with no valid input
343343
// we don't need to check proper token id since we only added parents with same ID in above steps.
344344
const parentTxids = [...new Set(this.cachedValidations[txid].parents.map(p => p.txid))];
345-
for (let i = 0; i < parentTxids.length; i++) {
346-
const valid = await this.isValidSlpTxid(parentTxids[i]);
347-
this.cachedValidations[txid].parents.filter(p => p.txid === parentTxids[i]).map(p => p.valid = valid);
348-
if (this.cachedValidations[txid].details!.transactionType === SlpTransactionType.MINT && !valid) {
345+
for (const id of parentTxids) {
346+
const valid = await this.isValidSlpTxid(id);
347+
this.cachedValidations[txid].parents.filter(p => p.txid === id).map(p => p.valid = valid);
348+
}
349+
350+
// Check MINT for exactly 1 valid MINT baton
351+
if (this.cachedValidations[txid].details!.transactionType === SlpTransactionType.MINT) {
352+
if (this.cachedValidations[txid].parents.filter(p => p.valid && p.inputQty === null).length !== 1) {
349353
this.cachedValidations[txid].validity = false;
350354
this.cachedValidations[txid].waiting = false;
351355
this.cachedValidations[txid].invalidReason = "MINT transaction with invalid baton parent.";

0 commit comments

Comments
 (0)