openclaw-overlay-plugin 0.7.34 → 0.7.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +13 -2
  3. package/dist/src/scripts/config.d.ts +1 -1
  4. package/dist/src/scripts/config.js +1 -1
  5. package/index.ts +15 -2
  6. package/openclaw.plugin.json +2 -1
  7. package/package.json +1 -1
  8. package/src/scripts/config.ts +1 -1
  9. package/dist/cli-main.d.ts +0 -7
  10. package/dist/cli-main.js +0 -192
  11. package/dist/cli.d.ts +0 -8
  12. package/dist/cli.js +0 -14
  13. package/dist/core/config.d.ts +0 -11
  14. package/dist/core/config.js +0 -13
  15. package/dist/core/index.d.ts +0 -25
  16. package/dist/core/index.js +0 -26
  17. package/dist/core/payment.d.ts +0 -16
  18. package/dist/core/payment.js +0 -94
  19. package/dist/core/types.d.ts +0 -94
  20. package/dist/core/types.js +0 -4
  21. package/dist/core/verify.d.ts +0 -28
  22. package/dist/core/verify.js +0 -104
  23. package/dist/core/wallet.d.ts +0 -99
  24. package/dist/core/wallet.js +0 -219
  25. package/dist/scripts/baemail/commands.d.ts +0 -64
  26. package/dist/scripts/baemail/commands.js +0 -259
  27. package/dist/scripts/baemail/handler.d.ts +0 -36
  28. package/dist/scripts/baemail/handler.js +0 -284
  29. package/dist/scripts/baemail/index.d.ts +0 -5
  30. package/dist/scripts/baemail/index.js +0 -5
  31. package/dist/scripts/config.d.ts +0 -48
  32. package/dist/scripts/config.js +0 -68
  33. package/dist/scripts/index.d.ts +0 -7
  34. package/dist/scripts/index.js +0 -7
  35. package/dist/scripts/messaging/connect.d.ts +0 -8
  36. package/dist/scripts/messaging/connect.js +0 -114
  37. package/dist/scripts/messaging/handlers.d.ts +0 -21
  38. package/dist/scripts/messaging/handlers.js +0 -334
  39. package/dist/scripts/messaging/inbox.d.ts +0 -11
  40. package/dist/scripts/messaging/inbox.js +0 -51
  41. package/dist/scripts/messaging/index.d.ts +0 -8
  42. package/dist/scripts/messaging/index.js +0 -8
  43. package/dist/scripts/messaging/poll.d.ts +0 -7
  44. package/dist/scripts/messaging/poll.js +0 -52
  45. package/dist/scripts/messaging/send.d.ts +0 -7
  46. package/dist/scripts/messaging/send.js +0 -43
  47. package/dist/scripts/output.d.ts +0 -12
  48. package/dist/scripts/output.js +0 -19
  49. package/dist/scripts/overlay/discover.d.ts +0 -7
  50. package/dist/scripts/overlay/discover.js +0 -72
  51. package/dist/scripts/overlay/index.d.ts +0 -7
  52. package/dist/scripts/overlay/index.js +0 -7
  53. package/dist/scripts/overlay/registration.d.ts +0 -19
  54. package/dist/scripts/overlay/registration.js +0 -176
  55. package/dist/scripts/overlay/services.d.ts +0 -29
  56. package/dist/scripts/overlay/services.js +0 -167
  57. package/dist/scripts/overlay/transaction.d.ts +0 -42
  58. package/dist/scripts/overlay/transaction.js +0 -103
  59. package/dist/scripts/payment/build.d.ts +0 -24
  60. package/dist/scripts/payment/build.js +0 -54
  61. package/dist/scripts/payment/commands.d.ts +0 -15
  62. package/dist/scripts/payment/commands.js +0 -73
  63. package/dist/scripts/payment/index.d.ts +0 -6
  64. package/dist/scripts/payment/index.js +0 -6
  65. package/dist/scripts/payment/types.d.ts +0 -56
  66. package/dist/scripts/payment/types.js +0 -4
  67. package/dist/scripts/services/index.d.ts +0 -6
  68. package/dist/scripts/services/index.js +0 -6
  69. package/dist/scripts/services/queue.d.ts +0 -11
  70. package/dist/scripts/services/queue.js +0 -28
  71. package/dist/scripts/services/request.d.ts +0 -7
  72. package/dist/scripts/services/request.js +0 -82
  73. package/dist/scripts/services/respond.d.ts +0 -11
  74. package/dist/scripts/services/respond.js +0 -132
  75. package/dist/scripts/types.d.ts +0 -107
  76. package/dist/scripts/types.js +0 -4
  77. package/dist/scripts/utils/index.d.ts +0 -6
  78. package/dist/scripts/utils/index.js +0 -6
  79. package/dist/scripts/utils/merkle.d.ts +0 -12
  80. package/dist/scripts/utils/merkle.js +0 -47
  81. package/dist/scripts/utils/storage.d.ts +0 -66
  82. package/dist/scripts/utils/storage.js +0 -211
  83. package/dist/scripts/utils/woc.d.ts +0 -26
  84. package/dist/scripts/utils/woc.js +0 -91
  85. package/dist/scripts/wallet/balance.d.ts +0 -22
  86. package/dist/scripts/wallet/balance.js +0 -240
  87. package/dist/scripts/wallet/identity.d.ts +0 -70
  88. package/dist/scripts/wallet/identity.js +0 -151
  89. package/dist/scripts/wallet/index.d.ts +0 -6
  90. package/dist/scripts/wallet/index.js +0 -6
  91. package/dist/scripts/wallet/setup.d.ts +0 -15
  92. package/dist/scripts/wallet/setup.js +0 -105
  93. package/dist/scripts/x-verification/commands.d.ts +0 -27
  94. package/dist/scripts/x-verification/commands.js +0 -222
  95. package/dist/scripts/x-verification/index.d.ts +0 -4
  96. package/dist/scripts/x-verification/index.js +0 -4
  97. package/dist/services/built-in/api-proxy/index.d.ts +0 -6
  98. package/dist/services/built-in/api-proxy/index.js +0 -23
  99. package/dist/services/built-in/code-develop/index.d.ts +0 -6
  100. package/dist/services/built-in/code-develop/index.js +0 -23
  101. package/dist/services/built-in/code-review/index.d.ts +0 -10
  102. package/dist/services/built-in/code-review/index.js +0 -51
  103. package/dist/services/built-in/image-analysis/index.d.ts +0 -6
  104. package/dist/services/built-in/image-analysis/index.js +0 -33
  105. package/dist/services/built-in/memory-store/index.d.ts +0 -6
  106. package/dist/services/built-in/memory-store/index.js +0 -22
  107. package/dist/services/built-in/roulette/index.d.ts +0 -6
  108. package/dist/services/built-in/roulette/index.js +0 -27
  109. package/dist/services/built-in/summarize/index.d.ts +0 -6
  110. package/dist/services/built-in/summarize/index.js +0 -21
  111. package/dist/services/built-in/tell-joke/handler.d.ts +0 -7
  112. package/dist/services/built-in/tell-joke/handler.js +0 -122
  113. package/dist/services/built-in/tell-joke/index.d.ts +0 -9
  114. package/dist/services/built-in/tell-joke/index.js +0 -31
  115. package/dist/services/built-in/translate/index.d.ts +0 -6
  116. package/dist/services/built-in/translate/index.js +0 -21
  117. package/dist/services/built-in/web-research/index.d.ts +0 -9
  118. package/dist/services/built-in/web-research/index.js +0 -51
  119. package/dist/services/index.d.ts +0 -13
  120. package/dist/services/index.js +0 -14
  121. package/dist/services/loader.d.ts +0 -77
  122. package/dist/services/loader.js +0 -292
  123. package/dist/services/manager.d.ts +0 -86
  124. package/dist/services/manager.js +0 -255
  125. package/dist/services/registry.d.ts +0 -98
  126. package/dist/services/registry.js +0 -204
  127. package/dist/services/types.d.ts +0 -230
  128. package/dist/services/types.js +0 -30
  129. package/dist/test/cli.test.d.ts +0 -7
  130. package/dist/test/cli.test.js +0 -329
  131. package/dist/test/comprehensive-overlay.test.d.ts +0 -13
  132. package/dist/test/comprehensive-overlay.test.js +0 -593
  133. package/dist/test/key-derivation.test.d.ts +0 -12
  134. package/dist/test/key-derivation.test.js +0 -86
  135. package/dist/test/overlay-submit.test.d.ts +0 -10
  136. package/dist/test/overlay-submit.test.js +0 -460
  137. package/dist/test/request-response-flow.test.d.ts +0 -5
  138. package/dist/test/request-response-flow.test.js +0 -209
  139. package/dist/test/service-system.test.d.ts +0 -5
  140. package/dist/test/service-system.test.js +0 -190
  141. package/dist/test/utils/server-logic.d.ts +0 -98
  142. package/dist/test/utils/server-logic.js +0 -286
  143. package/dist/test/wallet.test.d.ts +0 -7
  144. package/dist/test/wallet.test.js +0 -146
