@bsv/sdk 2.0.9 → 2.0.10
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/cjs/package.json +1 -1
- package/dist/cjs/src/auth/certificates/Certificate.js +1 -1
- package/dist/cjs/src/auth/certificates/Certificate.js.map +1 -1
- package/dist/cjs/src/primitives/BigNumber.js +4 -5
- package/dist/cjs/src/primitives/BigNumber.js.map +1 -1
- package/dist/cjs/src/script/OP.js +22 -16
- package/dist/cjs/src/script/OP.js.map +1 -1
- package/dist/cjs/src/script/Spend.js +21 -78
- package/dist/cjs/src/script/Spend.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/auth/certificates/Certificate.js +1 -1
- package/dist/esm/src/auth/certificates/Certificate.js.map +1 -1
- package/dist/esm/src/primitives/BigNumber.js +4 -5
- package/dist/esm/src/primitives/BigNumber.js.map +1 -1
- package/dist/esm/src/script/OP.js +22 -16
- package/dist/esm/src/script/OP.js.map +1 -1
- package/dist/esm/src/script/Spend.js +21 -78
- package/dist/esm/src/script/Spend.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/primitives/BigNumber.d.ts.map +1 -1
- package/dist/types/src/script/OP.d.ts +9 -7
- package/dist/types/src/script/OP.d.ts.map +1 -1
- package/dist/types/src/script/Spend.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +3 -3
- package/dist/umd/bundle.js.map +1 -1
- package/docs/reference/script.md +76 -0
- package/docs/reference/transaction.md +63 -6
- package/docs/reference/wallet.md +285 -1094
- package/package.json +1 -1
- package/src/auth/certificates/Certificate.ts +1 -1
- package/src/primitives/BigNumber.ts +4 -5
- package/src/primitives/__tests/BigNumber.constructor.test.ts +3 -3
- package/src/script/OP.ts +21 -16
- package/src/script/Spend.ts +21 -28
- package/src/script/__tests/Chronicle.test.ts +39 -103
- package/src/script/__tests/ChronicleOpcodes.test.ts +548 -0
package/docs/reference/script.md
CHANGED
|
@@ -6,6 +6,7 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
6
6
|
|
|
7
7
|
| |
|
|
8
8
|
| --- |
|
|
9
|
+
| [FormatPreimageParams](#interface-formatpreimageparams) |
|
|
9
10
|
| [ScriptChunk](#interface-scriptchunk) |
|
|
10
11
|
| [ScriptTemplate](#interface-scripttemplate) |
|
|
11
12
|
| [ScriptTemplateUnlock](#interface-scripttemplateunlock) |
|
|
@@ -14,6 +15,28 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
14
15
|
|
|
15
16
|
---
|
|
16
17
|
|
|
18
|
+
### Interface: FormatPreimageParams
|
|
19
|
+
|
|
20
|
+
Parameters for formatting the transaction preimage
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
export interface FormatPreimageParams {
|
|
24
|
+
tx: Transaction;
|
|
25
|
+
inputIndex: number;
|
|
26
|
+
signatureScope: number;
|
|
27
|
+
sourceTXID: string;
|
|
28
|
+
sourceSatoshis: number;
|
|
29
|
+
lockingScript: Script;
|
|
30
|
+
otherInputs: Transaction["inputs"];
|
|
31
|
+
inputSequence?: number;
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
See also: [Script](./script.md#class-script), [Transaction](./transaction.md#class-transaction)
|
|
36
|
+
|
|
37
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
38
|
+
|
|
39
|
+
---
|
|
17
40
|
### Interface: ScriptChunk
|
|
18
41
|
|
|
19
42
|
A representation of a chunk of a script, which includes an opcode. For push operations, the associated data to push onto the stack is also included.
|
|
@@ -942,6 +965,59 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
942
965
|
---
|
|
943
966
|
## Functions
|
|
944
967
|
|
|
968
|
+
| |
|
|
969
|
+
| --- |
|
|
970
|
+
| [computeSignatureScope](#function-computesignaturescope) |
|
|
971
|
+
| [formatPreimage](#function-formatpreimage) |
|
|
972
|
+
| [resolveSourceDetails](#function-resolvesourcedetails) |
|
|
973
|
+
|
|
974
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
975
|
+
|
|
976
|
+
---
|
|
977
|
+
|
|
978
|
+
### Function: computeSignatureScope
|
|
979
|
+
|
|
980
|
+
Computes the signature scope flags from the given signing parameters.
|
|
981
|
+
|
|
982
|
+
```ts
|
|
983
|
+
export function computeSignatureScope(signOutputs: "all" | "none" | "single", anyoneCanPay: boolean): number
|
|
984
|
+
```
|
|
985
|
+
|
|
986
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
987
|
+
|
|
988
|
+
---
|
|
989
|
+
### Function: formatPreimage
|
|
990
|
+
|
|
991
|
+
Formats the transaction preimage for signing.
|
|
992
|
+
|
|
993
|
+
```ts
|
|
994
|
+
export function formatPreimage(params: FormatPreimageParams): number[]
|
|
995
|
+
```
|
|
996
|
+
|
|
997
|
+
See also: [FormatPreimageParams](./script.md#interface-formatpreimageparams)
|
|
998
|
+
|
|
999
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
1000
|
+
|
|
1001
|
+
---
|
|
1002
|
+
### Function: resolveSourceDetails
|
|
1003
|
+
|
|
1004
|
+
Resolves and validates the source transaction details needed for signing.
|
|
1005
|
+
Returns the resolved sourceTXID, sourceSatoshis, lockingScript, and otherInputs.
|
|
1006
|
+
|
|
1007
|
+
```ts
|
|
1008
|
+
export function resolveSourceDetails(tx: Transaction, inputIndex: number, providedSourceSatoshis?: number, providedLockingScript?: Script): {
|
|
1009
|
+
sourceTXID: string;
|
|
1010
|
+
sourceSatoshis: number;
|
|
1011
|
+
lockingScript: Script;
|
|
1012
|
+
otherInputs: typeof tx.inputs;
|
|
1013
|
+
}
|
|
1014
|
+
```
|
|
1015
|
+
|
|
1016
|
+
See also: [Script](./script.md#class-script), [Transaction](./transaction.md#class-transaction)
|
|
1017
|
+
|
|
1018
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
1019
|
+
|
|
1020
|
+
---
|
|
945
1021
|
## Types
|
|
946
1022
|
|
|
947
1023
|
## Enums
|
|
@@ -6,14 +6,15 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
6
6
|
|
|
7
7
|
| | |
|
|
8
8
|
| --- | --- |
|
|
9
|
-
| [ArcConfig](#interface-arcconfig) | [
|
|
9
|
+
| [ArcConfig](#interface-arcconfig) | [HttpsModuleLike](#interface-httpsmodulelike) |
|
|
10
10
|
| [BroadcastFailure](#interface-broadcastfailure) | [HttpsNodejs](#interface-httpsnodejs) |
|
|
11
11
|
| [BroadcastResponse](#interface-broadcastresponse) | [MerklePathLeaf](#interface-merklepathleaf) |
|
|
12
12
|
| [Broadcaster](#interface-broadcaster) | [NodejsHttpClientRequest](#interface-nodejshttpclientrequest) |
|
|
13
|
-
| [ChainTracker](#interface-chaintracker) | [
|
|
14
|
-
| [FeeModel](#interface-feemodel) | [
|
|
15
|
-
| [FetchOptions](#interface-fetchoptions) | [
|
|
16
|
-
| [HttpClient](#interface-httpclient) |
|
|
13
|
+
| [ChainTracker](#interface-chaintracker) | [NodejsRequestLike](#interface-nodejsrequestlike) |
|
|
14
|
+
| [FeeModel](#interface-feemodel) | [TransactionInput](#interface-transactioninput) |
|
|
15
|
+
| [FetchOptions](#interface-fetchoptions) | [TransactionOutput](#interface-transactionoutput) |
|
|
16
|
+
| [HttpClient](#interface-httpclient) | [WhatsOnChainConfig](#interface-whatsonchainconfig) |
|
|
17
|
+
| [HttpClientRequestOptions](#interface-httpclientrequestoptions) | |
|
|
17
18
|
|
|
18
19
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
19
20
|
|
|
@@ -297,6 +298,21 @@ signal?: AbortSignal
|
|
|
297
298
|
|
|
298
299
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
299
300
|
|
|
301
|
+
---
|
|
302
|
+
### Interface: HttpsModuleLike
|
|
303
|
+
|
|
304
|
+
Common interface for Node.js https modules
|
|
305
|
+
|
|
306
|
+
```ts
|
|
307
|
+
export interface HttpsModuleLike {
|
|
308
|
+
request: (url: string, options: HttpClientRequestOptions, callback: (res: any) => void) => NodejsRequestLike;
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
See also: [HttpClientRequestOptions](./transaction.md#interface-httpclientrequestoptions), [NodejsRequestLike](./transaction.md#interface-nodejsrequestlike)
|
|
313
|
+
|
|
314
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
315
|
+
|
|
300
316
|
---
|
|
301
317
|
### Interface: HttpsNodejs
|
|
302
318
|
|
|
@@ -335,7 +351,22 @@ Nodejs result of the Node https.request call limited to options needed by ts-sdk
|
|
|
335
351
|
export interface NodejsHttpClientRequest {
|
|
336
352
|
write: (chunk: string) => void;
|
|
337
353
|
on: (event: string, callback: (data: any) => void) => void;
|
|
338
|
-
end: (
|
|
354
|
+
end: () => void;
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
### Interface: NodejsRequestLike
|
|
362
|
+
|
|
363
|
+
Common interface for Node.js https module request objects
|
|
364
|
+
|
|
365
|
+
```ts
|
|
366
|
+
export interface NodejsRequestLike {
|
|
367
|
+
write: (chunk: any) => void;
|
|
368
|
+
on: (event: string, callback: (data: any) => void) => void;
|
|
369
|
+
end: () => void;
|
|
339
370
|
}
|
|
340
371
|
```
|
|
341
372
|
|
|
@@ -2351,6 +2382,7 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
2351
2382
|
| [defaultBroadcaster](#function-defaultbroadcaster) |
|
|
2352
2383
|
| [defaultChainTracker](#function-defaultchaintracker) |
|
|
2353
2384
|
| [defaultHttpClient](#function-defaulthttpclient) |
|
|
2385
|
+
| [executeNodejsRequest](#function-executenodejsrequest) |
|
|
2354
2386
|
| [isBroadcastFailure](#function-isbroadcastfailure) |
|
|
2355
2387
|
| [isBroadcastResponse](#function-isbroadcastresponse) |
|
|
2356
2388
|
|
|
@@ -2394,6 +2426,31 @@ See also: [HttpClient](./transaction.md#interface-httpclient)
|
|
|
2394
2426
|
|
|
2395
2427
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
2396
2428
|
|
|
2429
|
+
---
|
|
2430
|
+
### Function: executeNodejsRequest
|
|
2431
|
+
|
|
2432
|
+
Shared implementation for handling Node.js HTTP requests.
|
|
2433
|
+
Used by both NodejsHttpClient and BinaryNodejsHttpClient.
|
|
2434
|
+
|
|
2435
|
+
```ts
|
|
2436
|
+
export function executeNodejsRequest(https: HttpsModuleLike, url: string, requestOptions: HttpClientRequestOptions, serializeData: (data: any) => any): Promise<HttpClientResponse>
|
|
2437
|
+
```
|
|
2438
|
+
|
|
2439
|
+
See also: [HttpClientRequestOptions](./transaction.md#interface-httpclientrequestoptions), [HttpClientResponse](./transaction.md#type-httpclientresponse), [HttpsModuleLike](./transaction.md#interface-httpsmodulelike)
|
|
2440
|
+
|
|
2441
|
+
Argument Details
|
|
2442
|
+
|
|
2443
|
+
+ **https**
|
|
2444
|
+
+ The Node.js https module (or compatible)
|
|
2445
|
+
+ **url**
|
|
2446
|
+
+ The URL to make the request to
|
|
2447
|
+
+ **requestOptions**
|
|
2448
|
+
+ The request configuration
|
|
2449
|
+
+ **serializeData**
|
|
2450
|
+
+ Function to serialize the request data for writing
|
|
2451
|
+
|
|
2452
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
2453
|
+
|
|
2397
2454
|
---
|
|
2398
2455
|
### Function: isBroadcastFailure
|
|
2399
2456
|
|