Merge branch 'add_transaction_is_valid' into 'development'
Add function Transaction.isValid See merge request GeneralProtocols/xo/stack!16
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user