Add function Transaction.isValid

This commit is contained in:
Jim Hamill
2025-01-13 03:18:08 +00:00
parent 9e8663f398
commit e633d8ccf2
+16
View File
@@ -100,6 +100,22 @@ export class Transaction {
return new this(transaction);
}
/**
* Validates the structure of a transaction.
*
* @param transaction The transaction (as hex or bytes).
* @returns boolean indicating whether the transaction structure is valid.
*/
public static isValid(transaction: Uint8Array | string): boolean {
try {
Transaction.from(transaction);
} catch (_error) {
return false;
}
return true;
}
public toBytes(): Uint8Array {
const bytes = encodeTransaction(this.transaction);