Validate

The validateMneeTx method validates MNEE transactions to ensure they are properly formatted and authorized by the cosigner. It supports both basic validation (checking if the transaction is well-formed) and deep validation (verifying against expected outputs).

Usage

Basic Validation

const rawtx = '0100000002b170f2d41764c...'; // raw tx hex
const isValid = await mnee.validateMneeTx(rawtx);
console.log('Transaction is valid:', isValid);

Deep Validation (with expected outputs)

const rawtx = '0100000002b170f2d41764c...'; // raw tx hex
const expectedOutputs = [
  { address: 'recipient-1-address', amount: 1 },
  { address: 'recipient-2-address', amount: 10.25 },
];

const isValid = await mnee.validateMneeTx(rawtx, expectedOutputs);
console.log('Transaction matches expected outputs:', isValid);

Parameters

  • rawTxHex: The raw transaction hex string to validate

  • request (optional): An array of SendMNEE objects representing the expected transfer details

    • If provided: Validates that the transaction matches the specified outputs

    • If not provided: Only validates that the transaction is well-formed with proper cosigner authorization

Response

Returns a Promise that resolves to a boolean:

  • true: The transaction is valid

  • false: The transaction is invalid

Common Use Cases

Validate Before Broadcasting

Verify External Transactions

Validate Multi-Recipient Transactions

Integration Testing

Validation Checks

The method performs the following validations:

Basic Validation (always performed)

  • Transaction hex is valid and can be decoded

  • Transaction has proper MNEE inscription format

  • Cosigner signature is present and valid

  • Transaction structure follows MNEE protocol rules

Deep Validation (when request provided)

  • All specified recipients are present in outputs

  • Transfer amounts match exactly (in atomic units)

  • No unexpected outputs (except change and fees)

  • Total output amounts are correct

Notes

  • Validation is performed locally without network calls

  • The cosigner public key is obtained from the MNEE configuration

  • Amount comparisons are done in atomic units to avoid floating-point issues

  • Change outputs and fee outputs are automatically accounted for in deep validation

See Also

Last updated