XO wallet integration
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user