@btc-vision/bitcoin 6.3.2 → 6.3.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/.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 +52 -10
- package/build/payments/p2sh.js +2 -1
- package/build/psbt/psbtutils.d.ts +1 -1
- package/build/psbt/psbtutils.js +22 -7
- 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 +210 -149
- package/src/payments/p2sh.ts +206 -205
- package/src/psbt/bip371.ts +441 -441
- package/src/psbt/psbtutils.ts +315 -299
- package/src/psbt.ts +2187 -2174
- package/src/types.ts +122 -122
- package/webpack.config.js +79 -79
package/src/networks.ts
CHANGED
|
@@ -1,235 +1,235 @@
|
|
|
1
|
-
// https://en.bitcoin.it/wiki/List_of_address_prefixes
|
|
2
|
-
// Dogecoin BIP32 is a proposed standard: https://bitcointalk.org/index.php?topic=409731
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Represents a Bitcoin network configuration,including messagePrefix, bech32, bip32, pubKeyHash, scriptHash, wif.
|
|
6
|
-
* Support bitcoin、bitcoin testnet and bitcoin regtest.
|
|
7
|
-
* @packageDocumentation
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export interface Bip32 {
|
|
11
|
-
public: number;
|
|
12
|
-
private: number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface Network {
|
|
16
|
-
wif: number;
|
|
17
|
-
bip32: Bip32;
|
|
18
|
-
messagePrefix: string;
|
|
19
|
-
bech32: string;
|
|
20
|
-
pubKeyHash: number;
|
|
21
|
-
scriptHash: number;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Represents the Bitcoin network configuration.
|
|
26
|
-
*/
|
|
27
|
-
export const bitcoin: Network = {
|
|
28
|
-
/**
|
|
29
|
-
* The message prefix used for signing Bitcoin messages.
|
|
30
|
-
*/
|
|
31
|
-
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
|
32
|
-
/**
|
|
33
|
-
* The Bech32 prefix used for Bitcoin addresses.
|
|
34
|
-
*/
|
|
35
|
-
bech32: 'bc',
|
|
36
|
-
/**
|
|
37
|
-
* The BIP32 key prefixes for Bitcoin.
|
|
38
|
-
*/
|
|
39
|
-
bip32: {
|
|
40
|
-
/**
|
|
41
|
-
* The public key prefix for BIP32 extended public keys.
|
|
42
|
-
*/
|
|
43
|
-
public: 0x0488b21e,
|
|
44
|
-
/**
|
|
45
|
-
* The private key prefix for BIP32 extended private keys.
|
|
46
|
-
*/
|
|
47
|
-
private: 0x0488ade4,
|
|
48
|
-
},
|
|
49
|
-
/**
|
|
50
|
-
* The prefix for Bitcoin public key hashes.
|
|
51
|
-
*/
|
|
52
|
-
pubKeyHash: 0x00,
|
|
53
|
-
/**
|
|
54
|
-
* The prefix for Bitcoin script hashes.
|
|
55
|
-
*/
|
|
56
|
-
scriptHash: 0x05,
|
|
57
|
-
/**
|
|
58
|
-
* The prefix for Bitcoin Wallet Import Format (WIF) private keys.
|
|
59
|
-
*/
|
|
60
|
-
wif: 0x80,
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Represents the regtest network configuration.
|
|
64
|
-
*/
|
|
65
|
-
export const regtest: Network = {
|
|
66
|
-
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
|
67
|
-
bech32: 'bcrt',
|
|
68
|
-
bip32: {
|
|
69
|
-
public: 0x043587cf,
|
|
70
|
-
private: 0x04358394,
|
|
71
|
-
},
|
|
72
|
-
pubKeyHash: 0x6f,
|
|
73
|
-
scriptHash: 0xc4,
|
|
74
|
-
wif: 0xef,
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* Represents the testnet network configuration.
|
|
78
|
-
*/
|
|
79
|
-
export const testnet: Network = {
|
|
80
|
-
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
|
81
|
-
bech32: 'tb',
|
|
82
|
-
bip32: {
|
|
83
|
-
public: 0x043587cf,
|
|
84
|
-
private: 0x04358394,
|
|
85
|
-
},
|
|
86
|
-
pubKeyHash: 0x6f,
|
|
87
|
-
scriptHash: 0xc4,
|
|
88
|
-
wif: 0xef,
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Represents the Dogecoin mainnet configuration.
|
|
93
|
-
*
|
|
94
|
-
* Prefixes from:
|
|
95
|
-
* - P2PKH: 0x1e (30 decimal) - addresses start with 'D'
|
|
96
|
-
* - P2SH: 0x16 (22 decimal) - addresses often start with '9' or 'A'
|
|
97
|
-
* - WIF: 0x9e (158 decimal)
|
|
98
|
-
* - BIP32:
|
|
99
|
-
* - public: 0x02facafd
|
|
100
|
-
* - private: 0x02fac398
|
|
101
|
-
* Message prefix:
|
|
102
|
-
* - Dogecoin uses "\x19Dogecoin Signed Message:\n"
|
|
103
|
-
*/
|
|
104
|
-
export const dogecoin: Network = {
|
|
105
|
-
messagePrefix: '\x19Dogecoin Signed Message:\n',
|
|
106
|
-
bech32: '', // Dogecoin does not currently use Bech32
|
|
107
|
-
bip32: {
|
|
108
|
-
public: 0x02facafd,
|
|
109
|
-
private: 0x02fac398,
|
|
110
|
-
},
|
|
111
|
-
pubKeyHash: 0x1e,
|
|
112
|
-
scriptHash: 0x16,
|
|
113
|
-
wif: 0x9e,
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Represents the Dogecoin testnet configuration.
|
|
118
|
-
*
|
|
119
|
-
* Prefixes from Dogecoin testnet chainparams:
|
|
120
|
-
* - P2PKH: 0x71 (113 decimal)
|
|
121
|
-
* - P2SH: 0xc4 (196 decimal)
|
|
122
|
-
* - WIF: 0xf1 (241 decimal)
|
|
123
|
-
* - BIP32:
|
|
124
|
-
* - public: 0x0432a9a8
|
|
125
|
-
* - private: 0x0432a243
|
|
126
|
-
* Message prefix:
|
|
127
|
-
* - Same as mainnet: "\x19Dogecoin Signed Message:\n"
|
|
128
|
-
*/
|
|
129
|
-
export const dogecoinTestnet: Network = {
|
|
130
|
-
messagePrefix: '\x19Dogecoin Signed Message:\n',
|
|
131
|
-
bech32: '', // Dogecoin testnet does not currently use Bech32
|
|
132
|
-
bip32: {
|
|
133
|
-
public: 0x0432a9a8,
|
|
134
|
-
private: 0x0432a243,
|
|
135
|
-
},
|
|
136
|
-
pubKeyHash: 0x71,
|
|
137
|
-
scriptHash: 0xc4,
|
|
138
|
-
wif: 0xf1,
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Litecoin mainnet configuration.
|
|
143
|
-
*/
|
|
144
|
-
export const litecoin: Network = {
|
|
145
|
-
messagePrefix: '\x19Litecoin Signed Message:\n',
|
|
146
|
-
bech32: 'ltc',
|
|
147
|
-
bip32: {
|
|
148
|
-
public: 0x019da462,
|
|
149
|
-
private: 0x019d9cfe,
|
|
150
|
-
},
|
|
151
|
-
pubKeyHash: 0x30,
|
|
152
|
-
scriptHash: 0x32,
|
|
153
|
-
wif: 0xb0,
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Litecoin testnet configuration.
|
|
158
|
-
*/
|
|
159
|
-
export const litecoinTestnet: Network = {
|
|
160
|
-
messagePrefix: '\x19Litecoin Signed Message:\n',
|
|
161
|
-
bech32: 'tltc',
|
|
162
|
-
bip32: {
|
|
163
|
-
public: 0x0436ef7d,
|
|
164
|
-
private: 0x0436f6e1,
|
|
165
|
-
},
|
|
166
|
-
pubKeyHash: 0x6f,
|
|
167
|
-
scriptHash: 0x3a,
|
|
168
|
-
wif: 0xef,
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Bitcoin Cash mainnet configuration (legacy).
|
|
173
|
-
* Note: Bitcoin Cash uses Cashaddr starting with 'q' or 'p',
|
|
174
|
-
* but we retain the legacy prefixes for compatibility.
|
|
175
|
-
*/
|
|
176
|
-
export const bitcoinCash: Network = {
|
|
177
|
-
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
|
178
|
-
// Cashaddr prefix differs from bech32 for general usage, but we can set it similarly.
|
|
179
|
-
// Actual cashaddr prefix is "bitcoincash", but this field is for bech32 which BCH doesn't fully use for segwit (it doesn't have segwit).
|
|
180
|
-
bech32: 'bitcoincash',
|
|
181
|
-
bip32: {
|
|
182
|
-
public: 0x0488b21e,
|
|
183
|
-
private: 0x0488ade4,
|
|
184
|
-
},
|
|
185
|
-
pubKeyHash: 0x00,
|
|
186
|
-
scriptHash: 0x05,
|
|
187
|
-
wif: 0x80,
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Bitcoin Cash testnet configuration (legacy).
|
|
192
|
-
*/
|
|
193
|
-
export const bitcoinCashTestnet: Network = {
|
|
194
|
-
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
|
195
|
-
bech32: 'bchtest',
|
|
196
|
-
bip32: {
|
|
197
|
-
public: 0x043587cf,
|
|
198
|
-
private: 0x04358394,
|
|
199
|
-
},
|
|
200
|
-
pubKeyHash: 0x6f,
|
|
201
|
-
scriptHash: 0xc4,
|
|
202
|
-
wif: 0xef,
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Dash mainnet configuration.
|
|
207
|
-
*/
|
|
208
|
-
export const dash: Network = {
|
|
209
|
-
// Historically Dash used DarkCoin message prefix, and most implementations use this:
|
|
210
|
-
// As of Dash Core 0.17, this has not changed in code.
|
|
211
|
-
messagePrefix: '\x19DarkCoin Signed Message:\n',
|
|
212
|
-
bech32: '', // Dash does not use Bech32
|
|
213
|
-
bip32: {
|
|
214
|
-
public: 0x02fe52cc,
|
|
215
|
-
private: 0x02fe52f8,
|
|
216
|
-
},
|
|
217
|
-
pubKeyHash: 0x4c,
|
|
218
|
-
scriptHash: 0x10,
|
|
219
|
-
wif: 0xcc,
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Dash testnet configuration.
|
|
224
|
-
*/
|
|
225
|
-
export const dashTestnet: Network = {
|
|
226
|
-
messagePrefix: '\x19DarkCoin Signed Message:\n',
|
|
227
|
-
bech32: '', // Dash testnet does not use Bech32
|
|
228
|
-
bip32: {
|
|
229
|
-
public: 0x3a8061a0,
|
|
230
|
-
private: 0x3a805837,
|
|
231
|
-
},
|
|
232
|
-
pubKeyHash: 0x8c,
|
|
233
|
-
scriptHash: 0x13,
|
|
234
|
-
wif: 0xef,
|
|
235
|
-
};
|
|
1
|
+
// https://en.bitcoin.it/wiki/List_of_address_prefixes
|
|
2
|
+
// Dogecoin BIP32 is a proposed standard: https://bitcointalk.org/index.php?topic=409731
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Represents a Bitcoin network configuration,including messagePrefix, bech32, bip32, pubKeyHash, scriptHash, wif.
|
|
6
|
+
* Support bitcoin、bitcoin testnet and bitcoin regtest.
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export interface Bip32 {
|
|
11
|
+
public: number;
|
|
12
|
+
private: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface Network {
|
|
16
|
+
wif: number;
|
|
17
|
+
bip32: Bip32;
|
|
18
|
+
messagePrefix: string;
|
|
19
|
+
bech32: string;
|
|
20
|
+
pubKeyHash: number;
|
|
21
|
+
scriptHash: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Represents the Bitcoin network configuration.
|
|
26
|
+
*/
|
|
27
|
+
export const bitcoin: Network = {
|
|
28
|
+
/**
|
|
29
|
+
* The message prefix used for signing Bitcoin messages.
|
|
30
|
+
*/
|
|
31
|
+
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
|
32
|
+
/**
|
|
33
|
+
* The Bech32 prefix used for Bitcoin addresses.
|
|
34
|
+
*/
|
|
35
|
+
bech32: 'bc',
|
|
36
|
+
/**
|
|
37
|
+
* The BIP32 key prefixes for Bitcoin.
|
|
38
|
+
*/
|
|
39
|
+
bip32: {
|
|
40
|
+
/**
|
|
41
|
+
* The public key prefix for BIP32 extended public keys.
|
|
42
|
+
*/
|
|
43
|
+
public: 0x0488b21e,
|
|
44
|
+
/**
|
|
45
|
+
* The private key prefix for BIP32 extended private keys.
|
|
46
|
+
*/
|
|
47
|
+
private: 0x0488ade4,
|
|
48
|
+
},
|
|
49
|
+
/**
|
|
50
|
+
* The prefix for Bitcoin public key hashes.
|
|
51
|
+
*/
|
|
52
|
+
pubKeyHash: 0x00,
|
|
53
|
+
/**
|
|
54
|
+
* The prefix for Bitcoin script hashes.
|
|
55
|
+
*/
|
|
56
|
+
scriptHash: 0x05,
|
|
57
|
+
/**
|
|
58
|
+
* The prefix for Bitcoin Wallet Import Format (WIF) private keys.
|
|
59
|
+
*/
|
|
60
|
+
wif: 0x80,
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Represents the regtest network configuration.
|
|
64
|
+
*/
|
|
65
|
+
export const regtest: Network = {
|
|
66
|
+
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
|
67
|
+
bech32: 'bcrt',
|
|
68
|
+
bip32: {
|
|
69
|
+
public: 0x043587cf,
|
|
70
|
+
private: 0x04358394,
|
|
71
|
+
},
|
|
72
|
+
pubKeyHash: 0x6f,
|
|
73
|
+
scriptHash: 0xc4,
|
|
74
|
+
wif: 0xef,
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Represents the testnet network configuration.
|
|
78
|
+
*/
|
|
79
|
+
export const testnet: Network = {
|
|
80
|
+
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
|
81
|
+
bech32: 'tb',
|
|
82
|
+
bip32: {
|
|
83
|
+
public: 0x043587cf,
|
|
84
|
+
private: 0x04358394,
|
|
85
|
+
},
|
|
86
|
+
pubKeyHash: 0x6f,
|
|
87
|
+
scriptHash: 0xc4,
|
|
88
|
+
wif: 0xef,
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Represents the Dogecoin mainnet configuration.
|
|
93
|
+
*
|
|
94
|
+
* Prefixes from:
|
|
95
|
+
* - P2PKH: 0x1e (30 decimal) - addresses start with 'D'
|
|
96
|
+
* - P2SH: 0x16 (22 decimal) - addresses often start with '9' or 'A'
|
|
97
|
+
* - WIF: 0x9e (158 decimal)
|
|
98
|
+
* - BIP32:
|
|
99
|
+
* - public: 0x02facafd
|
|
100
|
+
* - private: 0x02fac398
|
|
101
|
+
* Message prefix:
|
|
102
|
+
* - Dogecoin uses "\x19Dogecoin Signed Message:\n"
|
|
103
|
+
*/
|
|
104
|
+
export const dogecoin: Network = {
|
|
105
|
+
messagePrefix: '\x19Dogecoin Signed Message:\n',
|
|
106
|
+
bech32: '', // Dogecoin does not currently use Bech32
|
|
107
|
+
bip32: {
|
|
108
|
+
public: 0x02facafd,
|
|
109
|
+
private: 0x02fac398,
|
|
110
|
+
},
|
|
111
|
+
pubKeyHash: 0x1e,
|
|
112
|
+
scriptHash: 0x16,
|
|
113
|
+
wif: 0x9e,
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Represents the Dogecoin testnet configuration.
|
|
118
|
+
*
|
|
119
|
+
* Prefixes from Dogecoin testnet chainparams:
|
|
120
|
+
* - P2PKH: 0x71 (113 decimal)
|
|
121
|
+
* - P2SH: 0xc4 (196 decimal)
|
|
122
|
+
* - WIF: 0xf1 (241 decimal)
|
|
123
|
+
* - BIP32:
|
|
124
|
+
* - public: 0x0432a9a8
|
|
125
|
+
* - private: 0x0432a243
|
|
126
|
+
* Message prefix:
|
|
127
|
+
* - Same as mainnet: "\x19Dogecoin Signed Message:\n"
|
|
128
|
+
*/
|
|
129
|
+
export const dogecoinTestnet: Network = {
|
|
130
|
+
messagePrefix: '\x19Dogecoin Signed Message:\n',
|
|
131
|
+
bech32: '', // Dogecoin testnet does not currently use Bech32
|
|
132
|
+
bip32: {
|
|
133
|
+
public: 0x0432a9a8,
|
|
134
|
+
private: 0x0432a243,
|
|
135
|
+
},
|
|
136
|
+
pubKeyHash: 0x71,
|
|
137
|
+
scriptHash: 0xc4,
|
|
138
|
+
wif: 0xf1,
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Litecoin mainnet configuration.
|
|
143
|
+
*/
|
|
144
|
+
export const litecoin: Network = {
|
|
145
|
+
messagePrefix: '\x19Litecoin Signed Message:\n',
|
|
146
|
+
bech32: 'ltc',
|
|
147
|
+
bip32: {
|
|
148
|
+
public: 0x019da462,
|
|
149
|
+
private: 0x019d9cfe,
|
|
150
|
+
},
|
|
151
|
+
pubKeyHash: 0x30,
|
|
152
|
+
scriptHash: 0x32,
|
|
153
|
+
wif: 0xb0,
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Litecoin testnet configuration.
|
|
158
|
+
*/
|
|
159
|
+
export const litecoinTestnet: Network = {
|
|
160
|
+
messagePrefix: '\x19Litecoin Signed Message:\n',
|
|
161
|
+
bech32: 'tltc',
|
|
162
|
+
bip32: {
|
|
163
|
+
public: 0x0436ef7d,
|
|
164
|
+
private: 0x0436f6e1,
|
|
165
|
+
},
|
|
166
|
+
pubKeyHash: 0x6f,
|
|
167
|
+
scriptHash: 0x3a,
|
|
168
|
+
wif: 0xef,
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Bitcoin Cash mainnet configuration (legacy).
|
|
173
|
+
* Note: Bitcoin Cash uses Cashaddr starting with 'q' or 'p',
|
|
174
|
+
* but we retain the legacy prefixes for compatibility.
|
|
175
|
+
*/
|
|
176
|
+
export const bitcoinCash: Network = {
|
|
177
|
+
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
|
178
|
+
// Cashaddr prefix differs from bech32 for general usage, but we can set it similarly.
|
|
179
|
+
// Actual cashaddr prefix is "bitcoincash", but this field is for bech32 which BCH doesn't fully use for segwit (it doesn't have segwit).
|
|
180
|
+
bech32: 'bitcoincash',
|
|
181
|
+
bip32: {
|
|
182
|
+
public: 0x0488b21e,
|
|
183
|
+
private: 0x0488ade4,
|
|
184
|
+
},
|
|
185
|
+
pubKeyHash: 0x00,
|
|
186
|
+
scriptHash: 0x05,
|
|
187
|
+
wif: 0x80,
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Bitcoin Cash testnet configuration (legacy).
|
|
192
|
+
*/
|
|
193
|
+
export const bitcoinCashTestnet: Network = {
|
|
194
|
+
messagePrefix: '\x18Bitcoin Signed Message:\n',
|
|
195
|
+
bech32: 'bchtest',
|
|
196
|
+
bip32: {
|
|
197
|
+
public: 0x043587cf,
|
|
198
|
+
private: 0x04358394,
|
|
199
|
+
},
|
|
200
|
+
pubKeyHash: 0x6f,
|
|
201
|
+
scriptHash: 0xc4,
|
|
202
|
+
wif: 0xef,
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Dash mainnet configuration.
|
|
207
|
+
*/
|
|
208
|
+
export const dash: Network = {
|
|
209
|
+
// Historically Dash used DarkCoin message prefix, and most implementations use this:
|
|
210
|
+
// As of Dash Core 0.17, this has not changed in code.
|
|
211
|
+
messagePrefix: '\x19DarkCoin Signed Message:\n',
|
|
212
|
+
bech32: '', // Dash does not use Bech32
|
|
213
|
+
bip32: {
|
|
214
|
+
public: 0x02fe52cc,
|
|
215
|
+
private: 0x02fe52f8,
|
|
216
|
+
},
|
|
217
|
+
pubKeyHash: 0x4c,
|
|
218
|
+
scriptHash: 0x10,
|
|
219
|
+
wif: 0xcc,
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Dash testnet configuration.
|
|
224
|
+
*/
|
|
225
|
+
export const dashTestnet: Network = {
|
|
226
|
+
messagePrefix: '\x19DarkCoin Signed Message:\n',
|
|
227
|
+
bech32: '', // Dash testnet does not use Bech32
|
|
228
|
+
bip32: {
|
|
229
|
+
public: 0x3a8061a0,
|
|
230
|
+
private: 0x3a805837,
|
|
231
|
+
},
|
|
232
|
+
pubKeyHash: 0x8c,
|
|
233
|
+
scriptHash: 0x13,
|
|
234
|
+
wif: 0xef,
|
|
235
|
+
};
|
package/src/payments/embed.ts
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { bitcoin as BITCOIN_NETWORK } from '../networks.js';
|
|
2
|
-
import * as bscript from '../script.js';
|
|
3
|
-
import { stacksEqual, typeforce as typef } from '../types.js';
|
|
4
|
-
import { Payment, PaymentOpts, Stack } from './index.js';
|
|
5
|
-
import * as lazy from './lazy.js';
|
|
6
|
-
|
|
7
|
-
const OPS = bscript.OPS;
|
|
8
|
-
|
|
9
|
-
// output: OP_RETURN ...
|
|
10
|
-
/**
|
|
11
|
-
* Embeds data in a Bitcoin payment.
|
|
12
|
-
* @param a - The payment object.
|
|
13
|
-
* @param opts - Optional payment options.
|
|
14
|
-
* @returns The modified payment object.
|
|
15
|
-
* @throws {TypeError} If there is not enough data or if the output is invalid.
|
|
16
|
-
*/
|
|
17
|
-
export function p2data(a: Payment, opts?: PaymentOpts): Payment {
|
|
18
|
-
if (!a.data && !a.output) throw new TypeError('Not enough data');
|
|
19
|
-
opts = Object.assign({ validate: true }, opts || {});
|
|
20
|
-
|
|
21
|
-
typef(
|
|
22
|
-
{
|
|
23
|
-
network: typef.maybe(typef.Object),
|
|
24
|
-
output: typef.maybe(typef.Buffer),
|
|
25
|
-
data: typef.maybe(typef.arrayOf(typef.Buffer)),
|
|
26
|
-
},
|
|
27
|
-
a,
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
const network = a.network || BITCOIN_NETWORK;
|
|
31
|
-
const o = { name: 'embed', network } as Payment;
|
|
32
|
-
|
|
33
|
-
lazy.prop(o, 'output', () => {
|
|
34
|
-
if (!a.data) return;
|
|
35
|
-
return bscript.compile(([OPS.OP_RETURN] as Stack).concat(a.data));
|
|
36
|
-
});
|
|
37
|
-
lazy.prop(o, 'data', () => {
|
|
38
|
-
if (!a.output) return;
|
|
39
|
-
return bscript.decompile(a.output)!.slice(1);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// extended validation
|
|
43
|
-
if (opts.validate) {
|
|
44
|
-
if (a.output) {
|
|
45
|
-
const chunks = bscript.decompile(a.output);
|
|
46
|
-
if (chunks![0] !== OPS.OP_RETURN) throw new TypeError('Output is invalid');
|
|
47
|
-
if (!chunks!.slice(1).every(typef.Buffer)) throw new TypeError('Output is invalid');
|
|
48
|
-
|
|
49
|
-
if (a.data && !stacksEqual(a.data, o.data as Buffer[]))
|
|
50
|
-
throw new TypeError('Data mismatch');
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return Object.assign(o, a);
|
|
55
|
-
}
|
|
1
|
+
import { bitcoin as BITCOIN_NETWORK } from '../networks.js';
|
|
2
|
+
import * as bscript from '../script.js';
|
|
3
|
+
import { stacksEqual, typeforce as typef } from '../types.js';
|
|
4
|
+
import { Payment, PaymentOpts, Stack } from './index.js';
|
|
5
|
+
import * as lazy from './lazy.js';
|
|
6
|
+
|
|
7
|
+
const OPS = bscript.OPS;
|
|
8
|
+
|
|
9
|
+
// output: OP_RETURN ...
|
|
10
|
+
/**
|
|
11
|
+
* Embeds data in a Bitcoin payment.
|
|
12
|
+
* @param a - The payment object.
|
|
13
|
+
* @param opts - Optional payment options.
|
|
14
|
+
* @returns The modified payment object.
|
|
15
|
+
* @throws {TypeError} If there is not enough data or if the output is invalid.
|
|
16
|
+
*/
|
|
17
|
+
export function p2data(a: Payment, opts?: PaymentOpts): Payment {
|
|
18
|
+
if (!a.data && !a.output) throw new TypeError('Not enough data');
|
|
19
|
+
opts = Object.assign({ validate: true }, opts || {});
|
|
20
|
+
|
|
21
|
+
typef(
|
|
22
|
+
{
|
|
23
|
+
network: typef.maybe(typef.Object),
|
|
24
|
+
output: typef.maybe(typef.Buffer),
|
|
25
|
+
data: typef.maybe(typef.arrayOf(typef.Buffer)),
|
|
26
|
+
},
|
|
27
|
+
a,
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const network = a.network || BITCOIN_NETWORK;
|
|
31
|
+
const o = { name: 'embed', network } as Payment;
|
|
32
|
+
|
|
33
|
+
lazy.prop(o, 'output', () => {
|
|
34
|
+
if (!a.data) return;
|
|
35
|
+
return bscript.compile(([OPS.OP_RETURN] as Stack).concat(a.data));
|
|
36
|
+
});
|
|
37
|
+
lazy.prop(o, 'data', () => {
|
|
38
|
+
if (!a.output) return;
|
|
39
|
+
return bscript.decompile(a.output)!.slice(1);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// extended validation
|
|
43
|
+
if (opts.validate) {
|
|
44
|
+
if (a.output) {
|
|
45
|
+
const chunks = bscript.decompile(a.output);
|
|
46
|
+
if (chunks![0] !== OPS.OP_RETURN) throw new TypeError('Output is invalid');
|
|
47
|
+
if (!chunks!.slice(1).every(typef.Buffer)) throw new TypeError('Output is invalid');
|
|
48
|
+
|
|
49
|
+
if (a.data && !stacksEqual(a.data, o.data as Buffer[]))
|
|
50
|
+
throw new TypeError('Data mismatch');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return Object.assign(o, a);
|
|
55
|
+
}
|
package/src/payments/index.ts
CHANGED
|
@@ -39,6 +39,10 @@ export interface Payment {
|
|
|
39
39
|
redeemVersion?: number;
|
|
40
40
|
scriptTree?: Taptree;
|
|
41
41
|
witness?: Buffer[];
|
|
42
|
+
|
|
43
|
+
// NEW FIELDS
|
|
44
|
+
useHybrid?: boolean;
|
|
45
|
+
useUncompressed?: boolean;
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
export type PaymentCreator = (a: Payment, opts?: PaymentOpts) => Payment;
|
package/src/payments/lazy.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
export function prop(object: {}, name: string, f: () => any): void {
|
|
2
|
-
Object.defineProperty(object, name, {
|
|
3
|
-
configurable: true,
|
|
4
|
-
enumerable: true,
|
|
5
|
-
get(): any {
|
|
6
|
-
const _value = f.call(this);
|
|
7
|
-
this[name] = _value;
|
|
8
|
-
return _value;
|
|
9
|
-
},
|
|
10
|
-
set(_value: any): void {
|
|
11
|
-
Object.defineProperty(this, name, {
|
|
12
|
-
configurable: true,
|
|
13
|
-
enumerable: true,
|
|
14
|
-
value: _value,
|
|
15
|
-
writable: true,
|
|
16
|
-
});
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function value<T>(f: () => T): () => T {
|
|
22
|
-
let _value: T;
|
|
23
|
-
return (): T => {
|
|
24
|
-
if (_value !== undefined) return _value;
|
|
25
|
-
_value = f();
|
|
26
|
-
return _value;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
1
|
+
export function prop(object: {}, name: string, f: () => any): void {
|
|
2
|
+
Object.defineProperty(object, name, {
|
|
3
|
+
configurable: true,
|
|
4
|
+
enumerable: true,
|
|
5
|
+
get(): any {
|
|
6
|
+
const _value = f.call(this);
|
|
7
|
+
this[name] = _value;
|
|
8
|
+
return _value;
|
|
9
|
+
},
|
|
10
|
+
set(_value: any): void {
|
|
11
|
+
Object.defineProperty(this, name, {
|
|
12
|
+
configurable: true,
|
|
13
|
+
enumerable: true,
|
|
14
|
+
value: _value,
|
|
15
|
+
writable: true,
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function value<T>(f: () => T): () => T {
|
|
22
|
+
let _value: T;
|
|
23
|
+
return (): T => {
|
|
24
|
+
if (_value !== undefined) return _value;
|
|
25
|
+
_value = f();
|
|
26
|
+
return _value;
|
|
27
|
+
};
|
|
28
|
+
}
|