openclaw-simplesv-plugin 0.1.5 → 0.1.6

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 (53) hide show
  1. package/README.md +50 -10
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +61 -13
  5. package/dist/index.js.map +1 -1
  6. package/dist/src/actions.d.ts +19 -0
  7. package/dist/src/actions.d.ts.map +1 -0
  8. package/dist/src/actions.js +46 -0
  9. package/dist/src/actions.js.map +1 -0
  10. package/dist/src/core/config.d.ts +12 -0
  11. package/dist/src/core/config.d.ts.map +1 -0
  12. package/dist/src/core/config.js +14 -0
  13. package/dist/src/core/config.js.map +1 -0
  14. package/dist/src/core/index.d.ts +26 -0
  15. package/dist/src/core/index.d.ts.map +1 -0
  16. package/dist/src/core/index.js +27 -0
  17. package/dist/src/core/index.js.map +1 -0
  18. package/dist/src/core/payment.d.ts +17 -0
  19. package/dist/src/core/payment.d.ts.map +1 -0
  20. package/dist/src/core/payment.js +95 -0
  21. package/dist/src/core/payment.js.map +1 -0
  22. package/dist/src/core/types.d.ts +95 -0
  23. package/dist/src/core/types.d.ts.map +1 -0
  24. package/dist/src/core/types.js +5 -0
  25. package/dist/src/core/types.js.map +1 -0
  26. package/dist/src/core/verify.d.ts +29 -0
  27. package/dist/src/core/verify.d.ts.map +1 -0
  28. package/dist/src/core/verify.js +105 -0
  29. package/dist/src/core/verify.js.map +1 -0
  30. package/dist/src/core/wallet.d.ts +100 -0
  31. package/dist/src/core/wallet.d.ts.map +1 -0
  32. package/dist/src/core/wallet.js +225 -0
  33. package/dist/src/core/wallet.js.map +1 -0
  34. package/dist/src/wallet.d.ts +12 -0
  35. package/dist/src/wallet.d.ts.map +1 -0
  36. package/dist/src/wallet.js +16 -0
  37. package/dist/src/wallet.js.map +1 -0
  38. package/index.ts +73 -13
  39. package/openclaw.plugin.json +3 -2
  40. package/package.json +1 -1
  41. package/src/actions.ts +54 -0
  42. package/src/core/config.d.ts +12 -0
  43. package/src/core/config.ts +21 -0
  44. package/src/core/index.ts +42 -0
  45. package/src/core/payment.d.ts +17 -0
  46. package/src/core/payment.ts +111 -0
  47. package/src/core/types.d.ts +95 -0
  48. package/src/core/types.ts +102 -0
  49. package/src/core/verify.d.ts +29 -0
  50. package/src/core/verify.ts +119 -0
  51. package/src/core/wallet.d.ts +100 -0
  52. package/src/core/wallet.ts +289 -0
  53. package/src/wallet.ts +20 -0
package/README.md CHANGED
@@ -9,25 +9,65 @@ A programmatic OpenClaw plugin that provides a high-level blockchain "Utility Be
9
9
  - **Verifiable Credentials**: Issue W3C-compatible credentials for agents.
10
10
  - **Optional MCP Integration**: Mount advanced tools from the `@bsv/simple-mcp` ecosystem.
11
11
 
12
+ ---
13
+
14
+ ## Configuration
15
+
16
+ You can configure the plugin in your `openclaw.json` file. The plugin supports both a flat structure and a nested `config` object under its ID.
17
+
18
+ ### Example Configuration
19
+ ```json
20
+ {
21
+ "plugins": {
22
+ "entries": {
23
+ "openclaw-simplesv-plugin": {
24
+ "enabled": true,
25
+ "network": "mainnet",
26
+ "enableMcp": true,
27
+ "chaintracksUrl": "https://chaintracks-us-1.bsvb.tech",
28
+ "arcUrl": "https://arc.gorillapool.io",
29
+ "walletDir": "~/.openclaw/bsv-wallet"
30
+ }
31
+ }
32
+ }
33
+ }
34
+ ```
35
+
36
+ ### Options
37
+
38
+ | Option | Default | Description |
39
+ | :--- | :--- | :--- |
40
+ | `network` | `mainnet` | The BSV network to target (`mainnet` or `testnet`). |
41
+ | `enableMcp` | `false` | Enable advanced Model Context Protocol tools if `@bsv/simple-mcp` is installed. |
42
+ | `chaintracksUrl`| `https://chaintracks-us-1.bsvb.tech` | Custom server for SPV block header verification. |
43
+ | `arcUrl` | `https://arc.gorillapool.io` | Custom ARC/Arcade server for transaction broadcasting. |
44
+ | `walletDir` | `~/.openclaw/bsv-wallet` | Directory where `wallet-identity.json` and local databases are stored. |
45
+
46
+ ---
47
+
12
48
  ## AI Tool: `simplesv`