@@ -1,28 +0,0 @@
1
- /**
2
- * @a2a-bsv/core — Payment verification and acceptance helpers.
3
- *
4
- * Verification: parse the Atomic BEEF, validate structure.
5
- * Acceptance: internalize the payment into the recipient wallet via BRC-29
6
- * wallet payment protocol.
7
- */
8
- import type { SetupWallet } from '@bsv/wallet-toolbox';
9
- import type { VerifyParams, VerifyResult, AcceptParams, AcceptResult } from './types.js';
10
- /**
11
- * Verify an incoming Atomic BEEF payment.
12
- *
13
- * This performs structural validation:
14
- * - Decodes the base64 BEEF
15
- * - Checks the BEEF is parseable
16
- * - Checks there is at least one transaction
17
- * - Runs SPV verification via tx.verify()
18
- * - Optionally checks the sender identity key
19
- */
20
- export declare function verifyPayment(params: VerifyParams): Promise<VerifyResult>;
21
- /**
22
- * Accept (internalize) a verified BRC-29 payment into the recipient's wallet.
23
- *
24
- * This calls wallet.internalizeAction with the 'wallet payment' protocol,
25
- * providing the BRC-29 derivation info so the wallet can derive the correct
26
- * key and claim the output.
27
- */
28
- export declare function acceptPayment(setup: SetupWallet, params: AcceptParams): Promise<AcceptResult>;
@@ -1,104 +0,0 @@
1
- /**
2
- * @a2a-bsv/core — Payment verification and acceptance helpers.
3
- *
4
- * Verification: parse the Atomic BEEF, validate structure.
5
- * Acceptance: internalize the payment into the recipient wallet via BRC-29
6
- * wallet payment protocol.
7
- */
8
- import { Beef, Utils } from '@bsv/sdk';
9
- /**
10
- * Verify an incoming Atomic BEEF payment.
11
- *
12
- * This performs structural validation:
13
- * - Decodes the base64 BEEF
14
- * - Checks the BEEF is parseable
15
- * - Checks there is at least one transaction
16
- * - Runs SPV verification via tx.verify()
17
- * - Optionally checks the sender identity key
18
- */
19
- export async function verifyPayment(params) {
20
- const errors = [];
21
- let txid = '';
22
- let outputCount = 0;
23
- try {
24
- const binary = Utils.toArray(params.beef, 'base64');
25
- const beef = Beef.fromBinary(binary);
26
- if (beef.txs.length === 0) {
27
- errors.push('BEEF contains no transactions');
28
- }
29
- else {
30
- const lastTx = beef.txs[beef.txs.length - 1];
31
- txid = lastTx.txid;
32
- // Parse the atomic transaction to count outputs
33
- const tx = beef.findAtomicTransaction(txid);
34
- if (tx) {
35
- outputCount = tx.outputs.length;
36
- // Run SPV verification
37
- try {
38
- await tx.verify();
39
- }
40
- catch (err) {
41
- const message = err instanceof Error ? err.message : String(err);
42
- errors.push(`SPV verification failed: ${message}`);
43
- }
44
- }
45
- else {
46
- errors.push('Could not find atomic transaction in BEEF');
47
- }
48
- }
49
- }
50
- catch (err) {
51
- const message = err instanceof Error ? err.message : String(err);
52
- errors.push(`BEEF parse error: ${message}`);
53
- }
54
- // Sender validation is independent of BEEF parsing
55
- if (params.expectedSender) {
56
- if (!/^0[23][0-9a-fA-F]{64}$/.test(params.expectedSender)) {
57
- errors.push('expectedSender is not a valid compressed public key');
58
- }
59
- }
60
- return {
61
- valid: errors.length === 0,
62
- txid,
63
- outputCount,
64
- errors,
65
- };
66
- }
67
- /**
68
- * Accept (internalize) a verified BRC-29 payment into the recipient's wallet.
69
- *
70
- * This calls wallet.internalizeAction with the 'wallet payment' protocol,
71
- * providing the BRC-29 derivation info so the wallet can derive the correct
72
- * key and claim the output.
73
- */
74
- export async function acceptPayment(setup, params) {
75
- const desc = normalizeDescription(params.description ?? 'received payment');
76
- const vout = params.vout ?? 0;
77
- const binary = Utils.toArray(params.beef, 'base64');
78
- const args = {
79
- tx: binary,
80
- outputs: [
81
- {
82
- outputIndex: vout,
83
- protocol: 'wallet payment',
84
- paymentRemittance: {
85
- derivationPrefix: params.derivationPrefix,
86
- derivationSuffix: params.derivationSuffix,
87
- senderIdentityKey: params.senderIdentityKey,
88
- },
89
- },
90
- ],
91
- description: desc,
92
- };
93
- const result = await setup.wallet.internalizeAction(args);
94
- return {
95
- accepted: result.accepted,
96
- };
97
- }
98
- function normalizeDescription(desc) {
99
- if (desc.length < 5)
100
- return desc.padEnd(5, ' ');
101
- if (desc.length > 50)
102
- return desc.slice(0, 50);
103
- return desc;
104
- }
@@ -1,99 +0,0 @@
1
- /**
2
- * @a2a-bsv/core — BSVAgentWallet
3
- *
4
- * High-level wallet class for AI agent-to-agent BSV payments.
5
- * Wraps @bsv/wallet-toolbox's Wallet + StorageKnex with a clean,
6
- * minimal API surface designed for automated agent use.
7
- */
8
- import type { SetupWallet } from '@bsv/wallet-toolbox';
9
- import type { WalletConfig, PaymentParams, PaymentResult, VerifyParams, VerifyResult, AcceptParams, AcceptResult } from './types.js';
10
- /**
11
- * BSVAgentWallet — the primary class for agent-to-agent BSV payments.
12
- *
13
- * Usage:
14
- * ```ts
15
- * // Create a new wallet (generates keys)
16
- * const wallet = await BSVAgentWallet.load({ network: 'testnet', storageDir: './agent-wallet' });
17
- *
18
- * // Load an existing wallet
19
- * const wallet = await BSVAgentWallet.load({ network: 'testnet', storageDir: './agent-wallet' });
20
- *
21
- * // Make a payment
22
- * const payment = await wallet.createPayment({ to: recipientPubKey, satoshis: 500 });
23
- *
24
- * // Verify and accept a payment
25
- * const verification = wallet.verifyPayment({ beef: payment.beef });
26
- * if (verification.valid) {
27
- * await wallet.acceptPayment({ beef: payment.beef, ...derivationInfo });
28
- * }
29
- * ```
30
- */
31
- export declare class BSVAgentWallet {
32
- /** @internal — exposed for advanced operations (e.g. direct internalizeAction) */
33
- readonly _setup: SetupWallet;
34
- private constructor();
35
- /**
36
- * Create a new agent wallet. Generates a fresh root key and persists it.
37
- * The SQLite database and identity file are written to `config.storageDir`.
38
- */
39
- private static create;
40
- /**
41
- * Load an existing agent wallet from its storage directory.
42
- * Reads the persisted identity file and re-initializes the wallet.
43
- */
44
- static load(config: WalletConfig): Promise<BSVAgentWallet>;
45
- /**
46
- * Get this wallet's public identity key (compressed hex, 33 bytes).
47
- * This is the key other agents use to send payments to you.
48
- */
49
- getIdentityKey(): Promise<string>;
50
- /**
51
- * Get the wallet's current balance in satoshis.
52
- *
53
- * Uses the BRC-100 wallet's balance method which sums spendable outputs
54
- * in the default basket.
55
- */
56
- getBalance(): Promise<number>;
57
- /**
58
- * Cleanly shut down the wallet, releasing database connections and
59
- * stopping the background monitor.
60
- */
61
- destroy(): Promise<void>;
62
- /**
63
- * Build a BRC-29 payment to another agent.
64
- *
65
- * The transaction is created with `noSend: true` — the sender does NOT
66
- * broadcast it. Instead, the Atomic BEEF and derivation metadata are
67
- * returned so they can be transmitted to the recipient, who will
68
- * verify and internalize (broadcast) the payment.
69
- *
70
- * @param params.to — Recipient's compressed public key (hex).
71
- * @param params.satoshis — Amount in satoshis.
72
- * @param params.description — Optional human-readable note.
73
- */
74
- createPayment(params: PaymentParams): Promise<PaymentResult>;
75
- /**
76
- * Verify an incoming Atomic BEEF payment.
77
- *
78
- * This performs structural validation and SPV verification via tx.verify().
79
- */
80
- verifyPayment(params: VerifyParams): Promise<VerifyResult>;
81
- /**
82
- * Accept (internalize) a verified payment into this wallet.
83
- *
84
- * Uses the BRC-29 wallet payment protocol to derive the correct key
85
- * and claim the output. This triggers SPV verification and, if the
86
- * transaction hasn't been broadcast yet, broadcasts it.
87
- */
88
- acceptPayment(params: AcceptParams): Promise<AcceptResult>;
89
- /** Get the underlying wallet-toolbox SetupWallet for advanced operations. */
90
- getSetup(): SetupWallet;
91
- /**
92
- * Internal: manually construct a BRC-100 wallet backed by SQLite.
93
- *
94
- * We build this by hand instead of using Setup.createWalletSQLite because
95
- * the toolbox has a bug where its internal randomBytesHex is a stub.
96
- * We use the same components but wire them up correctly.
97
- */
98
- private static buildSetup;
99
- }
@@ -1,219 +0,0 @@
1
- /**
2
- * @a2a-bsv/core — BSVAgentWallet
3
- *
4
- * High-level wallet class for AI agent-to-agent BSV payments.
5
- * Wraps @bsv/wallet-toolbox's Wallet + StorageKnex with a clean,
6
- * minimal API surface designed for automated agent use.
7
- */
8
- import { PrivateKey, CachedKeyDeriver } from '@bsv/sdk';
9
- import { Wallet, WalletStorageManager, Services, Monitor, StorageKnex, randomBytesHex, ChaintracksServiceClient, } from '@bsv/wallet-toolbox';
10
- import knexLib from 'knex';
11
- import * as path from 'node:path';
12
- import * as fs from 'node:fs';
13
- import { toChain, DEFAULT_TAAL_API_KEYS, DEFAULT_DB_NAME } from './config.js';
14
- import { buildPayment } from './payment.js';
15
- import { verifyPayment, acceptPayment } from './verify.js';
16
- /** Filename for the persisted wallet identity JSON. */
17
- const IDENTITY_FILE = 'wallet-identity.json';
18
- /**
19
- * BSVAgentWallet — the primary class for agent-to-agent BSV payments.
20
- *
21
- * Usage:
22
- * ```ts
23
- * // Create a new wallet (generates keys)
24
- * const wallet = await BSVAgentWallet.load({ network: 'testnet', storageDir: './agent-wallet' });
25
- *
26
- * // Load an existing wallet
27
- * const wallet = await BSVAgentWallet.load({ network: 'testnet', storageDir: './agent-wallet' });
28
- *
29
- * // Make a payment
30
- * const payment = await wallet.createPayment({ to: recipientPubKey, satoshis: 500 });
31
- *
32
- * // Verify and accept a payment
33
- * const verification = wallet.verifyPayment({ beef: payment.beef });
34
- * if (verification.valid) {
35
- * await wallet.acceptPayment({ beef: payment.beef, ...derivationInfo });
36
- * }
37
- * ```
38
- */
39
- export class BSVAgentWallet {
40
- /** @internal — exposed for advanced operations (e.g. direct internalizeAction) */
41
- _setup;
42
- constructor(setup) {
43
- this._setup = setup;
44
- }
45
- // ---------------------------------------------------------------------------
46
- // Factory methods
47
- // ---------------------------------------------------------------------------
48
- /**
49
- * Create a new agent wallet. Generates a fresh root key and persists it.
50
- * The SQLite database and identity file are written to `config.storageDir`.
51
- */
52
- static async create(config) {
53
- // Generate a new root key (or use one provided in config)
54
- const rootKeyHex = config.rootKeyHex ?? PrivateKey.fromRandom().toHex();
55
- const rootKey = PrivateKey.fromHex(rootKeyHex);
56
- const identityKey = rootKey.toPublicKey().toString();
57
- // Ensure the storage directory exists
58
- fs.mkdirSync(config.storageDir, { recursive: true });
59
- // Persist identity for later loading
60
- const identity = {
61
- rootKeyHex,
62
- identityKey,
63
- network: config.network,
64
- };
65
- const identityPath = path.join(config.storageDir, IDENTITY_FILE);
66
- fs.writeFileSync(identityPath, JSON.stringify(identity, null, 2), 'utf-8');
67
- // Build the wallet
68
- const setup = await BSVAgentWallet.buildSetup(config, rootKeyHex);
69
- return new BSVAgentWallet(setup);
70
- }
71
- /**
72
- * Load an existing agent wallet from its storage directory.
73
- * Reads the persisted identity file and re-initializes the wallet.
74
- */
75
- static async load(config) {
76
- const identityPath = path.join(config.storageDir, IDENTITY_FILE);
77
- if (!fs.existsSync(identityPath)) {
78
- return this.create(config);
79
- }
80
- const identity = JSON.parse(fs.readFileSync(identityPath, 'utf-8'));
81
- const rootKeyHex = config.rootKeyHex ?? identity.rootKeyHex;
82
- const setup = await BSVAgentWallet.buildSetup(config, rootKeyHex);
83
- return new BSVAgentWallet(setup);
84
- }
85
- // ---------------------------------------------------------------------------
86
- // Wallet lifecycle
87
- // ---------------------------------------------------------------------------
88
- /**
89
- * Get this wallet's public identity key (compressed hex, 33 bytes).
90
- * This is the key other agents use to send payments to you.
91
- */
92
- async getIdentityKey() {
93
- return this._setup.identityKey;
94
- }
95
- /**
96
- * Get the wallet's current balance in satoshis.
97
- *
98
- * Uses the BRC-100 wallet's balance method which sums spendable outputs
99
- * in the default basket.
100
- */
101
- async getBalance() {
102
- return await this._setup.wallet.balance();
103
- }
104
- /**
105
- * Cleanly shut down the wallet, releasing database connections and
106
- * stopping the background monitor.
107
- */
108
- async destroy() {
109
- await this._setup.wallet.destroy();
110
- }
111
- // ---------------------------------------------------------------------------
112
- // Payment creation (sender/payer side)
113
- // ---------------------------------------------------------------------------
114
- /**
115
- * Build a BRC-29 payment to another agent.
116
- *
117
- * The transaction is created with `noSend: true` — the sender does NOT
118
- * broadcast it. Instead, the Atomic BEEF and derivation metadata are
119
- * returned so they can be transmitted to the recipient, who will
120
- * verify and internalize (broadcast) the payment.
121
- *
122
- * @param params.to — Recipient's compressed public key (hex).
123
- * @param params.satoshis — Amount in satoshis.
124
- * @param params.description — Optional human-readable note.
125
- */
126
- async createPayment(params) {
127
- return buildPayment(this._setup, params);
128
- }
129
- // ---------------------------------------------------------------------------
130
- // Payment verification & acceptance (receiver/merchant side)
131
- // ---------------------------------------------------------------------------
132
- /**
133
- * Verify an incoming Atomic BEEF payment.
134
- *
135
- * This performs structural validation and SPV verification via tx.verify().
136
- */
137
- async verifyPayment(params) {
138
- return await verifyPayment(params);
139
- }
140
- /**
141
- * Accept (internalize) a verified payment into this wallet.
142
- *
143
- * Uses the BRC-29 wallet payment protocol to derive the correct key
144
- * and claim the output. This triggers SPV verification and, if the
145
- * transaction hasn't been broadcast yet, broadcasts it.
146
- */
147
- async acceptPayment(params) {
148
- return acceptPayment(this._setup, params);
149
- }
150
- // ---------------------------------------------------------------------------
151
- // Access to underlying toolbox objects (for advanced use)
152
- // ---------------------------------------------------------------------------
153
- /** Get the underlying wallet-toolbox SetupWallet for advanced operations. */
154
- getSetup() {
155
- return this._setup;
156
- }
157
- // ---------------------------------------------------------------------------
158
- // Private helpers
159
- // ---------------------------------------------------------------------------
160
- /**
161
- * Internal: manually construct a BRC-100 wallet backed by SQLite.
162
- *
163
- * We build this by hand instead of using Setup.createWalletSQLite because
164
- * the toolbox has a bug where its internal randomBytesHex is a stub.
165
- * We use the same components but wire them up correctly.
166
- */
167
- static async buildSetup(config, rootKeyHex) {
168
- const chain = toChain(config.network);
169
- const taalApiKey = config.taalApiKey ?? DEFAULT_TAAL_API_KEYS[chain];
170
- const rootKey = PrivateKey.fromHex(rootKeyHex);
171
- const identityKey = rootKey.toPublicKey().toString();
172
- // 1. Key derivation
173
- const keyDeriver = new CachedKeyDeriver(rootKey);
174
- // 2. Storage manager (empty initially)
175
- const storage = new WalletStorageManager(identityKey);
176
- // 3. Network services (ARC broadcasting, chain tracking, etc.)
177
- const serviceOptions = Services.createDefaultOptions(chain);
178
- serviceOptions.chaintracks = new ChaintracksServiceClient(chain, 'https://chaintracks-us-1.bsvb.tech');
179
- serviceOptions.taalApiKey = taalApiKey;
180
- const services = new Services(serviceOptions);
181
- // 4. Background monitor
182
- const monopts = Monitor.createDefaultWalletMonitorOptions(chain, storage, services);
183
- const monitor = new Monitor(monopts);
184
- monitor.addDefaultTasks();
185
- // 5. The BRC-100 Wallet
186
- const wallet = new Wallet({ chain, keyDeriver, storage, services, monitor });
187
- // 6. SQLite storage via knex
188
- const filePath = path.join(config.storageDir, `${DEFAULT_DB_NAME}.sqlite`);
189
- const knex = knexLib({
190
- client: 'sqlite3',
191
- connection: { filename: filePath },
192
- useNullAsDefault: true,
193
- });
194
- // Fee model: configurable via BSV_FEE_MODEL env var (default: 100 sat/KB)
195
- const feeModelValue = config.feeModel ??
196
- (process.env.BSV_FEE_MODEL ? parseInt(process.env.BSV_FEE_MODEL, 10) : 100);
197
- const activeStorage = new StorageKnex({
198
- chain,
199
- knex,
200
- commissionSatoshis: 0,
201
- commissionPubKeyHex: undefined,
202
- feeModel: { model: 'sat/kb', value: feeModelValue },
203
- });
204
- await activeStorage.migrate(DEFAULT_DB_NAME, randomBytesHex(33));
205
- await activeStorage.makeAvailable();
206
- await storage.addWalletStorageProvider(activeStorage);
207
- await activeStorage.findOrInsertUser(identityKey);
208
- return {
209
- rootKey,
210
- identityKey,
211
- keyDeriver,
212
- chain,
213
- storage,
214
- services,
215
- monitor,
216
- wallet,
217
- };
218
- }
219
- }
@@ -1,64 +0,0 @@
1
- /**
2
- * Baemail commands - paid message forwarding service.
3
- */
4
- export interface BaemailConfig {
5
- deliveryChannel: string;
6
- tiers: {
7
- standard: number;
8
- priority: number;
9
- urgent: number;
10
- };
11
- maxMessageLength: number;
12
- blocklist: string[];
13
- createdAt: string;
14
- updatedAt: string;
15
- }
16
- export interface BaemailLogEntry {
17
- requestId: string;
18
- from: string;
19
- senderName: string;
20
- tier: string;
21
- paidSats: number;
22
- messageLength: number;
23
- deliveryChannel: string;
24
- deliverySuccess: boolean;
25
- deliveryError: string | null;
26
- paymentTxid: string;
27
- refundStatus: string | null;
28
- refundTxid?: string;
29
- refundedAt?: string;
30
- timestamp: string;
31
- _lineIdx?: number;
32
- }
33
- /**
34
- * Load baemail configuration.
35
- */
36
- export declare function loadBaemailConfig(): BaemailConfig | null;
37
- /**
38
- * Save baemail configuration.
39
- */
40
- export declare function saveBaemailConfig(config: BaemailConfig): void;
41
- /**
42
- * Setup baemail service with delivery channel and tier pricing.
43
- */
44
- export declare function cmdBaemailSetup(channel: string | undefined, standardStr: string | undefined, priorityStr?: string, urgentStr?: string): Promise<never>;
45
- /**
46
- * View current baemail configuration.
47
- */
48
- export declare function cmdBaemailConfig(): Promise<never>;
49
- /**
50
- * Block a sender from using baemail.
51
- */
52
- export declare function cmdBaemailBlock(identityKey: string | undefined): Promise<never>;
53
- /**
54
- * Unblock a sender.
55
- */
56
- export declare function cmdBaemailUnblock(identityKey: string | undefined): Promise<never>;
57
- /**
58
- * View baemail delivery log.
59
- */
60
- export declare function cmdBaemailLog(limitStr?: string): Promise<never>;
61
- /**
62
- * Refund a failed baemail delivery.
63
- */
64
- export declare function cmdBaemailRefund(requestId: string | undefined): Promise<never>;