@btc-vision/bitcoin 6.3.2 → 6.3.3
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/.gitattributes +2 -2
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/.ready +0 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/.release-please-manifest.json +3 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/CHANGELOG.md +962 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/CONTRIBUTING.md +34 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/LICENSE +24 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/README.md +273 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/SECURITY.md +2 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/addon.gypi +204 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/bin/node-gyp.js +138 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/.release-please-manifest.json +3 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/LICENSE +28 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/data/ninja/build.ninja +4 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/data/win/large-pdb-shim.cc +12 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/GypVsCMake.md +116 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/Hacking.md +46 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/InputFormatReference.md +1080 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/LanguageSpecification.md +430 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/README.md +27 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/Testing.md +450 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/UserDocumentation.md +965 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp +8 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp.bat +5 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp_main.py +45 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +365 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +206 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +1272 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +1547 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +59 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +153 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +271 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +574 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +692 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/common.py +711 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +171 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +169 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +113 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +55 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +804 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +1173 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +1318 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +127 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +103 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +461 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +89 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +57 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +2745 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +3976 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +44 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +2964 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +67 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +1391 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +25 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/input.py +3115 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +98 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +771 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +1260 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +174 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +61 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +373 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +1938 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation_test.py +53 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +302 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +3198 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +65 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE +3 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.APACHE +177 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.BSD +23 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/__init__.py +15 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_elffile.py +108 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_manylinux.py +252 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_musllinux.py +83 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_parser.py +359 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_structures.py +61 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_tokenizer.py +192 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/markers.py +252 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/metadata.py +825 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/py.typed +0 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/requirements.py +90 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/specifiers.py +1030 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/tags.py +553 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/utils.py +172 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/version.py +563 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pyproject.toml +120 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/release-please-config.json +11 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/test_gyp.py +261 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/Find-VisualStudio.cs +250 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/build.js +227 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/clean.js +15 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/configure.js +328 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/create-config-gypi.js +150 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/download.js +39 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-node-directory.js +63 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-python.js +310 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-visualstudio.js +590 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/install.js +415 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/list.js +26 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/log.js +168 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/node-gyp.js +188 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/process-release.js +146 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/rebuild.js +12 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/remove.js +43 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/util.js +81 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/macOS_Catalina_acid_test.sh +21 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/package.json +51 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/release-please-config.json +40 -0
- package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/src/win_delay_load_hook.cc +39 -0
- package/browser/index.js +1 -1
- package/browser/payments/index.d.ts +2 -0
- package/browser/psbt.d.ts +3 -3
- package/build/payments/index.d.ts +2 -0
- package/build/payments/p2pkh.js +48 -10
- package/build/payments/p2sh.js +2 -1
- package/build/psbt/psbtutils.js +11 -4
- package/build/psbt.d.ts +3 -3
- package/build/psbt.js +9 -7
- package/coverage/tmp/coverage-31752-1735543485354-0.json +1 -0
- package/coverage/tmp/coverage-59920-1735543484555-0.json +1 -0
- package/coverage/tmp/coverage-66252-1735543483919-0.json +1 -0
- package/coverage/tmp/coverage-68440-1735543485236-0.json +1 -0
- package/coverage/tmp/coverage-70588-1735543484426-0.json +1 -0
- package/coverage/tmp/coverage-79292-1735543485296-0.json +1 -0
- package/coverage/tmp/coverage-80212-1735543483980-0.json +1 -0
- package/eslint.config.js +56 -56
- package/package.json +1 -1
- package/src/address.ts +211 -211
- package/src/crypto/crypto-browser.js +75 -75
- package/src/crypto/crypto.ts +1 -1
- package/src/hooks/HookedSigner.ts +108 -108
- package/src/index.ts +86 -86
- package/src/networks.ts +235 -235
- package/src/payments/embed.ts +55 -55
- package/src/payments/index.ts +4 -0
- package/src/payments/lazy.ts +28 -28
- package/src/payments/p2pk.ts +85 -85
- package/src/payments/p2pkh.ts +67 -10
- package/src/payments/p2sh.ts +206 -205
- package/src/psbt/bip371.ts +441 -441
- package/src/psbt/psbtutils.ts +13 -11
- package/src/psbt.ts +2187 -2174
- package/src/types.ts +122 -122
- package/webpack.config.js +79 -79
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
/* Browser Crypto Shims */
|
|
2
|
-
import { hmac } from '@noble/hashes/hmac';
|
|
3
|
-
import { pbkdf2 } from '@noble/hashes/pbkdf2';
|
|
4
|
-
import { sha256 } from '@noble/hashes/sha256';
|
|
5
|
-
import { sha512 } from '@noble/hashes/sha512';
|
|
6
|
-
import assert from 'assert';
|
|
7
|
-
|
|
8
|
-
function assertArgument(check, message, name, value) {
|
|
9
|
-
assert(check, message, 'INVALID_ARGUMENT', { argument: name, value: value });
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function getGlobal() {
|
|
13
|
-
if (typeof self !== 'undefined') {
|
|
14
|
-
return self;
|
|
15
|
-
}
|
|
16
|
-
if (typeof window !== 'undefined') {
|
|
17
|
-
return window;
|
|
18
|
-
}
|
|
19
|
-
if (typeof global !== 'undefined') {
|
|
20
|
-
return global;
|
|
21
|
-
}
|
|
22
|
-
throw new Error('unable to locate global object');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const anyGlobal = getGlobal();
|
|
26
|
-
const crypto = anyGlobal.crypto || anyGlobal.msCrypto;
|
|
27
|
-
|
|
28
|
-
export function createHash(algo) {
|
|
29
|
-
switch (algo) {
|
|
30
|
-
case 'sha256':
|
|
31
|
-
return sha256.create();
|
|
32
|
-
case 'sha512':
|
|
33
|
-
return sha512.create();
|
|
34
|
-
}
|
|
35
|
-
assertArgument(false, 'invalid hashing algorithm name', 'algorithm', algo);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function createHmac(_algo, key) {
|
|
39
|
-
const algo = { sha256, sha512 }[_algo];
|
|
40
|
-
assertArgument(algo != null, 'invalid hmac algorithm', 'algorithm', _algo);
|
|
41
|
-
return hmac.create(algo, key);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function pbkdf2Sync(password, salt, iterations, keylen, _algo) {
|
|
45
|
-
const algo = { sha256, sha512 }[_algo];
|
|
46
|
-
assertArgument(algo != null, 'invalid pbkdf2 algorithm', 'algorithm', _algo);
|
|
47
|
-
return pbkdf2(algo, password, salt, { c: iterations, dkLen: keylen });
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function randomBytes(length) {
|
|
51
|
-
assert(
|
|
52
|
-
crypto != null,
|
|
53
|
-
'platform does not support secure random numbers',
|
|
54
|
-
'UNSUPPORTED_OPERATION',
|
|
55
|
-
{
|
|
56
|
-
operation: 'randomBytes',
|
|
57
|
-
},
|
|
58
|
-
);
|
|
59
|
-
assertArgument(
|
|
60
|
-
Number.isInteger(length) && length > 0 && length <= 1024,
|
|
61
|
-
'invalid length',
|
|
62
|
-
'length',
|
|
63
|
-
length,
|
|
64
|
-
);
|
|
65
|
-
const result = new Uint8Array(length);
|
|
66
|
-
crypto.getRandomValues(result);
|
|
67
|
-
return result;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export default {
|
|
71
|
-
createHash,
|
|
72
|
-
createHmac,
|
|
73
|
-
pbkdf2Sync,
|
|
74
|
-
randomBytes,
|
|
75
|
-
};
|
|
1
|
+
/* Browser Crypto Shims */
|
|
2
|
+
import { hmac } from '@noble/hashes/hmac';
|
|
3
|
+
import { pbkdf2 } from '@noble/hashes/pbkdf2';
|
|
4
|
+
import { sha256 } from '@noble/hashes/sha256';
|
|
5
|
+
import { sha512 } from '@noble/hashes/sha512';
|
|
6
|
+
import assert from 'assert';
|
|
7
|
+
|
|
8
|
+
function assertArgument(check, message, name, value) {
|
|
9
|
+
assert(check, message, 'INVALID_ARGUMENT', { argument: name, value: value });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getGlobal() {
|
|
13
|
+
if (typeof self !== 'undefined') {
|
|
14
|
+
return self;
|
|
15
|
+
}
|
|
16
|
+
if (typeof window !== 'undefined') {
|
|
17
|
+
return window;
|
|
18
|
+
}
|
|
19
|
+
if (typeof global !== 'undefined') {
|
|
20
|
+
return global;
|
|
21
|
+
}
|
|
22
|
+
throw new Error('unable to locate global object');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const anyGlobal = getGlobal();
|
|
26
|
+
const crypto = anyGlobal.crypto || anyGlobal.msCrypto;
|
|
27
|
+
|
|
28
|
+
export function createHash(algo) {
|
|
29
|
+
switch (algo) {
|
|
30
|
+
case 'sha256':
|
|
31
|
+
return sha256.create();
|
|
32
|
+
case 'sha512':
|
|
33
|
+
return sha512.create();
|
|
34
|
+
}
|
|
35
|
+
assertArgument(false, 'invalid hashing algorithm name', 'algorithm', algo);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function createHmac(_algo, key) {
|
|
39
|
+
const algo = { sha256, sha512 }[_algo];
|
|
40
|
+
assertArgument(algo != null, 'invalid hmac algorithm', 'algorithm', _algo);
|
|
41
|
+
return hmac.create(algo, key);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function pbkdf2Sync(password, salt, iterations, keylen, _algo) {
|
|
45
|
+
const algo = { sha256, sha512 }[_algo];
|
|
46
|
+
assertArgument(algo != null, 'invalid pbkdf2 algorithm', 'algorithm', _algo);
|
|
47
|
+
return pbkdf2(algo, password, salt, { c: iterations, dkLen: keylen });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function randomBytes(length) {
|
|
51
|
+
assert(
|
|
52
|
+
crypto != null,
|
|
53
|
+
'platform does not support secure random numbers',
|
|
54
|
+
'UNSUPPORTED_OPERATION',
|
|
55
|
+
{
|
|
56
|
+
operation: 'randomBytes',
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
assertArgument(
|
|
60
|
+
Number.isInteger(length) && length > 0 && length <= 1024,
|
|
61
|
+
'invalid length',
|
|
62
|
+
'length',
|
|
63
|
+
length,
|
|
64
|
+
);
|
|
65
|
+
const result = new Uint8Array(length);
|
|
66
|
+
crypto.getRandomValues(result);
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default {
|
|
71
|
+
createHash,
|
|
72
|
+
createHmac,
|
|
73
|
+
pbkdf2Sync,
|
|
74
|
+
randomBytes,
|
|
75
|
+
};
|
package/src/crypto/crypto.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createHash, createHmac, pbkdf2Sync, randomBytes } from 'crypto';
|
|
1
|
+
export { createHash, createHmac, pbkdf2Sync, randomBytes } from 'crypto';
|
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
import { BIP32Interface } from 'bip32';
|
|
2
|
-
import { ECPairInterface } from 'ecpair';
|
|
3
|
-
import { Signer, SignerAlternative, SignerAsync } from '../psbt.js';
|
|
4
|
-
|
|
5
|
-
import { SignatureManager } from './SignatureManager.js';
|
|
6
|
-
import { AdvancedSignatureManager } from './AdvancedSignatureManager.js';
|
|
7
|
-
|
|
8
|
-
interface HookSigner {
|
|
9
|
-
hasHook?: boolean;
|
|
10
|
-
signatureManager: SignatureManager;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
type HookedSigner = (Signer | SignerAlternative | SignerAsync | BIP32Interface | ECPairInterface) &
|
|
14
|
-
HookSigner;
|
|
15
|
-
|
|
16
|
-
const advancedSignatureManager: AdvancedSignatureManager = AdvancedSignatureManager.getInstance();
|
|
17
|
-
|
|
18
|
-
function getPublicKey(keyPair: HookedSigner): string | undefined {
|
|
19
|
-
if (keyPair.publicKey && Buffer.isBuffer(keyPair.publicKey)) {
|
|
20
|
-
return keyPair.publicKey.toString('hex');
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function hookKeyPair(keyPair: HookedSigner) {
|
|
25
|
-
const oldSign = keyPair.sign;
|
|
26
|
-
|
|
27
|
-
if (oldSign) {
|
|
28
|
-
keyPair.sign = new Proxy(oldSign, {
|
|
29
|
-
apply: function (target, thisArg, argumentsList) {
|
|
30
|
-
const publicKey = getPublicKey(keyPair);
|
|
31
|
-
const hash = argumentsList[0];
|
|
32
|
-
|
|
33
|
-
if (publicKey) {
|
|
34
|
-
let possibleSignature = advancedSignatureManager.getSignature(publicKey, hash);
|
|
35
|
-
|
|
36
|
-
if (!possibleSignature) {
|
|
37
|
-
possibleSignature = advancedSignatureManager.addSignature(
|
|
38
|
-
publicKey,
|
|
39
|
-
hash,
|
|
40
|
-
Reflect.apply(target, thisArg, argumentsList),
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return possibleSignature;
|
|
45
|
-
} else {
|
|
46
|
-
let possibleSignature = keyPair.signatureManager.getSignature(hash);
|
|
47
|
-
|
|
48
|
-
if (!possibleSignature) {
|
|
49
|
-
possibleSignature = keyPair.signatureManager.addSignature(
|
|
50
|
-
hash,
|
|
51
|
-
Reflect.apply(target, thisArg, argumentsList),
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return possibleSignature;
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const oldSignSchnorr = keyPair.signSchnorr;
|
|
62
|
-
if (oldSignSchnorr) {
|
|
63
|
-
keyPair.signSchnorr = new Proxy(oldSignSchnorr, {
|
|
64
|
-
apply: function (target, thisArg, argumentsList) {
|
|
65
|
-
const publicKey = getPublicKey(keyPair);
|
|
66
|
-
const hash = argumentsList[0];
|
|
67
|
-
|
|
68
|
-
if (publicKey) {
|
|
69
|
-
let possibleSignature = advancedSignatureManager.getSignature(publicKey, hash);
|
|
70
|
-
|
|
71
|
-
if (!possibleSignature) {
|
|
72
|
-
possibleSignature = advancedSignatureManager.addSignature(
|
|
73
|
-
publicKey,
|
|
74
|
-
hash,
|
|
75
|
-
Reflect.apply(target, thisArg, argumentsList),
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return possibleSignature;
|
|
80
|
-
} else {
|
|
81
|
-
let possibleSignature = keyPair.signatureManager.getSignature(hash);
|
|
82
|
-
|
|
83
|
-
if (!possibleSignature) {
|
|
84
|
-
possibleSignature = keyPair.signatureManager.addSignature(
|
|
85
|
-
hash,
|
|
86
|
-
Reflect.apply(target, thisArg, argumentsList),
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return possibleSignature;
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export function hookSigner(
|
|
98
|
-
keyPair: Signer | SignerAlternative | SignerAsync | BIP32Interface | ECPairInterface,
|
|
99
|
-
) {
|
|
100
|
-
const newKeypair: HookedSigner = keyPair as HookedSigner;
|
|
101
|
-
|
|
102
|
-
if (!newKeypair.hasHook) {
|
|
103
|
-
newKeypair.hasHook = true;
|
|
104
|
-
newKeypair.signatureManager = new SignatureManager();
|
|
105
|
-
|
|
106
|
-
hookKeyPair(newKeypair);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
1
|
+
import { BIP32Interface } from 'bip32';
|
|
2
|
+
import { ECPairInterface } from 'ecpair';
|
|
3
|
+
import { Signer, SignerAlternative, SignerAsync } from '../psbt.js';
|
|
4
|
+
|
|
5
|
+
import { SignatureManager } from './SignatureManager.js';
|
|
6
|
+
import { AdvancedSignatureManager } from './AdvancedSignatureManager.js';
|
|
7
|
+
|
|
8
|
+
interface HookSigner {
|
|
9
|
+
hasHook?: boolean;
|
|
10
|
+
signatureManager: SignatureManager;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type HookedSigner = (Signer | SignerAlternative | SignerAsync | BIP32Interface | ECPairInterface) &
|
|
14
|
+
HookSigner;
|
|
15
|
+
|
|
16
|
+
const advancedSignatureManager: AdvancedSignatureManager = AdvancedSignatureManager.getInstance();
|
|
17
|
+
|
|
18
|
+
function getPublicKey(keyPair: HookedSigner): string | undefined {
|
|
19
|
+
if (keyPair.publicKey && Buffer.isBuffer(keyPair.publicKey)) {
|
|
20
|
+
return keyPair.publicKey.toString('hex');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function hookKeyPair(keyPair: HookedSigner) {
|
|
25
|
+
const oldSign = keyPair.sign;
|
|
26
|
+
|
|
27
|
+
if (oldSign) {
|
|
28
|
+
keyPair.sign = new Proxy(oldSign, {
|
|
29
|
+
apply: function (target, thisArg, argumentsList) {
|
|
30
|
+
const publicKey = getPublicKey(keyPair);
|
|
31
|
+
const hash = argumentsList[0];
|
|
32
|
+
|
|
33
|
+
if (publicKey) {
|
|
34
|
+
let possibleSignature = advancedSignatureManager.getSignature(publicKey, hash);
|
|
35
|
+
|
|
36
|
+
if (!possibleSignature) {
|
|
37
|
+
possibleSignature = advancedSignatureManager.addSignature(
|
|
38
|
+
publicKey,
|
|
39
|
+
hash,
|
|
40
|
+
Reflect.apply(target, thisArg, argumentsList),
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return possibleSignature;
|
|
45
|
+
} else {
|
|
46
|
+
let possibleSignature = keyPair.signatureManager.getSignature(hash);
|
|
47
|
+
|
|
48
|
+
if (!possibleSignature) {
|
|
49
|
+
possibleSignature = keyPair.signatureManager.addSignature(
|
|
50
|
+
hash,
|
|
51
|
+
Reflect.apply(target, thisArg, argumentsList),
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return possibleSignature;
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const oldSignSchnorr = keyPair.signSchnorr;
|
|
62
|
+
if (oldSignSchnorr) {
|
|
63
|
+
keyPair.signSchnorr = new Proxy(oldSignSchnorr, {
|
|
64
|
+
apply: function (target, thisArg, argumentsList) {
|
|
65
|
+
const publicKey = getPublicKey(keyPair);
|
|
66
|
+
const hash = argumentsList[0];
|
|
67
|
+
|
|
68
|
+
if (publicKey) {
|
|
69
|
+
let possibleSignature = advancedSignatureManager.getSignature(publicKey, hash);
|
|
70
|
+
|
|
71
|
+
if (!possibleSignature) {
|
|
72
|
+
possibleSignature = advancedSignatureManager.addSignature(
|
|
73
|
+
publicKey,
|
|
74
|
+
hash,
|
|
75
|
+
Reflect.apply(target, thisArg, argumentsList),
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return possibleSignature;
|
|
80
|
+
} else {
|
|
81
|
+
let possibleSignature = keyPair.signatureManager.getSignature(hash);
|
|
82
|
+
|
|
83
|
+
if (!possibleSignature) {
|
|
84
|
+
possibleSignature = keyPair.signatureManager.addSignature(
|
|
85
|
+
hash,
|
|
86
|
+
Reflect.apply(target, thisArg, argumentsList),
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return possibleSignature;
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function hookSigner(
|
|
98
|
+
keyPair: Signer | SignerAlternative | SignerAsync | BIP32Interface | ECPairInterface,
|
|
99
|
+
) {
|
|
100
|
+
const newKeypair: HookedSigner = keyPair as HookedSigner;
|
|
101
|
+
|
|
102
|
+
if (!newKeypair.hasHook) {
|
|
103
|
+
newKeypair.hasHook = true;
|
|
104
|
+
newKeypair.signatureManager = new SignatureManager();
|
|
105
|
+
|
|
106
|
+
hookKeyPair(newKeypair);
|
|
107
|
+
}
|
|
108
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PsbtInput as _PsbtInput,
|
|
3
|
-
PsbtInputUpdate as _PsbtInputUpdate,
|
|
4
|
-
PsbtOutput as _PsbtOutput,
|
|
5
|
-
TapBip32Derivation as _TapBip32Derivation,
|
|
6
|
-
TapInternalKey as _TapInternalKey,
|
|
7
|
-
TapKeySig as _TapKeySig,
|
|
8
|
-
TapLeaf as _TapLeaf,
|
|
9
|
-
TapLeafScript as _TapLeafScript,
|
|
10
|
-
TapMerkleRoot as _TapMerkleRoot,
|
|
11
|
-
TapScriptSig as _TapScriptSig,
|
|
12
|
-
TapTree as _TapTree,
|
|
13
|
-
} from 'bip174/src/lib/interfaces.js';
|
|
14
|
-
import * as networks from './networks.js';
|
|
15
|
-
import * as address from './address.js';
|
|
16
|
-
import * as payments from './payments/index.js';
|
|
17
|
-
import * as script from './script.js';
|
|
18
|
-
import * as crypto from './crypto.js';
|
|
19
|
-
import * as Transaction from './transaction.js';
|
|
20
|
-
|
|
21
|
-
export * as address from './address.js';
|
|
22
|
-
export * as crypto from './crypto.js';
|
|
23
|
-
export * as networks from './networks.js';
|
|
24
|
-
export * as payments from './payments/index.js';
|
|
25
|
-
export * as script from './script.js';
|
|
26
|
-
|
|
27
|
-
export { Block } from './block.js';
|
|
28
|
-
/** @hidden */
|
|
29
|
-
export * from './crypto.js';
|
|
30
|
-
export * from './psbt.js';
|
|
31
|
-
/** @hidden */
|
|
32
|
-
export { OPS as opcodes } from './ops.js';
|
|
33
|
-
export { Transaction } from './transaction.js';
|
|
34
|
-
/** @hidden */
|
|
35
|
-
export { Network } from './networks.js';
|
|
36
|
-
/** @hidden */
|
|
37
|
-
export { initEccLib } from './ecc_lib.js';
|
|
38
|
-
export { Payment, PaymentCreator, PaymentOpts, Stack, StackElement } from './payments/index.js';
|
|
39
|
-
export { Input as TxInput, Output as TxOutput } from './transaction.js';
|
|
40
|
-
|
|
41
|
-
export interface PsbtInput extends _PsbtInput {}
|
|
42
|
-
|
|
43
|
-
export interface PsbtOutput extends _PsbtOutput {}
|
|
44
|
-
|
|
45
|
-
export interface TapInternalKey extends _TapInternalKey {}
|
|
46
|
-
|
|
47
|
-
export interface TapLeaf extends _TapLeaf {}
|
|
48
|
-
|
|
49
|
-
export interface TapScriptSig extends _TapScriptSig {}
|
|
50
|
-
|
|
51
|
-
export interface TapKeySig extends _TapKeySig {}
|
|
52
|
-
|
|
53
|
-
export interface TapTree extends _TapTree {}
|
|
54
|
-
|
|
55
|
-
export interface TapMerkleRoot extends _TapMerkleRoot {}
|
|
56
|
-
|
|
57
|
-
export interface TapLeafScript extends _TapLeafScript {}
|
|
58
|
-
|
|
59
|
-
export interface TapBip32Derivation extends _TapBip32Derivation {}
|
|
60
|
-
|
|
61
|
-
export interface PsbtInputUpdate extends _PsbtInputUpdate {}
|
|
62
|
-
|
|
63
|
-
export * from './psbt/bip371.js';
|
|
64
|
-
export * from './address.js';
|
|
65
|
-
export * from './bufferutils.js';
|
|
66
|
-
export * from './payments/bip341.js';
|
|
67
|
-
export * from './psbt/psbtutils.js';
|
|
68
|
-
|
|
69
|
-
export {
|
|
70
|
-
Taptree,
|
|
71
|
-
XOnlyPointAddTweakResult,
|
|
72
|
-
Tapleaf,
|
|
73
|
-
TinySecp256k1Interface,
|
|
74
|
-
TAPLEAF_VERSION_MASK,
|
|
75
|
-
} from './types.js';
|
|
76
|
-
|
|
77
|
-
const bitcoin = {
|
|
78
|
-
networks,
|
|
79
|
-
address,
|
|
80
|
-
payments,
|
|
81
|
-
script,
|
|
82
|
-
crypto,
|
|
83
|
-
Transaction,
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export default bitcoin;
|
|
1
|
+
import {
|
|
2
|
+
PsbtInput as _PsbtInput,
|
|
3
|
+
PsbtInputUpdate as _PsbtInputUpdate,
|
|
4
|
+
PsbtOutput as _PsbtOutput,
|
|
5
|
+
TapBip32Derivation as _TapBip32Derivation,
|
|
6
|
+
TapInternalKey as _TapInternalKey,
|
|
7
|
+
TapKeySig as _TapKeySig,
|
|
8
|
+
TapLeaf as _TapLeaf,
|
|
9
|
+
TapLeafScript as _TapLeafScript,
|
|
10
|
+
TapMerkleRoot as _TapMerkleRoot,
|
|
11
|
+
TapScriptSig as _TapScriptSig,
|
|
12
|
+
TapTree as _TapTree,
|
|
13
|
+
} from 'bip174/src/lib/interfaces.js';
|
|
14
|
+
import * as networks from './networks.js';
|
|
15
|
+
import * as address from './address.js';
|
|
16
|
+
import * as payments from './payments/index.js';
|
|
17
|
+
import * as script from './script.js';
|
|
18
|
+
import * as crypto from './crypto.js';
|
|
19
|
+
import * as Transaction from './transaction.js';
|
|
20
|
+
|
|
21
|
+
export * as address from './address.js';
|
|
22
|
+
export * as crypto from './crypto.js';
|
|
23
|
+
export * as networks from './networks.js';
|
|
24
|
+
export * as payments from './payments/index.js';
|
|
25
|
+
export * as script from './script.js';
|
|
26
|
+
|
|
27
|
+
export { Block } from './block.js';
|
|
28
|
+
/** @hidden */
|
|
29
|
+
export * from './crypto.js';
|
|
30
|
+
export * from './psbt.js';
|
|
31
|
+
/** @hidden */
|
|
32
|
+
export { OPS as opcodes } from './ops.js';
|
|
33
|
+
export { Transaction } from './transaction.js';
|
|
34
|
+
/** @hidden */
|
|
35
|
+
export { Network } from './networks.js';
|
|
36
|
+
/** @hidden */
|
|
37
|
+
export { initEccLib } from './ecc_lib.js';
|
|
38
|
+
export { Payment, PaymentCreator, PaymentOpts, Stack, StackElement } from './payments/index.js';
|
|
39
|
+
export { Input as TxInput, Output as TxOutput } from './transaction.js';
|
|
40
|
+
|
|
41
|
+
export interface PsbtInput extends _PsbtInput {}
|
|
42
|
+
|
|
43
|
+
export interface PsbtOutput extends _PsbtOutput {}
|
|
44
|
+
|
|
45
|
+
export interface TapInternalKey extends _TapInternalKey {}
|
|
46
|
+
|
|
47
|
+
export interface TapLeaf extends _TapLeaf {}
|
|
48
|
+
|
|
49
|
+
export interface TapScriptSig extends _TapScriptSig {}
|
|
50
|
+
|
|
51
|
+
export interface TapKeySig extends _TapKeySig {}
|
|
52
|
+
|
|
53
|
+
export interface TapTree extends _TapTree {}
|
|
54
|
+
|
|
55
|
+
export interface TapMerkleRoot extends _TapMerkleRoot {}
|
|
56
|
+
|
|
57
|
+
export interface TapLeafScript extends _TapLeafScript {}
|
|
58
|
+
|
|
59
|
+
export interface TapBip32Derivation extends _TapBip32Derivation {}
|
|
60
|
+
|
|
61
|
+
export interface PsbtInputUpdate extends _PsbtInputUpdate {}
|
|
62
|
+
|
|
63
|
+
export * from './psbt/bip371.js';
|
|
64
|
+
export * from './address.js';
|
|
65
|
+
export * from './bufferutils.js';
|
|
66
|
+
export * from './payments/bip341.js';
|
|
67
|
+
export * from './psbt/psbtutils.js';
|
|
68
|
+
|
|
69
|
+
export {
|
|
70
|
+
Taptree,
|
|
71
|
+
XOnlyPointAddTweakResult,
|
|
72
|
+
Tapleaf,
|
|
73
|
+
TinySecp256k1Interface,
|
|
74
|
+
TAPLEAF_VERSION_MASK,
|
|
75
|
+
} from './types.js';
|
|
76
|
+
|
|
77
|
+
const bitcoin = {
|
|
78
|
+
networks,
|
|
79
|
+
address,
|
|
80
|
+
payments,
|
|
81
|
+
script,
|
|
82
|
+
crypto,
|
|
83
|
+
Transaction,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export default bitcoin;
|