@knuth/js-wasm 2.11.0 → 4.0.0

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 (79) hide show
  1. package/LICENSE.md +23 -0
  2. package/README.md +119 -27
  3. package/SHA256SUMS +4 -0
  4. package/package.json +21 -8
  5. package/src/browser_headers_persistent_v1.js +2 -0
  6. package/src/browser_headers_persistent_v1.wasm +0 -0
  7. package/src/kth.js +6 -3
  8. package/src/kth.wasm +0 -0
  9. package/types/AsyncResults.d.ts +11 -0
  10. package/types/Bitcoin.d.ts +4 -0
  11. package/types/DerivationPath.d.ts +8 -0
  12. package/types/DoubleList.d.ts +5 -4
  13. package/types/EcCompressed.d.ts +8 -3
  14. package/types/EcPublic.d.ts +10 -4
  15. package/types/ElectrumClient.d.ts +79 -0
  16. package/types/EllipticCurve.d.ts +8 -2
  17. package/types/Hash.d.ts +5 -0
  18. package/types/HdPublic.d.ts +9 -3
  19. package/types/Input.d.ts +10 -7
  20. package/types/InputList.d.ts +6 -5
  21. package/types/Interpreter.d.ts +9 -1
  22. package/types/Kth.d.ts +4 -0
  23. package/types/LazySequence.d.ts +4 -0
  24. package/types/ListHelper.d.ts +13 -1
  25. package/types/ListNative.d.ts +4 -0
  26. package/types/NativeLifetime.d.ts +11 -0
  27. package/types/Opcode.d.ts +10 -3
  28. package/types/OpcodeAliases.d.ts +16 -0
  29. package/types/Operation.d.ts +31 -26
  30. package/types/OperationList.d.ts +6 -5
  31. package/types/Output.d.ts +11 -7
  32. package/types/OutputList.d.ts +6 -5
  33. package/types/OutputPoint.d.ts +8 -4
  34. package/types/PaymentAddress.d.ts +15 -10
  35. package/types/PaymentAddressList.d.ts +6 -5
  36. package/types/Program.d.ts +15 -2
  37. package/types/RuleFork.d.ts +4 -0
  38. package/types/Script.d.ts +34 -19
  39. package/types/ScriptFlags.d.ts +67 -0
  40. package/types/Secret.d.ts +4 -0
  41. package/types/SecretFunctions.d.ts +4 -0
  42. package/types/SighashAlgorithm.d.ts +4 -0
  43. package/types/SighashGuard.d.ts +10 -0
  44. package/types/StringList.d.ts +5 -4
  45. package/types/TokenData.d.ts +8 -3
  46. package/types/TokenDataBothKinds.d.ts +6 -3
  47. package/types/TokenDataFungible.d.ts +4 -0
  48. package/types/TokenDataNonFungible.d.ts +9 -2
  49. package/types/Transaction.d.ts +12 -10
  50. package/types/TransactionHelpers.d.ts +14 -0
  51. package/types/U32List.d.ts +5 -4
  52. package/types/U64List.d.ts +5 -4
  53. package/types/Utxo.d.ts +10 -6
  54. package/types/UtxoList.d.ts +6 -5
  55. package/types/Wallet.d.ts +28 -52
  56. package/types/WalletData.d.ts +5 -1
  57. package/types/WalletManager.d.ts +6 -3
  58. package/types/WalletUtils.d.ts +53 -0
  59. package/types/encoding.d.ts +4 -0
  60. package/types/env.d.ts +4 -0
  61. package/types/logger.d.ts +6 -0
  62. package/types/main.d.ts +75 -2
  63. package/types/nativeScope.d.ts +11 -0
  64. package/types/types.d.ts +4 -0
  65. package/types/utils.d.ts +4 -0
  66. package/types/wasm/EmscriptenModule.d.ts +4 -0
  67. package/types/wasm/bootloader.d.ts +4 -0
  68. package/types/wasm/callbacks.d.ts +30 -0
  69. package/types/wasm/exceptions.d.ts +4 -0
  70. package/types/wasm/glue.d.ts +960 -170
  71. package/types/wasm/glue_manual.d.ts +4 -0
  72. package/types/wasm/loadLib.d.ts +4 -0
  73. package/types/wasm/manualGeneratedTypes.d.ts +4 -0
  74. package/types/wasm/mem.d.ts +33 -1
  75. package/types/wasm/promises.d.ts +4 -0
  76. package/types/wasm/stack.d.ts +6 -0
  77. package/types/wasm/string.d.ts +13 -0
  78. package/types/LazySequence copy.d.ts +0 -0
  79. package/types/wasm/glue copy.d.ts +0 -230