13
- Agents can use the `simplesv` tool to:
14
- - `inscribe`: Store permanent JSON/Text records.
15
- - `token_issue`: Create new digital assets or state.
16
- - `token_transfer`: Send assets to other agents.
17
- - `resolve_did`: Look up agent profiles and public keys.
18
- - `vc_issue`: Certify facts about other agents (Web of Trust).
19
- - `pay_p2p`: Standard peer-to-peer payments.
49
+ Agents can use the `simplesv` tool to perform the following actions:
50
+
51
+ | Action | Description |
52
+ | :--- | :--- |
53
+ | `inscribe` | Store permanent JSON or Text records on the blockchain. |
54
+ | `token_issue` | Create new digital assets or stateful tokens. |
55
+ | `token_transfer` | Send ownership of a token to another agent's identity key. |
56
+ | `resolve_did` | Look up agent profiles and public keys via their `did:bsv`. |
57
+ | `vc_issue` | Certify facts about other agents to build a Web of Trust. |
58
+ | `pay_p2p` | Send standard peer-to-peer satoshi payments. |
59
+ | `status` | Display the agent's current identity key, DID, and wallet balance. |
20
60
 
21
61
  ## Advanced MCP Tools (Optional)
22
- When enabled, the plugin automatically mounts advanced tools from the Model Context Protocol server, prefixing them with `simplesv_`:
23
- - `simplesv_decode_tx`: Detail transaction analysis.
62
+ When `enableMcp` is set to `true` and the library is installed, the plugin automatically mounts advanced tools from the Model Context Protocol server, prefixing them with `simplesv_`:
63
+ - `simplesv_decode_tx`: Detailed transaction analysis.
24
64
  - `simplesv_brc_lookup`: Search blockchain standards documentation.
25
65
  - ...and many more from the `@bsv/simple-mcp` library.
26
66
 
27
67
  ## Architecture
28
68
  Built with the **OpenClaw Plugin SDK**, this extension uses:
29
69
  - `@bsv/simple` for high-level blockchain APIs.
30
- - `@bsv/sdk` for identity and crypto.
70
+ - `@bsv/sdk` for identity and cryptography.
31
71
  - Shared wallet identity with other OpenClaw BSV plugins.
32
72
 
33
73
  ## License
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ declare module "@bsv/simple-mcp";
1
2
  /**
2
3
  * OpenClaw SimpleSV Plugin
3
4
  * High-level blockchain utility belt (DIDs, Tokens, Inscriptions).
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,GAAG,EAAE,GAAG,QA8GxC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAOA,OAAO,QAAQ,iBAAiB,CAAC;AAEjC;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,GAAG,EAAE,GAAG,QAoKxC"}
package/dist/index.js CHANGED
@@ -1,19 +1,39 @@
1
1
  import path from "node:path";
2
2
  import os from "node:os";
3
+ import { SimpleSVManager } from "./src/actions.js";
4
+ import { ClawWalletCore } from "./src/wallet.js";
5
+ import { BSVAgentWallet } from "./src/core/wallet.js";
3
6
  /**
4
7
  * OpenClaw SimpleSV Plugin
5
8
  * High-level blockchain utility belt (DIDs, Tokens, Inscriptions).
6
9
  */
