@onetokenfe/coinselect 3.1.16
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 +21 -0
- package/README.md +95 -0
- package/accumulative.js +38 -0
- package/blackjack.js +35 -0
- package/break.js +34 -0
- package/index.js +21 -0
- package/package.json +82 -0
- package/split.js +45 -0
- package/third-party/utils/addDashesToSpaces.d.ts +2 -0
- package/third-party/utils/addDashesToSpaces.js +6 -0
- package/third-party/utils/arrayDistinct.d.ts +2 -0
- package/third-party/utils/arrayDistinct.js +6 -0
- package/third-party/utils/arrayPartition.d.ts +7 -0
- package/third-party/utils/arrayPartition.js +6 -0
- package/third-party/utils/arrayShuffle.d.ts +4 -0
- package/third-party/utils/arrayShuffle.js +13 -0
- package/third-party/utils/arrayToDictionary.d.ts +10 -0
- package/third-party/utils/arrayToDictionary.js +27 -0
- package/third-party/utils/asciiUtils.d.ts +3 -0
- package/third-party/utils/asciiUtils.js +16 -0
- package/third-party/utils/bigNumber.d.ts +5 -0
- package/third-party/utils/bigNumber.js +9 -0
- package/third-party/utils/bufferUtils.d.ts +3 -0
- package/third-party/utils/bufferUtils.js +23 -0
- package/third-party/utils/bytesToHumanReadable.d.ts +2 -0
- package/third-party/utils/bytesToHumanReadable.js +15 -0
- package/third-party/utils/capitalizeFirstLetter.d.ts +2 -0
- package/third-party/utils/capitalizeFirstLetter.js +6 -0
- package/third-party/utils/cloneObject.d.ts +2 -0
- package/third-party/utils/cloneObject.js +32 -0
- package/third-party/utils/countBytesInString.d.ts +2 -0
- package/third-party/utils/countBytesInString.js +6 -0
- package/third-party/utils/createCooldown.d.ts +2 -0
- package/third-party/utils/createCooldown.js +16 -0
- package/third-party/utils/createDeferred.d.ts +14 -0
- package/third-party/utils/createDeferred.js +19 -0
- package/third-party/utils/createDeferredManager.d.ts +19 -0
- package/third-party/utils/createDeferredManager.js +67 -0
- package/third-party/utils/createLazy.d.ts +7 -0
- package/third-party/utils/createLazy.js +42 -0
- package/third-party/utils/createTimeoutPromise.d.ts +2 -0
- package/third-party/utils/createTimeoutPromise.js +6 -0
- package/third-party/utils/enumUtils.d.ts +6 -0
- package/third-party/utils/enumUtils.js +12 -0
- package/third-party/utils/extractUrlsFromText.d.ts +5 -0
- package/third-party/utils/extractUrlsFromText.js +28 -0
- package/third-party/utils/getLocaleSeparators.d.ts +5 -0
- package/third-party/utils/getLocaleSeparators.js +13 -0
- package/third-party/utils/getLocaleSeparators.native.d.ts +5 -0
- package/third-party/utils/getLocaleSeparators.native.js +17 -0
- package/third-party/utils/getMutex.d.ts +2 -0
- package/third-party/utils/getMutex.js +22 -0
- package/third-party/utils/getNumberFromPixelString.d.ts +2 -0
- package/third-party/utils/getNumberFromPixelString.js +6 -0
- package/third-party/utils/getRandomInt.d.ts +2 -0
- package/third-party/utils/getRandomInt.js +56 -0
- package/third-party/utils/getSynchronize.d.ts +4 -0
- package/third-party/utils/getSynchronize.js +10 -0
- package/third-party/utils/getWeakRandomId.d.ts +2 -0
- package/third-party/utils/getWeakRandomId.js +13 -0
- package/third-party/utils/getWeakRandomInt.d.ts +2 -0
- package/third-party/utils/getWeakRandomInt.js +11 -0
- package/third-party/utils/getWeakRandomNumberInRange.d.ts +2 -0
- package/third-party/utils/getWeakRandomNumberInRange.js +6 -0
- package/third-party/utils/hasUppercaseLetter.d.ts +2 -0
- package/third-party/utils/hasUppercaseLetter.js +7 -0
- package/third-party/utils/index.d.ts +52 -0
- package/third-party/utils/index.js +56 -0
- package/third-party/utils/isArrayMember.d.ts +2 -0
- package/third-party/utils/isArrayMember.js +6 -0
- package/third-party/utils/isFullPath.d.ts +2 -0
- package/third-party/utils/isFullPath.js +9 -0
- package/third-party/utils/isHex.d.ts +2 -0
- package/third-party/utils/isHex.js +9 -0
- package/third-party/utils/isNotUndefined.d.ts +2 -0
- package/third-party/utils/isNotUndefined.js +6 -0
- package/third-party/utils/isUrl.d.ts +2 -0
- package/third-party/utils/isUrl.js +7 -0
- package/third-party/utils/logs.d.ts +32 -0
- package/third-party/utils/logs.js +82 -0
- package/third-party/utils/logsManager.d.ts +17 -0
- package/third-party/utils/logsManager.js +53 -0
- package/third-party/utils/mergeDeepObject.d.ts +26 -0
- package/third-party/utils/mergeDeepObject.js +68 -0
- package/third-party/utils/objectPartition.d.ts +6 -0
- package/third-party/utils/objectPartition.js +12 -0
- package/third-party/utils/parseElectrumUrl.d.ts +6 -0
- package/third-party/utils/parseElectrumUrl.js +17 -0
- package/third-party/utils/parseHostname.d.ts +2 -0
- package/third-party/utils/parseHostname.js +7 -0
- package/third-party/utils/promiseAllSequence.d.ts +2 -0
- package/third-party/utils/promiseAllSequence.js +14 -0
- package/third-party/utils/redactUserPath.d.ts +3 -0
- package/third-party/utils/redactUserPath.js +7 -0
- package/third-party/utils/scheduleAction.d.ts +15 -0
- package/third-party/utils/scheduleAction.js +125 -0
- package/third-party/utils/splitStringEveryNCharacters.d.ts +2 -0
- package/third-party/utils/splitStringEveryNCharacters.js +12 -0
- package/third-party/utils/throttler.d.ts +11 -0
- package/third-party/utils/throttler.js +38 -0
- package/third-party/utils/throwError.d.ts +2 -0
- package/third-party/utils/throwError.js +8 -0
- package/third-party/utils/topologicalSort.d.ts +2 -0
- package/third-party/utils/topologicalSort.js +19 -0
- package/third-party/utils/truncateMiddle.d.ts +2 -0
- package/third-party/utils/truncateMiddle.js +12 -0
- package/third-party/utils/typedEventEmitter.d.ts +23 -0
- package/third-party/utils/typedEventEmitter.js +11 -0
- package/third-party/utils/urlToOnion.d.ts +4 -0
- package/third-party/utils/urlToOnion.js +12 -0
- package/third-party/utils/versionUtils.d.ts +9 -0
- package/third-party/utils/versionUtils.js +28 -0
- package/third-party/utils/xssFilters.d.ts +4 -0
- package/third-party/utils/xssFilters.js +13 -0
- package/third-party/utxo-lib/address.d.ts +17 -0
- package/third-party/utxo-lib/address.js +174 -0
- package/third-party/utxo-lib/bip32.d.ts +28 -0
- package/third-party/utxo-lib/bip32.js +253 -0
- package/third-party/utxo-lib/bs58check.d.ts +12 -0
- package/third-party/utxo-lib/bs58check.js +92 -0
- package/third-party/utxo-lib/bufferutils.d.ts +59 -0
- package/third-party/utxo-lib/bufferutils.js +219 -0
- package/third-party/utxo-lib/coinselect/coinselectUtils.d.ts +53 -0
- package/third-party/utxo-lib/coinselect/coinselectUtils.js +232 -0
- package/third-party/utxo-lib/coinselect/index.d.ts +3 -0
- package/third-party/utxo-lib/coinselect/index.js +19 -0
- package/third-party/utxo-lib/coinselect/inputs/accumulative.d.ts +3 -0
- package/third-party/utxo-lib/coinselect/inputs/accumulative.js +55 -0
- package/third-party/utxo-lib/coinselect/inputs/branchAndBound.d.ts +3 -0
- package/third-party/utxo-lib/coinselect/inputs/branchAndBound.js +123 -0
- package/third-party/utxo-lib/coinselect/outputs/split.d.ts +3 -0
- package/third-party/utxo-lib/coinselect/outputs/split.js +35 -0
- package/third-party/utxo-lib/coinselect/tryconfirmed.d.ts +3 -0
- package/third-party/utxo-lib/coinselect/tryconfirmed.js +65 -0
- package/third-party/utxo-lib/compose/index.d.ts +3 -0
- package/third-party/utxo-lib/compose/index.js +20 -0
- package/third-party/utxo-lib/compose/request.d.ts +5 -0
- package/third-party/utxo-lib/compose/request.js +168 -0
- package/third-party/utxo-lib/compose/result.d.ts +4 -0
- package/third-party/utxo-lib/compose/result.js +64 -0
- package/third-party/utxo-lib/compose/sorting/bip69SortingStrategy.d.ts +3 -0
- package/third-party/utxo-lib/compose/sorting/bip69SortingStrategy.js +32 -0
- package/third-party/utxo-lib/compose/sorting/convertOutput.d.ts +13 -0
- package/third-party/utxo-lib/compose/sorting/convertOutput.js +14 -0
- package/third-party/utxo-lib/compose/sorting/noneSortingStrategy.d.ts +3 -0
- package/third-party/utxo-lib/compose/sorting/noneSortingStrategy.js +19 -0
- package/third-party/utxo-lib/compose/sorting/randomSortingStrategy.d.ts +3 -0
- package/third-party/utxo-lib/compose/sorting/randomSortingStrategy.js +28 -0
- package/third-party/utxo-lib/compose/sorting/sortingStrategy.d.ts +9 -0
- package/third-party/utxo-lib/compose/sorting/sortingStrategy.js +3 -0
- package/third-party/utxo-lib/compose/transaction.d.ts +3 -0
- package/third-party/utxo-lib/compose/transaction.js +16 -0
- package/third-party/utxo-lib/crypto.d.ts +9 -0
- package/third-party/utxo-lib/crypto.js +44 -0
- package/third-party/utxo-lib/derivation.d.ts +24 -0
- package/third-party/utxo-lib/derivation.js +121 -0
- package/third-party/utxo-lib/discovery.d.ts +9 -0
- package/third-party/utxo-lib/discovery.js +30 -0
- package/third-party/utxo-lib/global.d.ts +62 -0
- package/third-party/utxo-lib/global.js +2 -0
- package/third-party/utxo-lib/index.d.ts +18 -0
- package/third-party/utxo-lib/index.js +28 -0
- package/third-party/utxo-lib/networks.d.ts +45 -0
- package/third-party/utxo-lib/networks.js +250 -0
- package/third-party/utxo-lib/payments/embed.d.ts +3 -0
- package/third-party/utxo-lib/payments/embed.js +49 -0
- package/third-party/utxo-lib/payments/index.d.ts +13 -0
- package/third-party/utxo-lib/payments/index.js +28 -0
- package/third-party/utxo-lib/payments/lazy.d.ts +3 -0
- package/third-party/utxo-lib/payments/lazy.js +33 -0
- package/third-party/utxo-lib/payments/p2ms.d.ts +3 -0
- package/third-party/utxo-lib/payments/p2ms.js +139 -0
- package/third-party/utxo-lib/payments/p2pk.d.ts +3 -0
- package/third-party/utxo-lib/payments/p2pk.js +72 -0
- package/third-party/utxo-lib/payments/p2pkh.d.ts +3 -0
- package/third-party/utxo-lib/payments/p2pkh.js +132 -0
- package/third-party/utxo-lib/payments/p2sh.d.ts +3 -0
- package/third-party/utxo-lib/payments/p2sh.js +171 -0
- package/third-party/utxo-lib/payments/p2tr.d.ts +3 -0
- package/third-party/utxo-lib/payments/p2tr.js +123 -0
- package/third-party/utxo-lib/payments/p2wpkh.d.ts +3 -0
- package/third-party/utxo-lib/payments/p2wpkh.js +137 -0
- package/third-party/utxo-lib/payments/p2wsh.d.ts +3 -0
- package/third-party/utxo-lib/payments/p2wsh.js +183 -0
- package/third-party/utxo-lib/payments/sstxchange.d.ts +3 -0
- package/third-party/utxo-lib/payments/sstxchange.js +79 -0
- package/third-party/utxo-lib/payments/sstxcommitment.d.ts +3 -0
- package/third-party/utxo-lib/payments/sstxcommitment.js +74 -0
- package/third-party/utxo-lib/payments/sstxpkh.d.ts +3 -0
- package/third-party/utxo-lib/payments/sstxpkh.js +79 -0
- package/third-party/utxo-lib/payments/sstxsh.d.ts +3 -0
- package/third-party/utxo-lib/payments/sstxsh.js +70 -0
- package/third-party/utxo-lib/script/index.d.ts +17 -0
- package/third-party/utxo-lib/script/index.js +167 -0
- package/third-party/utxo-lib/script/ops.d.ts +4 -0
- package/third-party/utxo-lib/script/ops.js +13 -0
- package/third-party/utxo-lib/script/scriptNumber.d.ts +3 -0
- package/third-party/utxo-lib/script/scriptNumber.js +62 -0
- package/third-party/utxo-lib/script/scriptSignature.d.ts +8 -0
- package/third-party/utxo-lib/script/scriptSignature.js +55 -0
- package/third-party/utxo-lib/transaction/base.d.ts +56 -0
- package/third-party/utxo-lib/transaction/base.js +108 -0
- package/third-party/utxo-lib/transaction/bitcoin.d.ts +4 -0
- package/third-party/utxo-lib/transaction/bitcoin.js +109 -0
- package/third-party/utxo-lib/transaction/dash.d.ts +8 -0
- package/third-party/utxo-lib/transaction/dash.js +105 -0
- package/third-party/utxo-lib/transaction/decred.d.ts +4 -0
- package/third-party/utxo-lib/transaction/decred.js +149 -0
- package/third-party/utxo-lib/transaction/index.d.ts +15 -0
- package/third-party/utxo-lib/transaction/index.js +44 -0
- package/third-party/utxo-lib/transaction/peercoin.d.ts +4 -0
- package/third-party/utxo-lib/transaction/peercoin.js +64 -0
- package/third-party/utxo-lib/transaction/zcash.d.ts +66 -0
- package/third-party/utxo-lib/transaction/zcash.js +451 -0
- package/third-party/utxo-lib/types/coinselect.d.ts +61 -0
- package/third-party/utxo-lib/types/coinselect.js +3 -0
- package/third-party/utxo-lib/types/compose.d.ts +98 -0
- package/third-party/utxo-lib/types/compose.js +10 -0
- package/third-party/utxo-lib/types/index.d.ts +5 -0
- package/third-party/utxo-lib/types/index.js +8 -0
- package/third-party/utxo-lib/types/payments.d.ts +30 -0
- package/third-party/utxo-lib/types/payments.js +3 -0
- package/third-party/utxo-lib/types/typeforce.d.ts +8 -0
- package/third-party/utxo-lib/types/typeforce.js +16 -0
- package/third-party/utxo-lib/vsize.d.ts +13 -0
- package/third-party/utxo-lib/vsize.js +50 -0
- package/utils.js +78 -0
- package/witness.d.ts +70 -0
- package/witness.js +30 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.p2pkh = p2pkh;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const tiny_secp256k1_1 = tslib_1.__importDefault(require("tiny-secp256k1"));
|
|
6
|
+
const bs58check = tslib_1.__importStar(require("../bs58check"));
|
|
7
|
+
const bcrypto = tslib_1.__importStar(require("../crypto"));
|
|
8
|
+
const networks_1 = require("../networks");
|
|
9
|
+
const bscript = tslib_1.__importStar(require("../script"));
|
|
10
|
+
const lazy = tslib_1.__importStar(require("./lazy"));
|
|
11
|
+
const types_1 = require("../types");
|
|
12
|
+
const { OPS } = bscript;
|
|
13
|
+
function p2pkh(a, opts) {
|
|
14
|
+
if (!a.address && !a.hash && !a.output && !a.pubkey && !a.input)
|
|
15
|
+
throw new TypeError('Not enough data');
|
|
16
|
+
opts = Object.assign({ validate: true }, opts || {});
|
|
17
|
+
(0, types_1.typeforce)({
|
|
18
|
+
network: types_1.typeforce.maybe(types_1.typeforce.Object),
|
|
19
|
+
address: types_1.typeforce.maybe(types_1.typeforce.String),
|
|
20
|
+
hash: types_1.typeforce.maybe(types_1.typeforce.BufferN(20)),
|
|
21
|
+
output: types_1.typeforce.maybe(types_1.typeforce.BufferN(25)),
|
|
22
|
+
pubkey: types_1.typeforce.maybe(tiny_secp256k1_1.default.isPoint),
|
|
23
|
+
signature: types_1.typeforce.maybe(bscript.isCanonicalScriptSignature),
|
|
24
|
+
input: types_1.typeforce.maybe(types_1.typeforce.Buffer),
|
|
25
|
+
}, a);
|
|
26
|
+
const _address = lazy.value(() => bs58check.decodeAddress(a.address, a.network));
|
|
27
|
+
const _chunks = lazy.value(() => bscript.decompile(a.input));
|
|
28
|
+
const network = a.network || networks_1.bitcoin;
|
|
29
|
+
const o = { name: 'p2pkh', network };
|
|
30
|
+
lazy.prop(o, 'address', () => {
|
|
31
|
+
if (!o.hash)
|
|
32
|
+
return;
|
|
33
|
+
return bs58check.encodeAddress(o.hash, network.pubKeyHash, network);
|
|
34
|
+
});
|
|
35
|
+
lazy.prop(o, 'hash', () => {
|
|
36
|
+
if (a.output)
|
|
37
|
+
return a.output.subarray(3, 23);
|
|
38
|
+
if (a.address)
|
|
39
|
+
return _address().hash;
|
|
40
|
+
if (a.pubkey || o.pubkey)
|
|
41
|
+
return bcrypto.hash160(a.pubkey || o.pubkey);
|
|
42
|
+
});
|
|
43
|
+
lazy.prop(o, 'output', () => {
|
|
44
|
+
if (!o.hash)
|
|
45
|
+
return;
|
|
46
|
+
return bscript.compile([
|
|
47
|
+
OPS.OP_DUP,
|
|
48
|
+
OPS.OP_HASH160,
|
|
49
|
+
o.hash,
|
|
50
|
+
OPS.OP_EQUALVERIFY,
|
|
51
|
+
OPS.OP_CHECKSIG,
|
|
52
|
+
]);
|
|
53
|
+
});
|
|
54
|
+
lazy.prop(o, 'pubkey', () => {
|
|
55
|
+
if (!a.input)
|
|
56
|
+
return;
|
|
57
|
+
return _chunks()[1];
|
|
58
|
+
});
|
|
59
|
+
lazy.prop(o, 'signature', () => {
|
|
60
|
+
if (!a.input)
|
|
61
|
+
return;
|
|
62
|
+
return _chunks()[0];
|
|
63
|
+
});
|
|
64
|
+
lazy.prop(o, 'input', () => {
|
|
65
|
+
if (!a.pubkey)
|
|
66
|
+
return;
|
|
67
|
+
if (!a.signature)
|
|
68
|
+
return;
|
|
69
|
+
return bscript.compile([a.signature, a.pubkey]);
|
|
70
|
+
});
|
|
71
|
+
lazy.prop(o, 'witness', () => {
|
|
72
|
+
if (!o.input)
|
|
73
|
+
return;
|
|
74
|
+
return [];
|
|
75
|
+
});
|
|
76
|
+
if (opts.validate) {
|
|
77
|
+
let hash = Buffer.from([]);
|
|
78
|
+
if (a.address) {
|
|
79
|
+
const { version, hash: aHash } = _address();
|
|
80
|
+
if (version !== network.pubKeyHash)
|
|
81
|
+
throw new TypeError('Invalid version or Network mismatch');
|
|
82
|
+
if (aHash.length !== 20)
|
|
83
|
+
throw new TypeError('Invalid address');
|
|
84
|
+
hash = aHash;
|
|
85
|
+
}
|
|
86
|
+
if (a.hash) {
|
|
87
|
+
if (hash.length > 0 && !hash.equals(a.hash))
|
|
88
|
+
throw new TypeError('Hash mismatch');
|
|
89
|
+
else
|
|
90
|
+
hash = a.hash;
|
|
91
|
+
}
|
|
92
|
+
if (a.output) {
|
|
93
|
+
if (a.output.length !== 25 ||
|
|
94
|
+
a.output[0] !== OPS.OP_DUP ||
|
|
95
|
+
a.output[1] !== OPS.OP_HASH160 ||
|
|
96
|
+
a.output[2] !== 0x14 ||
|
|
97
|
+
a.output[23] !== OPS.OP_EQUALVERIFY ||
|
|
98
|
+
a.output[24] !== OPS.OP_CHECKSIG)
|
|
99
|
+
throw new TypeError('Output is invalid');
|
|
100
|
+
const hash2 = a.output.subarray(3, 23);
|
|
101
|
+
if (hash.length > 0 && !hash.equals(hash2))
|
|
102
|
+
throw new TypeError('Hash mismatch');
|
|
103
|
+
else
|
|
104
|
+
hash = hash2;
|
|
105
|
+
}
|
|
106
|
+
if (a.pubkey) {
|
|
107
|
+
const pkh = bcrypto.hash160(a.pubkey);
|
|
108
|
+
if (hash.length > 0 && !hash.equals(pkh))
|
|
109
|
+
throw new TypeError('Hash mismatch');
|
|
110
|
+
else
|
|
111
|
+
hash = pkh;
|
|
112
|
+
}
|
|
113
|
+
if (a.input) {
|
|
114
|
+
const chunks = _chunks();
|
|
115
|
+
if (chunks.length !== 2)
|
|
116
|
+
throw new TypeError('Input is invalid');
|
|
117
|
+
if (!bscript.isCanonicalScriptSignature(chunks[0]))
|
|
118
|
+
throw new TypeError('Input has invalid signature');
|
|
119
|
+
if (!tiny_secp256k1_1.default.isPoint(chunks[1]))
|
|
120
|
+
throw new TypeError('Input has invalid pubkey');
|
|
121
|
+
if (a.signature && !a.signature.equals(chunks[0]))
|
|
122
|
+
throw new TypeError('Signature mismatch');
|
|
123
|
+
if (a.pubkey && !a.pubkey.equals(chunks[1]))
|
|
124
|
+
throw new TypeError('Pubkey mismatch');
|
|
125
|
+
const pkh = bcrypto.hash160(chunks[1]);
|
|
126
|
+
if (hash.length > 0 && !hash.equals(pkh))
|
|
127
|
+
throw new TypeError('Hash mismatch');
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return Object.assign(o, a);
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=p2pkh.js.map
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.p2sh = p2sh;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const bs58check = tslib_1.__importStar(require("../bs58check"));
|
|
6
|
+
const bcrypto = tslib_1.__importStar(require("../crypto"));
|
|
7
|
+
const networks_1 = require("../networks");
|
|
8
|
+
const bscript = tslib_1.__importStar(require("../script"));
|
|
9
|
+
const lazy = tslib_1.__importStar(require("./lazy"));
|
|
10
|
+
const types_1 = require("../types");
|
|
11
|
+
const { OPS } = bscript;
|
|
12
|
+
function stacksEqual(a, b) {
|
|
13
|
+
if (a.length !== b.length)
|
|
14
|
+
return false;
|
|
15
|
+
return a.every((x, i) => x.equals(b[i]));
|
|
16
|
+
}
|
|
17
|
+
function p2sh(a, opts) {
|
|
18
|
+
if (!a.address && !a.hash && !a.output && !a.redeem && !a.input)
|
|
19
|
+
throw new TypeError('Not enough data');
|
|
20
|
+
opts = Object.assign({ validate: true }, opts || {});
|
|
21
|
+
(0, types_1.typeforce)({
|
|
22
|
+
network: types_1.typeforce.maybe(types_1.typeforce.Object),
|
|
23
|
+
address: types_1.typeforce.maybe(types_1.typeforce.String),
|
|
24
|
+
hash: types_1.typeforce.maybe(types_1.typeforce.BufferN(20)),
|
|
25
|
+
output: types_1.typeforce.maybe(types_1.typeforce.BufferN(23)),
|
|
26
|
+
redeem: types_1.typeforce.maybe({
|
|
27
|
+
network: types_1.typeforce.maybe(types_1.typeforce.Object),
|
|
28
|
+
output: types_1.typeforce.maybe(types_1.typeforce.Buffer),
|
|
29
|
+
input: types_1.typeforce.maybe(types_1.typeforce.Buffer),
|
|
30
|
+
witness: types_1.typeforce.maybe(types_1.typeforce.arrayOf(types_1.typeforce.Buffer)),
|
|
31
|
+
}),
|
|
32
|
+
input: types_1.typeforce.maybe(types_1.typeforce.Buffer),
|
|
33
|
+
witness: types_1.typeforce.maybe(types_1.typeforce.arrayOf(types_1.typeforce.Buffer)),
|
|
34
|
+
}, a);
|
|
35
|
+
let { network } = a;
|
|
36
|
+
if (!network) {
|
|
37
|
+
network = (a.redeem && a.redeem.network) || networks_1.bitcoin;
|
|
38
|
+
}
|
|
39
|
+
const o = { name: 'p2sh', network };
|
|
40
|
+
const _address = lazy.value(() => bs58check.decodeAddress(a.address, a.network));
|
|
41
|
+
const _chunks = lazy.value(() => bscript.decompile(a.input));
|
|
42
|
+
const _redeem = lazy.value(() => {
|
|
43
|
+
const chunks = _chunks();
|
|
44
|
+
return {
|
|
45
|
+
network,
|
|
46
|
+
output: chunks[chunks.length - 1],
|
|
47
|
+
input: bscript.compile(chunks.slice(0, -1)),
|
|
48
|
+
witness: a.witness || [],
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
lazy.prop(o, 'address', () => {
|
|
52
|
+
if (!o.hash)
|
|
53
|
+
return;
|
|
54
|
+
return bs58check.encodeAddress(o.hash, network.scriptHash, network);
|
|
55
|
+
});
|
|
56
|
+
lazy.prop(o, 'hash', () => {
|
|
57
|
+
if (a.output)
|
|
58
|
+
return a.output.subarray(2, 22);
|
|
59
|
+
if (a.address)
|
|
60
|
+
return _address().hash;
|
|
61
|
+
if (o.redeem && o.redeem.output)
|
|
62
|
+
return bcrypto.hash160(o.redeem.output);
|
|
63
|
+
});
|
|
64
|
+
lazy.prop(o, 'output', () => {
|
|
65
|
+
if (!o.hash)
|
|
66
|
+
return;
|
|
67
|
+
return bscript.compile([OPS.OP_HASH160, o.hash, OPS.OP_EQUAL]);
|
|
68
|
+
});
|
|
69
|
+
lazy.prop(o, 'redeem', () => {
|
|
70
|
+
if (!a.input)
|
|
71
|
+
return;
|
|
72
|
+
return _redeem();
|
|
73
|
+
});
|
|
74
|
+
lazy.prop(o, 'input', () => {
|
|
75
|
+
if (!a.redeem || !a.redeem.input || !a.redeem.output)
|
|
76
|
+
return;
|
|
77
|
+
return bscript.compile([].concat(bscript.decompile(a.redeem.input), a.redeem.output));
|
|
78
|
+
});
|
|
79
|
+
lazy.prop(o, 'witness', () => {
|
|
80
|
+
if (o.redeem && o.redeem.witness)
|
|
81
|
+
return o.redeem.witness;
|
|
82
|
+
if (o.input)
|
|
83
|
+
return [];
|
|
84
|
+
});
|
|
85
|
+
lazy.prop(o, 'name', () => {
|
|
86
|
+
const nameParts = ['p2sh'];
|
|
87
|
+
if (o.redeem !== undefined && o.redeem.name !== undefined)
|
|
88
|
+
nameParts.push(o.redeem.name);
|
|
89
|
+
return nameParts.join('-');
|
|
90
|
+
});
|
|
91
|
+
if (opts.validate) {
|
|
92
|
+
let hash = Buffer.from([]);
|
|
93
|
+
if (a.address) {
|
|
94
|
+
const { version, hash: aHash } = _address();
|
|
95
|
+
if (version !== network.scriptHash)
|
|
96
|
+
throw new TypeError('Invalid version or Network mismatch');
|
|
97
|
+
if (aHash.length !== 20)
|
|
98
|
+
throw new TypeError('Invalid address');
|
|
99
|
+
hash = aHash;
|
|
100
|
+
}
|
|
101
|
+
if (a.hash) {
|
|
102
|
+
if (hash.length > 0 && !hash.equals(a.hash))
|
|
103
|
+
throw new TypeError('Hash mismatch');
|
|
104
|
+
else
|
|
105
|
+
hash = a.hash;
|
|
106
|
+
}
|
|
107
|
+
if (a.output) {
|
|
108
|
+
if (a.output.length !== 23 ||
|
|
109
|
+
a.output[0] !== OPS.OP_HASH160 ||
|
|
110
|
+
a.output[1] !== 0x14 ||
|
|
111
|
+
a.output[22] !== OPS.OP_EQUAL)
|
|
112
|
+
throw new TypeError('Output is invalid');
|
|
113
|
+
const hash2 = a.output.subarray(2, 22);
|
|
114
|
+
if (hash.length > 0 && !hash.equals(hash2))
|
|
115
|
+
throw new TypeError('Hash mismatch');
|
|
116
|
+
else
|
|
117
|
+
hash = hash2;
|
|
118
|
+
}
|
|
119
|
+
const checkRedeem = (redeem) => {
|
|
120
|
+
if (redeem.output) {
|
|
121
|
+
const decompile = bscript.decompile(redeem.output);
|
|
122
|
+
if (!decompile || decompile.length < 1)
|
|
123
|
+
throw new TypeError('Redeem.output too short');
|
|
124
|
+
const hash2 = bcrypto.hash160(redeem.output);
|
|
125
|
+
if (hash.length > 0 && !hash.equals(hash2))
|
|
126
|
+
throw new TypeError('Hash mismatch');
|
|
127
|
+
else
|
|
128
|
+
hash = hash2;
|
|
129
|
+
}
|
|
130
|
+
if (redeem.input) {
|
|
131
|
+
const hasInput = redeem.input.length > 0;
|
|
132
|
+
const hasWitness = redeem.witness && redeem.witness.length > 0;
|
|
133
|
+
if (!hasInput && !hasWitness)
|
|
134
|
+
throw new TypeError('Empty input');
|
|
135
|
+
if (hasInput && hasWitness)
|
|
136
|
+
throw new TypeError('Input and witness provided');
|
|
137
|
+
if (hasInput) {
|
|
138
|
+
const richunks = bscript.decompile(redeem.input);
|
|
139
|
+
if (!bscript.isPushOnly(richunks))
|
|
140
|
+
throw new TypeError('Non push-only scriptSig');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
if (a.input) {
|
|
145
|
+
const chunks = _chunks();
|
|
146
|
+
if (!chunks || chunks.length < 1)
|
|
147
|
+
throw new TypeError('Input too short');
|
|
148
|
+
if (!Buffer.isBuffer(_redeem().output))
|
|
149
|
+
throw new TypeError('Input is invalid');
|
|
150
|
+
checkRedeem(_redeem());
|
|
151
|
+
}
|
|
152
|
+
if (a.redeem) {
|
|
153
|
+
if (a.redeem.network && a.redeem.network !== network)
|
|
154
|
+
throw new TypeError('Network mismatch');
|
|
155
|
+
if (a.input) {
|
|
156
|
+
const redeem = _redeem();
|
|
157
|
+
if (a.redeem.output && !a.redeem.output.equals(redeem.output))
|
|
158
|
+
throw new TypeError('Redeem.output mismatch');
|
|
159
|
+
if (a.redeem.input && !a.redeem.input.equals(redeem.input))
|
|
160
|
+
throw new TypeError('Redeem.input mismatch');
|
|
161
|
+
}
|
|
162
|
+
checkRedeem(a.redeem);
|
|
163
|
+
}
|
|
164
|
+
if (a.witness) {
|
|
165
|
+
if (a.redeem && a.redeem.witness && !stacksEqual(a.redeem.witness, a.witness))
|
|
166
|
+
throw new TypeError('Witness and redeem.witness mismatch');
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return Object.assign(o, a);
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=p2sh.js.map
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.p2tr = p2tr;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const tiny_secp256k1_1 = tslib_1.__importDefault(require("tiny-secp256k1"));
|
|
6
|
+
const bech32_1 = require("bech32");
|
|
7
|
+
const networks_1 = require("../networks");
|
|
8
|
+
const bcrypto = tslib_1.__importStar(require("../crypto"));
|
|
9
|
+
const bscript = tslib_1.__importStar(require("../script"));
|
|
10
|
+
const lazy = tslib_1.__importStar(require("./lazy"));
|
|
11
|
+
const types_1 = require("../types");
|
|
12
|
+
const { OPS } = bscript;
|
|
13
|
+
const TAGS = ['TapLeaf', 'TapBranch', 'TapTweak', 'KeyAgg list', 'KeyAgg coefficient'];
|
|
14
|
+
const TAGGED_HASH_PREFIXES = TAGS.reduce((obj, tag) => {
|
|
15
|
+
const tagHash = bcrypto.sha256(Buffer.from(tag));
|
|
16
|
+
obj[tag] = Buffer.concat([tagHash, tagHash]);
|
|
17
|
+
return obj;
|
|
18
|
+
}, {});
|
|
19
|
+
const EVEN_Y_COORD_PREFIX = new Uint8Array([0x02]);
|
|
20
|
+
function taggedHash(prefix, data) {
|
|
21
|
+
return bcrypto.sha256(Buffer.concat([TAGGED_HASH_PREFIXES[prefix], data]));
|
|
22
|
+
}
|
|
23
|
+
function tapTweakPubkey(pubkey, tapTreeRoot) {
|
|
24
|
+
let tapTweak;
|
|
25
|
+
if (tapTreeRoot) {
|
|
26
|
+
tapTweak = taggedHash('TapTweak', Buffer.concat([pubkey, tapTreeRoot]));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
tapTweak = taggedHash('TapTweak', pubkey);
|
|
30
|
+
}
|
|
31
|
+
const tweakedPubkey = tiny_secp256k1_1.default.pointAddScalar(Buffer.concat([EVEN_Y_COORD_PREFIX, pubkey]), tapTweak);
|
|
32
|
+
return {
|
|
33
|
+
parity: tweakedPubkey[0] === EVEN_Y_COORD_PREFIX[0] ? 0 : 1,
|
|
34
|
+
pubkey: tweakedPubkey.slice(1),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const liftX = (pubkey) => {
|
|
38
|
+
const offset = pubkey.length === 33 ? 1 : 0;
|
|
39
|
+
return pubkey.subarray(offset);
|
|
40
|
+
};
|
|
41
|
+
function p2tr(a, opts) {
|
|
42
|
+
if (!a.address && !a.pubkey && !a.output)
|
|
43
|
+
throw new TypeError('Not enough data');
|
|
44
|
+
opts = Object.assign({ validate: true }, opts || {});
|
|
45
|
+
const network = a.network || networks_1.bitcoin;
|
|
46
|
+
const o = { name: 'p2tr', network };
|
|
47
|
+
(0, types_1.typeforce)({
|
|
48
|
+
network: types_1.typeforce.maybe(types_1.typeforce.Object),
|
|
49
|
+
address: types_1.typeforce.maybe(types_1.typeforce.String),
|
|
50
|
+
output: types_1.typeforce.maybe(types_1.typeforce.BufferN(34)),
|
|
51
|
+
pubkey: types_1.typeforce.maybe(types_1.typeforce.anyOf(types_1.typeforce.BufferN(32), types_1.typeforce.BufferN(33))),
|
|
52
|
+
}, a);
|
|
53
|
+
const _address = lazy.value(() => {
|
|
54
|
+
const result = bech32_1.bech32m.decode(a.address);
|
|
55
|
+
const version = result.words.shift();
|
|
56
|
+
const data = bech32_1.bech32m.fromWords(result.words);
|
|
57
|
+
return {
|
|
58
|
+
version,
|
|
59
|
+
prefix: result.prefix,
|
|
60
|
+
data: Buffer.from(data),
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
lazy.prop(o, 'address', () => {
|
|
64
|
+
if (!o.hash)
|
|
65
|
+
return;
|
|
66
|
+
const words = bech32_1.bech32m.toWords(o.hash);
|
|
67
|
+
words.unshift(0x01);
|
|
68
|
+
return bech32_1.bech32m.encode(network.bech32, words);
|
|
69
|
+
});
|
|
70
|
+
lazy.prop(o, 'hash', () => {
|
|
71
|
+
if (a.output)
|
|
72
|
+
return a.output.subarray(2);
|
|
73
|
+
if (a.address)
|
|
74
|
+
return _address().data;
|
|
75
|
+
if (a.pubkey) {
|
|
76
|
+
return tapTweakPubkey(liftX(a.pubkey)).pubkey;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
lazy.prop(o, 'output', () => {
|
|
80
|
+
if (!o.hash)
|
|
81
|
+
return;
|
|
82
|
+
return bscript.compile([OPS.OP_1, o.hash]);
|
|
83
|
+
});
|
|
84
|
+
if (opts.validate) {
|
|
85
|
+
let hash = Buffer.from([]);
|
|
86
|
+
if (a.address) {
|
|
87
|
+
const { prefix, version, data } = _address();
|
|
88
|
+
if (prefix !== network.bech32)
|
|
89
|
+
throw new TypeError('Invalid prefix or Network mismatch');
|
|
90
|
+
if (version !== 0x01)
|
|
91
|
+
throw new TypeError('Invalid address version');
|
|
92
|
+
if (data.length !== 32)
|
|
93
|
+
throw new TypeError('Invalid address data');
|
|
94
|
+
hash = data;
|
|
95
|
+
}
|
|
96
|
+
if (a.hash) {
|
|
97
|
+
if (hash.length > 0 && !hash.equals(a.hash))
|
|
98
|
+
throw new TypeError('Hash mismatch');
|
|
99
|
+
else
|
|
100
|
+
hash = a.hash;
|
|
101
|
+
}
|
|
102
|
+
if (a.output) {
|
|
103
|
+
if (a.output[0] !== OPS.OP_1 || a.output[1] !== 0x20)
|
|
104
|
+
throw new TypeError('p2tr output is invalid');
|
|
105
|
+
const hash2 = a.output.subarray(2);
|
|
106
|
+
if (hash.length > 0 && !hash.equals(hash2))
|
|
107
|
+
throw new TypeError('Hash mismatch');
|
|
108
|
+
else
|
|
109
|
+
hash = hash2;
|
|
110
|
+
}
|
|
111
|
+
if (a.pubkey) {
|
|
112
|
+
const pkh = tapTweakPubkey(liftX(a.pubkey)).pubkey;
|
|
113
|
+
if (hash.length > 0 && !hash.equals(pkh))
|
|
114
|
+
throw new TypeError('Hash mismatch');
|
|
115
|
+
else
|
|
116
|
+
hash = pkh;
|
|
117
|
+
if (!tiny_secp256k1_1.default.isPoint(Buffer.concat([EVEN_Y_COORD_PREFIX, liftX(a.pubkey)])))
|
|
118
|
+
throw new TypeError('Invalid pubkey for p2tr');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return Object.assign(o, a);
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=p2tr.js.map
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.p2wpkh = p2wpkh;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const tiny_secp256k1_1 = tslib_1.__importDefault(require("tiny-secp256k1"));
|
|
6
|
+
const bech32_1 = require("bech32");
|
|
7
|
+
const bcrypto = tslib_1.__importStar(require("../crypto"));
|
|
8
|
+
const networks_1 = require("../networks");
|
|
9
|
+
const bscript = tslib_1.__importStar(require("../script"));
|
|
10
|
+
const types_1 = require("../types");
|
|
11
|
+
const lazy = tslib_1.__importStar(require("./lazy"));
|
|
12
|
+
const { OPS } = bscript;
|
|
13
|
+
const EMPTY_BUFFER = Buffer.alloc(0);
|
|
14
|
+
function p2wpkh(a, opts) {
|
|
15
|
+
if (!a.address && !a.hash && !a.output && !a.pubkey && !a.witness)
|
|
16
|
+
throw new TypeError('Not enough data');
|
|
17
|
+
opts = Object.assign({ validate: true }, opts || {});
|
|
18
|
+
(0, types_1.typeforce)({
|
|
19
|
+
address: types_1.typeforce.maybe(types_1.typeforce.String),
|
|
20
|
+
hash: types_1.typeforce.maybe(types_1.typeforce.BufferN(20)),
|
|
21
|
+
input: types_1.typeforce.maybe(types_1.typeforce.BufferN(0)),
|
|
22
|
+
network: types_1.typeforce.maybe(types_1.typeforce.Object),
|
|
23
|
+
output: types_1.typeforce.maybe(types_1.typeforce.BufferN(22)),
|
|
24
|
+
pubkey: types_1.typeforce.maybe(tiny_secp256k1_1.default.isPoint),
|
|
25
|
+
signature: types_1.typeforce.maybe(bscript.isCanonicalScriptSignature),
|
|
26
|
+
witness: types_1.typeforce.maybe(types_1.typeforce.arrayOf(types_1.typeforce.Buffer)),
|
|
27
|
+
}, a);
|
|
28
|
+
const _address = lazy.value(() => {
|
|
29
|
+
const result = bech32_1.bech32.decode(a.address);
|
|
30
|
+
const version = result.words.shift();
|
|
31
|
+
const data = bech32_1.bech32.fromWords(result.words);
|
|
32
|
+
return {
|
|
33
|
+
version,
|
|
34
|
+
prefix: result.prefix,
|
|
35
|
+
data: Buffer.from(data),
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
const network = a.network || networks_1.bitcoin;
|
|
39
|
+
const o = { name: 'p2wpkh', network };
|
|
40
|
+
lazy.prop(o, 'address', () => {
|
|
41
|
+
if (!o.hash)
|
|
42
|
+
return;
|
|
43
|
+
const words = bech32_1.bech32.toWords(o.hash);
|
|
44
|
+
words.unshift(0x00);
|
|
45
|
+
return bech32_1.bech32.encode(network.bech32, words);
|
|
46
|
+
});
|
|
47
|
+
lazy.prop(o, 'hash', () => {
|
|
48
|
+
if (a.output)
|
|
49
|
+
return a.output.subarray(2, 22);
|
|
50
|
+
if (a.address)
|
|
51
|
+
return _address().data;
|
|
52
|
+
if (a.pubkey || o.pubkey)
|
|
53
|
+
return bcrypto.hash160(a.pubkey || o.pubkey);
|
|
54
|
+
});
|
|
55
|
+
lazy.prop(o, 'output', () => {
|
|
56
|
+
if (!o.hash)
|
|
57
|
+
return;
|
|
58
|
+
return bscript.compile([OPS.OP_0, o.hash]);
|
|
59
|
+
});
|
|
60
|
+
lazy.prop(o, 'pubkey', () => {
|
|
61
|
+
if (a.pubkey)
|
|
62
|
+
return a.pubkey;
|
|
63
|
+
if (!a.witness)
|
|
64
|
+
return;
|
|
65
|
+
return a.witness[1];
|
|
66
|
+
});
|
|
67
|
+
lazy.prop(o, 'signature', () => {
|
|
68
|
+
if (!a.witness)
|
|
69
|
+
return;
|
|
70
|
+
return a.witness[0];
|
|
71
|
+
});
|
|
72
|
+
lazy.prop(o, 'input', () => {
|
|
73
|
+
if (!o.witness)
|
|
74
|
+
return;
|
|
75
|
+
return EMPTY_BUFFER;
|
|
76
|
+
});
|
|
77
|
+
lazy.prop(o, 'witness', () => {
|
|
78
|
+
if (!a.pubkey)
|
|
79
|
+
return;
|
|
80
|
+
if (!a.signature)
|
|
81
|
+
return;
|
|
82
|
+
return [a.signature, a.pubkey];
|
|
83
|
+
});
|
|
84
|
+
if (opts.validate) {
|
|
85
|
+
let hash = Buffer.from([]);
|
|
86
|
+
if (a.address) {
|
|
87
|
+
const { prefix, version, data } = _address();
|
|
88
|
+
if (network && network.bech32 !== prefix)
|
|
89
|
+
throw new TypeError('Invalid prefix or Network mismatch');
|
|
90
|
+
if (version !== 0x00)
|
|
91
|
+
throw new TypeError('Invalid address version');
|
|
92
|
+
if (data.length !== 20)
|
|
93
|
+
throw new TypeError('Invalid address data');
|
|
94
|
+
hash = data;
|
|
95
|
+
}
|
|
96
|
+
if (a.hash) {
|
|
97
|
+
if (hash.length > 0 && !hash.equals(a.hash))
|
|
98
|
+
throw new TypeError('Hash mismatch');
|
|
99
|
+
else
|
|
100
|
+
hash = a.hash;
|
|
101
|
+
}
|
|
102
|
+
if (a.output) {
|
|
103
|
+
if (a.output.length !== 22 || a.output[0] !== OPS.OP_0 || a.output[1] !== 0x14)
|
|
104
|
+
throw new TypeError('Output is invalid');
|
|
105
|
+
if (hash.length > 0 && !hash.equals(a.output.subarray(2)))
|
|
106
|
+
throw new TypeError('Hash mismatch');
|
|
107
|
+
else
|
|
108
|
+
hash = a.output.subarray(2);
|
|
109
|
+
}
|
|
110
|
+
if (a.pubkey) {
|
|
111
|
+
const pkh = bcrypto.hash160(a.pubkey);
|
|
112
|
+
if (hash.length > 0 && !hash.equals(pkh))
|
|
113
|
+
throw new TypeError('Hash mismatch');
|
|
114
|
+
else
|
|
115
|
+
hash = pkh;
|
|
116
|
+
if (!tiny_secp256k1_1.default.isPoint(a.pubkey) || a.pubkey.length !== 33)
|
|
117
|
+
throw new TypeError('Invalid pubkey for p2wpkh');
|
|
118
|
+
}
|
|
119
|
+
if (a.witness) {
|
|
120
|
+
if (a.witness.length !== 2)
|
|
121
|
+
throw new TypeError('Witness is invalid');
|
|
122
|
+
if (!bscript.isCanonicalScriptSignature(a.witness[0]))
|
|
123
|
+
throw new TypeError('Witness has invalid signature');
|
|
124
|
+
if (!tiny_secp256k1_1.default.isPoint(a.witness[1]) || a.witness[1].length !== 33)
|
|
125
|
+
throw new TypeError('Witness has invalid pubkey');
|
|
126
|
+
if (a.signature && !a.signature.equals(a.witness[0]))
|
|
127
|
+
throw new TypeError('Signature mismatch');
|
|
128
|
+
if (a.pubkey && !a.pubkey.equals(a.witness[1]))
|
|
129
|
+
throw new TypeError('Pubkey mismatch');
|
|
130
|
+
const pkh = bcrypto.hash160(a.witness[1]);
|
|
131
|
+
if (hash.length > 0 && !hash.equals(pkh))
|
|
132
|
+
throw new TypeError('Hash mismatch');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return Object.assign(o, a);
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=p2wpkh.js.map
|