@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.
- package/LICENSE.md +23 -0
- package/README.md +119 -27
- package/SHA256SUMS +4 -0
- package/package.json +21 -8
- package/src/browser_headers_persistent_v1.js +2 -0
- package/src/browser_headers_persistent_v1.wasm +0 -0
- package/src/kth.js +6 -3
- package/src/kth.wasm +0 -0
- package/types/AsyncResults.d.ts +11 -0
- package/types/Bitcoin.d.ts +4 -0
- package/types/DerivationPath.d.ts +8 -0
- package/types/DoubleList.d.ts +5 -4
- package/types/EcCompressed.d.ts +8 -3
- package/types/EcPublic.d.ts +10 -4
- package/types/ElectrumClient.d.ts +79 -0
- package/types/EllipticCurve.d.ts +8 -2
- package/types/Hash.d.ts +5 -0
- package/types/HdPublic.d.ts +9 -3
- package/types/Input.d.ts +10 -7
- package/types/InputList.d.ts +6 -5
- package/types/Interpreter.d.ts +9 -1
- package/types/Kth.d.ts +4 -0
- package/types/LazySequence.d.ts +4 -0
- package/types/ListHelper.d.ts +13 -1
- package/types/ListNative.d.ts +4 -0
- package/types/NativeLifetime.d.ts +11 -0
- package/types/Opcode.d.ts +10 -3
- package/types/OpcodeAliases.d.ts +16 -0
- package/types/Operation.d.ts +31 -26
- package/types/OperationList.d.ts +6 -5
- package/types/Output.d.ts +11 -7
- package/types/OutputList.d.ts +6 -5
- package/types/OutputPoint.d.ts +8 -4
- package/types/PaymentAddress.d.ts +15 -10
- package/types/PaymentAddressList.d.ts +6 -5
- package/types/Program.d.ts +15 -2
- package/types/RuleFork.d.ts +4 -0
- package/types/Script.d.ts +34 -19
- package/types/ScriptFlags.d.ts +67 -0
- package/types/Secret.d.ts +4 -0
- package/types/SecretFunctions.d.ts +4 -0
- package/types/SighashAlgorithm.d.ts +4 -0
- package/types/SighashGuard.d.ts +10 -0
- package/types/StringList.d.ts +5 -4
- package/types/TokenData.d.ts +8 -3
- package/types/TokenDataBothKinds.d.ts +6 -3
- package/types/TokenDataFungible.d.ts +4 -0
- package/types/TokenDataNonFungible.d.ts +9 -2
- package/types/Transaction.d.ts +12 -10
- package/types/TransactionHelpers.d.ts +14 -0
- package/types/U32List.d.ts +5 -4
- package/types/U64List.d.ts +5 -4
- package/types/Utxo.d.ts +10 -6
- package/types/UtxoList.d.ts +6 -5
- package/types/Wallet.d.ts +28 -52
- package/types/WalletData.d.ts +5 -1
- package/types/WalletManager.d.ts +6 -3
- package/types/WalletUtils.d.ts +53 -0
- package/types/encoding.d.ts +4 -0
- package/types/env.d.ts +4 -0
- package/types/logger.d.ts +6 -0
- package/types/main.d.ts +75 -2
- package/types/nativeScope.d.ts +11 -0
- package/types/types.d.ts +4 -0
- package/types/utils.d.ts +4 -0
- package/types/wasm/EmscriptenModule.d.ts +4 -0
- package/types/wasm/bootloader.d.ts +4 -0
- package/types/wasm/callbacks.d.ts +30 -0
- package/types/wasm/exceptions.d.ts +4 -0
- package/types/wasm/glue.d.ts +960 -170
- package/types/wasm/glue_manual.d.ts +4 -0
- package/types/wasm/loadLib.d.ts +4 -0
- package/types/wasm/manualGeneratedTypes.d.ts +4 -0
- package/types/wasm/mem.d.ts +33 -1
- package/types/wasm/promises.d.ts +4 -0
- package/types/wasm/stack.d.ts +6 -0
- package/types/wasm/string.d.ts +13 -0
- package/types/LazySequence copy.d.ts +0 -0
- package/types/wasm/glue copy.d.ts +0 -230
package/src/kth.wasm
CHANGED
|
Binary file
|
|
@@ -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
|
+
type Conversion = {
|
|
6
|
+
owned: boolean;
|
|
7
|
+
adopt: boolean;
|
|
8
|
+
read: (value: any) => unknown;
|
|
9
|
+
};
|
|
10
|
+
export declare function convertAsyncResults(values: readonly unknown[], conversions: readonly Conversion[]): unknown[];
|
|
11
|
+
export {};
|
package/types/Bitcoin.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
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 bitcoinToSatoshis(amount: number): bigint;
|
|
2
6
|
export declare function satoshisToBitcoin(satoshis: bigint): number;
|
|
@@ -0,0 +1,8 @@
|
|
|
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 const HARDENED_OFFSET = 2147483648;
|
|
6
|
+
export declare function parseDerivationPath(path: string): Array<number>;
|
|
7
|
+
export declare function indexRange(count: number, from: number): Array<number>;
|
|
8
|
+
export declare function findFirst<T>(limit: number, probe: (index: number) => T | undefined): T | undefined;
|
package/types/DoubleList.d.ts
CHANGED
|
@@ -1,6 +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 { DoubleListNative } from './wasm/glue';
|
|
2
|
-
export declare
|
|
3
|
-
static fromNative(native: DoubleListNative): Array<number>;
|
|
4
|
-
static toNative(numbers: Array<number>): DoubleListNative;
|
|
5
|
-
}
|
|
6
|
+
export declare const DoubleList: import("./ListHelper").ListAdapter<number, DoubleListNative>;
|
|
6
7
|
export default DoubleList;
|
package/types/EcCompressed.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
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 { EcCompressedNative } from './wasm/glue';
|
|
6
|
+
export declare const EC_COMPRESSED_SIZE = 33;
|
|
2
7
|
export declare class EcCompressed {
|
|
3
|
-
|
|
4
|
-
constructor(
|
|
5
|
-
|
|
8
|
+
readonly bytes: Uint8Array;
|
|
9
|
+
constructor(bytes: Uint8Array);
|
|
10
|
+
static fromNative(native: EcCompressedNative): EcCompressed;
|
|
6
11
|
}
|
|
7
12
|
export default EcCompressed;
|
package/types/EcPublic.d.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
+
|
|
3
5
|
import { EcCompressed } from './EcCompressed';
|
|
6
|
+
import { PaymentAddress } from './PaymentAddress';
|
|
7
|
+
import { EcPublicNative } from './wasm/glue';
|
|
4
8
|
export declare class EcPublic {
|
|
5
9
|
private native;
|
|
10
|
+
constructor(compressed: EcCompressed, compress?: boolean);
|
|
6
11
|
constructor(native: EcPublicNative);
|
|
7
|
-
|
|
12
|
+
private live;
|
|
13
|
+
dispose(): void;
|
|
8
14
|
toNative(): EcPublicNative;
|
|
9
15
|
toPaymentAddress(version: number): PaymentAddress;
|
|
10
16
|
get encoded(): string;
|
|
11
|
-
toData(): Uint8Array
|
|
17
|
+
toData(): Uint8Array;
|
|
12
18
|
}
|
|
13
19
|
export default EcPublic;
|
|
@@ -0,0 +1,79 @@
|
|
|
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 const PRIMARY_RELAY_ENABLED = true;
|
|
6
|
+
export declare function selectFreshServerProbes<T extends {
|
|
7
|
+
responseTime: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
}>(probes: T[], requireTip: boolean): T[];
|
|
10
|
+
type SubscriptionCallback = (status: any) => void;
|
|
11
|
+
type ConnectionCallback = () => void;
|
|
12
|
+
declare class ElectrumClient {
|
|
13
|
+
private static instance;
|
|
14
|
+
private ws;
|
|
15
|
+
private requestId;
|
|
16
|
+
private pendingRequests;
|
|
17
|
+
private subscriptions;
|
|
18
|
+
private connectionListeners;
|
|
19
|
+
private isConnected;
|
|
20
|
+
private reconnectAttempts;
|
|
21
|
+
private maxReconnectAttempts;
|
|
22
|
+
private connectionPromise;
|
|
23
|
+
private currentServer;
|
|
24
|
+
private useFallback;
|
|
25
|
+
private lastRelayFailureReportAt;
|
|
26
|
+
private constructor();
|
|
27
|
+
static getInstance(): ElectrumClient;
|
|
28
|
+
private reportRelayUnavailable;
|
|
29
|
+
/**
|
|
30
|
+
* Test a single server to see if it's available
|
|
31
|
+
*/
|
|
32
|
+
private testServer;
|
|
33
|
+
/**
|
|
34
|
+
* Test servers in parallel and return the fastest responding one
|
|
35
|
+
*/
|
|
36
|
+
private findFastestServer;
|
|
37
|
+
/**
|
|
38
|
+
* Select the best available server for reading (localhost if available, otherwise fastest read server)
|
|
39
|
+
*/
|
|
40
|
+
private selectReadServer;
|
|
41
|
+
/**
|
|
42
|
+
* Select a server for broadcasting (localhost if available, otherwise fastest broadcast server)
|
|
43
|
+
*/
|
|
44
|
+
private selectBroadcastServer;
|
|
45
|
+
private ensureConnection;
|
|
46
|
+
private handleMessage;
|
|
47
|
+
private handleSubscriptionUpdate;
|
|
48
|
+
private sendRequest;
|
|
49
|
+
private handleReconnect;
|
|
50
|
+
private restoreSubscriptions;
|
|
51
|
+
addConnectionListener(callback: ConnectionCallback): () => void;
|
|
52
|
+
getServerFeatures(): Promise<any>;
|
|
53
|
+
subscribeToAddress(address: string, callback: SubscriptionCallback): Promise<void>;
|
|
54
|
+
subscribe(scriptHashOrAddress: string, callback: SubscriptionCallback): Promise<void>;
|
|
55
|
+
unsubscribeFromAddress(address: string, callback?: SubscriptionCallback): Promise<void>;
|
|
56
|
+
getAddressHistory(address: string): Promise<any>;
|
|
57
|
+
getUTXOs(address: string): Promise<any>;
|
|
58
|
+
getBalance(address: string): Promise<any>;
|
|
59
|
+
getTransaction(txid: string): Promise<any>;
|
|
60
|
+
getScriptHashHistory(scriptHash: string): Promise<any>;
|
|
61
|
+
getTransactionHistory(address: string): Promise<any>;
|
|
62
|
+
broadcastTransaction(txHex: string): Promise<string>;
|
|
63
|
+
getTransactions(txids: string[]): Promise<Array<{
|
|
64
|
+
txid: string;
|
|
65
|
+
hex: string;
|
|
66
|
+
} | null>>;
|
|
67
|
+
}
|
|
68
|
+
export declare const electrumClient: ElectrumClient;
|
|
69
|
+
interface WalletData {
|
|
70
|
+
addresses: Array<{
|
|
71
|
+
address: string;
|
|
72
|
+
isUsed: boolean;
|
|
73
|
+
}>;
|
|
74
|
+
usedAddresses: Set<string>;
|
|
75
|
+
firstUnusedIndex: number;
|
|
76
|
+
}
|
|
77
|
+
export declare function updateAddressUsage(wallet: WalletData): Promise<void>;
|
|
78
|
+
export { ElectrumClient };
|
|
79
|
+
export type { SubscriptionCallback, WalletData };
|
package/types/EllipticCurve.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
|
|
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
|
+
import { EcCompressed } from './EcCompressed';
|
|
6
|
+
import { EcSecret } from './Secret';
|
|
7
|
+
import { EcSecretNative } from './wasm/glue';
|
|
2
8
|
export declare class EllipticCurve {
|
|
3
|
-
static secretToPublic(secret: EcSecretNative):
|
|
9
|
+
static secretToPublic(secret: EcSecretNative | EcSecret): EcCompressed | undefined;
|
|
4
10
|
}
|
|
5
11
|
export default EllipticCurve;
|
package/types/Hash.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 { HashNative, ShortHashNative, EncryptedSeedNative, LongHashNative } from './wasm/glue';
|
|
2
6
|
export type Hash = Uint8Array & {
|
|
3
7
|
length: 32;
|
|
@@ -28,5 +32,6 @@ export declare class HashFunctions {
|
|
|
28
32
|
static sha256(data: Uint8Array): Hash;
|
|
29
33
|
static sha256Reversed(data: Uint8Array): Hash;
|
|
30
34
|
static sha256ReversedStr(data: Uint8Array): string;
|
|
35
|
+
static ripemd160(data: Uint8Array): ShortHash;
|
|
31
36
|
}
|
|
32
37
|
export default HashFunctions;
|
package/types/HdPublic.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
|
|
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
|
+
|
|
2
5
|
import { EcCompressed } from './EcCompressed';
|
|
6
|
+
import { HdPublicNative } from './wasm/glue';
|
|
3
7
|
export declare class HdPublic {
|
|
4
8
|
private native;
|
|
5
|
-
static fromString(encoded: string): HdPublic | undefined;
|
|
6
|
-
static isValid(encoded: string): boolean;
|
|
7
9
|
constructor(native: HdPublicNative);
|
|
10
|
+
private live;
|
|
11
|
+
dispose(): void;
|
|
8
12
|
toNative(): HdPublicNative;
|
|
13
|
+
static fromString(encoded: string): HdPublic | undefined;
|
|
14
|
+
static isValid(encoded: string): boolean;
|
|
9
15
|
derivePublic(index: number): HdPublic;
|
|
10
16
|
get encoded(): string;
|
|
11
17
|
get point(): EcCompressed;
|
package/types/Input.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
+
|
|
3
5
|
import { OutputPoint } from './OutputPoint';
|
|
6
|
+
import { Script } from './Script';
|
|
7
|
+
import { InputNative } from './wasm/glue';
|
|
4
8
|
export declare class Input {
|
|
5
9
|
previousOutput?: OutputPoint;
|
|
6
10
|
script?: Script;
|
|
7
11
|
seq?: number;
|
|
8
12
|
static fromNative(native: InputNative, destroy?: boolean): Input;
|
|
9
|
-
static fromData(data: Uint8Array): Input | undefined;
|
|
10
|
-
static isValid(previousOutput: OutputPoint, script: Script, seq: number): boolean;
|
|
11
13
|
constructor(previousOutput?: OutputPoint, script?: Script, seq?: number);
|
|
12
|
-
get valid(): boolean;
|
|
13
14
|
toNative(): InputNative;
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
get hasComponents(): boolean;
|
|
16
|
+
static fromData(data: Uint8Array): Input | undefined;
|
|
17
|
+
serializedSize(wire?: boolean): number;
|
|
18
|
+
toData(wire: boolean): Uint8Array;
|
|
16
19
|
}
|
|
17
20
|
export default Input;
|
package/types/InputList.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
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
|
+
|
|
2
5
|
import { Input } from './Input';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
static toNative(inputs: Array<Input>): InputListNative;
|
|
6
|
-
}
|
|
6
|
+
import { InputListNative } from './wasm/glue';
|
|
7
|
+
export declare const InputList: import("./ListHelper").ListAdapter<Input, InputListNative>;
|
|
7
8
|
export default InputList;
|
package/types/Interpreter.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
|
|
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
|
+
|
|
2
5
|
import { Operation } from './Operation';
|
|
6
|
+
import { Program } from './Program';
|
|
3
7
|
export declare class Debugger {
|
|
4
8
|
stepNumber?: number;
|
|
5
9
|
programHistory: Map<number, Program>;
|
|
10
|
+
private snapshot?;
|
|
11
|
+
private root?;
|
|
12
|
+
private created;
|
|
6
13
|
get lastProgram(): Program | undefined;
|
|
7
14
|
start(program: Program): number;
|
|
8
15
|
get stepsAvailable(): boolean;
|
|
9
16
|
stepForward(): number;
|
|
10
17
|
end(): number;
|
|
18
|
+
dispose(): void;
|
|
11
19
|
}
|
|
12
20
|
export declare class Interpreter {
|
|
13
21
|
static run(program: Program): number;
|
package/types/Kth.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 declare class Kth {
|
|
2
6
|
static getLibconfig(): {
|
|
3
7
|
architecture: string;
|
package/types/LazySequence.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 declare class LazySequence<T> {
|
|
2
6
|
private generatorFunc;
|
|
3
7
|
private startIndex;
|
package/types/ListHelper.d.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
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 { ListNative } from './ListNative';
|
|
2
|
-
export declare function fromNative<T, N, L extends ListNative<N>>(nativeList: L, fromNativeFunc: (nativeItem: N) => T): Array<T>;
|
|
6
|
+
export declare function fromNative<T, N, L extends ListNative<N>>(nativeList: L, fromNativeFunc: (nativeItem: N) => T, releaseElement?: (item: T) => void): Array<T>;
|
|
3
7
|
export declare function toNative<T, N, L extends ListNative<N>>(items: Array<T>, toNativeFunc: (item: T) => N, NativeConstructor: new () => L): L;
|
|
8
|
+
export declare function toNativeCopied<T, N, L extends ListNative<N>>(items: Array<T>, toNativeFunc: (item: T) => N, NativeConstructor: new () => L): L;
|
|
4
9
|
export declare function fromNativePrimitive<T, L extends ListNative<T>>(nativeList: L): Array<T>;
|
|
5
10
|
export declare function toNativePrimitive<T, L extends ListNative<T>>(items: Array<T>, NativeConstructor: new () => L): L;
|
|
11
|
+
export interface ListAdapter<T, L> {
|
|
12
|
+
fromNative(native: L, destroy?: boolean): T[];
|
|
13
|
+
toNative(items: T[]): L;
|
|
14
|
+
}
|
|
15
|
+
export declare function definePrimitiveList<T, L extends ListNative<T>>(NativeConstructor: new () => L): ListAdapter<T, L>;
|
|
16
|
+
export declare function defineCopiedList<T, N, L extends ListNative<N>>(NativeConstructor: new () => L, readElement: (native: N) => T, writeElement: (item: T) => N): ListAdapter<T, L>;
|
|
17
|
+
export declare function defineBorrowedList<T, N, L extends ListNative<N>>(NativeConstructor: new () => L, readElement: (native: N) => T, writeElement: (item: T) => N, releaseElement?: (item: T) => void): ListAdapter<T, L>;
|
package/types/ListNative.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 interface ListNative<T> {
|
|
2
6
|
count(): number;
|
|
3
7
|
nth(index: number): T;
|
|
@@ -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 NativeLifetime {
|
|
6
|
+
private readonly held;
|
|
7
|
+
private readonly owners;
|
|
8
|
+
holds<T>(native: T): T;
|
|
9
|
+
dependsOn(owner: unknown): void;
|
|
10
|
+
release(): void;
|
|
11
|
+
}
|
package/types/Opcode.d.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
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
|
+
import { OpcodeAlias } from './OpcodeAliases';
|
|
1
6
|
import { OpcodeEnumNative } from './wasm/glue';
|
|
7
|
+
export type OpcodeName = OpcodeEnumNative | OpcodeAlias;
|
|
2
8
|
export declare class Opcode {
|
|
3
|
-
static
|
|
4
|
-
static
|
|
9
|
+
static resolve(name: OpcodeName): OpcodeEnumNative;
|
|
10
|
+
static toInt(value: OpcodeName): number;
|
|
11
|
+
static toString(value: OpcodeName, activeFlags: bigint): string;
|
|
5
12
|
static fromString(value: string): OpcodeEnumNative | undefined;
|
|
6
|
-
static toHexadecimal(code:
|
|
13
|
+
static toHexadecimal(code: OpcodeName): string;
|
|
7
14
|
static fromHexadecimal(value: string): OpcodeEnumNative | undefined;
|
|
8
15
|
}
|
|
9
16
|
export default Opcode;
|
|
@@ -0,0 +1,16 @@
|
|
|
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 const OPCODE_ALIASES: Readonly<{
|
|
6
|
+
disabled_verif: "op_begin";
|
|
7
|
+
disabled_vernotif: "op_until";
|
|
8
|
+
disabled_invert: "op_invert";
|
|
9
|
+
reserved_137: "op_define";
|
|
10
|
+
reserved_138: "op_invoke";
|
|
11
|
+
disabled_mul2: "op_lshiftnum";
|
|
12
|
+
disabled_div2: "op_rshiftnum";
|
|
13
|
+
disabled_lshift: "op_lshiftbin";
|
|
14
|
+
disabled_rshift: "op_rshiftbin";
|
|
15
|
+
}>;
|
|
16
|
+
export type OpcodeAlias = keyof typeof OPCODE_ALIASES;
|
package/types/Operation.d.ts
CHANGED
|
@@ -1,47 +1,52 @@
|
|
|
1
|
-
|
|
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
|
+
import { OpcodeName } from './Opcode';
|
|
6
|
+
import { OpcodeEnumNative, OperationNative } from './wasm/glue';
|
|
2
7
|
export declare class Operation {
|
|
3
|
-
private opcode
|
|
4
|
-
private encoded
|
|
5
|
-
private minimal
|
|
6
|
-
private rawData
|
|
8
|
+
private opcode?;
|
|
9
|
+
private encoded?;
|
|
10
|
+
private minimal?;
|
|
11
|
+
private rawData?;
|
|
7
12
|
static fromNative(native: OperationNative, destroy?: boolean): Operation;
|
|
8
|
-
static fromData(encoded: Uint8Array): Operation | undefined;
|
|
9
|
-
static fromString(str: string): Operation | undefined;
|
|
10
|
-
static isValid(encoded: Uint8Array, minimal: boolean): boolean;
|
|
11
13
|
constructor();
|
|
12
|
-
constructor(opcode:
|
|
14
|
+
constructor(opcode: OpcodeName);
|
|
13
15
|
constructor(encoded: Uint8Array, minimal?: boolean);
|
|
14
16
|
toNative(): OperationNative;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
static fromData(encoded: Uint8Array): Operation | undefined;
|
|
18
|
+
static fromString(str: string): Operation | undefined;
|
|
19
|
+
static isValid(encoded: Uint8Array, minimal: boolean): boolean;
|
|
20
|
+
toString(activeFlags: bigint): string;
|
|
21
|
+
toData(): Uint8Array;
|
|
17
22
|
get isValid(): boolean;
|
|
18
23
|
get serializedSize(): number;
|
|
19
|
-
get code():
|
|
20
|
-
get data(): Uint8Array
|
|
24
|
+
get code(): OpcodeEnumNative;
|
|
25
|
+
get data(): Uint8Array;
|
|
21
26
|
get isPush(): boolean;
|
|
22
27
|
get isCounted(): boolean;
|
|
23
28
|
get isVersion(): boolean;
|
|
24
29
|
get isPositive(): boolean;
|
|
25
|
-
isDisabled(activeForks: number): void;
|
|
26
30
|
get isConditional(): boolean;
|
|
27
31
|
get isRelaxedPush(): boolean;
|
|
28
|
-
isOversized(maxSize: number): boolean;
|
|
29
32
|
get isMinimalPush(): boolean;
|
|
30
33
|
get isNominalPush(): boolean;
|
|
34
|
+
isDisabled(activeFlags: bigint): boolean;
|
|
35
|
+
isOversized(maxSize: number): boolean;
|
|
31
36
|
static opcodeFromSize(size: number): OpcodeEnumNative;
|
|
32
37
|
static minimalOpcodeFromData(data: Uint8Array): OpcodeEnumNative;
|
|
33
38
|
static nominalOpcodeFromData(data: Uint8Array): OpcodeEnumNative;
|
|
34
39
|
static opcodeFromPositive(value: number): OpcodeEnumNative;
|
|
35
|
-
static opcodeToPositive(code:
|
|
36
|
-
static opcodeIsPush(code:
|
|
37
|
-
static opcodeIsPayload(code:
|
|
38
|
-
static opcodeIsCounted(code:
|
|
39
|
-
static opcodeIsVersion(code:
|
|
40
|
-
static opcodeIsNumeric(code:
|
|
41
|
-
static opcodeIsPositive(code:
|
|
42
|
-
static opcodeIsReserved(code:
|
|
43
|
-
static opcodeIsDisabled(code:
|
|
44
|
-
static opcodeIsConditional(code:
|
|
45
|
-
static opcodeIsRelaxedPush(code:
|
|
40
|
+
static opcodeToPositive(code: OpcodeName): number;
|
|
41
|
+
static opcodeIsPush(code: OpcodeName): boolean;
|
|
42
|
+
static opcodeIsPayload(code: OpcodeName): boolean;
|
|
43
|
+
static opcodeIsCounted(code: OpcodeName): boolean;
|
|
44
|
+
static opcodeIsVersion(code: OpcodeName): boolean;
|
|
45
|
+
static opcodeIsNumeric(code: OpcodeName): boolean;
|
|
46
|
+
static opcodeIsPositive(code: OpcodeName): boolean;
|
|
47
|
+
static opcodeIsReserved(code: OpcodeName): boolean;
|
|
48
|
+
static opcodeIsDisabled(code: OpcodeName, activeFlags: bigint): boolean;
|
|
49
|
+
static opcodeIsConditional(code: OpcodeName): boolean;
|
|
50
|
+
static opcodeIsRelaxedPush(code: OpcodeName): boolean;
|
|
46
51
|
}
|
|
47
52
|
export default Operation;
|
package/types/OperationList.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
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
|
+
|
|
2
5
|
import { Operation } from './Operation';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
static toNative(operations: Array<Operation>): OperationListNative;
|
|
6
|
-
}
|
|
6
|
+
import { OperationListNative } from './wasm/glue';
|
|
7
|
+
export declare const OperationList: import("./ListHelper").ListAdapter<Operation, OperationListNative>;
|
|
7
8
|
export default OperationList;
|
package/types/Output.d.ts
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
|
|
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
|
+
|
|
2
5
|
import { Script } from './Script';
|
|
3
6
|
import { TokenData } from './TokenData';
|
|
7
|
+
import { OutputNative } from './wasm/glue';
|
|
4
8
|
export declare class Output {
|
|
5
9
|
value?: bigint;
|
|
6
10
|
script?: Script;
|
|
7
11
|
tokenData?: TokenData;
|
|
8
12
|
static fromNative(native: OutputNative, destroy?: boolean): Output;
|
|
9
|
-
static fromData(data: Uint8Array): Output | undefined;
|
|
10
|
-
static isValid(value: bigint, script: Script, tokenData?: TokenData): boolean;
|
|
11
|
-
private static validU64Int;
|
|
12
13
|
constructor(value?: bigint, script?: Script, tokenData?: TokenData);
|
|
13
|
-
|
|
14
|
+
private static validU64;
|
|
14
15
|
toNative(): OutputNative;
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
static isValid(value: bigint, script: Script, tokenData?: TokenData): boolean;
|
|
17
|
+
get valid(): boolean;
|
|
18
|
+
static fromData(data: Uint8Array): Output | undefined;
|
|
19
|
+
serializedSize(wire?: boolean): number;
|
|
20
|
+
toData(wire: boolean): Uint8Array;
|
|
17
21
|
}
|
|
18
22
|
export default Output;
|
package/types/OutputList.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
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
|
+
|
|
2
5
|
import { Output } from './Output';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
static toNative(operations: Array<Output>): OutputListNative;
|
|
6
|
-
}
|
|
6
|
+
import { OutputListNative } from './wasm/glue';
|
|
7
|
+
export declare const OutputList: import("./ListHelper").ListAdapter<Output, OutputListNative>;
|
|
7
8
|
export default OutputList;
|
package/types/OutputPoint.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
|
|
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
|
+
|
|
2
5
|
import { Hash } from './Hash';
|
|
3
|
-
import Output from './Output';
|
|
6
|
+
import { Output } from './Output';
|
|
7
|
+
import { OutputPointNative } from './wasm/glue';
|
|
4
8
|
export declare class OutputPoint {
|
|
5
9
|
hash?: Hash;
|
|
6
10
|
index?: number;
|
|
7
11
|
cachedOutput?: Output;
|
|
8
12
|
static fromNative(native: OutputPointNative, destroy?: boolean): OutputPoint;
|
|
9
|
-
static isValid(hash: Hash, index: number): boolean;
|
|
10
13
|
constructor(hash?: Hash, index?: number);
|
|
11
|
-
get valid(): boolean;
|
|
12
14
|
toNative(): OutputPointNative;
|
|
15
|
+
static isValid(hash: Hash, index: number): boolean;
|
|
16
|
+
get valid(): boolean;
|
|
13
17
|
}
|
|
14
18
|
export default OutputPoint;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
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
|
+
|
|
2
5
|
import { Hash, ShortHash } from './Hash';
|
|
3
6
|
import { Script } from './Script';
|
|
7
|
+
import { PaymentAddressNative } from './wasm/glue';
|
|
4
8
|
export declare class PaymentAddress {
|
|
5
9
|
private addressStr;
|
|
6
10
|
private tokenAware;
|
|
@@ -10,14 +14,15 @@ export declare class PaymentAddress {
|
|
|
10
14
|
static testnetP2kh: number;
|
|
11
15
|
static testnetP2sh: number;
|
|
12
16
|
static fromNative(native: PaymentAddressNative, destroy?: boolean): PaymentAddress;
|
|
13
|
-
static fromHash(hash: Hash, version: number): PaymentAddress;
|
|
14
|
-
static fromShortHash(hash: ShortHash, version: number): PaymentAddress;
|
|
15
|
-
static fromString(addressStr: string): PaymentAddress | undefined;
|
|
16
|
-
static isValid(addressStr: string): boolean;
|
|
17
17
|
constructor(addressStr: string, tokenAware?: boolean, legacy?: boolean);
|
|
18
|
-
static fromScript(script: Script, version: number): PaymentAddress;
|
|
19
|
-
static fromPayPublicKeyHashScript(script: Script, version: number): PaymentAddress;
|
|
20
18
|
toNative(): PaymentAddressNative;
|
|
19
|
+
static fromHash(hash: Hash, version: number): PaymentAddress | undefined;
|
|
20
|
+
static fromShortHash(hash: ShortHash, version: number): PaymentAddress | undefined;
|
|
21
|
+
private static parse;
|
|
22
|
+
static fromString(addressStr: string): PaymentAddress | undefined;
|
|
23
|
+
static isValid(addressStr: string): boolean;
|
|
24
|
+
static fromScript(script: Script, version: number): PaymentAddress | undefined;
|
|
25
|
+
static fromPayPublicKeyHashScript(script: Script, version: number): PaymentAddress | undefined;
|
|
21
26
|
get hash20(): ShortHash;
|
|
22
27
|
get hash32(): Hash;
|
|
23
28
|
get hash(): ShortHash;
|
|
@@ -26,8 +31,8 @@ export declare class PaymentAddress {
|
|
|
26
31
|
encodedCashAddr(): string;
|
|
27
32
|
encodedCashTokens(): string;
|
|
28
33
|
encodedLegacy(): string;
|
|
29
|
-
static extract(script: Script, p2khVersion: number, p2shVersion: number): PaymentAddress
|
|
30
|
-
static extractInput(script: Script, p2khVersion: number, p2shVersion: number): PaymentAddress
|
|
31
|
-
static extractOutput(script: Script, p2khVersion: number, p2shVersion: number): PaymentAddress
|
|
34
|
+
static extract(script: Script, p2khVersion: number, p2shVersion: number): Array<PaymentAddress>;
|
|
35
|
+
static extractInput(script: Script, p2khVersion: number, p2shVersion: number): Array<PaymentAddress>;
|
|
36
|
+
static extractOutput(script: Script, p2khVersion: number, p2shVersion: number): Array<PaymentAddress>;
|
|
32
37
|
}
|
|
33
38
|
export default PaymentAddress;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
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
|
+
|
|
2
5
|
import { PaymentAddress } from './PaymentAddress';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
static toNative(paymentAddresses: Array<PaymentAddress>): PaymentAddressListNative;
|
|
6
|
-
}
|
|
6
|
+
import { PaymentAddressListNative } from './wasm/glue';
|
|
7
|
+
export declare const PaymentAddressList: import("./ListHelper").ListAdapter<PaymentAddress, PaymentAddressListNative>;
|
|
7
8
|
export default PaymentAddressList;
|