@bsv/sdk 2.0.12 → 2.0.14
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 +2 -0
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/auth/clients/__tests__/AuthFetch.additional.test.js +827 -0
- package/dist/cjs/src/auth/clients/__tests__/AuthFetch.additional.test.js.map +1 -0
- package/dist/cjs/src/auth/transports/__tests__/SimplifiedFetchTransport.additional.test.js +654 -0
- package/dist/cjs/src/auth/transports/__tests__/SimplifiedFetchTransport.additional.test.js.map +1 -0
- package/dist/cjs/src/identity/IdentityClient.js +3 -3
- package/dist/cjs/src/identity/IdentityClient.js.map +1 -1
- package/dist/cjs/src/identity/types/index.js +1 -1
- package/dist/cjs/src/identity/types/index.js.map +1 -1
- package/dist/cjs/src/storage/StorageUploader.js +315 -96
- package/dist/cjs/src/storage/StorageUploader.js.map +1 -1
- package/dist/cjs/src/storage/index.js +3 -1
- package/dist/cjs/src/storage/index.js.map +1 -1
- package/dist/cjs/src/transaction/MerklePath.js +132 -0
- package/dist/cjs/src/transaction/MerklePath.js.map +1 -1
- package/dist/cjs/src/wallet/WERR_REVIEW_ACTIONS.js +2 -2
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/auth/clients/__tests__/AuthFetch.additional.test.js +825 -0
- package/dist/esm/src/auth/clients/__tests__/AuthFetch.additional.test.js.map +1 -0
- package/dist/esm/src/auth/transports/__tests__/SimplifiedFetchTransport.additional.test.js +619 -0
- package/dist/esm/src/auth/transports/__tests__/SimplifiedFetchTransport.additional.test.js.map +1 -0
- package/dist/esm/src/identity/IdentityClient.js +3 -3
- package/dist/esm/src/identity/IdentityClient.js.map +1 -1
- package/dist/esm/src/identity/types/index.js +1 -1
- package/dist/esm/src/identity/types/index.js.map +1 -1
- package/dist/esm/src/storage/StorageUploader.js +319 -95
- package/dist/esm/src/storage/StorageUploader.js.map +1 -1
- package/dist/esm/src/storage/index.js +1 -1
- package/dist/esm/src/storage/index.js.map +1 -1
- package/dist/esm/src/transaction/MerklePath.js +132 -0
- package/dist/esm/src/transaction/MerklePath.js.map +1 -1
- package/dist/esm/src/wallet/WERR_REVIEW_ACTIONS.js +2 -2
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/auth/clients/__tests__/AuthFetch.additional.test.d.ts +21 -0
- package/dist/types/src/auth/clients/__tests__/AuthFetch.additional.test.d.ts.map +1 -0
- package/dist/types/src/auth/transports/__tests__/SimplifiedFetchTransport.additional.test.d.ts +2 -0
- package/dist/types/src/auth/transports/__tests__/SimplifiedFetchTransport.additional.test.d.ts.map +1 -0
- package/dist/types/src/storage/StorageUploader.d.ts +94 -55
- package/dist/types/src/storage/StorageUploader.d.ts.map +1 -1
- package/dist/types/src/storage/index.d.ts +1 -1
- package/dist/types/src/storage/index.d.ts.map +1 -1
- package/dist/types/src/transaction/MerklePath.d.ts +27 -0
- package/dist/types/src/transaction/MerklePath.d.ts.map +1 -1
- package/dist/types/src/wallet/WERR_REVIEW_ACTIONS.d.ts +2 -2
- package/dist/types/src/wallet/Wallet.interfaces.d.ts +2 -2
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +4 -4
- package/dist/umd/bundle.js.map +1 -1
- package/docs/index.md +3 -1
- package/docs/reference/identity.md +1 -1
- package/docs/reference/storage.md +215 -86
- package/docs/reference/transaction.md +40 -0
- package/docs/reference/wallet.md +4 -4
- package/package.json +1 -1
- package/src/auth/clients/__tests__/AuthFetch.additional.test.ts +1131 -0
- package/src/auth/transports/__tests__/SimplifiedFetchTransport.additional.test.ts +770 -0
- package/src/compat/__tests/Mnemonic.additional.test.ts +64 -0
- package/src/identity/IdentityClient.ts +3 -3
- package/src/identity/__tests/IdentityClient.additional.test.ts +767 -0
- package/src/identity/types/index.ts +1 -1
- package/src/kvstore/__tests/LocalKVStore.additional.test.ts +611 -0
- package/src/kvstore/__tests/kvStoreInterpreter.test.ts +327 -0
- package/src/overlay-tools/__tests/HostReputationTracker.additional.test.ts +561 -0
- package/src/overlay-tools/__tests/LookupResolver.additional.test.ts +612 -0
- package/src/overlay-tools/__tests/withDoubleSpendRetry.test.ts +278 -0
- package/src/primitives/__tests/BigNumber.additional.test.ts +79 -0
- package/src/primitives/__tests/Curve.additional.test.ts +208 -0
- package/src/primitives/__tests/ECDSA.additional.test.ts +122 -0
- package/src/primitives/__tests/Hash.additional.test.ts +59 -0
- package/src/primitives/__tests/JacobianPoint.test.ts +308 -0
- package/src/primitives/__tests/Point.additional.test.ts +503 -0
- package/src/primitives/__tests/PublicKey.additional.test.ts +383 -0
- package/src/primitives/__tests/Random.additional.test.ts +262 -0
- package/src/primitives/__tests/Signature.test.ts +333 -0
- package/src/primitives/__tests/TransactionSignature.additional.test.ts +241 -0
- package/src/registry/__tests/RegistryClient.additional.test.ts +750 -0
- package/src/remittance/__tests/BasicBRC29.additional.test.ts +657 -0
- package/src/remittance/__tests/RemittanceManager.additional.test.ts +1272 -0
- package/src/script/__tests/LockingUnlockingScript.test.ts +79 -0
- package/src/script/__tests/Script.additional.test.ts +100 -0
- package/src/script/__tests/ScriptEvaluationError.test.ts +98 -0
- package/src/script/__tests/Spend.additional.test.ts +837 -0
- package/src/script/templates/__tests/RPuzzle.test.ts +134 -0
- package/src/storage/StorageUploader.ts +427 -105
- package/src/storage/__tests/StorageUploader.test.ts +881 -64
- package/src/storage/index.ts +1 -1
- package/src/transaction/MerklePath.ts +155 -0
- package/src/transaction/__tests/BeefParty.additional.test.ts +22 -0
- package/src/transaction/__tests/Broadcaster.test.ts +159 -0
- package/src/transaction/__tests/MerklePath.bench.test.ts +105 -0
- package/src/transaction/__tests/MerklePath.test.ts +80 -0
- package/src/transaction/__tests/Transaction.additional.test.ts +225 -0
- package/src/transaction/broadcasters/__tests/ARC.additional.test.ts +585 -0
- package/src/transaction/broadcasters/__tests/Teranode.test.ts +349 -0
- package/src/transaction/chaintrackers/__tests/BlockHeadersService.test.ts +253 -0
- package/src/transaction/chaintrackers/__tests/DefaultChainTracker.test.ts +44 -0
- package/src/transaction/chaintrackers/__tests/WhatsOnChain.additional.test.ts +193 -0
- package/src/transaction/fee-models/__tests/SatoshisPerKilobyte.test.ts +262 -0
- package/src/transaction/http/__tests/BinaryFetchClient.test.ts +212 -0
- package/src/transaction/http/__tests/DefaultHttpClient.additional.test.ts +192 -0
- package/src/transaction/http/__tests/DefaultHttpClient.test.ts +71 -0
- package/src/wallet/WERR_REVIEW_ACTIONS.ts +2 -2
- package/src/wallet/Wallet.interfaces.ts +2 -2
- package/src/wallet/__tests/ProtoWallet.additional.test.ts +134 -0
- package/src/wallet/__tests/WERR.test.ts +212 -0
- package/src/wallet/__tests/WalletClient.additional.test.ts +699 -0
- package/src/wallet/__tests/WalletClient.substrate.test.ts +759 -0
- package/src/wallet/__tests/WalletError.test.ts +290 -0
- package/src/wallet/__tests/validationHelpers.test.ts +1218 -0
- package/src/wallet/substrates/__tests/HTTPWalletJSON.test.ts +496 -0
- package/src/wallet/substrates/__tests/HTTPWalletWire.test.ts +273 -0
package/docs/index.md
CHANGED
|
@@ -29,6 +29,8 @@ const { WalletClient, PrivateKey, Transaction } = require("@bsv/sdk");
|
|
|
29
29
|
|
|
30
30
|
This interface is what most application developers will use to interact with the BSV blockchain.
|
|
31
31
|
|
|
32
|
+
BSV Desktop and BSV Browser are the BSV Association reference implementations for BRC-100. Vendor distributions, including Babbage's Metanet Desktop / Metanet Explorer and Hudos Browser, can implement the same interface with their own branding and service defaults.
|
|
33
|
+
|
|
32
34
|
🚀 **[WalletClient Quickstart](https://fast.brc.dev/)**
|
|
33
35
|
|
|
34
36
|
- Run SDK code examples without any setup
|
|
@@ -53,7 +55,7 @@ Finally, you can deep dive into the details of the interface and types in the re
|
|
|
53
55
|
- [Primitives](./reference/primitives.md)
|
|
54
56
|
- [Script](./reference/script.md)
|
|
55
57
|
- [Transaction](./reference/transaction.md)
|
|
56
|
-
- [Mutual
|
|
58
|
+
- [Mutual Authentication](./reference/auth.md)
|
|
57
59
|
- [Identity](./reference/identity.md)
|
|
58
60
|
- [Overlay Tools](./reference/overlay-tools.md)
|
|
59
61
|
- [Registry](./reference/registry.md)
|
|
@@ -372,7 +372,7 @@ defaultIdentity: DisplayableIdentity = {
|
|
|
372
372
|
abbreviatedKey: "",
|
|
373
373
|
badgeIconURL: "XUUV39HVPkpmMzYNTx7rpKzJvXfeiVyQWg2vfSpjBAuhunTCA9uG",
|
|
374
374
|
badgeLabel: "Not verified by anyone you trust.",
|
|
375
|
-
badgeClickURL: "https://
|
|
375
|
+
badgeClickURL: "https://bsv-blockchain.github.io/ts-sdk/reference/identity/"
|
|
376
376
|
}
|
|
377
377
|
```
|
|
378
378
|
|
|
@@ -8,8 +8,11 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
8
8
|
| --- |
|
|
9
9
|
| [DownloadResult](#interface-downloadresult) |
|
|
10
10
|
| [DownloaderConfig](#interface-downloaderconfig) |
|
|
11
|
+
| [EstimateCostResult](#interface-estimatecostresult) |
|
|
11
12
|
| [FindFileData](#interface-findfiledata) |
|
|
13
|
+
| [HostScopeOptions](#interface-hostscopeoptions) |
|
|
12
14
|
| [RenewFileResult](#interface-renewfileresult) |
|
|
15
|
+
| [RenewPerHostResult](#interface-renewperhostresult) |
|
|
13
16
|
| [UploadFileResult](#interface-uploadfileresult) |
|
|
14
17
|
| [UploadableFile](#interface-uploadablefile) |
|
|
15
18
|
| [UploaderConfig](#interface-uploaderconfig) |
|
|
@@ -40,6 +43,50 @@ export interface DownloaderConfig {
|
|
|
40
43
|
|
|
41
44
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
42
45
|
|
|
46
|
+
---
|
|
47
|
+
### Interface: EstimateCostResult
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
export interface EstimateCostResult {
|
|
51
|
+
quotes: Array<{
|
|
52
|
+
host: string;
|
|
53
|
+
amount: number;
|
|
54
|
+
}>;
|
|
55
|
+
resilienceLevel: number;
|
|
56
|
+
totalForResilience: number;
|
|
57
|
+
meetsResilienceThreshold: boolean;
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
#### Property meetsResilienceThreshold
|
|
62
|
+
|
|
63
|
+
False when `publishFile` would throw without uploading.
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
meetsResilienceThreshold: boolean
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### Property quotes
|
|
70
|
+
|
|
71
|
+
Cheapest-first quotes from configured providers.
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
quotes: Array<{
|
|
75
|
+
host: string;
|
|
76
|
+
amount: number;
|
|
77
|
+
}>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### Property totalForResilience
|
|
81
|
+
|
|
82
|
+
Sum of the cheapest `resilienceLevel` amounts (or all collected, if below threshold).
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
totalForResilience: number
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
89
|
+
|
|
43
90
|
---
|
|
44
91
|
### Interface: FindFileData
|
|
45
92
|
|
|
@@ -49,9 +96,37 @@ export interface FindFileData {
|
|
|
49
96
|
size: string;
|
|
50
97
|
mimeType: string;
|
|
51
98
|
expiryTime: number;
|
|
99
|
+
hostedBy?: string[];
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### Property hostedBy
|
|
104
|
+
|
|
105
|
+
Providers that reported this UHRP URL. Omitted in single-host mode.
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
hostedBy?: string[]
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
### Interface: HostScopeOptions
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
export interface HostScopeOptions {
|
|
118
|
+
hostedBy?: string[];
|
|
52
119
|
}
|
|
53
120
|
```
|
|
54
121
|
|
|
122
|
+
#### Property hostedBy
|
|
123
|
+
|
|
124
|
+
Restrict the operation to this subset of configured providers.
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
hostedBy?: string[]
|
|
128
|
+
```
|
|
129
|
+
|
|
55
130
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
56
131
|
|
|
57
132
|
---
|
|
@@ -63,6 +138,42 @@ export interface RenewFileResult {
|
|
|
63
138
|
prevExpiryTime?: number;
|
|
64
139
|
newExpiryTime?: number;
|
|
65
140
|
amount?: number;
|
|
141
|
+
results?: RenewPerHostResult[];
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
See also: [RenewPerHostResult](./storage.md#interface-renewperhostresult)
|
|
146
|
+
|
|
147
|
+
#### Property amount
|
|
148
|
+
|
|
149
|
+
Total satoshis paid across every host that renewed.
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
amount?: number
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
#### Property results
|
|
156
|
+
|
|
157
|
+
Per-host outcomes. Omitted in single-host mode.
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
results?: RenewPerHostResult[]
|
|
161
|
+
```
|
|
162
|
+
See also: [RenewPerHostResult](./storage.md#interface-renewperhostresult)
|
|
163
|
+
|
|
164
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
### Interface: RenewPerHostResult
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
export interface RenewPerHostResult {
|
|
171
|
+
host: string;
|
|
172
|
+
status: "success" | "error";
|
|
173
|
+
prevExpiryTime?: number;
|
|
174
|
+
newExpiryTime?: number;
|
|
175
|
+
amount?: number;
|
|
176
|
+
error?: string;
|
|
66
177
|
}
|
|
67
178
|
```
|
|
68
179
|
|
|
@@ -75,9 +186,18 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
75
186
|
export interface UploadFileResult {
|
|
76
187
|
published: boolean;
|
|
77
188
|
uhrpURL: string;
|
|
189
|
+
hostedBy: string[];
|
|
78
190
|
}
|
|
79
191
|
```
|
|
80
192
|
|
|
193
|
+
#### Property hostedBy
|
|
194
|
+
|
|
195
|
+
Providers that successfully hosted the file.
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
hostedBy: string[]
|
|
199
|
+
```
|
|
200
|
+
|
|
81
201
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
82
202
|
|
|
83
203
|
---
|
|
@@ -97,13 +217,39 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
97
217
|
|
|
98
218
|
```ts
|
|
99
219
|
export interface UploaderConfig {
|
|
100
|
-
storageURL
|
|
220
|
+
storageURL?: string;
|
|
221
|
+
storageURLs?: string[];
|
|
222
|
+
resilienceLevel?: number;
|
|
101
223
|
wallet: WalletInterface;
|
|
102
224
|
}
|
|
103
225
|
```
|
|
104
226
|
|
|
105
227
|
See also: [WalletInterface](./wallet.md#interface-walletinterface)
|
|
106
228
|
|
|
229
|
+
#### Property resilienceLevel
|
|
230
|
+
|
|
231
|
+
Minimum replicas to store the file on. Defaults to 1.
|
|
232
|
+
|
|
233
|
+
```ts
|
|
234
|
+
resilienceLevel?: number
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
#### Property storageURL
|
|
238
|
+
|
|
239
|
+
Legacy single-host URL. Mutually exclusive with `storageURLs`.
|
|
240
|
+
|
|
241
|
+
```ts
|
|
242
|
+
storageURL?: string
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
#### Property storageURLs
|
|
246
|
+
|
|
247
|
+
Explicit provider list. Takes precedence over `storageURL`.
|
|
248
|
+
|
|
249
|
+
```ts
|
|
250
|
+
storageURLs?: string[]
|
|
251
|
+
```
|
|
252
|
+
|
|
107
253
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
108
254
|
|
|
109
255
|
---
|
|
@@ -111,6 +257,7 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
111
257
|
|
|
112
258
|
| |
|
|
113
259
|
| --- |
|
|
260
|
+
| [RenewResiliencyError](#class-renewresiliencyerror) |
|
|
114
261
|
| [StorageDownloader](#class-storagedownloader) |
|
|
115
262
|
| [StorageUploader](#class-storageuploader) |
|
|
116
263
|
|
|
@@ -118,6 +265,26 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
118
265
|
|
|
119
266
|
---
|
|
120
267
|
|
|
268
|
+
### Class: RenewResiliencyError
|
|
269
|
+
|
|
270
|
+
Thrown by `renewFile` when successful renewals fall below the resilience
|
|
271
|
+
threshold. Per-host outcomes are attached so callers can reconcile which
|
|
272
|
+
providers were billed.
|
|
273
|
+
|
|
274
|
+
```ts
|
|
275
|
+
export class RenewResiliencyError extends Error {
|
|
276
|
+
readonly results: RenewPerHostResult[];
|
|
277
|
+
readonly requiredSuccesses: number;
|
|
278
|
+
readonly successCount: number;
|
|
279
|
+
constructor(message: string, results: RenewPerHostResult[], requiredSuccesses: number, successCount: number)
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
See also: [RenewPerHostResult](./storage.md#interface-renewperhostresult)
|
|
284
|
+
|
|
285
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
286
|
+
|
|
287
|
+
---
|
|
121
288
|
### Class: StorageDownloader
|
|
122
289
|
|
|
123
290
|
```ts
|
|
@@ -170,87 +337,70 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
170
337
|
---
|
|
171
338
|
### Class: StorageUploader
|
|
172
339
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
- Finding file metadata by UHRP URL
|
|
176
|
-
- Listing all user uploads
|
|
177
|
-
- Renewing an existing advertisement's expiry time
|
|
340
|
+
Client for publishing, finding, listing, and renewing UHRP-hosted files
|
|
341
|
+
across one or more storage providers.
|
|
178
342
|
|
|
179
343
|
```ts
|
|
180
344
|
export class StorageUploader {
|
|
181
345
|
constructor(config: UploaderConfig)
|
|
346
|
+
public async estimateCost(params: {
|
|
347
|
+
fileSize: number;
|
|
348
|
+
retentionPeriod: number;
|
|
349
|
+
}): Promise<EstimateCostResult>
|
|
182
350
|
public async publishFile(params: {
|
|
183
351
|
file: UploadableFile;
|
|
184
352
|
retentionPeriod: number;
|
|
185
353
|
}): Promise<UploadFileResult>
|
|
186
|
-
public async findFile(uhrpUrl: string): Promise<FindFileData>
|
|
187
|
-
public async listUploads(): Promise<any>
|
|
188
|
-
public async renewFile(uhrpUrl: string, additionalMinutes: number): Promise<RenewFileResult>
|
|
354
|
+
public async findFile(uhrpUrl: string, options: HostScopeOptions = {}): Promise<FindFileData>
|
|
355
|
+
public async listUploads(options: HostScopeOptions = {}): Promise<any>
|
|
356
|
+
public async renewFile(uhrpUrl: string, additionalMinutes: number, options: HostScopeOptions = {}): Promise<RenewFileResult>
|
|
189
357
|
}
|
|
190
358
|
```
|
|
191
359
|
|
|
192
|
-
See also: [FindFileData](./storage.md#interface-findfiledata), [RenewFileResult](./storage.md#interface-renewfileresult), [UploadFileResult](./storage.md#interface-uploadfileresult), [UploadableFile](./storage.md#interface-uploadablefile), [UploaderConfig](./storage.md#interface-uploaderconfig)
|
|
360
|
+
See also: [EstimateCostResult](./storage.md#interface-estimatecostresult), [FindFileData](./storage.md#interface-findfiledata), [HostScopeOptions](./storage.md#interface-hostscopeoptions), [RenewFileResult](./storage.md#interface-renewfileresult), [UploadFileResult](./storage.md#interface-uploadfileresult), [UploadableFile](./storage.md#interface-uploadablefile), [UploaderConfig](./storage.md#interface-uploaderconfig)
|
|
193
361
|
|
|
194
|
-
####
|
|
362
|
+
#### Method estimateCost
|
|
195
363
|
|
|
196
|
-
|
|
364
|
+
Queries the unauthenticated `/quote` endpoint on up to `2 * resilienceLevel`
|
|
365
|
+
providers and returns the cheapest-first quote list plus the aggregate
|
|
366
|
+
cost `publishFile` would pay. No provider is billed.
|
|
197
367
|
|
|
198
368
|
```ts
|
|
199
|
-
|
|
369
|
+
public async estimateCost(params: {
|
|
370
|
+
fileSize: number;
|
|
371
|
+
retentionPeriod: number;
|
|
372
|
+
}): Promise<EstimateCostResult>
|
|
200
373
|
```
|
|
201
|
-
See also: [
|
|
202
|
-
|
|
203
|
-
Argument Details
|
|
204
|
-
|
|
205
|
-
+ **config**
|
|
206
|
-
+ An object containing the storage server's URL and a wallet interface
|
|
374
|
+
See also: [EstimateCostResult](./storage.md#interface-estimatecostresult)
|
|
207
375
|
|
|
208
376
|
#### Method findFile
|
|
209
377
|
|
|
210
|
-
|
|
378
|
+
Fans `/find` out across configured hosts (UHRP storage is host-local,
|
|
379
|
+
so any one host may not know the file) and returns the record with the
|
|
380
|
+
longest remaining expiry. Single-host configurations preserve the
|
|
381
|
+
legacy error-message contract verbatim.
|
|
211
382
|
|
|
212
383
|
```ts
|
|
213
|
-
public async findFile(uhrpUrl: string): Promise<FindFileData>
|
|
384
|
+
public async findFile(uhrpUrl: string, options: HostScopeOptions = {}): Promise<FindFileData>
|
|
214
385
|
```
|
|
215
|
-
See also: [FindFileData](./storage.md#interface-findfiledata)
|
|
216
|
-
|
|
217
|
-
Returns
|
|
218
|
-
|
|
219
|
-
An object with file name, size, MIME type, and expiry time
|
|
220
|
-
|
|
221
|
-
Argument Details
|
|
222
|
-
|
|
223
|
-
+ **uhrpUrl**
|
|
224
|
-
+ The UHRP URL, e.g. "uhrp://abcd..."
|
|
225
|
-
|
|
226
|
-
Throws
|
|
227
|
-
|
|
228
|
-
If the server or the route returns an error
|
|
386
|
+
See also: [FindFileData](./storage.md#interface-findfiledata), [HostScopeOptions](./storage.md#interface-hostscopeoptions)
|
|
229
387
|
|
|
230
388
|
#### Method listUploads
|
|
231
389
|
|
|
232
|
-
|
|
390
|
+
Unions `/list` output across configured hosts, merging duplicate UHRP
|
|
391
|
+
URLs by the longest expiry observed. One failing host does not hide
|
|
392
|
+
the rest. Single-host configurations preserve the legacy error contract.
|
|
233
393
|
|
|
234
394
|
```ts
|
|
235
|
-
public async listUploads(): Promise<any>
|
|
395
|
+
public async listUploads(options: HostScopeOptions = {}): Promise<any>
|
|
236
396
|
```
|
|
237
|
-
|
|
238
|
-
Returns
|
|
239
|
-
|
|
240
|
-
The array of uploads returned by the server
|
|
241
|
-
|
|
242
|
-
Throws
|
|
243
|
-
|
|
244
|
-
If the server or the route returns an error
|
|
397
|
+
See also: [HostScopeOptions](./storage.md#interface-hostscopeoptions)
|
|
245
398
|
|
|
246
399
|
#### Method publishFile
|
|
247
400
|
|
|
248
|
-
Publishes a file
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
1. Request an upload URL from the server.
|
|
252
|
-
2. Perform an HTTP PUT to upload the file’s raw bytes.
|
|
253
|
-
3. Return a UHRP URL referencing the file once published.
|
|
401
|
+
Publishes a file across the cheapest configured providers, falling
|
|
402
|
+
through to the next-cheapest quote if a paid upload fails. Throws when
|
|
403
|
+
the resilience threshold cannot be met.
|
|
254
404
|
|
|
255
405
|
```ts
|
|
256
406
|
public async publishFile(params: {
|
|
@@ -260,40 +410,6 @@ public async publishFile(params: {
|
|
|
260
410
|
```
|
|
261
411
|
See also: [UploadFileResult](./storage.md#interface-uploadfileresult), [UploadableFile](./storage.md#interface-uploadablefile)
|
|
262
412
|
|
|
263
|
-
Returns
|
|
264
|
-
|
|
265
|
-
An object with the file's UHRP URL
|
|
266
|
-
|
|
267
|
-
Throws
|
|
268
|
-
|
|
269
|
-
If the server or upload step returns a non-OK response
|
|
270
|
-
|
|
271
|
-
#### Method renewFile
|
|
272
|
-
|
|
273
|
-
Renews the hosting time for an existing file advertisement identified by uhrpUrl.
|
|
274
|
-
Calls the `/renew` route to add `additionalMinutes` to the GCS customTime
|
|
275
|
-
and re-mint the advertisement token on-chain.
|
|
276
|
-
|
|
277
|
-
```ts
|
|
278
|
-
public async renewFile(uhrpUrl: string, additionalMinutes: number): Promise<RenewFileResult>
|
|
279
|
-
```
|
|
280
|
-
See also: [RenewFileResult](./storage.md#interface-renewfileresult)
|
|
281
|
-
|
|
282
|
-
Returns
|
|
283
|
-
|
|
284
|
-
An object with the new and previous expiry times, plus any cost
|
|
285
|
-
|
|
286
|
-
Argument Details
|
|
287
|
-
|
|
288
|
-
+ **uhrpUrl**
|
|
289
|
-
+ The UHRP URL of the file (e.g., "uhrp://abcd1234...")
|
|
290
|
-
+ **additionalMinutes**
|
|
291
|
-
+ The number of minutes to extend
|
|
292
|
-
|
|
293
|
-
Throws
|
|
294
|
-
|
|
295
|
-
If the request fails or the server returns an error
|
|
296
|
-
|
|
297
413
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
298
414
|
|
|
299
415
|
---
|
|
@@ -307,6 +423,7 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
307
423
|
|
|
308
424
|
| |
|
|
309
425
|
| --- |
|
|
426
|
+
| [DEFAULT_UHRP_SERVERS](#variable-default_uhrp_servers) |
|
|
310
427
|
| [getHashFromURL](#variable-gethashfromurl) |
|
|
311
428
|
| [getURLForFile](#variable-geturlforfile) |
|
|
312
429
|
| [getURLForHash](#variable-geturlforhash) |
|
|
@@ -317,6 +434,18 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
317
434
|
|
|
318
435
|
---
|
|
319
436
|
|
|
437
|
+
### Variable: DEFAULT_UHRP_SERVERS
|
|
438
|
+
|
|
439
|
+
```ts
|
|
440
|
+
DEFAULT_UHRP_SERVERS: string[] = [
|
|
441
|
+
"https://nanostore.babbage.systems",
|
|
442
|
+
"https://bsv-storage-cloudflare.dev-a3e.workers.dev"
|
|
443
|
+
]
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
447
|
+
|
|
448
|
+
---
|
|
320
449
|
### Variable: getHashFromURL
|
|
321
450
|
|
|
322
451
|
```ts
|
|
@@ -383,7 +512,7 @@ isValidURL = (URL: string): boolean => {
|
|
|
383
512
|
getHashFromURL(URL);
|
|
384
513
|
return true;
|
|
385
514
|
}
|
|
386
|
-
catch
|
|
515
|
+
catch {
|
|
387
516
|
return false;
|
|
388
517
|
}
|
|
389
518
|
}
|
|
@@ -1374,6 +1374,7 @@ export default class MerklePath {
|
|
|
1374
1374
|
async verify(txid: string, chainTracker: ChainTracker): Promise<boolean>
|
|
1375
1375
|
combine(other: MerklePath): void
|
|
1376
1376
|
trim(): void
|
|
1377
|
+
extract(txids: string[]): MerklePath
|
|
1377
1378
|
}
|
|
1378
1379
|
```
|
|
1379
1380
|
|
|
@@ -1418,6 +1419,45 @@ Throws
|
|
|
1418
1419
|
|
|
1419
1420
|
- If the transaction ID is not part of the Merkle Path.
|
|
1420
1421
|
|
|
1422
|
+
#### Method extract
|
|
1423
|
+
|
|
1424
|
+
Extracts a minimal compound MerklePath covering only the specified transaction IDs.
|
|
1425
|
+
|
|
1426
|
+
Given a compound MerklePath (e.g. all block txids at level 0, or a trimmed
|
|
1427
|
+
compound path), this method reconstructs the sibling hashes at each tree level
|
|
1428
|
+
for every requested txid using cached Map-indexed lookups, then assembles them
|
|
1429
|
+
into a single trimmed compound path.
|
|
1430
|
+
|
|
1431
|
+
The extracted path is verified to compute the same Merkle root as the source.
|
|
1432
|
+
|
|
1433
|
+
```ts
|
|
1434
|
+
extract(txids: string[]): MerklePath
|
|
1435
|
+
```
|
|
1436
|
+
See also: [MerklePath](./transaction.md#class-merklepath)
|
|
1437
|
+
|
|
1438
|
+
Returns
|
|
1439
|
+
|
|
1440
|
+
- A new trimmed compound MerklePath covering only the requested txids.
|
|
1441
|
+
|
|
1442
|
+
Argument Details
|
|
1443
|
+
|
|
1444
|
+
+ **txids**
|
|
1445
|
+
+ Transaction IDs to extract proofs for.
|
|
1446
|
+
|
|
1447
|
+
Throws
|
|
1448
|
+
|
|
1449
|
+
- If no txids are provided, a txid is not found, or the roots do not match.
|
|
1450
|
+
|
|
1451
|
+
Example
|
|
1452
|
+
|
|
1453
|
+
```ts
|
|
1454
|
+
// Full block compound path (all txids at level 0)
|
|
1455
|
+
const fullBlock = new MerklePath(height, [allTxidsAtLevel0])
|
|
1456
|
+
// Extract a smaller compound proof covering just two transactions
|
|
1457
|
+
const twoTxProof = fullBlock.extract([txid1, txid2])
|
|
1458
|
+
twoTxProof.computeRoot(txid1) // === fullBlock.computeRoot()
|
|
1459
|
+
```
|
|
1460
|
+
|
|
1421
1461
|
#### Method findOrComputeLeaf
|
|
1422
1462
|
|
|
1423
1463
|
Find leaf with `offset` at `height` or compute from level below, recursively.
|
package/docs/reference/wallet.md
CHANGED
|
@@ -2930,7 +2930,7 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
2930
2930
|
### Class: WERR_REVIEW_ACTIONS
|
|
2931
2931
|
|
|
2932
2932
|
When a `createAction` or `signAction` is completed in undelayed mode (`acceptDelayedBroadcast`: false),
|
|
2933
|
-
any
|
|
2933
|
+
any unsuccessful result will return the results by way of this exception to ensure attention is
|
|
2934
2934
|
paid to processing errors.
|
|
2935
2935
|
|
|
2936
2936
|
```ts
|
|
@@ -2945,7 +2945,7 @@ See also: [AtomicBEEF](./wallet.md#type-atomicbeef), [OutpointString](./wallet.m
|
|
|
2945
2945
|
|
|
2946
2946
|
#### Constructor
|
|
2947
2947
|
|
|
2948
|
-
All parameters correspond to their comparable `createAction` or `
|
|
2948
|
+
All parameters correspond to their comparable `createAction` or `signAction` results
|
|
2949
2949
|
with the exception of `reviewActionResults`;
|
|
2950
2950
|
which contains more details, particularly for double spend results.
|
|
2951
2951
|
|
|
@@ -5063,10 +5063,10 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
5063
5063
|
### Type: ReviewActionResultStatus
|
|
5064
5064
|
|
|
5065
5065
|
Indicates status of a new Action following a `createAction` or `signAction` in immediate mode:
|
|
5066
|
-
When `acceptDelayedBroadcast` is
|
|
5066
|
+
When `acceptDelayedBroadcast` is false.
|
|
5067
5067
|
|
|
5068
5068
|
'success': The action has been broadcast and accepted by the bitcoin processing network.
|
|
5069
|
-
'
|
|
5069
|
+
'doubleSpend': The action has been confirmed to double spend one or more inputs, and by the "first-seen-rule" is the losing transaction.
|
|
5070
5070
|
'invalidTx': The action was rejected by the processing network as an invalid bitcoin transaction.
|
|
5071
5071
|
'serviceError': The broadcast services are currently unable to reach the bitcoin network. The action is now queued for delayed retries.
|
|
5072
5072
|
|