package/types/main.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ // Copyright (c) 2016-present Knuth Project developers.
2
+ // Distributed under the MIT software license, see the accompanying
3
+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
+
1
5
  import Kth from './Kth';
2
6
  import Utxo from './Utxo';
3
7
  import Opcode from './Opcode';
@@ -24,6 +28,7 @@ import { ScriptNative } from './wasm/glue';
24
28
  import Operation from './Operation';
25
29
  import OperationList from './OperationList';
26
30
  import RuleFork from './RuleFork';
31
+ import { ScriptFlags, ScriptUpgrades } from './ScriptFlags';
27
32
  import SighashAlgorithm from './SighashAlgorithm';
28
33
  import Program from './Program';
29
34
  import { Interpreter, Debugger } from './Interpreter';
@@ -33,9 +38,11 @@ import { bytesToHexStr, hexStrToBytes, encodeHash, decodeHash } from './encoding
33
38
  import { HashFunctions, Hash, ShortHash, LongHash, EncryptedSeed } from './Hash';
34
39
  import WalletManager from './WalletManager';
35
40
  import WalletData from './WalletData';
41
+ import WalletUtils from './WalletUtils';
42
+ import { ElectrumClient, electrumClient } from './ElectrumClient';
36
43
  import loadLib from './wasm/loadLib';
37
44
  import { free, malloc } from './wasm/mem';
