@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,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OPS = exports.signature = exports.number = void 0;
|
|
4
|
+
exports.isPushOnly = isPushOnly;
|
|
5
|
+
exports.compile = compile;
|
|
6
|
+
exports.decompile = decompile;
|
|
7
|
+
exports.toASM = toASM;
|
|
8
|
+
exports.fromASM = fromASM;
|
|
9
|
+
exports.toStack = toStack;
|
|
10
|
+
exports.isCanonicalPubKey = isCanonicalPubKey;
|
|
11
|
+
exports.isDefinedHashType = isDefinedHashType;
|
|
12
|
+
exports.isCanonicalScriptSignature = isCanonicalScriptSignature;
|
|
13
|
+
const tslib_1 = require("tslib");
|
|
14
|
+
const bip66 = tslib_1.__importStar(require("bip66"));
|
|
15
|
+
const pushdata_bitcoin_1 = tslib_1.__importDefault(require("pushdata-bitcoin"));
|
|
16
|
+
const tiny_secp256k1_1 = tslib_1.__importDefault(require("tiny-secp256k1"));
|
|
17
|
+
const scriptNumber = tslib_1.__importStar(require("./scriptNumber"));
|
|
18
|
+
const scriptSignature = tslib_1.__importStar(require("./scriptSignature"));
|
|
19
|
+
const ops_1 = require("./ops");
|
|
20
|
+
const types = tslib_1.__importStar(require("../types"));
|
|
21
|
+
const types_1 = require("../types");
|
|
22
|
+
const OP_INT_BASE = ops_1.OPS.OP_RESERVED;
|
|
23
|
+
function isOPInt(value) {
|
|
24
|
+
return (types.Number(value) &&
|
|
25
|
+
(value === ops_1.OPS.OP_0 ||
|
|
26
|
+
(value >= ops_1.OPS.OP_1 && value <= ops_1.OPS.OP_16) ||
|
|
27
|
+
value === ops_1.OPS.OP_1NEGATE));
|
|
28
|
+
}
|
|
29
|
+
function isPushOnlyChunk(value) {
|
|
30
|
+
return types.Buffer(value) || isOPInt(value);
|
|
31
|
+
}
|
|
32
|
+
function isPushOnly(value) {
|
|
33
|
+
return types.Array(value) && value.every(isPushOnlyChunk);
|
|
34
|
+
}
|
|
35
|
+
function asMinimalOP(buffer) {
|
|
36
|
+
if (buffer.length === 0)
|
|
37
|
+
return ops_1.OPS.OP_0;
|
|
38
|
+
if (buffer.length !== 1)
|
|
39
|
+
return;
|
|
40
|
+
if (buffer[0] >= 1 && buffer[0] <= 16)
|
|
41
|
+
return OP_INT_BASE + buffer[0];
|
|
42
|
+
if (buffer[0] === 0x81)
|
|
43
|
+
return ops_1.OPS.OP_1NEGATE;
|
|
44
|
+
}
|
|
45
|
+
function compile(chunks) {
|
|
46
|
+
if (types.Buffer(chunks))
|
|
47
|
+
return chunks;
|
|
48
|
+
(0, types_1.typeforce)(types.Array, chunks);
|
|
49
|
+
const bufferSize = chunks.reduce((accum, chunk) => {
|
|
50
|
+
if (types.Buffer(chunk)) {
|
|
51
|
+
if (chunk.length === 1 && asMinimalOP(chunk) !== undefined) {
|
|
52
|
+
return accum + 1;
|
|
53
|
+
}
|
|
54
|
+
return accum + pushdata_bitcoin_1.default.encodingLength(chunk.length) + chunk.length;
|
|
55
|
+
}
|
|
56
|
+
return accum + 1;
|
|
57
|
+
}, 0.0);
|
|
58
|
+
const buffer = Buffer.allocUnsafe(bufferSize);
|
|
59
|
+
let offset = 0;
|
|
60
|
+
chunks.forEach(chunk => {
|
|
61
|
+
if (types.Buffer(chunk)) {
|
|
62
|
+
const opcode = asMinimalOP(chunk);
|
|
63
|
+
if (opcode !== undefined) {
|
|
64
|
+
buffer.writeUInt8(opcode, offset);
|
|
65
|
+
offset += 1;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
offset += pushdata_bitcoin_1.default.encode(buffer, chunk.length, offset);
|
|
69
|
+
chunk.copy(buffer, offset);
|
|
70
|
+
offset += chunk.length;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
buffer.writeUInt8(chunk, offset);
|
|
74
|
+
offset += 1;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
if (offset !== buffer.length)
|
|
78
|
+
throw new Error('Could not decode chunks');
|
|
79
|
+
return buffer;
|
|
80
|
+
}
|
|
81
|
+
function decompile(buffer) {
|
|
82
|
+
if (types.Array(buffer))
|
|
83
|
+
return buffer;
|
|
84
|
+
(0, types_1.typeforce)(types.Buffer, buffer);
|
|
85
|
+
const chunks = [];
|
|
86
|
+
let i = 0;
|
|
87
|
+
while (i < buffer.length) {
|
|
88
|
+
const opcode = buffer[i];
|
|
89
|
+
if (opcode > ops_1.OPS.OP_0 && opcode <= ops_1.OPS.OP_PUSHDATA4) {
|
|
90
|
+
const d = pushdata_bitcoin_1.default.decode(buffer, i);
|
|
91
|
+
if (d === null)
|
|
92
|
+
return [];
|
|
93
|
+
i += d.size;
|
|
94
|
+
if (i + d.number > buffer.length)
|
|
95
|
+
return [];
|
|
96
|
+
const data = buffer.subarray(i, i + d.number);
|
|
97
|
+
i += d.number;
|
|
98
|
+
const op = asMinimalOP(data);
|
|
99
|
+
if (op !== undefined) {
|
|
100
|
+
chunks.push(op);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
chunks.push(data);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
chunks.push(opcode);
|
|
108
|
+
i += 1;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return chunks;
|
|
112
|
+
}
|
|
113
|
+
function toASM(chunks) {
|
|
114
|
+
if (types.Buffer(chunks)) {
|
|
115
|
+
chunks = decompile(chunks);
|
|
116
|
+
}
|
|
117
|
+
return chunks
|
|
118
|
+
.map(chunk => {
|
|
119
|
+
if (types.Buffer(chunk)) {
|
|
120
|
+
const op = asMinimalOP(chunk);
|
|
121
|
+
if (op === undefined)
|
|
122
|
+
return chunk.toString('hex');
|
|
123
|
+
chunk = op;
|
|
124
|
+
}
|
|
125
|
+
return ops_1.REVERSE_OPS[chunk];
|
|
126
|
+
})
|
|
127
|
+
.join(' ');
|
|
128
|
+
}
|
|
129
|
+
function fromASM(asm) {
|
|
130
|
+
(0, types_1.typeforce)(types.String, asm);
|
|
131
|
+
return compile(asm.split(' ').map(chunkStr => {
|
|
132
|
+
if (ops_1.OPS[chunkStr] !== undefined)
|
|
133
|
+
return ops_1.OPS[chunkStr];
|
|
134
|
+
(0, types_1.typeforce)(types.Hex, chunkStr);
|
|
135
|
+
return Buffer.from(chunkStr, 'hex');
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
function toStack(chunks0) {
|
|
139
|
+
const chunks = decompile(chunks0);
|
|
140
|
+
(0, types_1.typeforce)(isPushOnly, chunks);
|
|
141
|
+
return chunks === null || chunks === void 0 ? void 0 : chunks.map(op => {
|
|
142
|
+
if (types.Buffer(op))
|
|
143
|
+
return op;
|
|
144
|
+
if (op === ops_1.OPS.OP_0)
|
|
145
|
+
return Buffer.allocUnsafe(0);
|
|
146
|
+
return scriptNumber.encode(op - OP_INT_BASE);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function isCanonicalPubKey(buffer) {
|
|
150
|
+
return tiny_secp256k1_1.default.isPoint(buffer);
|
|
151
|
+
}
|
|
152
|
+
function isDefinedHashType(hashType) {
|
|
153
|
+
const hashTypeMod = hashType & ~0x80;
|
|
154
|
+
return hashTypeMod > 0x00 && hashTypeMod < 0x04;
|
|
155
|
+
}
|
|
156
|
+
function isCanonicalScriptSignature(buffer) {
|
|
157
|
+
if (!types.Buffer(buffer))
|
|
158
|
+
return false;
|
|
159
|
+
if (!isDefinedHashType(buffer[buffer.length - 1]))
|
|
160
|
+
return false;
|
|
161
|
+
return bip66.check(buffer.subarray(0, -1));
|
|
162
|
+
}
|
|
163
|
+
exports.number = scriptNumber;
|
|
164
|
+
exports.signature = scriptSignature;
|
|
165
|
+
var ops_2 = require("./ops");
|
|
166
|
+
Object.defineProperty(exports, "OPS", { enumerable: true, get: function () { return ops_2.OPS; } });
|
|
167
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REVERSE_OPS = exports.OPS = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const ops = tslib_1.__importStar(require("bitcoin-ops"));
|
|
6
|
+
const OPS = Object.assign(Object.assign({}, ops), { OP_SSTX: 0xba, OP_SSTXCHANGE: 0xbd, OP_SSGEN: 0xbb, OP_SSRTX: 0xbc });
|
|
7
|
+
exports.OPS = OPS;
|
|
8
|
+
const REVERSE_OPS = [];
|
|
9
|
+
exports.REVERSE_OPS = REVERSE_OPS;
|
|
10
|
+
Object.keys(OPS).forEach(code => {
|
|
11
|
+
REVERSE_OPS[OPS[code]] = code;
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=ops.js.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decode = decode;
|
|
4
|
+
exports.encode = encode;
|
|
5
|
+
function decode(buffer, maxLength = 4, minimal = true) {
|
|
6
|
+
const { length } = buffer;
|
|
7
|
+
if (length === 0)
|
|
8
|
+
return 0;
|
|
9
|
+
if (length > maxLength)
|
|
10
|
+
throw new TypeError('Script number overflow');
|
|
11
|
+
if (minimal) {
|
|
12
|
+
if ((buffer[length - 1] & 0x7f) === 0) {
|
|
13
|
+
if (length <= 1 || (buffer[length - 2] & 0x80) === 0)
|
|
14
|
+
throw new Error('Non-minimally encoded script number');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (length === 5) {
|
|
18
|
+
const a = buffer.readUInt32LE(0);
|
|
19
|
+
const b = buffer.readUInt8(4);
|
|
20
|
+
if (b & 0x80)
|
|
21
|
+
return -((b & ~0x80) * 0x100000000 + a);
|
|
22
|
+
return b * 0x100000000 + a;
|
|
23
|
+
}
|
|
24
|
+
let result = 0;
|
|
25
|
+
for (let i = 0; i < length; ++i) {
|
|
26
|
+
result |= buffer[i] << (8 * i);
|
|
27
|
+
}
|
|
28
|
+
if (buffer[length - 1] & 0x80)
|
|
29
|
+
return -(result & ~(0x80 << (8 * (length - 1))));
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
function scriptNumSize(i) {
|
|
33
|
+
if (i > 0x7fffffff)
|
|
34
|
+
return 5;
|
|
35
|
+
if (i > 0x7fffff)
|
|
36
|
+
return 4;
|
|
37
|
+
if (i > 0x7fff)
|
|
38
|
+
return 3;
|
|
39
|
+
if (i > 0x7f)
|
|
40
|
+
return 2;
|
|
41
|
+
if (i > 0x00)
|
|
42
|
+
return 1;
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
function encode(number) {
|
|
46
|
+
let value = Math.abs(number);
|
|
47
|
+
const size = scriptNumSize(value);
|
|
48
|
+
const buffer = Buffer.allocUnsafe(size);
|
|
49
|
+
const negative = number < 0;
|
|
50
|
+
for (let i = 0; i < size; ++i) {
|
|
51
|
+
buffer.writeUInt8(value & 0xff, i);
|
|
52
|
+
value >>= 8;
|
|
53
|
+
}
|
|
54
|
+
if (buffer[size - 1] & 0x80) {
|
|
55
|
+
buffer.writeUInt8(negative ? 0x80 : 0x00, size - 1);
|
|
56
|
+
}
|
|
57
|
+
else if (negative) {
|
|
58
|
+
buffer[size - 1] |= 0x80;
|
|
59
|
+
}
|
|
60
|
+
return buffer;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=scriptNumber.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function toDER(x: Buffer): Buffer;
|
|
2
|
+
export declare function fromDER(x: Buffer): Buffer;
|
|
3
|
+
export declare function decode(buffer: Buffer): {
|
|
4
|
+
signature: Buffer;
|
|
5
|
+
hashType: number;
|
|
6
|
+
};
|
|
7
|
+
export declare function encode(signature: Buffer, hashType: number): Buffer;
|
|
8
|
+
//# sourceMappingURL=scriptSignature.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toDER = toDER;
|
|
4
|
+
exports.fromDER = fromDER;
|
|
5
|
+
exports.decode = decode;
|
|
6
|
+
exports.encode = encode;
|
|
7
|
+
const tslib_1 = require("tslib");
|
|
8
|
+
const bip66 = tslib_1.__importStar(require("bip66"));
|
|
9
|
+
const types = tslib_1.__importStar(require("../types"));
|
|
10
|
+
const ZERO = Buffer.alloc(1, 0);
|
|
11
|
+
function toDER(x) {
|
|
12
|
+
let i = 0;
|
|
13
|
+
while (x[i] === 0)
|
|
14
|
+
++i;
|
|
15
|
+
if (i === x.length)
|
|
16
|
+
return ZERO;
|
|
17
|
+
x = x.subarray(i);
|
|
18
|
+
if (x[0] & 0x80)
|
|
19
|
+
return Buffer.concat([ZERO, x], 1 + x.length);
|
|
20
|
+
return x;
|
|
21
|
+
}
|
|
22
|
+
function fromDER(x) {
|
|
23
|
+
if (x[0] === 0x00)
|
|
24
|
+
x = x.subarray(1);
|
|
25
|
+
const buffer = Buffer.alloc(32, 0);
|
|
26
|
+
const bstart = Math.max(0, 32 - x.length);
|
|
27
|
+
x.copy(buffer, bstart);
|
|
28
|
+
return buffer;
|
|
29
|
+
}
|
|
30
|
+
function decode(buffer) {
|
|
31
|
+
const hashType = buffer.readUInt8(buffer.length - 1);
|
|
32
|
+
const hashTypeMod = hashType & ~0x80;
|
|
33
|
+
if (hashTypeMod <= 0 || hashTypeMod >= 4)
|
|
34
|
+
throw new Error(`Invalid hashType ${hashType}`);
|
|
35
|
+
const decoded = bip66.decode(buffer.subarray(0, -1));
|
|
36
|
+
const r = fromDER(decoded.r);
|
|
37
|
+
const s = fromDER(decoded.s);
|
|
38
|
+
const signature = Buffer.concat([r, s], 64);
|
|
39
|
+
return { signature, hashType };
|
|
40
|
+
}
|
|
41
|
+
function encode(signature, hashType) {
|
|
42
|
+
types.typeforce({
|
|
43
|
+
signature: types.BufferN(64),
|
|
44
|
+
hashType: types.UInt8,
|
|
45
|
+
}, { signature, hashType });
|
|
46
|
+
const hashTypeMod = hashType & ~0x80;
|
|
47
|
+
if (hashTypeMod <= 0 || hashTypeMod >= 4)
|
|
48
|
+
throw new Error(`Invalid hashType ${hashType}`);
|
|
49
|
+
const hashTypeBuffer = Buffer.allocUnsafe(1);
|
|
50
|
+
hashTypeBuffer.writeUInt8(hashType, 0);
|
|
51
|
+
const r = toDER(signature.subarray(0, 32));
|
|
52
|
+
const s = toDER(signature.subarray(32, 64));
|
|
53
|
+
return Buffer.concat([bip66.encode(r, s), hashTypeBuffer]);
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=scriptSignature.js.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Network } from '../networks';
|
|
2
|
+
export declare function varSliceSize(someScript: Buffer): number;
|
|
3
|
+
export declare function vectorSize(someVector: Buffer[]): number;
|
|
4
|
+
export declare function isCoinbaseHash(buffer: Buffer): boolean;
|
|
5
|
+
export declare const EMPTY_SCRIPT: Buffer;
|
|
6
|
+
export interface TxOutput {
|
|
7
|
+
script: Buffer;
|
|
8
|
+
value: string;
|
|
9
|
+
decredVersion?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface TxInput {
|
|
12
|
+
hash: Buffer;
|
|
13
|
+
index: number;
|
|
14
|
+
script: Buffer;
|
|
15
|
+
sequence: number;
|
|
16
|
+
witness: Buffer[];
|
|
17
|
+
decredTree?: number;
|
|
18
|
+
decredWitness?: {
|
|
19
|
+
value: string;
|
|
20
|
+
height: number;
|
|
21
|
+
blockIndex: number;
|
|
22
|
+
script: Buffer;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export type TransactionOptions = {
|
|
26
|
+
nostrict?: boolean;
|
|
27
|
+
network?: Network;
|
|
28
|
+
};
|
|
29
|
+
export declare class TransactionBase<S = undefined> {
|
|
30
|
+
version: number;
|
|
31
|
+
locktime: number;
|
|
32
|
+
ins: TxInput[];
|
|
33
|
+
outs: TxOutput[];
|
|
34
|
+
specific: S | undefined;
|
|
35
|
+
network: Network;
|
|
36
|
+
type: number | undefined;
|
|
37
|
+
timestamp: number | undefined;
|
|
38
|
+
expiry: number | undefined;
|
|
39
|
+
constructor(options: TransactionOptions & {
|
|
40
|
+
txSpecific?: S;
|
|
41
|
+
});
|
|
42
|
+
isCoinbase(): boolean;
|
|
43
|
+
hasWitnesses(): boolean;
|
|
44
|
+
isMwebPegOutTx(): boolean;
|
|
45
|
+
weight(): number;
|
|
46
|
+
virtualSize(): number;
|
|
47
|
+
byteLength(_ALLOW_WITNESS?: boolean, _ALLOW_MWEB?: boolean): number;
|
|
48
|
+
getHash(forWitness?: boolean, forMweb?: boolean): Buffer;
|
|
49
|
+
getId(): string;
|
|
50
|
+
getWitness(index: number): Buffer | undefined;
|
|
51
|
+
getExtraData(): Buffer | void;
|
|
52
|
+
getSpecificData(): S | void;
|
|
53
|
+
toBuffer(_buffer?: Buffer, _initialOffset?: number, _ALLOW_WITNESS?: boolean, _ALLOW_MWEB?: boolean): Buffer;
|
|
54
|
+
toHex(): string;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransactionBase = exports.EMPTY_SCRIPT = void 0;
|
|
4
|
+
exports.varSliceSize = varSliceSize;
|
|
5
|
+
exports.vectorSize = vectorSize;
|
|
6
|
+
exports.isCoinbaseHash = isCoinbaseHash;
|
|
7
|
+
const tslib_1 = require("tslib");
|
|
8
|
+
const varuint = tslib_1.__importStar(require("varuint-bitcoin"));
|
|
9
|
+
const bufferutils_1 = require("../bufferutils");
|
|
10
|
+
const bcrypto = tslib_1.__importStar(require("../crypto"));
|
|
11
|
+
const types = tslib_1.__importStar(require("../types"));
|
|
12
|
+
const bscript = tslib_1.__importStar(require("../script"));
|
|
13
|
+
const networks_1 = require("../networks");
|
|
14
|
+
function varSliceSize(someScript) {
|
|
15
|
+
const { length } = someScript;
|
|
16
|
+
return varuint.encodingLength(length) + length;
|
|
17
|
+
}
|
|
18
|
+
function vectorSize(someVector) {
|
|
19
|
+
return (varuint.encodingLength(someVector.length) +
|
|
20
|
+
someVector.reduce((sum, witness) => sum + varSliceSize(witness), 0));
|
|
21
|
+
}
|
|
22
|
+
function isCoinbaseHash(buffer) {
|
|
23
|
+
types.typeforce(types.Hash256bit, buffer);
|
|
24
|
+
for (let i = 0; i < 32; ++i) {
|
|
25
|
+
if (buffer[i] !== 0)
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
exports.EMPTY_SCRIPT = Buffer.allocUnsafe(0);
|
|
31
|
+
class TransactionBase {
|
|
32
|
+
constructor(options) {
|
|
33
|
+
this.version = 1;
|
|
34
|
+
this.locktime = 0;
|
|
35
|
+
this.ins = [];
|
|
36
|
+
this.outs = [];
|
|
37
|
+
this.network = options.network || networks_1.bitcoin;
|
|
38
|
+
this.specific = options.txSpecific;
|
|
39
|
+
}
|
|
40
|
+
isCoinbase() {
|
|
41
|
+
return this.ins.length === 1 && isCoinbaseHash(this.ins[0].hash);
|
|
42
|
+
}
|
|
43
|
+
hasWitnesses() {
|
|
44
|
+
return this.ins.some(x => x.witness.length !== 0);
|
|
45
|
+
}
|
|
46
|
+
isMwebPegOutTx() {
|
|
47
|
+
if (!(0, networks_1.isNetworkType)('litecoin', this.network)) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
return (this.outs.some(output => {
|
|
51
|
+
const asm = bscript.toASM(output.script);
|
|
52
|
+
return asm.startsWith('OP_8');
|
|
53
|
+
}) &&
|
|
54
|
+
this.ins.some(input => !input.script.length));
|
|
55
|
+
}
|
|
56
|
+
weight() {
|
|
57
|
+
const base = this.byteLength(false, false);
|
|
58
|
+
const total = this.byteLength(true, false);
|
|
59
|
+
return base * 3 + total;
|
|
60
|
+
}
|
|
61
|
+
virtualSize() {
|
|
62
|
+
return Math.ceil(this.weight() / 4);
|
|
63
|
+
}
|
|
64
|
+
byteLength(_ALLOW_WITNESS = true, _ALLOW_MWEB = true) {
|
|
65
|
+
const hasWitnesses = _ALLOW_WITNESS && this.hasWitnesses();
|
|
66
|
+
return ((hasWitnesses ? 10 : 8) +
|
|
67
|
+
(this.timestamp ? 4 : 0) +
|
|
68
|
+
varuint.encodingLength(this.ins.length) +
|
|
69
|
+
varuint.encodingLength(this.outs.length) +
|
|
70
|
+
this.ins.reduce((sum, input) => sum + 40 + varSliceSize(input.script), 0) +
|
|
71
|
+
this.outs.reduce((sum, output) => sum + 8 + varSliceSize(output.script), 0) +
|
|
72
|
+
(hasWitnesses
|
|
73
|
+
? this.ins.reduce((sum, input) => sum + vectorSize(input.witness), 0)
|
|
74
|
+
: 0) +
|
|
75
|
+
(_ALLOW_MWEB && this.isMwebPegOutTx() ? 3 : 0));
|
|
76
|
+
}
|
|
77
|
+
getHash(forWitness = false, forMweb = false) {
|
|
78
|
+
if (forWitness && this.isCoinbase())
|
|
79
|
+
return Buffer.alloc(32, 0);
|
|
80
|
+
return bcrypto.hash256(this.toBuffer(undefined, undefined, forWitness, forMweb));
|
|
81
|
+
}
|
|
82
|
+
getId() {
|
|
83
|
+
return (0, bufferutils_1.reverseBuffer)(this.getHash(false)).toString('hex');
|
|
84
|
+
}
|
|
85
|
+
getWitness(index) {
|
|
86
|
+
if (!this.hasWitnesses() ||
|
|
87
|
+
!this.ins[index] ||
|
|
88
|
+
!Array.isArray(this.ins[index].witness) ||
|
|
89
|
+
this.ins[index].witness.length < 1)
|
|
90
|
+
return;
|
|
91
|
+
const { witness } = this.ins[index];
|
|
92
|
+
const chunks = witness.reduce((arr, chunk) => arr.concat([(0, bufferutils_1.getChunkSize)(chunk.length), chunk]), [(0, bufferutils_1.getChunkSize)(witness.length)]);
|
|
93
|
+
return Buffer.concat(chunks);
|
|
94
|
+
}
|
|
95
|
+
getExtraData() {
|
|
96
|
+
}
|
|
97
|
+
getSpecificData() {
|
|
98
|
+
return this.specific;
|
|
99
|
+
}
|
|
100
|
+
toBuffer(_buffer, _initialOffset, _ALLOW_WITNESS = true, _ALLOW_MWEB = true) {
|
|
101
|
+
return exports.EMPTY_SCRIPT;
|
|
102
|
+
}
|
|
103
|
+
toHex() {
|
|
104
|
+
return this.toBuffer().toString('hex');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.TransactionBase = TransactionBase;
|
|
108
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TransactionBase, TransactionOptions } from './base';
|
|
2
|
+
export declare function fromConstructor(options: TransactionOptions): TransactionBase<undefined>;
|
|
3
|
+
export declare function fromBuffer(buffer: Buffer, options: TransactionOptions): TransactionBase<undefined>;
|
|
4
|
+
//# sourceMappingURL=bitcoin.d.ts.map
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fromConstructor = fromConstructor;
|
|
4
|
+
exports.fromBuffer = fromBuffer;
|
|
5
|
+
const bufferutils_1 = require("../bufferutils");
|
|
6
|
+
const networks_1 = require("../networks");
|
|
7
|
+
const base_1 = require("./base");
|
|
8
|
+
const ADVANCED_TRANSACTION_MARKER = 0x00;
|
|
9
|
+
const ADVANCED_TRANSACTION_FLAG = 0x01;
|
|
10
|
+
const MWEB_PEGOUT_TX_FLAG = 0x08;
|
|
11
|
+
function toBuffer(tx, buffer, initialOffset, _ALLOW_WITNESS = true, _ALLOW_MWEB = true) {
|
|
12
|
+
if (!buffer)
|
|
13
|
+
buffer = Buffer.allocUnsafe(tx.byteLength(_ALLOW_WITNESS, _ALLOW_MWEB));
|
|
14
|
+
const bufferWriter = new bufferutils_1.BufferWriter(buffer, initialOffset || 0);
|
|
15
|
+
bufferWriter.writeInt32(tx.version);
|
|
16
|
+
const hasWitnesses = _ALLOW_WITNESS && tx.hasWitnesses();
|
|
17
|
+
const hasMweb = _ALLOW_MWEB && tx.isMwebPegOutTx();
|
|
18
|
+
if (hasWitnesses) {
|
|
19
|
+
bufferWriter.writeUInt8(ADVANCED_TRANSACTION_MARKER);
|
|
20
|
+
bufferWriter.writeUInt8(ADVANCED_TRANSACTION_FLAG);
|
|
21
|
+
}
|
|
22
|
+
else if (hasMweb) {
|
|
23
|
+
bufferWriter.writeUInt8(ADVANCED_TRANSACTION_MARKER);
|
|
24
|
+
bufferWriter.writeUInt8(MWEB_PEGOUT_TX_FLAG);
|
|
25
|
+
}
|
|
26
|
+
bufferWriter.writeVarInt(tx.ins.length);
|
|
27
|
+
tx.ins.forEach(txIn => {
|
|
28
|
+
bufferWriter.writeSlice(txIn.hash);
|
|
29
|
+
bufferWriter.writeUInt32(txIn.index);
|
|
30
|
+
bufferWriter.writeVarSlice(txIn.script);
|
|
31
|
+
bufferWriter.writeUInt32(txIn.sequence);
|
|
32
|
+
});
|
|
33
|
+
bufferWriter.writeVarInt(tx.outs.length);
|
|
34
|
+
tx.outs.forEach(txOut => {
|
|
35
|
+
bufferWriter.writeUInt64(txOut.value);
|
|
36
|
+
bufferWriter.writeVarSlice(txOut.script);
|
|
37
|
+
});
|
|
38
|
+
if (hasWitnesses) {
|
|
39
|
+
tx.ins.forEach(input => {
|
|
40
|
+
bufferWriter.writeVector(input.witness);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (hasMweb) {
|
|
44
|
+
bufferWriter.writeUInt8(0);
|
|
45
|
+
}
|
|
46
|
+
bufferWriter.writeUInt32(tx.locktime);
|
|
47
|
+
if (initialOffset !== undefined)
|
|
48
|
+
return buffer.subarray(initialOffset, bufferWriter.offset);
|
|
49
|
+
return buffer;
|
|
50
|
+
}
|
|
51
|
+
function fromConstructor(options) {
|
|
52
|
+
const tx = new base_1.TransactionBase(options);
|
|
53
|
+
tx.toBuffer = toBuffer.bind(null, tx);
|
|
54
|
+
return tx;
|
|
55
|
+
}
|
|
56
|
+
function fromBuffer(buffer, options) {
|
|
57
|
+
const bufferReader = new bufferutils_1.BufferReader(buffer);
|
|
58
|
+
const tx = fromConstructor(options);
|
|
59
|
+
tx.version = bufferReader.readInt32();
|
|
60
|
+
const marker = bufferReader.readUInt8();
|
|
61
|
+
const flag = bufferReader.readUInt8();
|
|
62
|
+
let hasWitnesses = false;
|
|
63
|
+
let hasMweb = false;
|
|
64
|
+
if ((0, networks_1.isNetworkType)('litecoin', tx.network)) {
|
|
65
|
+
if (marker === ADVANCED_TRANSACTION_MARKER && flag === MWEB_PEGOUT_TX_FLAG) {
|
|
66
|
+
hasMweb = true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (marker === ADVANCED_TRANSACTION_MARKER && flag === ADVANCED_TRANSACTION_FLAG) {
|
|
70
|
+
hasWitnesses = true;
|
|
71
|
+
}
|
|
72
|
+
else if (!hasMweb) {
|
|
73
|
+
bufferReader.offset -= 2;
|
|
74
|
+
}
|
|
75
|
+
const vinLen = bufferReader.readVarInt();
|
|
76
|
+
for (let i = 0; i < vinLen; ++i) {
|
|
77
|
+
tx.ins.push({
|
|
78
|
+
hash: bufferReader.readSlice(32),
|
|
79
|
+
index: bufferReader.readUInt32(),
|
|
80
|
+
script: bufferReader.readVarSlice(),
|
|
81
|
+
sequence: bufferReader.readUInt32(),
|
|
82
|
+
witness: [],
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const voutLen = bufferReader.readVarInt();
|
|
86
|
+
for (let i = 0; i < voutLen; ++i) {
|
|
87
|
+
tx.outs.push({
|
|
88
|
+
value: bufferReader.readUInt64String(),
|
|
89
|
+
script: bufferReader.readVarSlice(),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if (hasWitnesses) {
|
|
93
|
+
for (let i = 0; i < vinLen; ++i) {
|
|
94
|
+
tx.ins[i].witness = bufferReader.readVector();
|
|
95
|
+
}
|
|
96
|
+
if (!tx.hasWitnesses())
|
|
97
|
+
throw new Error('Transaction has superfluous witness data');
|
|
98
|
+
}
|
|
99
|
+
if (hasMweb) {
|
|
100
|
+
bufferReader.readUInt8();
|
|
101
|
+
}
|
|
102
|
+
tx.locktime = bufferReader.readUInt32();
|
|
103
|
+
if (options.nostrict)
|
|
104
|
+
return tx;
|
|
105
|
+
if (bufferReader.offset !== buffer.length)
|
|
106
|
+
throw new Error('Transaction has unexpected data');
|
|
107
|
+
return tx;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=bitcoin.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TransactionBase, TransactionOptions } from './base';
|
|
2
|
+
export interface DashSpecific {
|
|
3
|
+
type: 'dash';
|
|
4
|
+
extraPayload?: Buffer;
|
|
5
|
+
}
|
|
6
|
+
export declare function fromConstructor(options: TransactionOptions): TransactionBase<DashSpecific>;
|
|
7
|
+
export declare function fromBuffer(buffer: Buffer, options: TransactionOptions): TransactionBase<DashSpecific>;
|
|
8
|
+
//# sourceMappingURL=dash.d.ts.map
|