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
+12 -7
View File
@@ -1,18 +1,21 @@
import {
WalletUTXOs,
type InputTemplateBCH,
type TransactionTemplate,
type WalletAddresses,
type WalletBlockchain,
type WalletTransactions,
} from './types.js';
import { type BlockchainUTXOs } from '../blockchain/index.js';
import { type Activities } from '../storage/index.js';
import { type Activities, type BaseStore } from '../storage/index.js';
import { EventEmitter } from '../utils/index.js';
import { type TokenBalances, type Address } from '@xocash/primitives';
export type WalletEvents = {
shouldMonitorUpdated: boolean;
addressesUpdated: WalletAddresses;
transactionsUpdated: WalletTransactions;
unspentsUpdated: BlockchainUTXOs;
stateUpdated: string | null;
@@ -30,6 +33,13 @@ export type WalletEvents = {
export abstract class BaseWallet<
WalletEventsType extends WalletEvents = WalletEvents,
> extends EventEmitter<WalletEventsType> {
static readonly deriveKey: (keyName: string) => Promise<Uint8Array>;
// Dependencies.
abstract readonly activities: Activities;
abstract readonly blockchain: WalletBlockchain;
abstract readonly cache: BaseStore;
/**
* Get the ID for this wallet.
*/
@@ -50,11 +60,6 @@ export abstract class BaseWallet<
*/
abstract getSigningKey(): Promise<Uint8Array>;
/**
* Get the activities implementation
*/
abstract getActivities(): Promise<Activities>;
/**
* Start monitoring this wallet for any transaction activity.
*/
@@ -109,7 +114,7 @@ export abstract class BaseWallet<
* May as well just getUnspentDirectives() from the local state instead of fetch.
* Likewise for balances.
*/
abstract getUnspentDirectives(): Promise<Array<InputTemplateBCH>>;
abstract getUnspentDirectives(): Promise<WalletUTXOs>;
/**
* Get the satoshi balance of this wallet.