38
- export { loadLib, Kth, OutputPoint, Utxo, Output, OutputList, TokenData, TokenDataFungible, TokenDataNonFungible, TokenDataBothKinds, Input, InputList, UtxoList, PaymentAddress, Script, ScriptNative, Transaction, Wallet, HdPublic, EcPublic, EcSecret, SecretFunctions, Opcode, OpcodeEnumNative, OpcodeEnumNativeToInt, Operation, OperationList, RuleFork, RuleForkEnumNative, RuleForkEnumNativeToInt, SighashAlgorithm, Interpreter, Debugger, Program, bytesToHexStr, hexStrToBytes, encodeHash, decodeHash, bitcoinToSatoshis, satoshisToBitcoin, HashFunctions, Hash, ShortHash, LongHash, EncryptedSeed, WalletManager, WalletData, free, malloc };
45
+ export { loadLib, Kth, OutputPoint, Utxo, Output, OutputList, TokenData, TokenDataFungible, TokenDataNonFungible, TokenDataBothKinds, Input, InputList, UtxoList, PaymentAddress, Script, ScriptNative, Transaction, Wallet, HdPublic, EcPublic, EcSecret, SecretFunctions, Opcode, OpcodeEnumNative, OpcodeEnumNativeToInt, Operation, OperationList, RuleFork, ScriptFlags, ScriptUpgrades, RuleForkEnumNative, RuleForkEnumNativeToInt, SighashAlgorithm, Interpreter, Debugger, Program, bytesToHexStr, hexStrToBytes, encodeHash, decodeHash, bitcoinToSatoshis, satoshisToBitcoin, HashFunctions, Hash, ShortHash, LongHash, EncryptedSeed, WalletManager, WalletData, WalletUtils, ElectrumClient, electrumClient, free, malloc, };
39
46
  declare const _default: {
40
47
  loadLib: typeof loadLib;
41
48
  Kth: typeof Kth;
@@ -49,10 +56,73 @@ declare const _default: {
49
56
  OpcodeEnumNativeToInt: typeof OpcodeEnumNativeToInt;
50
57
  Operation: typeof Operation;
51
58
  RuleFork: typeof RuleFork;
59
+ ScriptFlags: Readonly<{
60
+ noRules: 0n;
61
+ easyBlocks: 1n;
62
+ bip16Rule: 2n;
63
+ bip30Rule: 4n;
64
+ bip34Rule: 8n;
65
+ bip66Rule: 16n;
66
+ bip65Rule: 32n;
67
+ bip90Rule: 64n;
68
+ allowCollisions: 128n;
69
+ bip68Rule: 256n;
70
+ bip112Rule: 512n;
71
+ bip113Rule: 1024n;
72
+ bchStrictenc: 2048n;
73
+ bchSighashForkid: 4096n;
74
+ bchLowS: 8192n;
75
+ bchNullfail: 16384n;
76
+ bchReactivatedOpcodes: 32768n;
77
+ bchSigpushonly: 65536n;
78
+ bchCleanstack: 131072n;
79
+ bchSchnorrMultisig: 262144n;
80
+ bchMinimaldata: 524288n;
81
+ bchEnforceSigchecks: 1048576n;
82
+ bch64bitIntegers: 2097152n;
83
+ bchNativeIntrospection: 4194304n;
84
+ bchP2sh32: 8388608n;
85
+ bchTokens: 16777216n;
86
+ bchVmLimits: 33554432n;
87
+ bchBigint: 67108864n;
88
+ bchLoops: 134217728n;
89
+ bchSubroutines: 268435456n;
90
+ bchBitwiseOps: 536870912n;
91
+ bchP2s: 1073741824n;
92
+ bch2027May: 2147483648n;
93
+ bchVmLimitsStandard: 144115188075855872n;
94
+ bchMinimalif: 288230376151711744n;
95
+ bchInputSigchecks: 576460752303423488n;
96
+ bchDiscourageUpgradableNops: 1152921504606846976n;
97
+ bchDisallowSegwitRecovery: 2305843009213693952n;
98
+ retarget: 4611686018427387904n;
99
+ unverified: 9223372036854775808n;
100
+ allPolicyFlags: 4467570830351532032n;
101
+ allRules: 144115188075855871n;
102
+ allBits: 18446744073709551615n;
103
+ standardPolicyFlags: 4467570830351532032n;
104
+ }>;
105
+ ScriptUpgrades: Readonly<{
106
+ bip34Activations: 56n;
107
+ bchUahf: 6144n;
108
+ bchDaaCw144: 30720n;
109
+ bchPythagoras: 63488n;
110
+ bchEuclid: 260096n;
111
+ bchPisano: 260096n;
112
+ bchMersenne: 1046528n;
113
+ bchFermat: 2095104n;
114
+ bchEuler: 2095104n;
115
+ bchGauss: 8386560n;
116
+ bchDescartes: 33552384n;
117
+ bchLobachevski: 33552384n;
118
+ bchGalois: 134215680n;
119
+ bchLeibniz: 2147481600n;
120
+ bchCantor: 4294965248n;
121
+ }>;
52
122
  RuleForkEnumNativeToInt: typeof RuleForkEnumNativeToInt;
53
123
  SighashAlgorithm: typeof SighashAlgorithm;
54
124
  Utxo: typeof Utxo;
55
- UtxoList: typeof UtxoList;
125
+ UtxoList: import("./ListHelper").ListAdapter<Utxo, import("./wasm/glue").UtxoListNative>;
56
126
  bytesToHexStr: typeof bytesToHexStr;
57
127
  hexStrToBytes: typeof hexStrToBytes;
58
128
  encodeHash: typeof encodeHash;
@@ -62,6 +132,9 @@ declare const _default: {
62
132
  HashFunctions: typeof HashFunctions;
63
133
  WalletManager: typeof WalletManager;
64
134
  WalletData: typeof WalletData;
135
+ WalletUtils: typeof WalletUtils;
136
+ ElectrumClient: typeof ElectrumClient;
137
+ electrumClient: ElectrumClient;
65
138
  free: typeof free;
66
139
  malloc: typeof malloc;
67
140
  };
@@ -0,0 +1,11 @@
1
+ // Copyright (c) 2016-present Knuth Project developers.
2
+ // Distributed under the MIT software license, see the accompanying
3
+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
+
5
+ export declare class NativeScope {
6
+ private readonly owned;
7
+ own<T>(native: T): T;
8
+ release(): void;
9
+ }
10
+ export declare function withNatives<T>(body: (scope: NativeScope) => T): T;
11
+ export declare function withNativesAsync<T>(body: (scope: NativeScope) => Promise<T>): Promise<T>;
package/types/types.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ // Copyright (c) 2016-present Knuth Project developers.
2
+ // Distributed under the MIT software license, see the accompanying
3
+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
+
1
5
  export type OnlyAttributes<T extends object> = WithoutValueType<WithoutKeyType<T, Symbol>, Function>;
2
6
  export type WithoutKeyType<T extends object, KT> = {
3
7
  [P in keyof T as P extends KT ? never : P]: T[P];
package/types/utils.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ // Copyright (c) 2016-present Knuth Project developers.
2
+ // Distributed under the MIT software license, see the accompanying
3
+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
+
1
5
  import type { WithoutKeyType } from './types';
2
6
  export declare function isArrayString(obj: any): obj is Array<string | null>;
3
7
  export declare function isArrayArrayString(obj: any): obj is Array<Array<string>>;
@@ -1,3 +1,7 @@
1
+ // Copyright (c) 2016-present Knuth Project developers.
2
+ // Distributed under the MIT software license, see the accompanying
3
+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
+
1
5
  export default interface EmscriptenModule {
2
6
  readonly _malloc: (size: number) => number;
3
7
  readonly _free: (ptr: number) => void;
@@ -1,3 +1,7 @@
1
+ // Copyright (c) 2016-present Knuth Project developers.
2
+ // Distributed under the MIT software license, see the accompanying
3
+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
+
1
5
  import KthModule from '../main';
2
6
  export * from '../main';
3
7
  export default KthModule;
@@ -0,0 +1,30 @@
1
+ // Copyright (c) 2016-present Knuth Project developers.
2
+ // Distributed under the MIT software license, see the accompanying
3
+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
+
5
+ export declare class CallbackStatusError extends Error {
6
+ readonly code: number;
7
+ constructor(code: number);
8
+ }
9
+ export interface CallbackConversion<T> {
10
+ take(value: unknown): T;
11
+ release(value: unknown): void;
12
+ }
13
+ /** One registry per module/executor. The native terminal callback owns completion.
14
+ * A JS timeout/abort must not release the receiver while C++ still uses it.
15
+ */
16
+ export declare class CallbackRegistry {
17
+ private readonly capacity;
18
+ private readonly pending;
19
+ private readonly owners;
20
+ private sequence;
21
+ constructor(capacity?: number);
22
+ get size(): number;
23
+ assertIdle(owner: object): void;
24
+ invoke<T>(owner: object, start: (id: number, enterNative: () => void) => void): Promise<T>;
25
+ /** Call enterNative immediately before crossing the native boundary.
26
+ * Once entered, only terminal completion releases ownership pins/inputs.
27
+ */
28
+ invokeWithOwners<T>(receivers: readonly object[], start: (id: number, enterNative: () => void) => void, conversion?: CallbackConversion<T>): Promise<T>;
29
+ complete(id: number, status: number, value: unknown): boolean;
30
+ }
@@ -1 +1,5 @@
1
+ // Copyright (c) 2016-present Knuth Project developers.
2
+ // Distributed under the MIT software license, see the accompanying
3
+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
+
1
5
  export declare function dummyFunction(): void;