@1sat/wallet-toolbox 0.0.1
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/README.md +301 -0
- package/dist/OneSatWallet.d.ts +132 -0
- package/dist/errors.d.ts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +91681 -0
- package/dist/indexers/Bsv21Indexer.d.ts +35 -0
- package/dist/indexers/CosignIndexer.d.ts +13 -0
- package/dist/indexers/FundIndexer.d.ts +19 -0
- package/dist/indexers/InscriptionIndexer.d.ts +31 -0
- package/dist/indexers/LockIndexer.d.ts +10 -0
- package/dist/indexers/MapIndexer.d.ts +14 -0
- package/dist/indexers/OpNSIndexer.d.ts +9 -0
- package/dist/indexers/OrdLockIndexer.d.ts +17 -0
- package/dist/indexers/OriginIndexer.d.ts +23 -0
- package/dist/indexers/Outpoint.d.ts +9 -0
- package/dist/indexers/SigmaIndexer.d.ts +16 -0
- package/dist/indexers/TransactionParser.d.ts +53 -0
- package/dist/indexers/index.d.ts +15 -0
- package/dist/indexers/parseAddress.d.ts +9 -0
- package/dist/indexers/types.d.ts +99 -0
- package/dist/services/OneSatServices.d.ts +83 -0
- package/dist/signers/ReadOnlySigner.d.ts +15 -0
- package/package.json +47 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Indexer, type IndexData, type IndexSummary, type ParseContext } from "./types";
|
|
2
|
+
import type { OneSatServices } from "../services/OneSatServices";
|
|
3
|
+
export interface Bsv21 {
|
|
4
|
+
id: string;
|
|
5
|
+
op: string;
|
|
6
|
+
amt: bigint;
|
|
7
|
+
dec: number;
|
|
8
|
+
sym?: string;
|
|
9
|
+
icon?: string;
|
|
10
|
+
status: "valid" | "invalid" | "pending";
|
|
11
|
+
reason?: string;
|
|
12
|
+
fundAddress: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Bsv21Indexer identifies and validates BSV21 tokens.
|
|
16
|
+
* These are 1-sat outputs with application/bsv-20 inscription type.
|
|
17
|
+
*
|
|
18
|
+
* Data structure: Bsv21 with id, op, amt, dec, status, etc.
|
|
19
|
+
*
|
|
20
|
+
* Basket: 'bsv21'
|
|
21
|
+
* Events: address, id, status
|
|
22
|
+
*/
|
|
23
|
+
export declare class Bsv21Indexer extends Indexer {
|
|
24
|
+
owners: Set<string>;
|
|
25
|
+
network: "mainnet" | "testnet";
|
|
26
|
+
services: OneSatServices;
|
|
27
|
+
tag: string;
|
|
28
|
+
name: string;
|
|
29
|
+
constructor(owners: Set<string> | undefined, network: "mainnet" | "testnet" | undefined, services: OneSatServices);
|
|
30
|
+
parse(ctx: ParseContext, vout: number, _isBroadcasted: boolean): Promise<IndexData | undefined>;
|
|
31
|
+
summerize(ctx: ParseContext): Promise<IndexSummary | undefined>;
|
|
32
|
+
serialize(bsv21: Bsv21): string;
|
|
33
|
+
deserialize(str: string): Bsv21;
|
|
34
|
+
}
|
|
35
|
+
export declare function deriveFundAddress(idOrOutpoint: string | number[]): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Indexer, type IndexData, type ParseContext } from "./types";
|
|
2
|
+
export interface Cosign {
|
|
3
|
+
address: string;
|
|
4
|
+
cosigner: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class CosignIndexer extends Indexer {
|
|
7
|
+
owners: Set<string>;
|
|
8
|
+
network: "mainnet" | "testnet";
|
|
9
|
+
tag: string;
|
|
10
|
+
name: string;
|
|
11
|
+
constructor(owners?: Set<string>, network?: "mainnet" | "testnet");
|
|
12
|
+
parse(ctx: ParseContext, vout: number): Promise<IndexData | undefined>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Indexer, type IndexData, type IndexSummary, type ParseContext } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* FundIndexer identifies P2PKH outputs to owned addresses.
|
|
4
|
+
* These are standard "funding" UTXOs that can be spent normally.
|
|
5
|
+
*
|
|
6
|
+
* Data structure: string (address)
|
|
7
|
+
*
|
|
8
|
+
* Basket: 'fund'
|
|
9
|
+
* Tags: None
|
|
10
|
+
*/
|
|
11
|
+
export declare class FundIndexer extends Indexer {
|
|
12
|
+
owners: Set<string>;
|
|
13
|
+
network: "mainnet" | "testnet";
|
|
14
|
+
tag: string;
|
|
15
|
+
name: string;
|
|
16
|
+
constructor(owners?: Set<string>, network?: "mainnet" | "testnet");
|
|
17
|
+
parse(ctx: ParseContext, vout: number): Promise<IndexData | undefined>;
|
|
18
|
+
summerize(ctx: ParseContext): Promise<IndexSummary | undefined>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Indexer, type IndexData, type ParseContext } from "./types";
|
|
2
|
+
export interface File {
|
|
3
|
+
hash: string;
|
|
4
|
+
size: number;
|
|
5
|
+
type: string;
|
|
6
|
+
content: number[];
|
|
7
|
+
}
|
|
8
|
+
export interface Inscription {
|
|
9
|
+
file?: File;
|
|
10
|
+
fields?: {
|
|
11
|
+
[key: string]: string;
|
|
12
|
+
};
|
|
13
|
+
parent?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* InscriptionIndexer identifies and parses ordinal inscriptions.
|
|
17
|
+
* These are outputs with exactly 1 satoshi containing OP_FALSE OP_IF "ord" envelope.
|
|
18
|
+
*
|
|
19
|
+
* Data structure: Inscription with file, fields, and optional parent
|
|
20
|
+
*
|
|
21
|
+
* Basket: None (no basket assignment - this is preliminary data for other indexers)
|
|
22
|
+
* Events: address for owned outputs
|
|
23
|
+
*/
|
|
24
|
+
export declare class InscriptionIndexer extends Indexer {
|
|
25
|
+
owners: Set<string>;
|
|
26
|
+
network: "mainnet" | "testnet";
|
|
27
|
+
tag: string;
|
|
28
|
+
name: string;
|
|
29
|
+
constructor(owners?: Set<string>, network?: "mainnet" | "testnet");
|
|
30
|
+
parse(ctx: ParseContext, vout: number): Promise<IndexData | undefined>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Indexer, type IndexData, type IndexSummary, type ParseContext } from "./types";
|
|
2
|
+
export interface LockData {
|
|
3
|
+
until: number;
|
|
4
|
+
}
|
|
5
|
+
export declare class LockIndexer extends Indexer {
|
|
6
|
+
tag: string;
|
|
7
|
+
name: string;
|
|
8
|
+
parse(ctx: ParseContext, vout: number): Promise<IndexData | undefined>;
|
|
9
|
+
summerize(ctx: ParseContext): Promise<IndexSummary | undefined>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Script } from "@bsv/sdk";
|
|
2
|
+
import { Indexer, type IndexData, type ParseContext } from "./types";
|
|
3
|
+
export declare const MAP_PROTO = "1PuQa7K62MiKCtssSLKy1kh56WWU7MtUR5";
|
|
4
|
+
export declare class MapIndexer extends Indexer {
|
|
5
|
+
owners: Set<string>;
|
|
6
|
+
network: "mainnet" | "testnet";
|
|
7
|
+
tag: string;
|
|
8
|
+
name: string;
|
|
9
|
+
constructor(owners?: Set<string>, network?: "mainnet" | "testnet");
|
|
10
|
+
parse(ctx: ParseContext, vout: number): Promise<IndexData | undefined>;
|
|
11
|
+
static parseMap(script: Script, mapPos: number): {
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
} | undefined;
|
|
14
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Indexer, type IndexData, type ParseContext } from "./types";
|
|
2
|
+
export declare class OpNSIndexer extends Indexer {
|
|
3
|
+
owners: Set<string>;
|
|
4
|
+
network: "mainnet" | "testnet";
|
|
5
|
+
tag: string;
|
|
6
|
+
name: string;
|
|
7
|
+
constructor(owners?: Set<string>, network?: "mainnet" | "testnet");
|
|
8
|
+
parse(ctx: ParseContext, vout: number): Promise<IndexData | undefined>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Indexer, type IndexData, type ParseContext, type IndexSummary } from "./types";
|
|
2
|
+
export declare class Listing {
|
|
3
|
+
payout: number[];
|
|
4
|
+
price: bigint;
|
|
5
|
+
constructor(payout?: number[], price?: bigint);
|
|
6
|
+
}
|
|
7
|
+
export declare class OrdLockIndexer extends Indexer {
|
|
8
|
+
owners: Set<string>;
|
|
9
|
+
network: "mainnet" | "testnet";
|
|
10
|
+
tag: string;
|
|
11
|
+
name: string;
|
|
12
|
+
constructor(owners?: Set<string>, network?: "mainnet" | "testnet");
|
|
13
|
+
parse(ctx: ParseContext, vout: number): Promise<IndexData | undefined>;
|
|
14
|
+
summerize(ctx: ParseContext): Promise<IndexSummary | undefined>;
|
|
15
|
+
serialize(listing: Listing): string;
|
|
16
|
+
deserialize(str: string): Listing;
|
|
17
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Indexer, type IndexData, type ParseContext, type IndexSummary } from "./types";
|
|
2
|
+
import type { Inscription } from "./InscriptionIndexer";
|
|
3
|
+
import type { Sigma } from "./SigmaIndexer";
|
|
4
|
+
import type { OneSatServices } from "../services/OneSatServices";
|
|
5
|
+
export interface Origin {
|
|
6
|
+
outpoint?: string;
|
|
7
|
+
nonce?: number;
|
|
8
|
+
insc?: Inscription;
|
|
9
|
+
map?: {
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
};
|
|
12
|
+
sigma?: Sigma[];
|
|
13
|
+
}
|
|
14
|
+
export declare class OriginIndexer extends Indexer {
|
|
15
|
+
owners: Set<string>;
|
|
16
|
+
network: "mainnet" | "testnet";
|
|
17
|
+
private services;
|
|
18
|
+
tag: string;
|
|
19
|
+
name: string;
|
|
20
|
+
constructor(owners: Set<string> | undefined, network: "mainnet" | "testnet" | undefined, services: OneSatServices);
|
|
21
|
+
parse(ctx: ParseContext, vout: number): Promise<IndexData | undefined>;
|
|
22
|
+
summerize(ctx: ParseContext): Promise<IndexSummary | undefined>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Indexer, type IndexData, type ParseContext } from "./types";
|
|
2
|
+
export interface Sigma {
|
|
3
|
+
algorithm: string;
|
|
4
|
+
address: string;
|
|
5
|
+
signature: number[];
|
|
6
|
+
vin: number;
|
|
7
|
+
valid: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare class SigmaIndexer extends Indexer {
|
|
10
|
+
owners: Set<string>;
|
|
11
|
+
network: "mainnet" | "testnet";
|
|
12
|
+
tag: string;
|
|
13
|
+
name: string;
|
|
14
|
+
constructor(owners?: Set<string>, network?: "mainnet" | "testnet");
|
|
15
|
+
parse(ctx: ParseContext, vout: number): Promise<IndexData | undefined>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Transaction } from "@bsv/sdk";
|
|
2
|
+
import type { Indexer } from "./types";
|
|
3
|
+
import type { OneSatServices } from "../services/OneSatServices";
|
|
4
|
+
/**
|
|
5
|
+
* Represents the result of parsing a single output
|
|
6
|
+
*/
|
|
7
|
+
export interface ParsedOutput {
|
|
8
|
+
vout: number;
|
|
9
|
+
basket: string;
|
|
10
|
+
tags: string[];
|
|
11
|
+
customInstructions?: unknown;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Represents the result of parsing an entire transaction
|
|
15
|
+
*/
|
|
16
|
+
export interface ParseResult {
|
|
17
|
+
outputs: ParsedOutput[];
|
|
18
|
+
summary?: unknown;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* TransactionParser runs indexers over a transaction to extract
|
|
22
|
+
* basket, tags, and custom instructions for wallet-toolbox.
|
|
23
|
+
*
|
|
24
|
+
* This is a stripped-down version of TxoStore.ingest() that only
|
|
25
|
+
* handles parsing without SPV verification or storage.
|
|
26
|
+
*/
|
|
27
|
+
export declare class TransactionParser {
|
|
28
|
+
indexers: Indexer[];
|
|
29
|
+
owners: Set<string>;
|
|
30
|
+
private services;
|
|
31
|
+
constructor(indexers: Indexer[], owners: Set<string>, services: OneSatServices);
|
|
32
|
+
/**
|
|
33
|
+
* Parse a transaction and extract wallet-toolbox metadata
|
|
34
|
+
*/
|
|
35
|
+
parse(tx: Transaction, isBroadcasted: boolean): Promise<ParseResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Parse all inputs - run indexers on source outputs to populate ctx.spends
|
|
38
|
+
*/
|
|
39
|
+
private parseInputs;
|
|
40
|
+
/**
|
|
41
|
+
* Load source transactions for all inputs and set them on tx.inputs[].sourceTransaction
|
|
42
|
+
*/
|
|
43
|
+
private loadSourceTransactions;
|
|
44
|
+
/**
|
|
45
|
+
* Build minimal parse context from transaction
|
|
46
|
+
*/
|
|
47
|
+
private buildContext;
|
|
48
|
+
/**
|
|
49
|
+
* Convert parsed context to wallet-toolbox format with baskets and tags
|
|
50
|
+
* Filters outputs to only return those owned by addresses in the owners set
|
|
51
|
+
*/
|
|
52
|
+
private convertToWalletToolboxFormat;
|
|
53
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { Indexer, type IndexData, type IndexSummary, type ParseContext, type Txo } from "./types";
|
|
2
|
+
export type { Bsv21TokenData, Bsv21OutputData, Bsv21TransactionData } from "./types";
|
|
3
|
+
export { Outpoint } from "./Outpoint";
|
|
4
|
+
export { parseAddress } from "./parseAddress";
|
|
5
|
+
export { FundIndexer } from "./FundIndexer";
|
|
6
|
+
export { LockIndexer } from "./LockIndexer";
|
|
7
|
+
export { InscriptionIndexer, type File, type Inscription } from "./InscriptionIndexer";
|
|
8
|
+
export { SigmaIndexer, type Sigma } from "./SigmaIndexer";
|
|
9
|
+
export { MapIndexer, MAP_PROTO } from "./MapIndexer";
|
|
10
|
+
export { OriginIndexer, type Origin } from "./OriginIndexer";
|
|
11
|
+
export { Bsv21Indexer, deriveFundAddress, type Bsv21 } from "./Bsv21Indexer";
|
|
12
|
+
export { OrdLockIndexer, Listing } from "./OrdLockIndexer";
|
|
13
|
+
export { OpNSIndexer } from "./OpNSIndexer";
|
|
14
|
+
export { CosignIndexer, type Cosign } from "./CosignIndexer";
|
|
15
|
+
export { TransactionParser, type ParsedOutput, type ParseResult } from "./TransactionParser";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Script } from "@bsv/sdk";
|
|
2
|
+
/**
|
|
3
|
+
* Parse a P2PKH address from a locking script
|
|
4
|
+
* @param script - The locking script to parse
|
|
5
|
+
* @param offset - Chunk offset (default 0)
|
|
6
|
+
* @param network - Network type for address encoding
|
|
7
|
+
* @returns Base58Check encoded address or empty string if not P2PKH
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseAddress(script: Script, offset?: number, network?: "mainnet" | "testnet"): string;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { Transaction } from "@bsv/sdk";
|
|
2
|
+
import type { Outpoint } from "./Outpoint";
|
|
3
|
+
/**
|
|
4
|
+
* BSV21 token data structure from overlay API
|
|
5
|
+
*/
|
|
6
|
+
export interface Bsv21TokenData {
|
|
7
|
+
id: string;
|
|
8
|
+
op: string;
|
|
9
|
+
amt: string;
|
|
10
|
+
sym?: string;
|
|
11
|
+
dec?: number;
|
|
12
|
+
icon?: string;
|
|
13
|
+
address?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* BSV21 output data from overlay API
|
|
17
|
+
*/
|
|
18
|
+
export interface Bsv21OutputData {
|
|
19
|
+
txid: string;
|
|
20
|
+
vout: number;
|
|
21
|
+
data: {
|
|
22
|
+
bsv21: Bsv21TokenData;
|
|
23
|
+
};
|
|
24
|
+
script: string;
|
|
25
|
+
satoshis: number;
|
|
26
|
+
spend: string | null;
|
|
27
|
+
score: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* BSV21 transaction data from overlay API
|
|
31
|
+
*/
|
|
32
|
+
export interface Bsv21TransactionData {
|
|
33
|
+
txid: string;
|
|
34
|
+
inputs: Bsv21OutputData[];
|
|
35
|
+
outputs: Bsv21OutputData[];
|
|
36
|
+
beef?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* IndexData contains the parsed data and tags from an indexer
|
|
40
|
+
* Tags are concatenated strings in the format "key:value" for searchability
|
|
41
|
+
*/
|
|
42
|
+
export interface IndexData {
|
|
43
|
+
data: unknown;
|
|
44
|
+
tags: string[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* IndexSummary contains transaction-level summary information
|
|
48
|
+
*/
|
|
49
|
+
export interface IndexSummary {
|
|
50
|
+
id?: string;
|
|
51
|
+
amount?: number;
|
|
52
|
+
icon?: string;
|
|
53
|
+
data?: unknown;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Minimal transaction output structure used during parsing
|
|
57
|
+
*/
|
|
58
|
+
export interface Txo {
|
|
59
|
+
satoshis: bigint;
|
|
60
|
+
script: number[];
|
|
61
|
+
owner?: string;
|
|
62
|
+
basket?: string;
|
|
63
|
+
data: {
|
|
64
|
+
[tag: string]: IndexData;
|
|
65
|
+
};
|
|
66
|
+
outpoint: Outpoint;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Minimal context structure for indexer parsing
|
|
70
|
+
*/
|
|
71
|
+
export interface ParseContext {
|
|
72
|
+
tx: Transaction;
|
|
73
|
+
txid: string;
|
|
74
|
+
txos: Txo[];
|
|
75
|
+
spends: Txo[];
|
|
76
|
+
summary: {
|
|
77
|
+
[tag: string]: IndexSummary;
|
|
78
|
+
};
|
|
79
|
+
indexers: Indexer[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Base indexer class that all indexers extend
|
|
83
|
+
*/
|
|
84
|
+
export declare abstract class Indexer {
|
|
85
|
+
owners: Set<string>;
|
|
86
|
+
network: "mainnet" | "testnet";
|
|
87
|
+
abstract tag: string;
|
|
88
|
+
abstract name: string;
|
|
89
|
+
constructor(owners?: Set<string>, network?: "mainnet" | "testnet");
|
|
90
|
+
/**
|
|
91
|
+
* Parses an output and returns the index data if it is relevant to this indexer.
|
|
92
|
+
* If the output is not relevant, it returns undefined.
|
|
93
|
+
*/
|
|
94
|
+
abstract parse(ctx: ParseContext, vout: number, isBroadcasted: boolean): Promise<IndexData | undefined>;
|
|
95
|
+
/**
|
|
96
|
+
* Evaluates the index data for the entire transaction and returns a summary.
|
|
97
|
+
*/
|
|
98
|
+
summerize(_ctx: ParseContext, _isBroadcasted: boolean): Promise<IndexSummary | undefined>;
|
|
99
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Beef, ChainTracker, Transaction } from "@bsv/sdk";
|
|
2
|
+
import type { WalletStorageManager } from "@bsv/wallet-toolbox/mobile";
|
|
3
|
+
import type { WalletServices, GetRawTxResult, GetMerklePathResult, PostBeefResult, GetUtxoStatusResult, GetStatusForTxidsResult, GetScriptHashHistoryResult, BlockHeader, GetUtxoStatusOutputFormat, ServicesCallHistory } from "@bsv/wallet-toolbox/mobile/out/src/sdk/WalletServices.interfaces";
|
|
4
|
+
import type { Chain } from "@bsv/wallet-toolbox/mobile/out/src/sdk/types";
|
|
5
|
+
import type { TableOutput } from "@bsv/wallet-toolbox/mobile/out/src/storage/schema/tables/TableOutput";
|
|
6
|
+
import type { Bsv21TransactionData } from "../indexers/types";
|
|
7
|
+
/**
|
|
8
|
+
* OrdFS metadata response structure
|
|
9
|
+
*/
|
|
10
|
+
export interface OrdfsMetadata {
|
|
11
|
+
outpoint: string;
|
|
12
|
+
origin?: string;
|
|
13
|
+
sequence: number;
|
|
14
|
+
contentType: string;
|
|
15
|
+
contentLength: number;
|
|
16
|
+
parent?: string;
|
|
17
|
+
map?: {
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* BSV21 token details from the overlay
|
|
23
|
+
*/
|
|
24
|
+
export interface Bsv21TokenDetails {
|
|
25
|
+
id: string;
|
|
26
|
+
txid: string;
|
|
27
|
+
vout: number;
|
|
28
|
+
op: string;
|
|
29
|
+
amt: string;
|
|
30
|
+
sym?: string;
|
|
31
|
+
dec: number;
|
|
32
|
+
icon?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* WalletServices implementation for 1Sat ecosystem.
|
|
36
|
+
*
|
|
37
|
+
* Data sources:
|
|
38
|
+
* - ordfs-server - Block headers, merkle proofs, raw transactions
|
|
39
|
+
* - OneSat API - Transaction broadcasting
|
|
40
|
+
*/
|
|
41
|
+
export declare class OneSatServices implements WalletServices {
|
|
42
|
+
chain: Chain;
|
|
43
|
+
private ordfsBaseUrl;
|
|
44
|
+
readonly onesatBaseUrl: string;
|
|
45
|
+
private bsv21TokenCache;
|
|
46
|
+
private chainTracker;
|
|
47
|
+
private storage?;
|
|
48
|
+
constructor(chain: Chain, ordfsUrl?: string, onesatUrl?: string, storage?: WalletStorageManager);
|
|
49
|
+
getChainTracker(): Promise<ChainTracker>;
|
|
50
|
+
getHeaderForHeight(height: number): Promise<number[]>;
|
|
51
|
+
getHeight(): Promise<number>;
|
|
52
|
+
getBsvExchangeRate(): Promise<number>;
|
|
53
|
+
getFiatExchangeRate(_currency: "USD" | "GBP" | "EUR", _base?: "USD" | "GBP" | "EUR"): Promise<number>;
|
|
54
|
+
getRawTx(txid: string, _useNext?: boolean): Promise<GetRawTxResult>;
|
|
55
|
+
getMerklePath(txid: string, _useNext?: boolean): Promise<GetMerklePathResult>;
|
|
56
|
+
postBeef(beef: Beef, txids: string[]): Promise<PostBeefResult[]>;
|
|
57
|
+
hashOutputScript(script: string): string;
|
|
58
|
+
getStatusForTxids(_txids: string[], _useNext?: boolean): Promise<GetStatusForTxidsResult>;
|
|
59
|
+
isUtxo(_output: TableOutput): Promise<boolean>;
|
|
60
|
+
getUtxoStatus(_output: string, _outputFormat?: GetUtxoStatusOutputFormat, _outpoint?: string, _useNext?: boolean): Promise<GetUtxoStatusResult>;
|
|
61
|
+
getScriptHashHistory(_hash: string, _useNext?: boolean): Promise<GetScriptHashHistoryResult>;
|
|
62
|
+
hashToHeader(_hash: string): Promise<BlockHeader>;
|
|
63
|
+
nLockTimeIsFinal(_txOrLockTime: string | number[] | Transaction | number): Promise<boolean>;
|
|
64
|
+
getBeefBytes(txid: string): Promise<number[]>;
|
|
65
|
+
getBeefForTxid(txid: string): Promise<Beef>;
|
|
66
|
+
/**
|
|
67
|
+
* Get OrdFS metadata for an outpoint
|
|
68
|
+
* @throws {HttpError} on HTTP errors (check status for specifics)
|
|
69
|
+
*/
|
|
70
|
+
getOrdfsMetadata(outpoint: string): Promise<OrdfsMetadata>;
|
|
71
|
+
/**
|
|
72
|
+
* Get BSV21 token data by txid from the overlay
|
|
73
|
+
* @throws {HttpError} on HTTP errors (check status for specifics)
|
|
74
|
+
*/
|
|
75
|
+
getBsv21TokenByTxid(_tokenId: string, txid: string): Promise<Bsv21TransactionData>;
|
|
76
|
+
/**
|
|
77
|
+
* Get BSV21 token details (metadata) by token ID
|
|
78
|
+
* Results are cached since token details are immutable
|
|
79
|
+
* @throws {HttpError} on HTTP errors (check status for specifics)
|
|
80
|
+
*/
|
|
81
|
+
getBsv21TokenDetails(tokenId: string): Promise<Bsv21TokenDetails>;
|
|
82
|
+
getServicesCallHistory(_reset?: boolean): ServicesCallHistory;
|
|
83
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type KeyDeriverApi, type PrivateKey, type WalletProtocol, type Counterparty } from "@bsv/sdk";
|
|
2
|
+
/**
|
|
3
|
+
* A read-only KeyDeriver that exposes an identity key but throws on any signing/derivation operation.
|
|
4
|
+
* Used when the wallet is instantiated with only a public key.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ReadOnlySigner implements KeyDeriverApi {
|
|
7
|
+
readonly identityKey: string;
|
|
8
|
+
readonly rootKey: PrivateKey;
|
|
9
|
+
constructor(identityPublicKey: string);
|
|
10
|
+
derivePrivateKey(_protocolID: WalletProtocol, _keyID: string, _counterparty: Counterparty): never;
|
|
11
|
+
derivePublicKey(_protocolID: WalletProtocol, _keyID: string, _counterparty: Counterparty, _forSelf?: boolean): never;
|
|
12
|
+
deriveSymmetricKey(_protocolID: WalletProtocol, _keyID: string, _counterparty: Counterparty): never;
|
|
13
|
+
revealCounterpartySecret(_counterparty: Counterparty): never;
|
|
14
|
+
revealSpecificSecret(_counterparty: Counterparty, _protocolID: WalletProtocol, _keyID: string): never;
|
|
15
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@1sat/wallet-toolbox",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "BSV wallet library extending @bsv/wallet-toolbox with 1Sat Ordinals protocol support",
|
|
5
|
+
"author": "1Sat Team",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/b-open-io/1sat-wallet-toolbox.git"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"bsv",
|
|
13
|
+
"bitcoin",
|
|
14
|
+
"ordinals",
|
|
15
|
+
"1sat",
|
|
16
|
+
"wallet"
|
|
17
|
+
],
|
|
18
|
+
"type": "module",
|
|
19
|
+
"main": "dist/index.js",
|
|
20
|
+
"types": "dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "bun build ./src/index.ts --outdir ./dist --target browser --define 'process.env={}' --define 'global=globalThis' --sourcemap=inline && tsc --emitDeclarationOnly",
|
|
32
|
+
"dev": "tsc --watch",
|
|
33
|
+
"lint": "biome check src",
|
|
34
|
+
"lint:fix": "biome check --write src",
|
|
35
|
+
"test": "bun test"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@bsv/sdk": "^1.9.24",
|
|
39
|
+
"@bsv/wallet-toolbox": "^1.7.14",
|
|
40
|
+
"buffer": "^6.0.3"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@biomejs/biome": "^1.9.4",
|
|
44
|
+
"@types/bun": "^1.3.4",
|
|
45
|
+
"typescript": "^5.9.3"
|
|
46
|
+
}
|
|
47
|
+
}
|