@btc-vision/transaction 1.1.3 → 1.1.4
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/browser/_version.d.ts +1 -1
- package/browser/index.js +1 -1
- package/browser/transaction/browser/types/Unisat.d.ts +7 -3
- package/browser/utils/BitcoinUtils.d.ts +1 -1
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/transaction/browser/types/Unisat.d.ts +7 -3
- package/build/utils/BitcoinUtils.d.ts +1 -1
- package/build/utils/BitcoinUtils.js +6 -3
- package/package.json +1 -1
- package/src/_version.ts +1 -1
- package/src/transaction/browser/types/Unisat.ts +11 -3
- package/src/utils/BitcoinUtils.ts +12 -3
|
@@ -52,7 +52,7 @@ export interface Unisat {
|
|
|
52
52
|
}): Promise<string>;
|
|
53
53
|
requestAccounts(): Promise<string[]>;
|
|
54
54
|
getNetwork(): Promise<UnisatNetwork>;
|
|
55
|
-
getChain(): Promise<
|
|
55
|
+
getChain(): Promise<UnisatChainInfo>;
|
|
56
56
|
getAccounts(): Promise<string[]>;
|
|
57
57
|
switchNetwork(network: UnisatNetwork): Promise<void>;
|
|
58
58
|
getPublicKey(): Promise<string>;
|
|
@@ -65,8 +65,12 @@ export interface Unisat {
|
|
|
65
65
|
signPsbts(psbtHex: string[], psbtOptions: PsbtSignatureOptions[]): Promise<string[]>;
|
|
66
66
|
pushPsbt(psbtHex: string): Promise<string>;
|
|
67
67
|
on(event: 'accountsChanged', listener: (accounts: string[]) => void): void;
|
|
68
|
-
on(event: 'chainChanged'
|
|
68
|
+
on(event: 'chainChanged', listener: (chain: UnisatChainInfo) => void): void;
|
|
69
|
+
on(event: 'networkChanged', listener: (network: UnisatChainInfo) => void): void;
|
|
70
|
+
on(event: 'disconnect', listener: () => void): void;
|
|
69
71
|
removeListener(event: 'accountsChanged', listener: (accounts: string[]) => void): void;
|
|
70
|
-
removeListener(event: '
|
|
72
|
+
removeListener(event: 'chainChanged', listener: (chain: UnisatChainInfo) => void): void;
|
|
73
|
+
removeListener(event: 'networkChanged', listener: (network: UnisatChainInfo) => void): void;
|
|
74
|
+
removeListener(event: 'disconnect', listener: () => void): void;
|
|
71
75
|
}
|
|
72
76
|
export {};
|
package/build/_version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.1.
|
|
1
|
+
export declare const version = "1.1.4";
|
package/build/_version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.1.
|
|
1
|
+
export const version = '1.1.4';
|
|
@@ -52,7 +52,7 @@ export interface Unisat {
|
|
|
52
52
|
}): Promise<string>;
|
|
53
53
|
requestAccounts(): Promise<string[]>;
|
|
54
54
|
getNetwork(): Promise<UnisatNetwork>;
|
|
55
|
-
getChain(): Promise<
|
|
55
|
+
getChain(): Promise<UnisatChainInfo>;
|
|
56
56
|
getAccounts(): Promise<string[]>;
|
|
57
57
|
switchNetwork(network: UnisatNetwork): Promise<void>;
|
|
58
58
|
getPublicKey(): Promise<string>;
|
|
@@ -65,8 +65,12 @@ export interface Unisat {
|
|
|
65
65
|
signPsbts(psbtHex: string[], psbtOptions: PsbtSignatureOptions[]): Promise<string[]>;
|
|
66
66
|
pushPsbt(psbtHex: string): Promise<string>;
|
|
67
67
|
on(event: 'accountsChanged', listener: (accounts: string[]) => void): void;
|
|
68
|
-
on(event: 'chainChanged'
|
|
68
|
+
on(event: 'chainChanged', listener: (chain: UnisatChainInfo) => void): void;
|
|
69
|
+
on(event: 'networkChanged', listener: (network: UnisatChainInfo) => void): void;
|
|
70
|
+
on(event: 'disconnect', listener: () => void): void;
|
|
69
71
|
removeListener(event: 'accountsChanged', listener: (accounts: string[]) => void): void;
|
|
70
|
-
removeListener(event: '
|
|
72
|
+
removeListener(event: 'chainChanged', listener: (chain: UnisatChainInfo) => void): void;
|
|
73
|
+
removeListener(event: 'networkChanged', listener: (network: UnisatChainInfo) => void): void;
|
|
74
|
+
removeListener(event: 'disconnect', listener: () => void): void;
|
|
71
75
|
}
|
|
72
76
|
export {};
|
|
@@ -4,11 +4,13 @@ export class BitcoinUtils {
|
|
|
4
4
|
return BigInt(btc * 100000000);
|
|
5
5
|
}
|
|
6
6
|
static rndBytes() {
|
|
7
|
-
const buf = BitcoinUtils.
|
|
7
|
+
const buf = BitcoinUtils.getSafeRandomValues(64);
|
|
8
8
|
return Buffer.from(buf);
|
|
9
9
|
}
|
|
10
|
-
static
|
|
11
|
-
if (typeof window !== 'undefined' &&
|
|
10
|
+
static getSafeRandomValues(length) {
|
|
11
|
+
if (typeof globalThis.window !== 'undefined' &&
|
|
12
|
+
globalThis.window.crypto &&
|
|
13
|
+
typeof globalThis.window.crypto.getRandomValues === 'function') {
|
|
12
14
|
const array = new Uint8Array(length);
|
|
13
15
|
window.crypto.getRandomValues(array);
|
|
14
16
|
return Buffer.from(array);
|
|
@@ -19,6 +21,7 @@ export class BitcoinUtils {
|
|
|
19
21
|
return Buffer.from(array);
|
|
20
22
|
}
|
|
21
23
|
else {
|
|
24
|
+
console.log(`No secure random number generator available. Please upgrade your environment.`, globalThis.window.crypto, crypto);
|
|
22
25
|
throw new Error('No secure random number generator available. Please upgrade your environment.');
|
|
23
26
|
}
|
|
24
27
|
}
|
package/package.json
CHANGED
package/src/_version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.1.
|
|
1
|
+
export const version = '1.1.4';
|
|
@@ -67,7 +67,7 @@ export interface Unisat {
|
|
|
67
67
|
|
|
68
68
|
getNetwork(): Promise<UnisatNetwork>;
|
|
69
69
|
|
|
70
|
-
getChain(): Promise<
|
|
70
|
+
getChain(): Promise<UnisatChainInfo>;
|
|
71
71
|
|
|
72
72
|
getAccounts(): Promise<string[]>;
|
|
73
73
|
|
|
@@ -89,9 +89,17 @@ export interface Unisat {
|
|
|
89
89
|
|
|
90
90
|
on(event: 'accountsChanged', listener: (accounts: string[]) => void): void;
|
|
91
91
|
|
|
92
|
-
on(event: 'chainChanged'
|
|
92
|
+
on(event: 'chainChanged', listener: (chain: UnisatChainInfo) => void): void;
|
|
93
|
+
|
|
94
|
+
on(event: 'networkChanged', listener: (network: UnisatChainInfo) => void): void;
|
|
95
|
+
|
|
96
|
+
on(event: 'disconnect', listener: () => void): void;
|
|
93
97
|
|
|
94
98
|
removeListener(event: 'accountsChanged', listener: (accounts: string[]) => void): void;
|
|
95
99
|
|
|
96
|
-
removeListener(event: '
|
|
100
|
+
removeListener(event: 'chainChanged', listener: (chain: UnisatChainInfo) => void): void;
|
|
101
|
+
|
|
102
|
+
removeListener(event: 'networkChanged', listener: (network: UnisatChainInfo) => void): void;
|
|
103
|
+
|
|
104
|
+
removeListener(event: 'disconnect', listener: () => void): void;
|
|
97
105
|
}
|
|
@@ -19,13 +19,17 @@ export class BitcoinUtils {
|
|
|
19
19
|
* @returns {Buffer} The random bytes
|
|
20
20
|
*/
|
|
21
21
|
public static rndBytes(): Buffer {
|
|
22
|
-
const buf = BitcoinUtils.
|
|
22
|
+
const buf = BitcoinUtils.getSafeRandomValues(64);
|
|
23
23
|
|
|
24
24
|
return Buffer.from(buf);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
public static
|
|
28
|
-
if (
|
|
27
|
+
public static getSafeRandomValues(length: number): Buffer {
|
|
28
|
+
if (
|
|
29
|
+
typeof globalThis.window !== 'undefined' &&
|
|
30
|
+
globalThis.window.crypto &&
|
|
31
|
+
typeof globalThis.window.crypto.getRandomValues === 'function'
|
|
32
|
+
) {
|
|
29
33
|
const array = new Uint8Array(length);
|
|
30
34
|
window.crypto.getRandomValues(array);
|
|
31
35
|
|
|
@@ -36,6 +40,11 @@ export class BitcoinUtils {
|
|
|
36
40
|
|
|
37
41
|
return Buffer.from(array);
|
|
38
42
|
} else {
|
|
43
|
+
console.log(
|
|
44
|
+
`No secure random number generator available. Please upgrade your environment.`,
|
|
45
|
+
globalThis.window.crypto,
|
|
46
|
+
crypto,
|
|
47
|
+
);
|
|
39
48
|
throw new Error(
|
|
40
49
|
'No secure random number generator available. Please upgrade your environment.',
|
|
41
50
|
);
|