XO wallet integration

This commit is contained in:
Jim Hamill
2025-05-05 03:19:47 +00:00
parent f9fe792542
commit e0a554e897
14 changed files with 745 additions and 213 deletions
+20 -1
View File
@@ -2,10 +2,11 @@ import { Transaction } from './transaction.js';
import { binToHex } from '@bitauth/libauth';
// TODO: The below should probably be moved and renamed.
/**
* Sort transactions by the order in which they should be broadcast.
*/
export function sortTransactions(
export function sortTransactionsByDependencies(
transactions: Array<Transaction>,
): Array<Transaction> {
const transactionMap = transactions.reduce(
@@ -139,6 +140,24 @@ export class ExtMap<T> extends Map<PropertyKey, T> {
return sorted;
}
/**
* Returns a new ExtMap containing a subset of entries from the original Map
* @param start - The starting index (inclusive)
* @param end - The ending index (exclusive)
* @returns A new ExtMap with the sliced entries
*/
slice(start: number, end?: number): ExtMap<T> {
const keys = Array.from(this.keys());
const slicedKeys = keys.slice(start, end);
const result = new ExtMap<T>();
for (const key of slicedKeys) {
result.set(key, this.get(key) as T);
}
return result;
}
/**
* Converts the collection to a plain object
*/