utxo-lib 1.1.5 → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of utxo-lib might be problematic. Click here for more details.
- package/index.js +47 -0
- package/package.json +6 -80
- package/LICENSE +0 -21
- package/README.md +0 -59
- package/dist/src/address.d.ts +0 -11
- package/dist/src/address.d.ts.map +0 -1
- package/dist/src/address.js +0 -37
- package/dist/src/addressFormat.d.ts +0 -53
- package/dist/src/addressFormat.d.ts.map +0 -1
- package/dist/src/addressFormat.js +0 -110
- package/dist/src/bitgo/Musig2.d.ts +0 -51
- package/dist/src/bitgo/Musig2.d.ts.map +0 -1
- package/dist/src/bitgo/Musig2.js +0 -175
- package/dist/src/bitgo/Unspent.d.ts +0 -95
- package/dist/src/bitgo/Unspent.d.ts.map +0 -1
- package/dist/src/bitgo/Unspent.js +0 -138
- package/dist/src/bitgo/UtxoPsbt.d.ts +0 -132
- package/dist/src/bitgo/UtxoPsbt.d.ts.map +0 -1
- package/dist/src/bitgo/UtxoPsbt.js +0 -469
- package/dist/src/bitgo/UtxoTransaction.d.ts +0 -22
- package/dist/src/bitgo/UtxoTransaction.d.ts.map +0 -1
- package/dist/src/bitgo/UtxoTransaction.js +0 -97
- package/dist/src/bitgo/UtxoTransactionBuilder.d.ts +0 -26
- package/dist/src/bitgo/UtxoTransactionBuilder.d.ts.map +0 -1
- package/dist/src/bitgo/UtxoTransactionBuilder.js +0 -67
- package/dist/src/bitgo/bbc/DashPsbt.d.ts +0 -12
- package/dist/src/bitgo/bbc/DashPsbt.d.ts.map +0 -1
- package/dist/src/bitgo/bbc/DashPsbt.js +0 -27
- package/dist/src/bitgo/bbc/DashTransaction.d.ts +0 -39
- package/dist/src/bitgo/bbc/DashTransaction.d.ts.map +0 -1
- package/dist/src/bitgo/bbc/DashTransaction.js +0 -109
- package/dist/src/bitgo/bbc/DashTransactionBuilder.d.ts +0 -14
- package/dist/src/bitgo/bbc/DashTransactionBuilder.d.ts.map +0 -1
- package/dist/src/bitgo/bbc/DashTransactionBuilder.js +0 -28
- package/dist/src/bitgo/bbc/index.d.ts +0 -4
- package/dist/src/bitgo/bbc/index.d.ts.map +0 -1
- package/dist/src/bitgo/bbc/index.js +0 -16
- package/dist/src/bitgo/bitcoincash/address.d.ts +0 -35
- package/dist/src/bitgo/bitcoincash/address.d.ts.map +0 -1
- package/dist/src/bitgo/bitcoincash/address.js +0 -151
- package/dist/src/bitgo/bitcoincash/index.d.ts +0 -2
- package/dist/src/bitgo/bitcoincash/index.d.ts.map +0 -1
- package/dist/src/bitgo/bitcoincash/index.js +0 -14
- package/dist/src/bitgo/dash/DashPsbt.d.ts +0 -12
- package/dist/src/bitgo/dash/DashPsbt.d.ts.map +0 -1
- package/dist/src/bitgo/dash/DashPsbt.js +0 -27
- package/dist/src/bitgo/dash/DashTransaction.d.ts +0 -39
- package/dist/src/bitgo/dash/DashTransaction.d.ts.map +0 -1
- package/dist/src/bitgo/dash/DashTransaction.js +0 -109
- package/dist/src/bitgo/dash/DashTransactionBuilder.d.ts +0 -14
- package/dist/src/bitgo/dash/DashTransactionBuilder.d.ts.map +0 -1
- package/dist/src/bitgo/dash/DashTransactionBuilder.js +0 -28
- package/dist/src/bitgo/dash/index.d.ts +0 -4
- package/dist/src/bitgo/dash/index.d.ts.map +0 -1
- package/dist/src/bitgo/dash/index.js +0 -16
- package/dist/src/bitgo/index.d.ts +0 -17
- package/dist/src/bitgo/index.d.ts.map +0 -1
- package/dist/src/bitgo/index.js +0 -30
- package/dist/src/bitgo/keyutil.d.ts +0 -17
- package/dist/src/bitgo/keyutil.d.ts.map +0 -1
- package/dist/src/bitgo/keyutil.js +0 -37
- package/dist/src/bitgo/nonStandardHalfSigned.d.ts +0 -7
- package/dist/src/bitgo/nonStandardHalfSigned.d.ts.map +0 -1
- package/dist/src/bitgo/nonStandardHalfSigned.js +0 -56
- package/dist/src/bitgo/outputScripts.d.ts +0 -84
- package/dist/src/bitgo/outputScripts.d.ts.map +0 -1
- package/dist/src/bitgo/outputScripts.js +0 -297
- package/dist/src/bitgo/parseInput.d.ts +0 -92
- package/dist/src/bitgo/parseInput.d.ts.map +0 -1
- package/dist/src/bitgo/parseInput.js +0 -344
- package/dist/src/bitgo/psbt/fromHalfSigned.d.ts +0 -24
- package/dist/src/bitgo/psbt/fromHalfSigned.d.ts.map +0 -1
- package/dist/src/bitgo/psbt/fromHalfSigned.js +0 -91
- package/dist/src/bitgo/psbt/scriptTypes.d.ts +0 -6
- package/dist/src/bitgo/psbt/scriptTypes.d.ts.map +0 -1
- package/dist/src/bitgo/psbt/scriptTypes.js +0 -23
- package/dist/src/bitgo/signature.d.ts +0 -84
- package/dist/src/bitgo/signature.d.ts.map +0 -1
- package/dist/src/bitgo/signature.js +0 -222
- package/dist/src/bitgo/tnumber.d.ts +0 -9
- package/dist/src/bitgo/tnumber.d.ts.map +0 -1
- package/dist/src/bitgo/tnumber.js +0 -31
- package/dist/src/bitgo/transaction.d.ts +0 -29
- package/dist/src/bitgo/transaction.d.ts.map +0 -1
- package/dist/src/bitgo/transaction.js +0 -231
- package/dist/src/bitgo/types.d.ts +0 -5
- package/dist/src/bitgo/types.d.ts.map +0 -1
- package/dist/src/bitgo/types.js +0 -12
- package/dist/src/bitgo/wallet/Psbt.d.ts +0 -47
- package/dist/src/bitgo/wallet/Psbt.d.ts.map +0 -1
- package/dist/src/bitgo/wallet/Psbt.js +0 -232
- package/dist/src/bitgo/wallet/Unspent.d.ts +0 -47
- package/dist/src/bitgo/wallet/Unspent.d.ts.map +0 -1
- package/dist/src/bitgo/wallet/Unspent.js +0 -154
- package/dist/src/bitgo/wallet/WalletKeys.d.ts +0 -72
- package/dist/src/bitgo/wallet/WalletKeys.d.ts.map +0 -1
- package/dist/src/bitgo/wallet/WalletKeys.js +0 -104
- package/dist/src/bitgo/wallet/WalletOutput.d.ts +0 -18
- package/dist/src/bitgo/wallet/WalletOutput.d.ts.map +0 -1
- package/dist/src/bitgo/wallet/WalletOutput.js +0 -69
- package/dist/src/bitgo/wallet/WalletScripts.d.ts +0 -7
- package/dist/src/bitgo/wallet/WalletScripts.d.ts.map +0 -1
- package/dist/src/bitgo/wallet/WalletScripts.js +0 -15
- package/dist/src/bitgo/wallet/WalletUnspentSigner.d.ts +0 -19
- package/dist/src/bitgo/wallet/WalletUnspentSigner.d.ts.map +0 -1
- package/dist/src/bitgo/wallet/WalletUnspentSigner.js +0 -47
- package/dist/src/bitgo/wallet/chains.d.ts +0 -57
- package/dist/src/bitgo/wallet/chains.d.ts.map +0 -1
- package/dist/src/bitgo/wallet/chains.js +0 -106
- package/dist/src/bitgo/wallet/index.d.ts +0 -8
- package/dist/src/bitgo/wallet/index.d.ts.map +0 -1
- package/dist/src/bitgo/wallet/index.js +0 -20
- package/dist/src/bitgo/zcash/ZcashBufferutils.d.ts +0 -26
- package/dist/src/bitgo/zcash/ZcashBufferutils.d.ts.map +0 -1
- package/dist/src/bitgo/zcash/ZcashBufferutils.js +0 -157
- package/dist/src/bitgo/zcash/ZcashPsbt.d.ts +0 -36
- package/dist/src/bitgo/zcash/ZcashPsbt.d.ts.map +0 -1
- package/dist/src/bitgo/zcash/ZcashPsbt.js +0 -146
- package/dist/src/bitgo/zcash/ZcashTransaction.d.ts +0 -61
- package/dist/src/bitgo/zcash/ZcashTransaction.d.ts.map +0 -1
- package/dist/src/bitgo/zcash/ZcashTransaction.js +0 -341
- package/dist/src/bitgo/zcash/ZcashTransactionBuilder.d.ts +0 -21
- package/dist/src/bitgo/zcash/ZcashTransactionBuilder.d.ts.map +0 -1
- package/dist/src/bitgo/zcash/ZcashTransactionBuilder.js +0 -105
- package/dist/src/bitgo/zcash/address.d.ts +0 -8
- package/dist/src/bitgo/zcash/address.d.ts.map +0 -1
- package/dist/src/bitgo/zcash/address.js +0 -57
- package/dist/src/bitgo/zcash/hashZip0244.d.ts +0 -27
- package/dist/src/bitgo/zcash/hashZip0244.d.ts.map +0 -1
- package/dist/src/bitgo/zcash/hashZip0244.js +0 -184
- package/dist/src/bitgo/zcash/index.d.ts +0 -4
- package/dist/src/bitgo/zcash/index.d.ts.map +0 -1
- package/dist/src/bitgo/zcash/index.js +0 -16
- package/dist/src/classify.d.ts +0 -19
- package/dist/src/classify.d.ts.map +0 -1
- package/dist/src/classify.js +0 -89
- package/dist/src/index.d.ts +0 -13
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -36
- package/dist/src/networks.d.ts +0 -115
- package/dist/src/networks.d.ts.map +0 -1
- package/dist/src/networks.js +0 -458
- package/dist/src/noble_ecc.d.ts +0 -28
- package/dist/src/noble_ecc.d.ts.map +0 -1
- package/dist/src/noble_ecc.js +0 -168
- package/dist/src/payments/index.d.ts +0 -4
- package/dist/src/payments/index.d.ts.map +0 -1
- package/dist/src/payments/index.js +0 -8
- package/dist/src/payments/p2tr.d.ts +0 -3
- package/dist/src/payments/p2tr.d.ts.map +0 -1
- package/dist/src/payments/p2tr.js +0 -348
- package/dist/src/payments/p2tr_ns.d.ts +0 -3
- package/dist/src/payments/p2tr_ns.d.ts.map +0 -1
- package/dist/src/payments/p2tr_ns.js +0 -134
- package/dist/src/taproot.d.ts +0 -141
- package/dist/src/taproot.d.ts.map +0 -1
- package/dist/src/taproot.js +0 -384
- package/dist/src/templates/multisig/index.d.ts +0 -4
- package/dist/src/templates/multisig/index.d.ts.map +0 -1
- package/dist/src/templates/multisig/index.js +0 -8
- package/dist/src/templates/multisig/input.d.ts +0 -7
- package/dist/src/templates/multisig/input.d.ts.map +0 -1
- package/dist/src/templates/multisig/input.js +0 -25
- package/dist/src/templates/multisig/output.d.ts +0 -7
- package/dist/src/templates/multisig/output.d.ts.map +0 -1
- package/dist/src/templates/multisig/output.js +0 -38
- package/dist/src/templates/nulldata.d.ts +0 -10
- package/dist/src/templates/nulldata.d.ts.map +0 -1
- package/dist/src/templates/nulldata.js +0 -17
- package/dist/src/templates/pubkey/index.d.ts +0 -4
- package/dist/src/templates/pubkey/index.d.ts.map +0 -1
- package/dist/src/templates/pubkey/index.js +0 -8
- package/dist/src/templates/pubkey/input.d.ts +0 -7
- package/dist/src/templates/pubkey/input.d.ts.map +0 -1
- package/dist/src/templates/pubkey/input.js +0 -14
- package/dist/src/templates/pubkey/output.d.ts +0 -7
- package/dist/src/templates/pubkey/output.d.ts.map +0 -1
- package/dist/src/templates/pubkey/output.js +0 -15
- package/dist/src/templates/pubkeyhash/index.d.ts +0 -4
- package/dist/src/templates/pubkeyhash/index.d.ts.map +0 -1
- package/dist/src/templates/pubkeyhash/index.js +0 -8
- package/dist/src/templates/pubkeyhash/input.d.ts +0 -7
- package/dist/src/templates/pubkeyhash/input.d.ts.map +0 -1
- package/dist/src/templates/pubkeyhash/input.js +0 -16
- package/dist/src/templates/pubkeyhash/output.d.ts +0 -6
- package/dist/src/templates/pubkeyhash/output.d.ts.map +0 -1
- package/dist/src/templates/pubkeyhash/output.js +0 -20
- package/dist/src/templates/scripthash/index.d.ts +0 -4
- package/dist/src/templates/scripthash/index.d.ts.map +0 -1
- package/dist/src/templates/scripthash/index.js +0 -8
- package/dist/src/templates/scripthash/input.d.ts +0 -6
- package/dist/src/templates/scripthash/input.d.ts.map +0 -1
- package/dist/src/templates/scripthash/input.js +0 -43
- package/dist/src/templates/scripthash/output.d.ts +0 -6
- package/dist/src/templates/scripthash/output.d.ts.map +0 -1
- package/dist/src/templates/scripthash/output.js +0 -15
- package/dist/src/templates/taproot/index.d.ts +0 -4
- package/dist/src/templates/taproot/index.d.ts.map +0 -1
- package/dist/src/templates/taproot/index.js +0 -8
- package/dist/src/templates/taproot/input.d.ts +0 -6
- package/dist/src/templates/taproot/input.d.ts.map +0 -1
- package/dist/src/templates/taproot/input.js +0 -23
- package/dist/src/templates/taproot/output.d.ts +0 -6
- package/dist/src/templates/taproot/output.d.ts.map +0 -1
- package/dist/src/templates/taproot/output.js +0 -15
- package/dist/src/templates/taprootnofn/index.d.ts +0 -4
- package/dist/src/templates/taprootnofn/index.d.ts.map +0 -1
- package/dist/src/templates/taprootnofn/index.js +0 -8
- package/dist/src/templates/taprootnofn/input.d.ts +0 -7
- package/dist/src/templates/taprootnofn/input.d.ts.map +0 -1
- package/dist/src/templates/taprootnofn/input.js +0 -24
- package/dist/src/templates/taprootnofn/output.d.ts +0 -7
- package/dist/src/templates/taprootnofn/output.d.ts.map +0 -1
- package/dist/src/templates/taprootnofn/output.js +0 -28
- package/dist/src/templates/witnesscommitment/index.d.ts +0 -3
- package/dist/src/templates/witnesscommitment/index.d.ts.map +0 -1
- package/dist/src/templates/witnesscommitment/index.js +0 -6
- package/dist/src/templates/witnesscommitment/output.d.ts +0 -8
- package/dist/src/templates/witnesscommitment/output.d.ts.map +0 -1
- package/dist/src/templates/witnesscommitment/output.js +0 -31
- package/dist/src/templates/witnesspubkeyhash/index.d.ts +0 -4
- package/dist/src/templates/witnesspubkeyhash/index.d.ts.map +0 -1
- package/dist/src/templates/witnesspubkeyhash/index.js +0 -8
- package/dist/src/templates/witnesspubkeyhash/input.d.ts +0 -7
- package/dist/src/templates/witnesspubkeyhash/input.d.ts.map +0 -1
- package/dist/src/templates/witnesspubkeyhash/input.js +0 -19
- package/dist/src/templates/witnesspubkeyhash/output.d.ts +0 -6
- package/dist/src/templates/witnesspubkeyhash/output.d.ts.map +0 -1
- package/dist/src/templates/witnesspubkeyhash/output.js +0 -15
- package/dist/src/templates/witnessscripthash/index.d.ts +0 -4
- package/dist/src/templates/witnessscripthash/index.d.ts.map +0 -1
- package/dist/src/templates/witnessscripthash/index.js +0 -8
- package/dist/src/templates/witnessscripthash/input.d.ts +0 -6
- package/dist/src/templates/witnessscripthash/input.d.ts.map +0 -1
- package/dist/src/templates/witnessscripthash/input.js +0 -35
- package/dist/src/templates/witnessscripthash/output.d.ts +0 -6
- package/dist/src/templates/witnessscripthash/output.d.ts.map +0 -1
- package/dist/src/templates/witnessscripthash/output.js +0 -15
- package/dist/src/testutil/index.d.ts +0 -3
- package/dist/src/testutil/index.d.ts.map +0 -1
- package/dist/src/testutil/index.js +0 -15
- package/dist/src/testutil/keys.d.ts +0 -10
- package/dist/src/testutil/keys.d.ts.map +0 -1
- package/dist/src/testutil/keys.js +0 -40
- package/dist/src/testutil/mock.d.ts +0 -21
- package/dist/src/testutil/mock.d.ts.map +0 -1
- package/dist/src/testutil/mock.js +0 -86
- package/dist/src/transaction_builder.d.ts +0 -47
- package/dist/src/transaction_builder.d.ts.map +0 -1
- package/dist/src/transaction_builder.js +0 -1084
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/templates/witnessscripthash/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC"}
|
@@ -1,8 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.output = exports.input = void 0;
|
4
|
-
const input = require("./input");
|
5
|
-
exports.input = input;
|
6
|
-
const output = require("./output");
|
7
|
-
exports.output = output;
|
8
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvdGVtcGxhdGVzL3dpdG5lc3NzY3JpcHRoYXNoL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLGlDQUFpQztBQUd4QixzQkFBSztBQUZkLG1DQUFtQztBQUVuQix3QkFBTSIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCAqIGFzIGlucHV0IGZyb20gJy4vaW5wdXQnO1xuaW1wb3J0ICogYXMgb3V0cHV0IGZyb20gJy4vb3V0cHV0JztcblxuZXhwb3J0IHsgaW5wdXQsIG91dHB1dCB9O1xuIl19
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../../src/templates/witnessscripthash/input.ts"],"names":[],"mappings":";AASA,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,eAAe,CAAC,EAAE,OAAO,GAAG,OAAO,CAsB1E;yBAtBe,KAAK"}
|
@@ -1,35 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
// <scriptSig> {serialized scriptPubKey script}
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.check = void 0;
|
5
|
-
const __1 = require("../../");
|
6
|
-
const typeforce = require('typeforce');
|
7
|
-
const p2ms = require("../multisig");
|
8
|
-
const p2pk = require("../pubkey");
|
9
|
-
const p2pkh = require("../pubkeyhash");
|
10
|
-
function check(chunks, allowIncomplete) {
|
11
|
-
typeforce(typeforce.Array, chunks);
|
12
|
-
if (chunks.length < 1)
|
13
|
-
return false;
|
14
|
-
const witnessScript = chunks[chunks.length - 1];
|
15
|
-
if (!Buffer.isBuffer(witnessScript))
|
16
|
-
return false;
|
17
|
-
const witnessScriptChunks = __1.script.decompile(witnessScript);
|
18
|
-
// is witnessScript a valid script?
|
19
|
-
if (!witnessScriptChunks || witnessScriptChunks.length === 0)
|
20
|
-
return false;
|
21
|
-
const witnessRawScriptSig = __1.script.compile(chunks.slice(0, -1));
|
22
|
-
// match types
|
23
|
-
if (p2pkh.input.check(witnessRawScriptSig) && p2pkh.output.check(witnessScriptChunks))
|
24
|
-
return true;
|
25
|
-
if (p2ms.input.check(witnessRawScriptSig, allowIncomplete) && p2ms.output.check(witnessScriptChunks))
|
26
|
-
return true;
|
27
|
-
if (p2pk.input.check(witnessRawScriptSig) && p2pk.output.check(witnessScriptChunks))
|
28
|
-
return true;
|
29
|
-
return false;
|
30
|
-
}
|
31
|
-
exports.check = check;
|
32
|
-
check.toJSON = () => {
|
33
|
-
return 'witnessScriptHash input';
|
34
|
-
};
|
35
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5wdXQuanMiLCJz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4gZmFsc2U7XG59XG5jaGVjay50b0pTT04gPSAoKTogc3RyaW5nID0+IHtcbiAgcmV0dXJuICd3aXRuZXNzU2NyaXB0SGFzaCBpbnB1dCc7XG59O1xuIl19
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../../src/templates/witnessscripthash/output.ts"],"names":[],"mappings":";AAKA,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,OAAO,CAItE;yBAJe,KAAK"}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
// OP_0 {scriptHash}
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.check = void 0;
|
5
|
-
const __1 = require("../../");
|
6
|
-
const __2 = require("../../");
|
7
|
-
function check(script) {
|
8
|
-
const buffer = __1.script.compile(script);
|
9
|
-
return buffer.length === 34 && buffer[0] === __2.opcodes.OP_0 && buffer[1] === 0x20;
|
10
|
-
}
|
11
|
-
exports.check = check;
|
12
|
-
check.toJSON = () => {
|
13
|
-
return 'Witness scriptHash output';
|
14
|
-
};
|
15
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3V0cHV0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RlbXBsYXRlcy93aXRuZXNzc2NyaXB0aGFzaC9vdXRwdXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLG9CQUFvQjs7O0FBRXBCLDhCQUEyQztBQUMzQyw4QkFBaUM7QUFFakMsU0FBZ0IsS0FBSyxDQUFDLE1BQXVDO0lBQzNELE1BQU0sTUFBTSxHQUFHLFVBQU8sQ0FBQyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUM7SUFFdkMsT0FBTyxNQUFNLENBQUMsTUFBTSxLQUFLLEVBQUUsSUFBSSxNQUFNLENBQUMsQ0FBQyxDQUFDLEtBQUssV0FBTyxDQUFDLElBQUksSUFBSSxNQUFNLENBQUMsQ0FBQyxDQUFDLEtBQUssSUFBSSxDQUFDO0FBQ2xGLENBQUM7QUFKRCxzQkFJQztBQUNELEtBQUssQ0FBQyxNQUFNLEdBQUcsR0FBVyxFQUFFO0lBQzFCLE9BQU8sMkJBQTJCLENBQUM7QUFDckMsQ0FBQyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLy8gT1BfMCB7c2NyaXB0SGFzaH1cblxuaW1wb3J0IHsgc2NyaXB0IGFzIGJzY3JpcHQgfSBmcm9tICcuLi8uLi8nO1xuaW1wb3J0IHsgb3Bjb2RlcyB9IGZyb20gJy4uLy4uLyc7XG5cbmV4cG9ydCBmdW5jdGlvbiBjaGVjayhzY3JpcHQ6IEJ1ZmZlciB8IEFycmF5PG51bWJlciB8IEJ1ZmZlcj4pOiBib29sZWFuIHtcbiAgY29uc3QgYnVmZmVyID0gYnNjcmlwdC5jb21waWxlKHNjcmlwdCk7XG5cbiAgcmV0dXJuIGJ1ZmZlci5sZW5ndGggPT09IDM0ICYmIGJ1ZmZlclswXSA9PT0gb3Bjb2Rlcy5PUF8wICYmIGJ1ZmZlclsxXSA9PT0gMHgyMDtcbn1cbmNoZWNrLnRvSlNPTiA9ICgpOiBzdHJpbmcgPT4ge1xuICByZXR1cm4gJ1dpdG5lc3Mgc2NyaXB0SGFzaCBvdXRwdXQnO1xufTtcbiJdfQ==
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testutil/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC"}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
-
}) : (function(o, m, k, k2) {
|
6
|
-
if (k2 === undefined) k2 = k;
|
7
|
-
o[k2] = m[k];
|
8
|
-
}));
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
11
|
-
};
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
13
|
-
__exportStar(require("./keys"), exports);
|
14
|
-
__exportStar(require("./mock"), exports);
|
15
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdGVzdHV0aWwvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7O0FBQUEseUNBQXVCO0FBQ3ZCLHlDQUF1QiIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCAqIGZyb20gJy4va2V5cyc7XG5leHBvcnQgKiBmcm9tICcuL21vY2snO1xuIl19
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import { BIP32Interface } from 'bip32';
|
2
|
-
import { Triple } from '../bitgo';
|
3
|
-
import { RootWalletKeys } from '../bitgo';
|
4
|
-
export declare type KeyTriple = Triple<BIP32Interface>;
|
5
|
-
export declare function getKey(seed: string): BIP32Interface;
|
6
|
-
export declare function getKeyTriple(seed: string): KeyTriple;
|
7
|
-
export declare function getKeyName(triple: Triple<BIP32Interface>, k: BIP32Interface): string | undefined;
|
8
|
-
export declare function getDefaultCosigner<T>(keyset: Triple<T>, signer: T): T;
|
9
|
-
export declare function getDefaultWalletKeys(): RootWalletKeys;
|
10
|
-
//# sourceMappingURL=keys.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../../src/testutil/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,cAAc,EAAE,MAAM,OAAO,CAAC;AAG/D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAK1C,oBAAY,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AAE/C,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAEnD;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAEpD;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS,CAEhG;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAarE;AAED,wBAAgB,oBAAoB,IAAI,cAAc,CAErD"}
|
@@ -1,40 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getDefaultWalletKeys = exports.getDefaultCosigner = exports.getKeyName = exports.getKeyTriple = exports.getKey = void 0;
|
4
|
-
const bip32_1 = require("bip32");
|
5
|
-
const crypto = require("crypto");
|
6
|
-
const bitgo_1 = require("../bitgo");
|
7
|
-
const noble_ecc_1 = require("../noble_ecc");
|
8
|
-
const bip32 = bip32_1.BIP32Factory(noble_ecc_1.ecc);
|
9
|
-
function getKey(seed) {
|
10
|
-
return bip32.fromSeed(crypto.createHash('sha256').update(seed).digest());
|
11
|
-
}
|
12
|
-
exports.getKey = getKey;
|
13
|
-
function getKeyTriple(seed) {
|
14
|
-
return [getKey(seed + '.0'), getKey(seed + '.1'), getKey(seed + '.2')];
|
15
|
-
}
|
16
|
-
exports.getKeyTriple = getKeyTriple;
|
17
|
-
function getKeyName(triple, k) {
|
18
|
-
return ['user', 'backup', 'bitgo'][triple.indexOf(k)];
|
19
|
-
}
|
20
|
-
exports.getKeyName = getKeyName;
|
21
|
-
function getDefaultCosigner(keyset, signer) {
|
22
|
-
const eq = (a, b) => a === b || (Buffer.isBuffer(a) && Buffer.isBuffer(b) && a.equals(b));
|
23
|
-
const [user, backup, bitgo] = keyset;
|
24
|
-
if (eq(signer, user)) {
|
25
|
-
return bitgo;
|
26
|
-
}
|
27
|
-
if (eq(signer, backup)) {
|
28
|
-
return bitgo;
|
29
|
-
}
|
30
|
-
if (eq(signer, bitgo)) {
|
31
|
-
return user;
|
32
|
-
}
|
33
|
-
throw new Error(`signer not in pubkeys`);
|
34
|
-
}
|
35
|
-
exports.getDefaultCosigner = getDefaultCosigner;
|
36
|
-
function getDefaultWalletKeys() {
|
37
|
-
return new bitgo_1.RootWalletKeys(getKeyTriple('default'));
|
38
|
-
}
|
39
|
-
exports.getDefaultWalletKeys = getDefaultWalletKeys;
|
40
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoia2V5cy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy90ZXN0dXRpbC9rZXlzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLGlDQUErRDtBQUMvRCxpQ0FBaUM7QUFHakMsb0NBQTBDO0FBQzFDLDRDQUFtQztBQUVuQyxNQUFNLEtBQUssR0FBYSxvQkFBWSxDQUFDLGVBQUcsQ0FBQyxDQUFDO0FBSTFDLFNBQWdCLE1BQU0sQ0FBQyxJQUFZO0lBQ2pDLE9BQU8sS0FBSyxDQUFDLFFBQVEsQ0FBQyxNQUFNLENBQUMsVUFBVSxDQUFDLFFBQVEsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxDQUFDO0FBQzNFLENBQUM7QUFGRCx3Qk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WQgKyAnLjEnKSwgZ2V0S2V5KHNlZWQgKyAnLjInKV07XG59XG5cbmV4cG9ydCBmdW5jdGlvbiBnZXRLZXlOYW1lKHRyaXBsZTogVHJpcGxlPEJJUDMySW50ZXJmYWNlPiwgazogQklQMzJJbnRlcmZhY2UpOiBzdHJpbmcgfCB1bmRlZmluZWQge1xuICByZXR1cm4gWyd1c2VyJywgJ2JhY2t1cCcsICdiaXRnbyddW3RyaXBsZS5pbmRleE9mKGspXTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIGdldERlZmF1bHRDb3NpZ25lcjxUPihrZXlzZXQ6IFRyaXBsZTxUPiwgc2lnbmVyOiBUKTogVCB7XG4gIGNvbnN0IGVxID0gKGE6IFQsIGI6IFQpID0+IGEgPT09IGIgfHwgKEJ1ZmZlci5pc0J1ZmZlcihhKSAmJiBCdWZmZXIuaXNCdWZmZXIoYikgJiYgYS5lcXVhbHMoYikpO1xuICBjb25zdCBbdXNlciwgYmFja3VwLCBiaXRnb10gPSBrZXlzZXQ7XG4gIGlmIChlcShzaWduZXIsIHVzZXIpKSB7XG4gICAgcmV0dXJuIGJpdGdvO1xuICB9XG4gIGlmIChlcShzaWduZXIsIGJhY2t1cCkpIHtcbiAgICByZXR1cm4gYml0Z287XG4gIH1cbiAgaWYgKGVxKHNpZ25lciwgYml0Z28pKSB7XG4gICAgcmV0dXJuIHVzZXI7XG4gIH1cbiAgdGhyb3cgbmV3IEVycm9yKGBzaWduZXIgbm90IGluIHB1YmtleXNgKTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIGdldERlZmF1bHRXYWxsZXRLZXlzKCk6IFJvb3RXYWxsZXRLZXlzIHtcbiAgcmV0dXJuIG5ldyBSb290V2FsbGV0S2V5cyhnZXRLZXlUcmlwbGUoJ2RlZmF1bHQnKSk7XG59XG4iXX0=
|
@@ -1,21 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
import { BIP32Interface } from 'bip32';
|
3
|
-
import { Network } from '../networks';
|
4
|
-
import { ChainCode, NonWitnessWalletUnspent, outputScripts, RootWalletKeys, Unspent, UnspentWithPrevTx, UtxoTransaction, WalletUnspent } from '../bitgo';
|
5
|
-
export declare type InputType = outputScripts.ScriptType2Of3;
|
6
|
-
export declare function mockPrevTx(vout: number, outputScript: Buffer, value: bigint, network: Network): UtxoTransaction<bigint>;
|
7
|
-
export declare const replayProtectionKeyPair: BIP32Interface;
|
8
|
-
export declare function isReplayProtectionUnspent<TNumber extends bigint | number>(u: Unspent<TNumber>, network: Network): boolean;
|
9
|
-
export declare function mockReplayProtectionUnspent<TNumber extends number | bigint>(network: Network, value: TNumber, { key, vout }?: {
|
10
|
-
key?: BIP32Interface;
|
11
|
-
vout?: number;
|
12
|
-
}): UnspentWithPrevTx<TNumber>;
|
13
|
-
export declare function mockWalletUnspent<TNumber extends number | bigint>(network: Network, value: TNumber, { chain, index, keys, vout, id, }?: {
|
14
|
-
chain?: ChainCode;
|
15
|
-
index?: number;
|
16
|
-
keys?: RootWalletKeys;
|
17
|
-
vout?: number;
|
18
|
-
id?: string;
|
19
|
-
}): WalletUnspent<TNumber> | NonWitnessWalletUnspent<TNumber>;
|
20
|
-
export declare function mockUnspents<TNumber extends number | bigint>(rootWalletKeys: RootWalletKeys, inputScriptTypes: InputType[], testOutputAmount: TNumber, network: Network): WalletUnspent<TNumber>[];
|
21
|
-
//# sourceMappingURL=mock.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../src/testutil/mock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,EAAc,OAAO,EAAY,MAAM,aAAa,CAAC;AAE5D,OAAO,EACL,SAAS,EAMT,uBAAuB,EACvB,aAAa,EACb,cAAc,EAEd,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,aAAa,EACd,MAAM,UAAU,CAAC;AAMlB,oBAAY,SAAS,GAAG,a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ACf,aAAa,CAAC,OAAO,CAAC,EAAE,CAW1B"}
|
@@ -1,86 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.mockUnspents = exports.mockWalletUnspent = exports.mockReplayProtectionUnspent = exports.isReplayProtectionUnspent = exports.replayProtectionKeyPair = exports.mockPrevTx = void 0;
|
4
|
-
const noble = require("@noble/secp256k1");
|
5
|
-
const utxolib = require("..");
|
6
|
-
const networks_1 = require("../networks");
|
7
|
-
const bitgo_1 = require("../bitgo");
|
8
|
-
const address_1 = require("../address");
|
9
|
-
const outputScripts_1 = require("../bitgo/outputScripts");
|
10
|
-
const keys_1 = require("./keys");
|
11
|
-
function mockPrevTx(vout, outputScript, value, network) {
|
12
|
-
const psbtFromNetwork = bitgo_1.createPsbtForNetwork({ network });
|
13
|
-
const privKey = noble.utils.randomPrivateKey();
|
14
|
-
const pubkey = Buffer.from(noble.getPublicKey(privKey, true));
|
15
|
-
const payment = utxolib.payments.p2wpkh({ pubkey });
|
16
|
-
const destOutput = payment.output;
|
17
|
-
if (!destOutput)
|
18
|
-
throw new Error('Impossible, payment we just constructed has no output');
|
19
|
-
for (let index = 0; index <= vout; index++) {
|
20
|
-
if (index === vout) {
|
21
|
-
psbtFromNetwork.addOutput({ script: outputScript, value });
|
22
|
-
}
|
23
|
-
else {
|
24
|
-
psbtFromNetwork.addOutput({ script: destOutput, value });
|
25
|
-
}
|
26
|
-
}
|
27
|
-
psbtFromNetwork.addInput({
|
28
|
-
hash: Buffer.alloc(32, 0x01),
|
29
|
-
index: 0,
|
30
|
-
witnessUtxo: { script: destOutput, value: value * (BigInt(vout) + BigInt(1)) + BigInt(1000) },
|
31
|
-
});
|
32
|
-
psbtFromNetwork.signInput(0, {
|
33
|
-
publicKey: pubkey,
|
34
|
-
sign: (hash, lowR) => Buffer.from(noble.signSync(hash, privKey, { canonical: !lowR, der: false })),
|
35
|
-
});
|
36
|
-
psbtFromNetwork.validateSignaturesOfAllInputs();
|
37
|
-
psbtFromNetwork.finalizeAllInputs();
|
38
|
-
return psbtFromNetwork.extractTransaction();
|
39
|
-
}
|
40
|
-
exports.mockPrevTx = mockPrevTx;
|
41
|
-
exports.replayProtectionKeyPair = keys_1.getKey('replay-protection');
|
42
|
-
const replayProtectionScriptPubKey = outputScripts_1.createOutputScriptP2shP2pk(exports.replayProtectionKeyPair.publicKey).scriptPubKey;
|
43
|
-
function isReplayProtectionUnspent(u, network) {
|
44
|
-
return u.address === address_1.fromOutputScript(replayProtectionScriptPubKey, network);
|
45
|
-
}
|
46
|
-
exports.isReplayProtectionUnspent = isReplayProtectionUnspent;
|
47
|
-
function mockReplayProtectionUnspent(network, value, { key = exports.replayProtectionKeyPair, vout = 0 } = {}) {
|
48
|
-
const outputScript = outputScripts_1.createOutputScriptP2shP2pk(key.publicKey).scriptPubKey;
|
49
|
-
const prevTransaction = mockPrevTx(vout, outputScript, BigInt(value), network);
|
50
|
-
return { ...bitgo_1.fromOutputWithPrevTx(prevTransaction, vout), value };
|
51
|
-
}
|
52
|
-
exports.mockReplayProtectionUnspent = mockReplayProtectionUnspent;
|
53
|
-
function mockWalletUnspent(network, value, { chain = 0, index = 0, keys = keys_1.getDefaultWalletKeys(), vout = 0, id, } = {}) {
|
54
|
-
const derivedKeys = keys.deriveForChainAndIndex(chain, index);
|
55
|
-
const address = address_1.fromOutputScript(outputScripts_1.createOutputScript2of3(derivedKeys.publicKeys, bitgo_1.scriptTypeForChain(chain)).scriptPubKey, network);
|
56
|
-
if (id && typeof id === 'string') {
|
57
|
-
return { id, address, chain, index, value };
|
58
|
-
}
|
59
|
-
else {
|
60
|
-
const prevTransaction = mockPrevTx(vout, outputScripts_1.createOutputScript2of3(derivedKeys.publicKeys, bitgo_1.scriptTypeForChain(chain), network).scriptPubKey, BigInt(value), network);
|
61
|
-
const unspent = bitgo_1.isSegwit(chain) || networks_1.getMainnet(network) === networks_1.networks.zcash
|
62
|
-
? bitgo_1.fromOutput(prevTransaction, vout)
|
63
|
-
: bitgo_1.fromOutputWithPrevTx(prevTransaction, vout);
|
64
|
-
return {
|
65
|
-
...unspent,
|
66
|
-
chain,
|
67
|
-
index,
|
68
|
-
value,
|
69
|
-
};
|
70
|
-
}
|
71
|
-
}
|
72
|
-
exports.mockWalletUnspent = mockWalletUnspent;
|
73
|
-
function mockUnspents(rootWalletKeys, inputScriptTypes, testOutputAmount, network) {
|
74
|
-
return inputScriptTypes.map((t, i) => {
|
75
|
-
if (bitgo_1.outputScripts.isScriptType2Of3(t)) {
|
76
|
-
return mockWalletUnspent(network, testOutputAmount, {
|
77
|
-
keys: rootWalletKeys,
|
78
|
-
chain: bitgo_1.getExternalChainCode(t),
|
79
|
-
vout: i,
|
80
|
-
});
|
81
|
-
}
|
82
|
-
throw new Error(`invalid input type ${t}`);
|
83
|
-
});
|
84
|
-
}
|
85
|
-
exports.mockUnspents = mockUnspents;
|
86
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9jay5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy90ZXN0dXRpbC9tb2NrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUNBLDBDQUEwQztBQUMxQyw4QkFBOEI7QUFDOUIsMENBQTREO0FBRTVELG9DQWVrQjtBQUNsQix3Q0FBOEM7QUFDOUMsMERBQTRGO0FBRTVGLGlDQUFzRDtBQUl0RCxTQUFnQixVQUFVLENBQ3hCLElBQVksRUFDWixZQUFvQixFQUNwQixLQUFhLEVBQ2IsT0FBZ0I7SUFFaEIsTUFBTSxlQUFlLEdBQUcsNEJBQW9CLENBQUMsRUFBRSxPQUFPLEVBQUUsQ0FBQyxDQUFDO0lBRTFELE1BQU0sT0FBTyxHQUFHLEtBQUssQ0FBQyxLQUFLLENBQUMsZ0JBQWdCLEVBQUUsQ0FBQztJQUMvQyxNQUFNLE1BQU0sR0FBRyxN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ZXgsXG4gICAgICB2YWx1ZSxcbiAgICB9O1xuICB9XG59XG5cbmV4cG9ydCBmdW5jdGlvbiBtb2NrVW5zcGVudHM8VE51bWJlciBleHRlbmRzIG51bWJlciB8IGJpZ2ludD4oXG4gIHJvb3RXYWxsZXRLZXlzOiBSb290V2FsbGV0S2V5cyxcbiAgaW5wdXRTY3JpcHRUeXBlczogSW5wdXRUeXBlW10sXG4gIHRlc3RPdXRwdXRBbW91bnQ6IFROdW1iZXIsXG4gIG5ldHdvcms6IE5ldHdvcmtcbik6IFdhbGxldFVuc3BlbnQ8VE51bWJlcj5bXSB7XG4gIHJldHVybiBpbnB1dFNjcmlwdFR5cGVzLm1hcCgodCwgaSk6IFdhbGxldFVuc3BlbnQ8VE51bWJlcj4gPT4ge1xuICAgIGlmIChvdXRwdXRTY3JpcHRzLmlzU2NyaXB0VHlwZTJPZjModCkpIHtcbiAgICAgIHJldHVybiBtb2NrV2FsbGV0VW5zcGVudChuZXR3b3JrLCB0ZXN0T3V0cHV0QW1vdW50LCB7XG4gICAgICAgIGtleXM6IHJvb3RXYWxsZXRLZXlzLFxuICAgICAgICBjaGFpbjogZ2V0RXh0ZXJuYWxDaGFpbkNvZGUodCksXG4gICAgICAgIHZvdXQ6IGksXG4gICAgICB9KTtcbiAgICB9XG4gICAgdGhyb3cgbmV3IEVycm9yKGBpbnZhbGlkIGlucHV0IHR5cGUgJHt0fWApO1xuICB9KTtcbn1cbiJdfQ==
|
@@ -1,47 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
import { Network } from './';
|
3
|
-
import { TxOutput, Transaction } from './';
|
4
|
-
export interface Signer {
|
5
|
-
privateKey?: Buffer;
|
6
|
-
publicKey: Buffer;
|
7
|
-
getPublicKey?(): Buffer;
|
8
|
-
sign(hash: Buffer, lowR?: boolean): Buffer;
|
9
|
-
signSchnorr(hash: Buffer): Buffer;
|
10
|
-
}
|
11
|
-
interface TxbSignArg<TNumber extends number | bigint = number> {
|
12
|
-
prevOutScriptType: string;
|
13
|
-
vin: number;
|
14
|
-
keyPair: Signer;
|
15
|
-
redeemScript?: Buffer;
|
16
|
-
hashType?: number;
|
17
|
-
witnessValue?: TNumber;
|
18
|
-
witnessScript?: Buffer;
|
19
|
-
controlBlock?: Buffer;
|
20
|
-
annex?: Buffer;
|
21
|
-
}
|
22
|
-
export declare class TransactionBuilder<TNumber extends number | bigint = number> {
|
23
|
-
network: Network;
|
24
|
-
maximumFeeRate: number;
|
25
|
-
static fromTransaction<TNumber extends number | bigint = number>(transaction: Transaction<TNumber>, network?: Network, prevOutputs?: TxOutput<TNumber>[]): TransactionBuilder<TNumber>;
|
26
|
-
private __PREV_TX_SET;
|
27
|
-
private __INPUTS;
|
28
|
-
private __TX;
|
29
|
-
private __USE_LOW_R;
|
30
|
-
constructor(network?: Network, maximumFeeRate?: number);
|
31
|
-
setLowR(setting?: boolean): boolean;
|
32
|
-
setLockTime(locktime: number): void;
|
33
|
-
setVersion(version: number): void;
|
34
|
-
addInput(txHash: Buffer | string | Transaction<TNumber>, vout: number, sequence?: number, prevOutScript?: Buffer, value?: TNumber): number;
|
35
|
-
addOutput(scriptPubKey: string | Buffer, value: TNumber): number;
|
36
|
-
build(): Transaction<TNumber>;
|
37
|
-
buildIncomplete(): Transaction<TNumber>;
|
38
|
-
sign(signParams: number | TxbSignArg<TNumber>, keyPair?: Signer, redeemScript?: Buffer, hashType?: number, witnessValue?: TNumber, witnessScript?: Buffer, controlBlock?: Buffer, annex?: Buffer): void;
|
39
|
-
private __addInputUnsafe;
|
40
|
-
private __build;
|
41
|
-
private __canModifyInputs;
|
42
|
-
private __needsOutputs;
|
43
|
-
private __canModifyOutputs;
|
44
|
-
private __overMaximumFees;
|
45
|
-
}
|
46
|
-
export {};
|
47
|
-
//# sourceMappingURL=transaction_builder.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"transaction_builder.d.ts","sourceRoot":"","sources":["../../src/transaction_builder.ts"],"names":[],"mappings":";AA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