@1sat/wallet-toolbox 0.0.30 → 0.0.32
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.
- package/dist/api/sweep/index.js +23 -1
- package/dist/services/OneSatServices.d.ts +3 -1
- package/dist/services/OneSatServices.js +4 -1
- package/dist/services/client/OverlayClient.d.ts +31 -0
- package/dist/services/client/OverlayClient.js +37 -0
- package/dist/services/client/index.d.ts +1 -0
- package/dist/services/client/index.js +1 -0
- package/package.json +4 -4
package/dist/api/sweep/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Functions for sweeping assets from external wallets into a BRC-100 wallet.
|
|
5
5
|
*/
|
|
6
|
-
import { P2PKH, PrivateKey, PublicKey, Transaction, } from "@bsv/sdk";
|
|
6
|
+
import { P2PKH, PrivateKey, PublicKey, Transaction, Utils, } from "@bsv/sdk";
|
|
7
7
|
import { BSV21 } from "@bopen-io/templates";
|
|
8
8
|
import { ONESAT_PROTOCOL, BSV21_PROTOCOL, BSV21_FEE_SATS, BSV21_BASKET } from "../constants";
|
|
9
9
|
import { deriveFundAddress } from "../../indexers";
|
|
@@ -343,6 +343,26 @@ export const sweepOrdinals = {
|
|
|
343
343
|
}
|
|
344
344
|
// Sign each input with our external key
|
|
345
345
|
const tx = Transaction.fromBEEF(createResult.signableTransaction.tx);
|
|
346
|
+
// Log transaction structure for debugging
|
|
347
|
+
console.log(`[sweepOrdinals] === Transaction Structure ===`);
|
|
348
|
+
console.log(`[sweepOrdinals] Inputs (${tx.inputs.length}):`);
|
|
349
|
+
let totalInputSats = 0;
|
|
350
|
+
for (let i = 0; i < tx.inputs.length; i++) {
|
|
351
|
+
const inp = tx.inputs[i];
|
|
352
|
+
const sats = inp.sourceTransaction?.outputs[inp.sourceOutputIndex]?.satoshis ?? 0;
|
|
353
|
+
totalInputSats += sats;
|
|
354
|
+
console.log(` [${i}] ${inp.sourceTXID}:${inp.sourceOutputIndex} = ${sats} sats`);
|
|
355
|
+
}
|
|
356
|
+
console.log(`[sweepOrdinals] Outputs (${tx.outputs.length}):`);
|
|
357
|
+
let totalOutputSats = 0;
|
|
358
|
+
for (let i = 0; i < tx.outputs.length; i++) {
|
|
359
|
+
const out = tx.outputs[i];
|
|
360
|
+
totalOutputSats += out.satoshis ?? 0;
|
|
361
|
+
console.log(` [${i}] ${out.satoshis} sats, script len=${out.lockingScript?.toHex().length ?? 0}`);
|
|
362
|
+
}
|
|
363
|
+
console.log(`[sweepOrdinals] Total in: ${totalInputSats}, Total out: ${totalOutputSats}, Fee: ${totalInputSats - totalOutputSats}`);
|
|
364
|
+
console.log(`[sweepOrdinals] Signable tx hex: ${Utils.toHex(createResult.signableTransaction.tx)}`);
|
|
365
|
+
console.log(`[sweepOrdinals] ==============================`);
|
|
346
366
|
// Build a set of outpoints we control
|
|
347
367
|
const ourOutpoints = new Set(inputs.map((input) => {
|
|
348
368
|
const [txid, vout] = input.outpoint.split("_");
|
|
@@ -358,6 +378,8 @@ export const sweepOrdinals = {
|
|
|
358
378
|
}
|
|
359
379
|
}
|
|
360
380
|
await tx.sign();
|
|
381
|
+
// Log signed transaction
|
|
382
|
+
console.log(`[sweepOrdinals] Signed tx hex: ${tx.toHex()}`);
|
|
361
383
|
// Extract unlocking scripts for signAction
|
|
362
384
|
const spends = {};
|
|
363
385
|
for (let i = 0; i < tx.inputs.length; i++) {
|
|
@@ -11,7 +11,7 @@ type GetUtxoStatusResult = toolboxSdk.GetUtxoStatusResult;
|
|
|
11
11
|
type PostBeefResult = toolboxSdk.PostBeefResult;
|
|
12
12
|
type ServicesCallHistory = toolboxSdk.ServicesCallHistory;
|
|
13
13
|
type WalletServices = toolboxSdk.WalletServices;
|
|
14
|
-
import { ArcadeClient, BeefClient, Bsv21Client, ChaintracksClient, OrdfsClient, OwnerClient, TxoClient } from "./client";
|
|
14
|
+
import { ArcadeClient, BeefClient, Bsv21Client, ChaintracksClient, OrdfsClient, OverlayClient, OwnerClient, TxoClient } from "./client";
|
|
15
15
|
import type { Capability, SyncOutput } from "./types";
|
|
16
16
|
export type { SyncOutput };
|
|
17
17
|
/**
|
|
@@ -28,6 +28,7 @@ export type { SyncOutput };
|
|
|
28
28
|
* - /1sat/txo/* - Transaction outputs
|
|
29
29
|
* - /1sat/owner/* - Address queries and sync
|
|
30
30
|
* - /1sat/ordfs/* - Content/inscription serving
|
|
31
|
+
* - /overlay/* - Overlay services (topic managers, lookups)
|
|
31
32
|
*/
|
|
32
33
|
export declare class OneSatServices implements WalletServices {
|
|
33
34
|
chain: Chain;
|
|
@@ -39,6 +40,7 @@ export declare class OneSatServices implements WalletServices {
|
|
|
39
40
|
readonly owner: OwnerClient;
|
|
40
41
|
readonly ordfs: OrdfsClient;
|
|
41
42
|
readonly bsv21: Bsv21Client;
|
|
43
|
+
readonly overlay: OverlayClient;
|
|
42
44
|
private fallbackServices?;
|
|
43
45
|
/**
|
|
44
46
|
* URL for wallet storage sync endpoint (BRC-100 JSON-RPC).
|
|
@@ -13,7 +13,7 @@ class ServiceError extends Error {
|
|
|
13
13
|
this.name = code;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
import { ArcadeClient, BeefClient, Bsv21Client, ChaintracksClient, OrdfsClient, OwnerClient, TxoClient, } from "./client";
|
|
16
|
+
import { ArcadeClient, BeefClient, Bsv21Client, ChaintracksClient, OrdfsClient, OverlayClient, OwnerClient, TxoClient, } from "./client";
|
|
17
17
|
/**
|
|
18
18
|
* WalletServices implementation for 1Sat ecosystem.
|
|
19
19
|
*
|
|
@@ -28,6 +28,7 @@ import { ArcadeClient, BeefClient, Bsv21Client, ChaintracksClient, OrdfsClient,
|
|
|
28
28
|
* - /1sat/txo/* - Transaction outputs
|
|
29
29
|
* - /1sat/owner/* - Address queries and sync
|
|
30
30
|
* - /1sat/ordfs/* - Content/inscription serving
|
|
31
|
+
* - /overlay/* - Overlay services (topic managers, lookups)
|
|
31
32
|
*/
|
|
32
33
|
export class OneSatServices {
|
|
33
34
|
chain;
|
|
@@ -40,6 +41,7 @@ export class OneSatServices {
|
|
|
40
41
|
owner;
|
|
41
42
|
ordfs;
|
|
42
43
|
bsv21;
|
|
44
|
+
overlay;
|
|
43
45
|
// Optional fallback to wallet-toolbox Services for methods we don't implement
|
|
44
46
|
fallbackServices;
|
|
45
47
|
/**
|
|
@@ -65,6 +67,7 @@ export class OneSatServices {
|
|
|
65
67
|
this.owner = new OwnerClient(this.baseUrl, opts);
|
|
66
68
|
this.ordfs = new OrdfsClient(this.baseUrl, opts);
|
|
67
69
|
this.bsv21 = new Bsv21Client(this.baseUrl, opts);
|
|
70
|
+
this.overlay = new OverlayClient(this.baseUrl, opts);
|
|
68
71
|
}
|
|
69
72
|
// ===== Utility Methods =====
|
|
70
73
|
/**
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BaseClient } from "./BaseClient";
|
|
2
|
+
import type { ClientOptions } from "../types";
|
|
3
|
+
/** Topic manager metadata returned by listTopicManagers */
|
|
4
|
+
export interface TopicManagerInfo {
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
/** Lookup service provider metadata returned by listLookupServiceProviders */
|
|
8
|
+
export interface LookupServiceInfo {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Client for overlay service routes.
|
|
13
|
+
* Handles topic manager queries and overlay lookups.
|
|
14
|
+
*/
|
|
15
|
+
export declare class OverlayClient extends BaseClient {
|
|
16
|
+
constructor(baseUrl: string, options?: ClientOptions);
|
|
17
|
+
/**
|
|
18
|
+
* List all registered topic managers.
|
|
19
|
+
* BSV-21 tokens have topic managers named `tm_{tokenId}`.
|
|
20
|
+
*/
|
|
21
|
+
listTopicManagers(): Promise<Record<string, TopicManagerInfo>>;
|
|
22
|
+
/**
|
|
23
|
+
* List all registered lookup service providers.
|
|
24
|
+
*/
|
|
25
|
+
listLookupServiceProviders(): Promise<Record<string, LookupServiceInfo>>;
|
|
26
|
+
/**
|
|
27
|
+
* Get list of active BSV-21 token IDs from topic managers.
|
|
28
|
+
* Extracts tokenIds from topics matching the `tm_{tokenId}` pattern.
|
|
29
|
+
*/
|
|
30
|
+
getActiveBsv21TokenIds(): Promise<string[]>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BaseClient } from "./BaseClient";
|
|
2
|
+
/**
|
|
3
|
+
* Client for overlay service routes.
|
|
4
|
+
* Handles topic manager queries and overlay lookups.
|
|
5
|
+
*/
|
|
6
|
+
export class OverlayClient extends BaseClient {
|
|
7
|
+
constructor(baseUrl, options = {}) {
|
|
8
|
+
super(baseUrl, options);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* List all registered topic managers.
|
|
12
|
+
* BSV-21 tokens have topic managers named `tm_{tokenId}`.
|
|
13
|
+
*/
|
|
14
|
+
async listTopicManagers() {
|
|
15
|
+
return this.request("/overlay/listTopicManagers");
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* List all registered lookup service providers.
|
|
19
|
+
*/
|
|
20
|
+
async listLookupServiceProviders() {
|
|
21
|
+
return this.request("/overlay/listLookupServiceProviders");
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get list of active BSV-21 token IDs from topic managers.
|
|
25
|
+
* Extracts tokenIds from topics matching the `tm_{tokenId}` pattern.
|
|
26
|
+
*/
|
|
27
|
+
async getActiveBsv21TokenIds() {
|
|
28
|
+
const topicManagers = await this.listTopicManagers();
|
|
29
|
+
const tokenIds = [];
|
|
30
|
+
for (const topic of Object.keys(topicManagers)) {
|
|
31
|
+
if (topic.startsWith("tm_")) {
|
|
32
|
+
tokenIds.push(topic.slice(3));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return tokenIds;
|
|
36
|
+
}
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1sat/wallet-toolbox",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32",
|
|
4
4
|
"description": "BSV wallet library extending @bsv/wallet-toolbox with 1Sat Ordinals protocol support",
|
|
5
5
|
"author": "1Sat Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"fflate": "^0.8.2"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@bsv/wallet-toolbox-mobile": "npm:@bopen-io/wallet-toolbox-mobile@^1.7.20-idb-fix.
|
|
47
|
+
"@bsv/wallet-toolbox-mobile": "npm:@bopen-io/wallet-toolbox-mobile@^1.7.20-idb-fix.17"
|
|
48
48
|
},
|
|
49
49
|
"peerDependenciesMeta": {
|
|
50
50
|
"@bsv/wallet-toolbox-mobile": {
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@biomejs/biome": "^1.9.4",
|
|
56
|
-
"@bsv/wallet-toolbox": "npm:@bopen-io/wallet-toolbox@^1.7.20-idb-fix.
|
|
57
|
-
"@bsv/wallet-toolbox-mobile": "npm:@bopen-io/wallet-toolbox-mobile@^1.7.20-idb-fix.
|
|
56
|
+
"@bsv/wallet-toolbox": "npm:@bopen-io/wallet-toolbox@^1.7.20-idb-fix.17",
|
|
57
|
+
"@bsv/wallet-toolbox-mobile": "npm:@bopen-io/wallet-toolbox-mobile@^1.7.20-idb-fix.17",
|
|
58
58
|
"@types/bun": "^1.3.4",
|
|
59
59
|
"@types/chrome": "^0.1.32",
|
|
60
60
|
"typescript": "^5.9.3"
|