7
10
  export default function register(api) {
8
- const entry = api.getConfig?.()?.plugins?.entries?.['openclaw-simplesv'] || {};
11
+ const entries = api.getConfig?.()?.plugins?.entries || {};
12
+ const entry = entries['openclaw-simplesv']
13
+ || entries['openclaw-simplesv-plugin']
14
+ || entries['bsv-simple']
15
+ || {};
9
16
  const pluginConfig = { ...entry, ...(entry.config || {}), ...(api.config || {}) };
10
17
  const network = pluginConfig.network || 'mainnet';
11
18
  const chaintracksUrl = pluginConfig.chaintracksUrl || 'https://chaintracks-us-1.bsvb.tech';
12
- const arcUrl = pluginConfig.arcUrl || '';
19
+ const arcUrl = pluginConfig.arcUrl || (network === 'testnet' ? 'https://testnet.arc.gorillapool.io' : 'https://arc.gorillapool.io');
13
20
  const walletDir = pluginConfig.walletDir || path.join(os.homedir(), '.openclaw', 'bsv-wallet');
14
21
  const enableMcp = pluginConfig.enableMcp === true;
15
- api.logger.info(`[simplesv] Initializing SimpleSV Plugin (network: ${network}, chaintracks: ${chaintracksUrl}, arc: ${arcUrl || 'default'})`);
16
- // Register the base simplesv tool
22
+ let manager = null;
23
+ api.logger.info(`[simplesv] Initializing SimpleSV Plugin (network: ${network}, host: ${chaintracksUrl}, arc: ${arcUrl})`);
24
+ async function ensureInitialized() {
25
+ if (manager)
26
+ return manager;
27
+ // Initialize shared wallet
28
+ const wallet = await BSVAgentWallet.load({
29
+ network: network,
30
+ storageDir: walletDir
31
+ });
32
+ const core = new ClawWalletCore(wallet);
33
+ manager = new SimpleSVManager(core);
34
+ return manager;
35
+ }
36
+ // Register the simplesv tool
17
37
  api.registerTool({
18
38
  name: "simplesv",
19
39
  description: "High-level BSV utility belt: DIDs, Tokens, and Inscriptions",
@@ -59,19 +79,49 @@ export default function register(api) {
59
79
  basket: {
60
80
  type: "string",
61
81
  description: "Basket name for tokens"
82
+ },
83
+ tokenId: {
84
+ type: "string",
85
+ description: "ID of the token to transfer"
62
86
  }
63
87
  },
64
88
  required: ["action"]
65
89
  },
66
90
  async execute(_id, params) {
67
91
  try {
68
- // Implementation logic using @bsv/simple will go here
69
- return {
70
- content: [{
71
- type: "text",
72
- text: `SimpleSV action '${params.action}' received. (Logic implementation pending)`
73
- }]
74
- };
92
+ const m = await ensureInitialized();
93
+ switch (params.action) {
94
+ case "inscribe":
95
+ const insResult = await m.inscribe(params.data, params.text);
96
+ return { content: [{ type: "text", text: `✅ Inscription created! TXID: ${insResult.txid}` }] };
97
+ case "resolve_did":
98
+ if (!params.did)
99
+ throw new Error("did is required");
100
+ const didDoc = await m.resolveDid(params.did);
101
+ return { content: [{ type: "text", text: `Decoded DID Document:\n${JSON.stringify(didDoc, null, 2)}` }] };
102
+ case "token_issue":
103
+ if (!params.basket || !params.data)
104
+ throw new Error("basket and data required");
105
+ const tokenResult = await m.issueToken(params.basket, params.data);
106
+ return { content: [{ type: "text", text: `✅ Token issued! ID: ${tokenResult.tokenId}\nTXID: ${tokenResult.txid}` }] };
107
+ case "token_transfer":
108
+ if (!params.tokenId || !params.recipientKey)
109
+ throw new Error("tokenId and recipientKey required");
110
+ const transResult = await m.transferToken(params.tokenId, params.recipientKey);
111
+ return { content: [{ type: "text", text: `✅ Token transferred!\nTXID: ${transResult.txid}` }] };
112
+ case "status":
113
+ const status = m.getStatus();
114
+ const myDid = await m.getMyDid();
115
+ // @ts-ignore
116
+ const balance = status.status.balance ?? "unknown";
117
+ return { content: [{ type: "text", text: `SimpleSV Status:\nIdentity Key: ${status.identityKey}\nDID: ${JSON.stringify(myDid)}\nAddress: ${status.address}\nBalance: ${balance} sats` }] };
118
+ case "pay_p2p":
119
+ return { content: [{ type: "text", text: "Standard P2P payment logic integration pending." }] };
120
+ case "vc_issue":
121
+ return { content: [{ type: "text", text: "Verifiable Credential logic integration pending." }] };
122
+ default:
123
+ throw new Error(`Unknown action: ${params.action}`);
124
+ }
75
125
  }
76
126
  catch (error) {
77
127
  return {
@@ -89,8 +139,6 @@ export default function register(api) {
89
139
  // @ts-ignore
90
140
  import('@bsv/simple-mcp').then((mcp) => {
91
141
  api.logger.info("[simplesv] @bsv/simple-mcp detected! Mounting advanced blockchain tools...");
92
- // Loop through all tools provided by the MCP library and register them
93
- // Note: This logic depends on the specific export structure of @bsv/simple-mcp
94
142
  if (mcp.tools) {
95
143
  Object.values(mcp.tools).forEach((tool) => {
96
144
  api.registerTool({
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,GAAQ;IACvC,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,mBAAmB,CAAC,IAAI,EAAE,CAAC;IAC/E,MAAM,YAAY,GAAG,EAAE,GAAG,KAAK,EAAE,GAAG,CAAC,KAA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C;AACH,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { ClawWalletCore } from './wallet.js';
2
+ export declare class SimpleSVManager {
3
+ private didMethods;
4
+ private inscriptionMethods;
5
+ private tokenMethods;
6
+ private core;
7
+ constructor(core: ClawWalletCore);
8
+ resolveDid(did: string): Promise<any>;
9
+ getMyDid(): Promise<any>;
10
+ inscribe(data: any, text?: string): Promise<any>;
11
+ issueToken(basket: string, data: any): Promise<any>;
12
+ transferToken(tokenId: string, recipientKey: string): Promise<any>;
13
+ getStatus(): {
14
+ identityKey: string;
15
+ address: string;
16
+ status: import("@bsv/simple").WalletStatus;
17
+ };
18
+ }
19
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAQ7C,qBAAa,eAAe;IAC1B,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,kBAAkB,CAAM;IAChC,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,IAAI,CAAiB;gBAEjB,IAAI,EAAE,cAAc;IAQ1B,UAAU,CAAC,GAAG,EAAE,MAAM;IAItB,QAAQ;IAIR,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM;IAOjC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG;IAIpC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAIzD,SAAS;;;;;CAQV"}
@@ -0,0 +1,46 @@
1
+ // @ts-ignore
2
+ import { createDIDMethods } from '@bsv/simple/dist/modules/did.js';
3
+ // @ts-ignore
4
+ import { createInscriptionMethods } from '@bsv/simple/dist/modules/inscriptions.js';
5
+ // @ts-ignore
6
+ import { createTokenMethods } from '@bsv/simple/dist/modules/tokens.js';
7
+ export class SimpleSVManager {
8
+ didMethods;
9
+ inscriptionMethods;
10
+ tokenMethods;
11
+ core;
12
+ constructor(core) {
13
+ this.core = core;
14
+ // Initialize high-level modules
15
+ this.didMethods = createDIDMethods(core);
16
+ this.inscriptionMethods = createInscriptionMethods(core);
17
+ this.tokenMethods = createTokenMethods(core);
18
+ }
19
+ async resolveDid(did) {
20
+ return await this.didMethods.resolveDID(did);
21
+ }
22
+ async getMyDid() {
23
+ return await this.didMethods.getDID();
24
+ }
25
+ async inscribe(data, text) {
26
+ if (text) {
27
+ return await this.inscriptionMethods.createInscription({ text });
28
+ }
29
+ return await this.inscriptionMethods.createInscription({ data });
30
+ }
31
+ async issueToken(basket, data) {
32
+ return await this.tokenMethods.issueToken({ basket, data });
33
+ }
34
+ async transferToken(tokenId, recipientKey) {
35
+ return await this.tokenMethods.transferToken({ tokenId, recipientKey });
36
+ }
37
+ getStatus() {
38
+ return {
39
+ identityKey: this.core.identityKey,
40
+ address: this.core.getAddress(),
41
+ // @ts-ignore
42
+ status: this.core.getStatus()
43
+ };
44
+ }
45
+ }
46
+ //# sourceMappingURL=actions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/actions.ts"],"names":[],"mappings":"AACA,aAAa;AACb,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,aAAa;AACb,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AACpF,aAAa;AACb,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAExE,MAAM,OAAO,eAAe;IAClB,UAAU,CAAM;IAChB,kBAAkB,CAAM;IACxB,YAAY,CAAM;IAClB,IAAI,CAAiB;IAE7B,YAAY,IAAoB;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,gCAAgC;QAChC,IAAI,CAAC,UAAU,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,kBAAkB,GAAG,wBAAwB,CA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map our 'mainnet'/'testnet' to the wallet-toolbox's 'main'/'test' chain type. */
6
+ export type Chain = 'main' | 'test';
7
+ export declare function toChain(network: WalletConfig['network']): Chain;
8
+ /** Default TAAL API keys from the wallet-toolbox examples. */
9
+ export declare const DEFAULT_TAAL_API_KEYS: Record<Chain, string>;
10
+ /** Default SQLite database name. */
11
+ export declare const DEFAULT_DB_NAME = "a2a_agent_wallet";
12
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/core/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,oFAAoF;AACpF,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpC,wBAAgB,OAAO,CAAC,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,GAAG,KAAK,CAE/D;AAED,8DAA8D;AAC9D,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAGvD,CAAC;AAEF,oCAAoC;AACpC,eAAO,MAAM,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @a2a-bsv/core — Configuration defaults and helpers.
3
+ */
4
+ export function toChain(network) {
5
+ return network === 'mainnet' ? 'main' : 'test';
6
+ }
7
+ /** Default TAAL API keys from the wallet-toolbox examples. */
8
+ export const DEFAULT_TAAL_API_KEYS = {
9
+ main: 'mainnet_9596de07e92300c6287e4393594ae39c',
10
+ test: 'testnet_0e6cf72133b43ea2d7861da2a38684e3',
11
+ };
12
+ /** Default SQLite database name. */
13
+ export const DEFAULT_DB_NAME = 'a2a_agent_wallet';
14
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/core/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,MAAM,UAAU,OAAO,CAAC,OAAgC;IACtD,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;AACjD,CAAC;AAED,8DAA8D;AAC9D,MAAM,CAAC,MAAM,qBAAqB,GAA0B;IAC1D,IAAI,EAAE,0CAA0C;IAChD,IAAI,EAAE,0CAA0C;CACjD,CAAC;AAEF,oCAAoC;AACpC,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @a2a-bsv/core — Agent-to-agent BSV payment library.
3
+ *
4
+ * Wraps @bsv/sdk and @bsv/wallet-toolbox to provide a clean, minimal API
5
+ * for AI agents to pay each other using BSV blockchain transactions.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { BSVAgentWallet } from '@a2a-bsv/core';
10
+ *
11
+ * const wallet = await BSVAgentWallet.load({
12
+ * network: 'testnet',
13
+ * storageDir: './my-agent-wallet',
14
+ * });
15
+ *
16
+ * const identityKey = await wallet.getIdentityKey();
17
+ * console.log('My identity:', identityKey);
18
+ * ```
19
+ */
20
+ export { BSVAgentWallet } from './wallet.js';
21
+ export type { WalletConfig, WalletIdentity, PaymentParams, PaymentResult, VerifyParams, VerifyResult, AcceptParams, AcceptResult, } from './types.js';
22
+ export { toChain, DEFAULT_TAAL_API_KEYS, DEFAULT_DB_NAME } from './config.js';
23
+ export type { Chain } from './config.js';
24
+ export { buildPayment } from './payment.js';
25
+ export { verifyPayment, acceptPayment } from './verify.js';
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,YAAY,EACV,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9E,YAAY,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @a2a-bsv/core — Agent-to-agent BSV payment library.
3
+ *
4
+ * Wraps @bsv/sdk and @bsv/wallet-toolbox to provide a clean, minimal API
5
+ * for AI agents to pay each other using BSV blockchain transactions.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { BSVAgentWallet } from '@a2a-bsv/core';
10
+ *
11
+ * const wallet = await BSVAgentWallet.load({
12
+ * network: 'testnet',
13
+ * storageDir: './my-agent-wallet',
14
+ * });
15
+ *
16
+ * const identityKey = await wallet.getIdentityKey();
17
+ * console.log('My identity:', identityKey);
18
+ * ```
19
+ */
20
+ // Main wallet class
21
+ export { BSVAgentWallet } from './wallet.js';
22
+ // Config helpers (for advanced use)
23
+ export { toChain, DEFAULT_TAAL_API_KEYS, DEFAULT_DB_NAME } from './config.js';
24
+ // Lower-level helpers (for advanced use)
25
+ export { buildPayment } from './payment.js';
26
+ export { verifyPayment, acceptPayment } from './verify.js';
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,oBAAoB;AACpB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAc7C,oCAAoC;AACpC,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9E,yCAAyC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @a2a-bsv/core — Payment construction helpers.
3
+ *
4
+ * Uses BRC-29 key derivation so the recipient can internalize the payment
5
+ * without ever reusing an address.
6
+ */
7
+ import type { SetupWallet } from '@bsv/wallet-toolbox';
8
+ import type { PaymentParams, PaymentResult } from './types.js';
9
+ /**
10
+ * Build a BRC-29 payment transaction using the wallet's createAction API.
11
+ *
12
+ * The transaction is created with `acceptDelayedBroadcast: false` — the sender
13
+ * broadcasts immediately. The resulting Atomic BEEF and derivation metadata are
14
+ * returned so the recipient can verify and internalize the payment on their side.
15
+ */
16
+ export declare function buildPayment(setup: SetupWallet, params: PaymentParams): Promise<PaymentResult>;
17
+ //# sourceMappingURL=payment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../../../src/core/payment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG/D;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,aAAa,CAAC,CA8ExB"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * @a2a-bsv/core — Payment construction helpers.
3
+ *
4
+ * Uses BRC-29 key derivation so the recipient can internalize the payment
5
+ * without ever reusing an address.
6
+ */
7
+ import { Beef, Utils } from '@bsv/sdk';
8
+ import { randomBytesBase64, ScriptTemplateBRC29 } from '@bsv/wallet-toolbox';
9
+ /**
10
+ * Build a BRC-29 payment transaction using the wallet's createAction API.
11
+ *
12
+ * The transaction is created with `acceptDelayedBroadcast: false` — the sender
13
+ * broadcasts immediately. The resulting Atomic BEEF and derivation metadata are
14
+ * returned so the recipient can verify and internalize the payment on their side.
15
+ */
16
+ export async function buildPayment(setup, params) {
17
+ const { to, satoshis, description } = params;
18
+ const desc = normalizeDescription(description ?? 'agent payment');
19
+ // Generate unique BRC-29 derivation prefixes and suffixes
20
+ const derivationPrefix = randomBytesBase64(8);
21
+ const derivationSuffix = randomBytesBase64(8);
22
+ // Build BRC-29 locking script
23
+ const keyDeriver = setup.keyDeriver;
24
+ const t = new ScriptTemplateBRC29({
25
+ derivationPrefix,
26
+ derivationSuffix,
27
+ keyDeriver,
28
+ });
29
+ // Determine the recipient identity key.
30
+ // If `to` is a compressed public key hex (66 chars, starts with 02/03), use directly.
31
+ // Otherwise treat as an address — for BRC-29 we need a public key.
32
+ let recipientPubKey;
33
+ if (/^0[23][0-9a-fA-F]{64}$/.test(to)) {
34
+ recipientPubKey = to;
35
+ }
36
+ else {
37
+ // If it's an address, we can't do BRC-29 (needs pubkey). Throw a clear error.
38
+ throw new Error('PaymentParams.to must be a compressed public key (hex) for BRC-29 payments. ' +
39
+ 'Raw BSV addresses are not supported — the recipient must share their identity key.');
40
+ }
41
+ const lockingScript = t.lock(setup.rootKey.toString(), recipientPubKey);
42
+ const label = 'a2a-payment';
43
+ const car = await setup.wallet.createAction({
44
+ outputs: [
45
+ {
46
+ lockingScript: lockingScript.toHex(),
47
+ satoshis,
48
+ outputDescription: desc,
49
+ tags: ['relinquish'],
50
+ customInstructions: JSON.stringify({
51
+ derivationPrefix,
52
+ derivationSuffix,
53
+ type: 'BRC29',
54
+ }),
55
+ },
56
+ ],
57
+ options: {
58
+ randomizeOutputs: false,
59
+ acceptDelayedBroadcast: false,
60
+ },
61
+ labels: [label],
62
+ description: desc,
63
+ });
64
+ // Extract the txid from the createAction result.
65
+ // The tx field is a number[] (AtomicBEEF binary). Parse it to get txid.
66
+ if (!car.tx) {
67
+ throw new Error('createAction did not return a transaction. Check wallet funding.');
68
+ }
69
+ const beef = Beef.fromBinary(car.tx);
70
+ // The last transaction in the beef is our new tx
71
+ const lastTx = beef.txs[beef.txs.length - 1];
72
+ const txid = lastTx.txid;
73
+ // Encode the atomic BEEF as base64
74
+ const atomicBinary = beef.toBinaryAtomic(txid);
75
+ const beefBase64 = Utils.toBase64(atomicBinary);
76
+ return {
77
+ beef: beefBase64,
78
+ txid,
79
+ satoshis,
80
+ derivationPrefix,
81
+ derivationSuffix,
82
+ senderIdentityKey: setup.identityKey,
83
+ };
84
+ }
85
+ /**
86
+ * Ensure description meets BRC-100's 5-50 character requirement.
87
+ */
88
+ function normalizeDescription(desc) {
89
+ if (desc.length < 5)
90
+ return desc.padEnd(5, ' ');
91
+ if (desc.length > 50)
92
+ return desc.slice(0, 50);
93
+ return desc;
94
+ }
95
+ //# sourceMappingURL=payment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment.js","sourceRoot":"","sources":["../../../src/core/payment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAK7E;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,KAAkB,EAClB,MAAqB;IAErB,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAC7C,MAAM,IAAI,GAAG,oBAAoB,CAAC,WAAW,IAAI,eAAe,CAAC,CAAC;IAElE,0DAA0D;IAC1D,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAC9C,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAE9C,8BAA8B;IAC9B,MAAM,UAAU,GAAG,KAAK,CAAC,UAA8B,CAAC;IACxD,MAAM,CAAC,GAAG,IAAI,mBAAmB,CAAC;QAChC,gBAAgB;QAChB,gBAAgB;QAChB,UAAU;KACX,CAAC,CAAC;IAEH,wCAAwC;IACxC,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AM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IAEzB,mCAAmC;IACnC,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,UAAU,GAAG,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAEhD,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,IAAI;QACJ,QAAQ;QACR,gBAAgB;QAChB,gBAAgB;QAChB,iBAAiB,EAAE,KAAK,CAAC,WAAW;KACrC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,oBAAoB,CAAC,IAAY;IACxC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAChD,IAAI,IAAI,CAAC,MAAM,GAAG,EAAE;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC/C,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * @a2a-bsv/core — Type definitions for agent-to-agent BSV payments.
3
+ */
4
+ /** Wallet configuration for creating or loading an agent wallet. */
5
+ export interface WalletConfig {
6
+ /** BSV network to use. */
7
+ network: 'mainnet' | 'testnet';
8
+ /** Directory path for SQLite wallet persistence. */
9
+ storageDir: string;
10
+ /** Optional: pre-existing root private key hex. If omitted on create(), a new one is generated. */
11
+ rootKeyHex?: string;
12
+ /** Optional TAAL API key for ARC broadcasting. Falls back to public default. */
13
+ taalApiKey?: string;
14
+ /** Optional fee model in sat/KB. Falls back to BSV_FEE_MODEL env var or default 100 sat/KB. */
15
+ feeModel?: number;
16
+ }
17
+ /** Parameters for building a payment transaction. */
18
+ export interface PaymentParams {
19
+ /** Recipient's compressed public key (hex) or BSV address. */
20
+ to: string;
21
+ /** Amount to pay in satoshis. */
22
+ satoshis: number;
23
+ /** Human-readable description (5-50 chars per BRC-100). */
24
+ description?: string;
25
+ /** Optional metadata embedded as OP_RETURN (future use). */
26
+ metadata?: {
27
+ taskId?: string;
28
+ protocol?: string;
29
+ };
30
+ }
31
+ /** Result from building a payment. */
32
+ export interface PaymentResult {
33
+ /** Base64-encoded Atomic BEEF transaction data. */
34
+ beef: string;
35
+ /** Transaction ID (hex). */
36
+ txid: string;
37
+ /** Amount paid in satoshis. */
38
+ satoshis: number;
39
+ /** BRC-29 derivation prefix (base64). Needed by recipient to internalize. */
40
+ derivationPrefix: string;
41
+ /** BRC-29 derivation suffix (base64). Needed by recipient to internalize. */
42
+ derivationSuffix: string;
43
+ /** Sender's identity key (compressed hex). Needed by recipient to internalize. */
44
+ senderIdentityKey: string;
45
+ }
46
+ /** Parameters for verifying an incoming payment. */
47
+ export interface VerifyParams {
48
+ /** Base64-encoded Atomic BEEF data. */
49
+ beef: string;
50
+ /** Expected payment amount in satoshis. */
51
+ expectedAmount?: number;
52
+ /** Expected sender identity key (optional). */
53
+ expectedSender?: string;
54
+ }
55
+ /** Result from verifying a payment. */
56
+ export interface VerifyResult {
57
+ /** Whether the payment passes all checks. */
58
+ valid: boolean;
59
+ /** Transaction ID (hex). */
60
+ txid: string;
61
+ /** Number of outputs found in the transaction. */
62
+ outputCount: number;
63
+ /** Errors encountered during verification. */
64
+ errors: string[];
65
+ }
66
+ /** Parameters for accepting (internalizing) a verified payment. */
67
+ export interface AcceptParams {
68
+ /** Base64-encoded Atomic BEEF data. */
69
+ beef: string;
70
+ /** The output index to internalize (default: 0). */
71
+ vout?: number;
72
+ /** BRC-29 derivation prefix from the PaymentResult. */
73
+ derivationPrefix: string;
74
+ /** BRC-29 derivation suffix from the PaymentResult. */
75
+ derivationSuffix: string;
76
+ /** Sender's identity key from the PaymentResult. */
77
+ senderIdentityKey: string;
78
+ /** Human-readable description for wallet records (5-50 chars). */
79
+ description?: string;
80
+ }
81
+ /** Result from accepting a payment. */
82
+ export interface AcceptResult {
83
+ /** Whether the payment was accepted. */
84
+ accepted: boolean;
85
+ }
86
+ /** Serializable wallet identity info, persisted alongside the SQLite database. */
87
+ export interface WalletIdentity {
88
+ /** The root private key (hex). Guard this carefully. */
89
+ rootKeyHex: string;
90
+ /** The wallet's public identity key (compressed hex). */
91
+ identityKey: string;
92
+ /** Network this wallet targets. */
93
+ network: 'mainnet' | 'testnet';
94
+ }
95
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,oEAAoE;AACpE,MAAM,WAAW,YAAY;IAC3B,0BAA0B;IAC1B,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/B,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,mGAAmG;IACnG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gFAAgF;IAChF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+FAA+F;IAC/F,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qDAAqD;AACrD,MAAM,WAAW,aAAa;IAC5B,8DAA8D;IAC9D,EAAE,EAAE,MAAM,CAAC;IACX,iCAAiC;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE;QACT,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,6EAA6E;IAC7E,gBAAgB,EAAE,MAAM,CAAC;IACzB,6EAA6E;IAC7E,gBAAgB,EAAE,MAAM,CAAC;IACzB,kFAAkF;IAClF,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,oDAAoD;AACpD,MAAM,WAAW,YAAY;IAC3B,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+CAA+C;IAC/C,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,uCAAuC;AACvC,MAAM,WAAW,YAAY;IAC3B,6CAA6C;IAC7C,KAAK,EAAE,OAAO,CAAC;IACf,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,mEAAmE;AACnE,MAAM,WAAW,YAAY;IAC3B,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,gBAAgB,EAAE,MAAM,CAAC;IACzB,uDAAuD;IACvD,gBAAgB,EAAE,MAAM,CAAC;IACzB,oDAAoD;IACpD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kEAAkE;IAClE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,uCAAuC;AACvC,MAAM,WAAW,YAAY;IAC3B,wCAAwC;IACxC,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,kFAAkF;AAClF,MAAM,WAAW,cAAc;IAC7B,wDAAwD;IACxD,UAAU,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,WAAW,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC;CAChC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @a2a-bsv/core — Type definitions for agent-to-agent BSV payments.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}