Skip to content

Commit cde95c0

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 4ca5ea8 commit cde95c0

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/validation.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,10 @@ export class ValidatorType1 {
408408
}
409409
} catch (_) { }
410410
}
411-
if (validation.parents.length !== 1) {
411+
if (validation.parents.length < 1) {
412412
validation.validity = false;
413413
validation.waiting = false;
414-
validation.invalidReason = "MINT transaction must have 1 valid baton parent.";
414+
validation.invalidReason = "MINT transaction must have at least 1 candidate baton parent input.";
415415
return validation.validity!;
416416
}
417417
} else if (slpmsg.transactionType === SlpTransactionType.SEND) {
@@ -468,10 +468,14 @@ export class ValidatorType1 {
468468
// Set validity validation-cache for parents, and handle MINT condition with no valid input
469469
// we don't need to check proper token id since we only added parents with same ID in above steps.
470470
const parentTxids = [...new Set(validation.parents.map(p => p.txid))];
471-
for (let i = 0; i < parentTxids.length; i++) {
472-
const valid = await this.isValidSlpTxid({ txid: parentTxids[i] });
473-
validation.parents.filter(p => p.txid === parentTxids[i]).map(p => p.valid = valid);
474-
if (validation.details!.transactionType === SlpTransactionType.MINT && !valid) {
471+
for (const id of parentTxids) {
472+
const valid = await this.isValidSlpTxid({ txid: id });
473+
validation.parents.filter(p => p.txid === id).map(p => p.valid = valid);
474+
}
475+
476+
// Check MINT for exactly 1 valid MINT baton
477+
if (validation.details!.transactionType === SlpTransactionType.MINT) {
478+
if (validation.parents.filter(p => p.valid && p.inputQty === null).length !== 1) {
475479
validation.validity = false;
476480
validation.waiting = false;
477481
validation.invalidReason = "MINT transaction with invalid baton parent.";

0 commit comments

Comments
 (0)