utxo-lib 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +21 -0
- package/README.md +59 -0
- package/dist/src/address.d.ts +11 -0
- package/dist/src/address.d.ts.map +1 -0
- package/dist/src/address.js +37 -0
- package/dist/src/addressFormat.d.ts +53 -0
- package/dist/src/addressFormat.d.ts.map +1 -0
- package/dist/src/addressFormat.js +110 -0
- package/dist/src/bitgo/Musig2.d.ts +51 -0
- package/dist/src/bitgo/Musig2.d.ts.map +1 -0
- package/dist/src/bitgo/Musig2.js +175 -0
- package/dist/src/bitgo/Unspent.d.ts +95 -0
- package/dist/src/bitgo/Unspent.d.ts.map +1 -0
- package/dist/src/bitgo/Unspent.js +138 -0
- package/dist/src/bitgo/UtxoPsbt.d.ts +132 -0
- package/dist/src/bitgo/UtxoPsbt.d.ts.map +1 -0
- package/dist/src/bitgo/UtxoPsbt.js +469 -0
- package/dist/src/bitgo/UtxoTransaction.d.ts +22 -0
- package/dist/src/bitgo/UtxoTransaction.d.ts.map +1 -0
- package/dist/src/bitgo/UtxoTransaction.js +97 -0
- package/dist/src/bitgo/UtxoTransactionBuilder.d.ts +26 -0
- package/dist/src/bitgo/UtxoTransactionBuilder.d.ts.map +1 -0
- package/dist/src/bitgo/UtxoTransactionBuilder.js +67 -0
- package/dist/src/bitgo/bbc/DashPsbt.d.ts +12 -0
- package/dist/src/bitgo/bbc/DashPsbt.d.ts.map +1 -0
- package/dist/src/bitgo/bbc/DashPsbt.js +27 -0
- package/dist/src/bitgo/bbc/DashTransaction.d.ts +39 -0
- package/dist/src/bitgo/bbc/DashTransaction.d.ts.map +1 -0
- package/dist/src/bitgo/bbc/DashTransaction.js +109 -0
- package/dist/src/bitgo/bbc/DashTransactionBuilder.d.ts +14 -0
- package/dist/src/bitgo/bbc/DashTransactionBuilder.d.ts.map +1 -0
- package/dist/src/bitgo/bbc/DashTransactionBuilder.js +28 -0
- package/dist/src/bitgo/bbc/index.d.ts +4 -0
- package/dist/src/bitgo/bbc/index.d.ts.map +1 -0
- package/dist/src/bitgo/bbc/index.js +16 -0
- package/dist/src/bitgo/bitcoincash/address.d.ts +35 -0
- package/dist/src/bitgo/bitcoincash/address.d.ts.map +1 -0
- package/dist/src/bitgo/bitcoincash/address.js +151 -0
- package/dist/src/bitgo/bitcoincash/index.d.ts +2 -0
- package/dist/src/bitgo/bitcoincash/index.d.ts.map +1 -0
- package/dist/src/bitgo/bitcoincash/index.js +14 -0
- package/dist/src/bitgo/dash/DashPsbt.d.ts +12 -0
- package/dist/src/bitgo/dash/DashPsbt.d.ts.map +1 -0
- package/dist/src/bitgo/dash/DashPsbt.js +27 -0
- package/dist/src/bitgo/dash/DashTransaction.d.ts +39 -0
- package/dist/src/bitgo/dash/DashTransaction.d.ts.map +1 -0
- package/dist/src/bitgo/dash/DashTransaction.js +109 -0
- package/dist/src/bitgo/dash/DashTransactionBuilder.d.ts +14 -0
- package/dist/src/bitgo/dash/DashTransactionBuilder.d.ts.map +1 -0
- package/dist/src/bitgo/dash/DashTransactionBuilder.js +28 -0
- package/dist/src/bitgo/dash/index.d.ts +4 -0
- package/dist/src/bitgo/dash/index.d.ts.map +1 -0
- package/dist/src/bitgo/dash/index.js +16 -0
- package/dist/src/bitgo/index.d.ts +17 -0
- package/dist/src/bitgo/index.d.ts.map +1 -0
- package/dist/src/bitgo/index.js +30 -0
- package/dist/src/bitgo/keyutil.d.ts +17 -0
- package/dist/src/bitgo/keyutil.d.ts.map +1 -0
- package/dist/src/bitgo/keyutil.js +37 -0
- package/dist/src/bitgo/nonStandardHalfSigned.d.ts +7 -0
- package/dist/src/bitgo/nonStandardHalfSigned.d.ts.map +1 -0
- package/dist/src/bitgo/nonStandardHalfSigned.js +56 -0
- package/dist/src/bitgo/outputScripts.d.ts +84 -0
- package/dist/src/bitgo/outputScripts.d.ts.map +1 -0
- package/dist/src/bitgo/outputScripts.js +297 -0
- package/dist/src/bitgo/parseInput.d.ts +92 -0
- package/dist/src/bitgo/parseInput.d.ts.map +1 -0
- package/dist/src/bitgo/parseInput.js +344 -0
- package/dist/src/bitgo/psbt/fromHalfSigned.d.ts +24 -0
- package/dist/src/bitgo/psbt/fromHalfSigned.d.ts.map +1 -0
- package/dist/src/bitgo/psbt/fromHalfSigned.js +91 -0
- package/dist/src/bitgo/psbt/scriptTypes.d.ts +6 -0
- package/dist/src/bitgo/psbt/scriptTypes.d.ts.map +1 -0
- package/dist/src/bitgo/psbt/scriptTypes.js +23 -0
- package/dist/src/bitgo/signature.d.ts +84 -0
- package/dist/src/bitgo/signature.d.ts.map +1 -0
- package/dist/src/bitgo/signature.js +222 -0
- package/dist/src/bitgo/tnumber.d.ts +9 -0
- package/dist/src/bitgo/tnumber.d.ts.map +1 -0
- package/dist/src/bitgo/tnumber.js +31 -0
- package/dist/src/bitgo/transaction.d.ts +29 -0
- package/dist/src/bitgo/transaction.d.ts.map +1 -0
- package/dist/src/bitgo/transaction.js +247 -0
- package/dist/src/bitgo/types.d.ts +5 -0
- package/dist/src/bitgo/types.d.ts.map +1 -0
- package/dist/src/bitgo/types.js +12 -0
- package/dist/src/bitgo/wallet/Psbt.d.ts +47 -0
- package/dist/src/bitgo/wallet/Psbt.d.ts.map +1 -0
- package/dist/src/bitgo/wallet/Psbt.js +232 -0
- package/dist/src/bitgo/wallet/Unspent.d.ts +47 -0
- package/dist/src/bitgo/wallet/Unspent.d.ts.map +1 -0
- package/dist/src/bitgo/wallet/Unspent.js +154 -0
- package/dist/src/bitgo/wallet/WalletKeys.d.ts +72 -0
- package/dist/src/bitgo/wallet/WalletKeys.d.ts.map +1 -0
- package/dist/src/bitgo/wallet/WalletKeys.js +104 -0
- package/dist/src/bitgo/wallet/WalletOutput.d.ts +18 -0
- package/dist/src/bitgo/wallet/WalletOutput.d.ts.map +1 -0
- package/dist/src/bitgo/wallet/WalletOutput.js +69 -0
- package/dist/src/bitgo/wallet/WalletScripts.d.ts +7 -0
- package/dist/src/bitgo/wallet/WalletScripts.d.ts.map +1 -0
- package/dist/src/bitgo/wallet/WalletScripts.js +15 -0
- package/dist/src/bitgo/wallet/WalletUnspentSigner.d.ts +19 -0
- package/dist/src/bitgo/wallet/WalletUnspentSigner.d.ts.map +1 -0
- package/dist/src/bitgo/wallet/WalletUnspentSigner.js +47 -0
- package/dist/src/bitgo/wallet/chains.d.ts +57 -0
- package/dist/src/bitgo/wallet/chains.d.ts.map +1 -0
- package/dist/src/bitgo/wallet/chains.js +106 -0
- package/dist/src/bitgo/wallet/index.d.ts +8 -0
- package/dist/src/bitgo/wallet/index.d.ts.map +1 -0
- package/dist/src/bitgo/wallet/index.js +20 -0
- package/dist/src/bitgo/zcash/ZcashBufferutils.d.ts +26 -0
- package/dist/src/bitgo/zcash/ZcashBufferutils.d.ts.map +1 -0
- package/dist/src/bitgo/zcash/ZcashBufferutils.js +157 -0
- package/dist/src/bitgo/zcash/ZcashPsbt.d.ts +36 -0
- package/dist/src/bitgo/zcash/ZcashPsbt.d.ts.map +1 -0
- package/dist/src/bitgo/zcash/ZcashPsbt.js +146 -0
- package/dist/src/bitgo/zcash/ZcashTransaction.d.ts +61 -0
- package/dist/src/bitgo/zcash/ZcashTransaction.d.ts.map +1 -0
- package/dist/src/bitgo/zcash/ZcashTransaction.js +341 -0
- package/dist/src/bitgo/zcash/ZcashTransactionBuilder.d.ts +21 -0
- package/dist/src/bitgo/zcash/ZcashTransactionBuilder.d.ts.map +1 -0
- package/dist/src/bitgo/zcash/ZcashTransactionBuilder.js +105 -0
- package/dist/src/bitgo/zcash/address.d.ts +8 -0
- package/dist/src/bitgo/zcash/address.d.ts.map +1 -0
- package/dist/src/bitgo/zcash/address.js +57 -0
- package/dist/src/bitgo/zcash/hashZip0244.d.ts +27 -0
- package/dist/src/bitgo/zcash/hashZip0244.d.ts.map +1 -0
- package/dist/src/bitgo/zcash/hashZip0244.js +184 -0
- package/dist/src/bitgo/zcash/index.d.ts +4 -0
- package/dist/src/bitgo/zcash/index.d.ts.map +1 -0
- package/dist/src/bitgo/zcash/index.js +16 -0
- package/dist/src/classify.d.ts +19 -0
- package/dist/src/classify.d.ts.map +1 -0
- package/dist/src/classify.js +89 -0
- package/dist/src/index.d.ts +13 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +36 -0
- package/dist/src/networks.d.ts +119 -0
- package/dist/src/networks.d.ts.map +1 -0
- package/dist/src/networks.js +477 -0
- package/dist/src/noble_ecc.d.ts +28 -0
- package/dist/src/noble_ecc.d.ts.map +1 -0
- package/dist/src/noble_ecc.js +168 -0
- package/dist/src/payments/index.d.ts +4 -0
- package/dist/src/payments/index.d.ts.map +1 -0
- package/dist/src/payments/index.js +8 -0
- package/dist/src/payments/p2tr.d.ts +3 -0
- package/dist/src/payments/p2tr.d.ts.map +1 -0
- package/dist/src/payments/p2tr.js +348 -0
- package/dist/src/payments/p2tr_ns.d.ts +3 -0
- package/dist/src/payments/p2tr_ns.d.ts.map +1 -0
- package/dist/src/payments/p2tr_ns.js +134 -0
- package/dist/src/taproot.d.ts +141 -0
- package/dist/src/taproot.d.ts.map +1 -0
- package/dist/src/taproot.js +384 -0
- package/dist/src/templates/multisig/index.d.ts +4 -0
- package/dist/src/templates/multisig/index.d.ts.map +1 -0
- package/dist/src/templates/multisig/index.js +8 -0
- package/dist/src/templates/multisig/input.d.ts +7 -0
- package/dist/src/templates/multisig/input.d.ts.map +1 -0
- package/dist/src/templates/multisig/input.js +25 -0
- package/dist/src/templates/multisig/output.d.ts +7 -0
- package/dist/src/templates/multisig/output.d.ts.map +1 -0
- package/dist/src/templates/multisig/output.js +38 -0
- package/dist/src/templates/nulldata.d.ts +10 -0
- package/dist/src/templates/nulldata.d.ts.map +1 -0
- package/dist/src/templates/nulldata.js +17 -0
- package/dist/src/templates/pubkey/index.d.ts +4 -0
- package/dist/src/templates/pubkey/index.d.ts.map +1 -0
- package/dist/src/templates/pubkey/index.js +8 -0
- package/dist/src/templates/pubkey/input.d.ts +7 -0
- package/dist/src/templates/pubkey/input.d.ts.map +1 -0
- package/dist/src/templates/pubkey/input.js +14 -0
- package/dist/src/templates/pubkey/output.d.ts +7 -0
- package/dist/src/templates/pubkey/output.d.ts.map +1 -0
- package/dist/src/templates/pubkey/output.js +15 -0
- package/dist/src/templates/pubkeyhash/index.d.ts +4 -0
- package/dist/src/templates/pubkeyhash/index.d.ts.map +1 -0
- package/dist/src/templates/pubkeyhash/index.js +8 -0
- package/dist/src/templates/pubkeyhash/input.d.ts +7 -0
- package/dist/src/templates/pubkeyhash/input.d.ts.map +1 -0
- package/dist/src/templates/pubkeyhash/input.js +16 -0
- package/dist/src/templates/pubkeyhash/output.d.ts +6 -0
- package/dist/src/templates/pubkeyhash/output.d.ts.map +1 -0
- package/dist/src/templates/pubkeyhash/output.js +20 -0
- package/dist/src/templates/scripthash/index.d.ts +4 -0
- package/dist/src/templates/scripthash/index.d.ts.map +1 -0
- package/dist/src/templates/scripthash/index.js +8 -0
- package/dist/src/templates/scripthash/input.d.ts +6 -0
- package/dist/src/templates/scripthash/input.d.ts.map +1 -0
- package/dist/src/templates/scripthash/input.js +43 -0
- package/dist/src/templates/scripthash/output.d.ts +6 -0
- package/dist/src/templates/scripthash/output.d.ts.map +1 -0
- package/dist/src/templates/scripthash/output.js +15 -0
- package/dist/src/templates/taproot/index.d.ts +4 -0
- package/dist/src/templates/taproot/index.d.ts.map +1 -0
- package/dist/src/templates/taproot/index.js +8 -0
- package/dist/src/templates/taproot/input.d.ts +6 -0
- package/dist/src/templates/taproot/input.d.ts.map +1 -0
- package/dist/src/templates/taproot/input.js +23 -0
- package/dist/src/templates/taproot/output.d.ts +6 -0
- package/dist/src/templates/taproot/output.d.ts.map +1 -0
- package/dist/src/templates/taproot/output.js +15 -0
- package/dist/src/templates/taprootnofn/index.d.ts +4 -0
- package/dist/src/templates/taprootnofn/index.d.ts.map +1 -0
- package/dist/src/templates/taprootnofn/index.js +8 -0
- package/dist/src/templates/taprootnofn/input.d.ts +7 -0
- package/dist/src/templates/taprootnofn/input.d.ts.map +1 -0
- package/dist/src/templates/taprootnofn/input.js +24 -0
- package/dist/src/templates/taprootnofn/output.d.ts +7 -0
- package/dist/src/templates/taprootnofn/output.d.ts.map +1 -0
- package/dist/src/templates/taprootnofn/output.js +28 -0
- package/dist/src/templates/witnesscommitment/index.d.ts +3 -0
- package/dist/src/templates/witnesscommitment/index.d.ts.map +1 -0
- package/dist/src/templates/witnesscommitment/index.js +6 -0
- package/dist/src/templates/witnesscommitment/output.d.ts +8 -0
- package/dist/src/templates/witnesscommitment/output.d.ts.map +1 -0
- package/dist/src/templates/witnesscommitment/output.js +31 -0
- package/dist/src/templates/witnesspubkeyhash/index.d.ts +4 -0
- package/dist/src/templates/witnesspubkeyhash/index.d.ts.map +1 -0
- package/dist/src/templates/witnesspubkeyhash/index.js +8 -0
- package/dist/src/templates/witnesspubkeyhash/input.d.ts +7 -0
- package/dist/src/templates/witnesspubkeyhash/input.d.ts.map +1 -0
- package/dist/src/templates/witnesspubkeyhash/input.js +19 -0
- package/dist/src/templates/witnesspubkeyhash/output.d.ts +6 -0
- package/dist/src/templates/witnesspubkeyhash/output.d.ts.map +1 -0
- package/dist/src/templates/witnesspubkeyhash/output.js +15 -0
- package/dist/src/templates/witnessscripthash/index.d.ts +4 -0
- package/dist/src/templates/witnessscripthash/index.d.ts.map +1 -0
- package/dist/src/templates/witnessscripthash/index.js +8 -0
- package/dist/src/templates/witnessscripthash/input.d.ts +6 -0
- package/dist/src/templates/witnessscripthash/input.d.ts.map +1 -0
- package/dist/src/templates/witnessscripthash/input.js +35 -0
- package/dist/src/templates/witnessscripthash/output.d.ts +6 -0
- package/dist/src/templates/witnessscripthash/output.d.ts.map +1 -0
- package/dist/src/templates/witnessscripthash/output.js +15 -0
- package/dist/src/testutil/index.d.ts +3 -0
- package/dist/src/testutil/index.d.ts.map +1 -0
- package/dist/src/testutil/index.js +15 -0
- package/dist/src/testutil/keys.d.ts +10 -0
- package/dist/src/testutil/keys.d.ts.map +1 -0
- package/dist/src/testutil/keys.js +40 -0
- package/dist/src/testutil/mock.d.ts +21 -0
- package/dist/src/testutil/mock.d.ts.map +1 -0
- package/dist/src/testutil/mock.js +86 -0
- package/dist/src/transaction_builder.d.ts +47 -0
- package/dist/src/transaction_builder.d.ts.map +1 -0
- package/dist/src/transaction_builder.js +1084 -0
- package/package.json +87 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import * as bitcoinjs from 'bitcoinjs-lib';
|
3
|
+
import { Network } from '../..';
|
4
|
+
import { ZcashNetwork, ZcashTransaction } from './ZcashTransaction';
|
5
|
+
import { UtxoTransactionBuilder } from '../UtxoTransactionBuilder';
|
6
|
+
export declare class ZcashTransactionBuilder<TNumber extends number | bigint = number> extends UtxoTransactionBuilder<TNumber, ZcashTransaction<TNumber>> {
|
7
|
+
constructor(network: ZcashNetwork);
|
8
|
+
protected createInitialTransaction(network: Network): ZcashTransaction<TNumber>;
|
9
|
+
static fromTransaction<TNumber extends number | bigint = number>(transaction: ZcashTransaction<TNumber>, network?: Network, prevOutput?: bitcoinjs.TxOutput<TNumber>[]): ZcashTransactionBuilder<TNumber>;
|
10
|
+
setVersion(version: number, overwinter?: boolean): void;
|
11
|
+
setDefaultsForVersion(network: Network, version: number): void;
|
12
|
+
private hasSignatures;
|
13
|
+
private setPropertyCheckSignatures;
|
14
|
+
setConsensusBranchId(consensusBranchId: number): void;
|
15
|
+
setVersionGroupId(versionGroupId: number): void;
|
16
|
+
setExpiryHeight(expiryHeight: number): void;
|
17
|
+
build(): ZcashTransaction<TNumber>;
|
18
|
+
buildIncomplete(): ZcashTransaction<TNumber>;
|
19
|
+
addOutput(scriptPubKey: string | Buffer, value: TNumber): number;
|
20
|
+
}
|
21
|
+
//# sourceMappingURL=ZcashTransactionBuilder.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ZcashTransactionBuilder.d.ts","sourceRoot":"","sources":["../../../../src/bitgo/zcash/ZcashTransactionBuilder.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,SAAS,MAAM,eA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+1,105 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ZcashTransactionBuilder = void 0;
|
4
|
+
const types = require("bitcoinjs-lib/src/types");
|
5
|
+
const typeforce = require('typeforce');
|
6
|
+
const ZcashTransaction_1 = require("./ZcashTransaction");
|
7
|
+
const UtxoTransactionBuilder_1 = require("../UtxoTransactionBuilder");
|
8
|
+
const address_1 = require("./address");
|
9
|
+
class ZcashTransactionBuilder extends UtxoTransactionBuilder_1.UtxoTransactionBuilder {
|
10
|
+
constructor(network) {
|
11
|
+
super(network);
|
12
|
+
}
|
13
|
+
createInitialTransaction(network) {
|
14
|
+
return new ZcashTransaction_1.ZcashTransaction(network);
|
15
|
+
}
|
16
|
+
static fromTransaction(transaction, network, prevOutput) {
|
17
|
+
const txb = new ZcashTransactionBuilder(transaction.network);
|
18
|
+
// Copy transaction fields
|
19
|
+
txb.setVersion(transaction.version, !!transaction.overwintered);
|
20
|
+
txb.setLockTime(transaction.locktime);
|
21
|
+
// Copy Zcash overwinter fields. Omitted if the transaction builder is not for Zcash.
|
22
|
+
if (txb.tx.isOverwinterCompatible()) {
|
23
|
+
txb.setVersionGroupId(transaction.versionGroupId);
|
24
|
+
txb.setExpiryHeight(transaction.expiryHeight);
|
25
|
+
}
|
26
|
+
txb.setConsensusBranchId(transaction.consensusBranchId);
|
27
|
+
// Copy outputs (done first to avoid signature invalidation)
|
28
|
+
transaction.outs.forEach(function (txOut) {
|
29
|
+
txb.addOutput(txOut.script, txOut.value);
|
30
|
+
});
|
31
|
+
// Copy inputs
|
32
|
+
transaction.ins.forEach(function (txIn) {
|
33
|
+
txb.__addInputUnsafe(txIn.hash, txIn.index, {
|
34
|
+
sequence: txIn.sequence,
|
35
|
+
script: txIn.script,
|
36
|
+
witness: txIn.witness,
|
37
|
+
value: txIn.value,
|
38
|
+
});
|
39
|
+
});
|
40
|
+
return txb;
|
41
|
+
}
|
42
|
+
setVersion(version, overwinter = true) {
|
43
|
+
typeforce(types.UInt32, version);
|
44
|
+
this.tx.overwintered = overwinter ? 1 : 0;
|
45
|
+
this.tx.version = version;
|
46
|
+
}
|
47
|
+
setDefaultsForVersion(network, version) {
|
48
|
+
switch (version) {
|
49
|
+
case 4:
|
50
|
+
case ZcashTransaction_1.ZcashTransaction.VERSION4_BRANCH_CANOPY:
|
51
|
+
case ZcashTransaction_1.ZcashTransaction.VERSION4_BRANCH_NU5:
|
52
|
+
this.setVersion(4);
|
53
|
+
break;
|
54
|
+
case 5:
|
55
|
+
case ZcashTransaction_1.ZcashTransaction.VERSION5_BRANCH_NU5:
|
56
|
+
this.setVersion(5);
|
57
|
+
break;
|
58
|
+
default:
|
59
|
+
throw new Error(`invalid version ${version}`);
|
60
|
+
}
|
61
|
+
this.tx.versionGroupId = ZcashTransaction_1.getDefaultVersionGroupIdForVersion(version);
|
62
|
+
this.tx.consensusBranchId = ZcashTransaction_1.getDefaultConsensusBranchIdForVersion(network, version);
|
63
|
+
}
|
64
|
+
hasSignatures() {
|
65
|
+
return this.__INPUTS.some(function (input) {
|
66
|
+
return input.signatures !== undefined;
|
67
|
+
});
|
68
|
+
}
|
69
|
+
setPropertyCheckSignatures(propName, value) {
|
70
|
+
if (this.tx[propName] === value) {
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
if (this.hasSignatures()) {
|
74
|
+
throw new Error(`Changing property ${propName} for a partially signed transaction would invalidate signatures`);
|
75
|
+
}
|
76
|
+
this.tx[propName] = value;
|
77
|
+
}
|
78
|
+
setConsensusBranchId(consensusBranchId) {
|
79
|
+
typeforce(types.UInt32, consensusBranchId);
|
80
|
+
this.setPropertyCheckSignatures('consensusBranchId', consensusBranchId);
|
81
|
+
}
|
82
|
+
setVersionGroupId(versionGroupId) {
|
83
|
+
typeforce(types.UInt32, versionGroupId);
|
84
|
+
this.setPropertyCheckSignatures('versionGroupId', versionGroupId);
|
85
|
+
}
|
86
|
+
setExpiryHeight(expiryHeight) {
|
87
|
+
typeforce(types.UInt32, expiryHeight);
|
88
|
+
this.setPropertyCheckSignatures('expiryHeight', expiryHeight);
|
89
|
+
}
|
90
|
+
build() {
|
91
|
+
return super.build();
|
92
|
+
}
|
93
|
+
buildIncomplete() {
|
94
|
+
return super.buildIncomplete();
|
95
|
+
}
|
96
|
+
addOutput(scriptPubKey, value) {
|
97
|
+
// Attempt to get a script if it's a base58 or bech32 address string
|
98
|
+
if (typeof scriptPubKey === 'string') {
|
99
|
+
scriptPubKey = address_1.toOutputScript(scriptPubKey, this.network);
|
100
|
+
}
|
101
|
+
return super.addOutput(scriptPubKey, value);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
exports.ZcashTransactionBuilder = ZcashTransactionBuilder;
|
105
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiWmNhc2hUcmFuc2FjdGlvbkJ1aWxkZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYml0Z28vemNhc2gvWmNhc2hUcmFuc2FjdGlvbkJ1aWxkZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQ0EsaURBQWlEO0FBQ2pELE1BQU0sU0FBUyxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQztBQUd2Qyx5REFLNEI7QUFDNUIsc0VBQW1FO0FBQ25FLHVDQUEyQztBQUUzQyxNQUFhLHVCQUFrRSxTQUFRLCtDQUd0RjtJQUNDLFlBQVksT0FBcUI7UUFDL0IsS0FBSyxDQUFDLE9BQU8sQ0FBQyxDQUFDO0lBQ2pCLENBQUM7SUFFUyx3QkFBd0IsQ0FBQyxPQUFnQjtRQUNqRCxPQUFPLElBQUksbUNBQWdCLENBQVUsT0FBdUIsQ0FBQyxDQUFDO0lBQ2hFLENBQUM7SUFFRCxNQUFNLENBQUMsZUFBZSxDQUNwQixXQUFzQyxFQUN0QyxPQUFpQixFQUNqQixVQUEwQztRQUUxQ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A9PT0gJ3N0cmluZycpIHtcbiAgICAgIHNjcmlwdFB1YktleSA9IHRvT3V0cHV0U2NyaXB0KHNjcmlwdFB1YktleSwgdGhpcy5uZXR3b3JrIGFzIE5ldHdvcmspO1xuICAgIH1cblxuICAgIHJldHVybiBzdXBlci5hZGRPdXRwdXQoc2NyaXB0UHViS2V5LCB2YWx1ZSk7XG4gIH1cbn1cbiJdfQ==
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import { Base58CheckResult } from 'bitcoinjs-lib/src/address';
|
3
|
+
import { Network } from '../../networks';
|
4
|
+
export declare function fromBase58Check(address: string): Base58CheckResult;
|
5
|
+
export declare function toBase58Check(hash: Buffer, version: number): string;
|
6
|
+
export declare function fromOutputScript(outputScript: Buffer, network: Network): string;
|
7
|
+
export declare function toOutputScript(address: string, network: Network): Buffer;
|
8
|
+
//# sourceMappingURL=address.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../../../src/bitgo/zcash/address.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAW,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAIlD,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,CAKlE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAOnE;AAED,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAgB/E;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAUxE"}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.toOutputScript = exports.fromOutputScript = exports.toBase58Check = exports.fromBase58Check = void 0;
|
4
|
+
const assert = require("assert");
|
5
|
+
const bitcoinjs_lib_1 = require("bitcoinjs-lib");
|
6
|
+
const types = require("bitcoinjs-lib/src/types");
|
7
|
+
const networks_1 = require("../../networks");
|
8
|
+
const bs58check = require('bs58check');
|
9
|
+
const typeforce = require('typeforce');
|
10
|
+
function fromBase58Check(address) {
|
11
|
+
const payload = bs58check.decode(address);
|
12
|
+
const version = payload.readUInt16BE(0);
|
13
|
+
const hash = payload.slice(2);
|
14
|
+
return { version, hash };
|
15
|
+
}
|
16
|
+
exports.fromBase58Check = fromBase58Check;
|
17
|
+
function toBase58Check(hash, version) {
|
18
|
+
typeforce(types.tuple(types.Hash160bit, types.Number), arguments);
|
19
|
+
const payload = Buffer.allocUnsafe(22);
|
20
|
+
payload.writeUInt16BE(version, 0);
|
21
|
+
hash.copy(payload, 2);
|
22
|
+
return bs58check.encode(payload);
|
23
|
+
}
|
24
|
+
exports.toBase58Check = toBase58Check;
|
25
|
+
function fromOutputScript(outputScript, network) {
|
26
|
+
assert(networks_1.isZcash(network));
|
27
|
+
let o;
|
28
|
+
let prefix;
|
29
|
+
try {
|
30
|
+
o = bitcoinjs_lib_1.payments.p2pkh({ output: outputScript });
|
31
|
+
prefix = network.pubKeyHash;
|
32
|
+
}
|
33
|
+
catch (e) { }
|
34
|
+
try {
|
35
|
+
o = bitcoinjs_lib_1.payments.p2sh({ output: outputScript });
|
36
|
+
prefix = network.scriptHash;
|
37
|
+
}
|
38
|
+
catch (e) { }
|
39
|
+
if (!o || !o.hash || prefix === undefined) {
|
40
|
+
throw new Error(`unsupported outputScript`);
|
41
|
+
}
|
42
|
+
return toBase58Check(o.hash, prefix);
|
43
|
+
}
|
44
|
+
exports.fromOutputScript = fromOutputScript;
|
45
|
+
function toOutputScript(address, network) {
|
46
|
+
assert(networks_1.isZcash(network));
|
47
|
+
const { version, hash } = fromBase58Check(address);
|
48
|
+
if (version === network.pubKeyHash) {
|
49
|
+
return bitcoinjs_lib_1.payments.p2pkh({ hash }).output;
|
50
|
+
}
|
51
|
+
if (version === network.scriptHash) {
|
52
|
+
return bitcoinjs_lib_1.payments.p2sh({ hash }).output;
|
53
|
+
}
|
54
|
+
throw new Error(address + ' has no matching Script');
|
55
|
+
}
|
56
|
+
exports.toOutputScript = toOutputScript;
|
57
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWRkcmVzcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9iaXRnby96Y2FzaC9hZGRyZXNzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLGlDQUFpQztBQUNqQyxpREFBeUM7QUFDekMsaURBQWlEO0FBRWpELDZDQUFrRDtBQUNsRCxNQUFNLFNBQVMsR0FBRyxPQUFPLENBQUMsV0FBVyxDQUFDLENBQUM7QUFDdkMsTUFBTSxTQUFTLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQUFDO0FBRXZDLFNBQWdCLGVBQWUsQ0FBQyxPQUFlO0lBQzdDLE1BQU0sT0FBTyxHQUFHLFNBQVMsQ0FBQyxNQUFNLENBQUMsT0FBTyxDQUFDLENBQUM7SUFDMUMsTUFBTSxPQUFPLEdBQUcsT0FBTyxDQUFDLFlBQVksQ0FBQyxDQUFDLENBQUMsQ0FBQztJQUN4QyxNQUFNLElBQUksR0FBRyxPQUFPLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQyxDQUFDO0lBQzlCLE9BQU8sRUFBRSxPQUFPLEVBQUUsSUFBSSxFQUFFLENBQUM7QUFDM0IsQ0FBQztBQUxELDBDQUtDO0FBRUQsU0FBZ0IsYUFBYSxDQUFDLElBQVksRUFBRSxPQUFlO0lBQ3pELFNBQVMsQ0FBQyxLQUFLLENBQUMsS0FBSyxDQUFDLEtBQUssQ0FBQyxVQUFVLEVBQUUsS0FBSyxDQUFDL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ements hashing methods described in https://zips.z.cash/zip-0244.
|
4
|
+
* Only supports full transparent transactions without shielded inputs or outputs.
|
5
|
+
*/
|
6
|
+
import { TxInput, TxOutput } from 'bitcoinjs-lib';
|
7
|
+
import { ZcashTransaction } from './ZcashTransaction';
|
8
|
+
declare type SignatureParams<TNumber extends number | bigint = number> = {
|
9
|
+
inIndex?: number;
|
10
|
+
prevOutScript: Buffer;
|
11
|
+
value: TNumber;
|
12
|
+
hashType: number;
|
13
|
+
};
|
14
|
+
/**
|
15
|
+
* Blake2b hashing algorithm for Zcash
|
16
|
+
* @param buffer
|
17
|
+
* @param personalization
|
18
|
+
* @returns 256-bit BLAKE2b hash
|
19
|
+
*/
|
20
|
+
export declare function getBlake2bHash(buffer: Buffer, personalization: string | Buffer): Buffer;
|
21
|
+
export declare function getPrevoutsDigest<TNumber extends number | bigint>(ins: TxInput[], tag?: string, sigParams?: SignatureParams<TNumber>): Buffer;
|
22
|
+
export declare function getSequenceDigest<TNumber extends number | bigint>(ins: TxInput[], tag?: string, sigParams?: SignatureParams<TNumber>): Buffer;
|
23
|
+
export declare function getOutputsDigest<TNumber extends number | bigint>(outs: TxOutput<TNumber>[], tag?: string, sigParams?: SignatureParams<TNumber>): Buffer;
|
24
|
+
export declare function getTxidDigest<TNumber extends number | bigint>(tx: ZcashTransaction<TNumber>): Buffer;
|
25
|
+
export declare function getSignatureDigest<TNumber extends number | bigint>(tx: ZcashTransaction<TNumber>, inIndex: number | undefined, prevOutScript: Buffer, value: TNumber, hashType: number): Buffer;
|
26
|
+
export {};
|
27
|
+
//# sourceMappingURL=hashZip0244.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"hashZip0244.d.ts","sourceRoot":"","sources":["../../../../src/bitgo/zcash/hashZip0244.ts"],"names":[],"mappings":";AAAA;;;GAGG;AACH,OAAO,EAAe,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAK/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,o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AQR"}
|
@@ -0,0 +1,184 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getSignatureDigest = exports.getTxidDigest = exports.getOutputsDigest = exports.getSequenceDigest = exports.getPrevoutsDigest = exports.getBlake2bHash = void 0;
|
4
|
+
/**
|
5
|
+
* Implements hashing methods described in https://zips.z.cash/zip-0244.
|
6
|
+
* Only supports full transparent transactions without shielded inputs or outputs.
|
7
|
+
*/
|
8
|
+
const bitcoinjs_lib_1 = require("bitcoinjs-lib");
|
9
|
+
const bufferutils_1 = require("bitcoinjs-lib/src/bufferutils");
|
10
|
+
const blake2b = require('@bitgo/blake2b');
|
11
|
+
const UtxoTransaction_1 = require("../UtxoTransaction");
|
12
|
+
/**
|
13
|
+
* Blake2b hashing algorithm for Zcash
|
14
|
+
* @param buffer
|
15
|
+
* @param personalization
|
16
|
+
* @returns 256-bit BLAKE2b hash
|
17
|
+
*/
|
18
|
+
function getBlake2bHash(buffer, personalization) {
|
19
|
+
const out = Buffer.allocUnsafe(32);
|
20
|
+
personalization = Buffer.from(personalization);
|
21
|
+
return blake2b(out.length, null, null, personalization).update(buffer).digest(out);
|
22
|
+
}
|
23
|
+
exports.getBlake2bHash = getBlake2bHash;
|
24
|
+
function getHeaderDigest(tx) {
|
25
|
+
// https://zips.z.cash/zip-0244#t-1-header-digest
|
26
|
+
const mask = tx.overwintered ? 1 : 0;
|
27
|
+
const writer = bufferutils_1.BufferWriter.withCapacity(4 * 5);
|
28
|
+
writer.writeInt32(tx.version | (mask << 31)); // Set overwinter bit
|
29
|
+
writer.writeUInt32(tx.versionGroupId);
|
30
|
+
writer.writeUInt32(tx.consensusBranchId);
|
31
|
+
writer.writeUInt32(tx.locktime);
|
32
|
+
writer.writeUInt32(tx.expiryHeight);
|
33
|
+
return getBlake2bHash(writer.end(), 'ZTxIdHeadersHash');
|
34
|
+
}
|
35
|
+
function getPrevoutsDigest(ins, tag = 'ZTxIdPrevoutHash', sigParams) {
|
36
|
+
if (sigParams) {
|
37
|
+
if (sigParams.hashType & bitcoinjs_lib_1.Transaction.SIGHASH_ANYONECANPAY) {
|
38
|
+
return getPrevoutsDigest([]);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
const bufferWriter = new bufferutils_1.BufferWriter(Buffer.allocUnsafe(36 * ins.length));
|
42
|
+
ins.forEach(function (txIn) {
|
43
|
+
bufferWriter.writeSlice(txIn.hash);
|
44
|
+
bufferWriter.writeUInt32(txIn.index);
|
45
|
+
});
|
46
|
+
return getBlake2bHash(bufferWriter.end(), tag);
|
47
|
+
}
|
48
|
+
exports.getPrevoutsDigest = getPrevoutsDigest;
|
49
|
+
function getSequenceDigest(ins, tag = 'ZTxIdSequencHash', sigParams) {
|
50
|
+
// txid: https://zips.z.cash/zip-0244#t-2b-sequence-digest
|
51
|
+
// sig: https://zips.z.cash/zip-0244#s-2b-sequence-sig-digest
|
52
|
+
// https://github.com/zcash-hackworks/zcash-test-vectors/blob/dd8fdb/zip_0244.py#L263
|
53
|
+
if (sigParams) {
|
54
|
+
const { hashType } = sigParams;
|
55
|
+
if (hashType & bitcoinjs_lib_1.Transaction.SIGHASH_ANYONECANPAY ||
|
56
|
+
(hashType & 0x1f) === bitcoinjs_lib_1.Transaction.SIGHASH_SINGLE ||
|
57
|
+
(hashType & 0x1f) === bitcoinjs_lib_1.Transaction.SIGHASH_NONE) {
|
58
|
+
return getSequenceDigest([]);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
const bufferWriter = new bufferutils_1.BufferWriter(Buffer.allocUnsafe(4 * ins.length));
|
62
|
+
ins.forEach(function (txIn) {
|
63
|
+
bufferWriter.writeUInt32(txIn.sequence);
|
64
|
+
});
|
65
|
+
return getBlake2bHash(bufferWriter.end(), tag);
|
66
|
+
}
|
67
|
+
exports.getSequenceDigest = getSequenceDigest;
|
68
|
+
function getOutputsDigest(outs, tag = 'ZTxIdOutputsHash', sigParams) {
|
69
|
+
// txid: https://zips.z.cash/zip-0244#t-2c-outputs-digest
|
70
|
+
// sig: https://zips.z.cash/zip-0244#s-2c-outputs-sig-digest
|
71
|
+
// https://github.com/zcash-hackworks/zcash-test-vectors/blob/dd8fdb/zip_0244.py#L275
|
72
|
+
if (sigParams) {
|
73
|
+
let { hashType } = sigParams;
|
74
|
+
hashType = hashType & 0x1f;
|
75
|
+
if (hashType === bitcoinjs_lib_1.Transaction.SIGHASH_SINGLE) {
|
76
|
+
if (sigParams.inIndex === undefined) {
|
77
|
+
throw new Error();
|
78
|
+
}
|
79
|
+
if (outs[sigParams.inIndex] === undefined) {
|
80
|
+
return getOutputsDigest(outs);
|
81
|
+
}
|
82
|
+
return getOutputsDigest([outs[sigParams.inIndex]]);
|
83
|
+
}
|
84
|
+
if (hashType === bitcoinjs_lib_1.Transaction.SIGHASH_NONE) {
|
85
|
+
return getOutputsDigest([]);
|
86
|
+
}
|
87
|
+
return getOutputsDigest(outs, tag);
|
88
|
+
}
|
89
|
+
// Find out the size of the outputs and write them
|
90
|
+
const txOutsSize = outs.reduce(function (sum, output) {
|
91
|
+
return sum + 8 + UtxoTransaction_1.varSliceSize(output.script);
|
92
|
+
}, 0);
|
93
|
+
const bufferWriter = new bufferutils_1.BufferWriter(Buffer.allocUnsafe(txOutsSize));
|
94
|
+
outs.forEach(function (out) {
|
95
|
+
bufferWriter.writeUInt64(out.value);
|
96
|
+
bufferWriter.writeVarSlice(out.script);
|
97
|
+
});
|
98
|
+
return getBlake2bHash(bufferWriter.end(), tag);
|
99
|
+
}
|
100
|
+
exports.getOutputsDigest = getOutputsDigest;
|
101
|
+
function getTxinDigest(input, sigParams) {
|
102
|
+
// https://zips.z.cash/zip-0244#s-2d-txin-sig-digest
|
103
|
+
// https://github.com/zcash-hackworks/zcash-test-vectors/blob/dd8fdb/zip_0244.py#L291
|
104
|
+
const writer = bufferutils_1.BufferWriter.withCapacity(32 /* prevout hash */ +
|
105
|
+
4 /* prevout vin */ +
|
106
|
+
UtxoTransaction_1.varSliceSize(sigParams.prevOutScript) +
|
107
|
+
8 /* value */ +
|
108
|
+
4 /* sequence */);
|
109
|
+
writer.writeSlice(input.hash);
|
110
|
+
writer.writeUInt32(input.index);
|
111
|
+
writer.writeVarSlice(sigParams.prevOutScript);
|
112
|
+
writer.writeUInt64(sigParams.value);
|
113
|
+
writer.writeUInt32(input.sequence);
|
114
|
+
return getBlake2bHash(writer.end(), 'Zcash___TxInHash');
|
115
|
+
}
|
116
|
+
function getTransparentDigest(tx, sigParams) {
|
117
|
+
// txid: https://zips.z.cash/zip-0244#t-2-transparent-digest
|
118
|
+
// sig: https://zips.z.cash/zip-0244#s-2a-prevouts-sig-digest
|
119
|
+
if (sigParams) {
|
120
|
+
if (sigParams.inIndex === undefined) {
|
121
|
+
return getTransparentDigest(tx);
|
122
|
+
}
|
123
|
+
}
|
124
|
+
let buffer;
|
125
|
+
if (tx.ins.length || tx.outs.length) {
|
126
|
+
const writer = bufferutils_1.BufferWriter.withCapacity(32 * (sigParams ? 4 : 3));
|
127
|
+
writer.writeSlice(getPrevoutsDigest(tx.ins, undefined, sigParams));
|
128
|
+
writer.writeSlice(getSequenceDigest(tx.ins, undefined, sigParams));
|
129
|
+
writer.writeSlice(getOutputsDigest(tx.outs, undefined, sigParams));
|
130
|
+
if (sigParams) {
|
131
|
+
if (sigParams.inIndex === undefined) {
|
132
|
+
throw new Error();
|
133
|
+
}
|
134
|
+
writer.writeSlice(getTxinDigest(tx.ins[sigParams.inIndex], sigParams));
|
135
|
+
}
|
136
|
+
buffer = writer.end();
|
137
|
+
}
|
138
|
+
else {
|
139
|
+
buffer = Buffer.of();
|
140
|
+
}
|
141
|
+
return getBlake2bHash(buffer, 'ZTxIdTranspaHash');
|
142
|
+
}
|
143
|
+
function getSaplingDigest(tx) {
|
144
|
+
// https://zips.z.cash/zip-0244#t-3-sapling-digest
|
145
|
+
return getBlake2bHash(Buffer.of(), 'ZTxIdSaplingHash');
|
146
|
+
}
|
147
|
+
function getOrchardDigest(tx) {
|
148
|
+
// https://zips.z.cash/zip-0244#t-4-orchard-digest
|
149
|
+
return getBlake2bHash(Buffer.of(), 'ZTxIdOrchardHash');
|
150
|
+
}
|
151
|
+
/**
|
152
|
+
* @param tx
|
153
|
+
* @param signatureParams - calculates txid when undefined
|
154
|
+
*/
|
155
|
+
function getDigest(tx, signatureParams) {
|
156
|
+
// txid: https://zips.z.cash/zip-0244#id4
|
157
|
+
// sig: https://zips.z.cash/zip-0244#id13
|
158
|
+
const writer = bufferutils_1.BufferWriter.withCapacity(32 * 4);
|
159
|
+
writer.writeSlice(getHeaderDigest(tx));
|
160
|
+
writer.writeSlice(getTransparentDigest(tx, signatureParams));
|
161
|
+
writer.writeSlice(getSaplingDigest(tx));
|
162
|
+
writer.writeSlice(getOrchardDigest(tx));
|
163
|
+
const tag = 'ZcashTxHash_';
|
164
|
+
const personalization = bufferutils_1.BufferWriter.withCapacity(tag.length + 4 /* UInt32 */);
|
165
|
+
personalization.writeSlice(Buffer.from(tag));
|
166
|
+
personalization.writeUInt32(tx.consensusBranchId);
|
167
|
+
return getBlake2bHash(writer.end(), personalization.end());
|
168
|
+
}
|
169
|
+
function getTxidDigest(tx) {
|
170
|
+
// https://zips.z.cash/zip-0244#id4
|
171
|
+
return getDigest(tx);
|
172
|
+
}
|
173
|
+
exports.getTxidDigest = getTxidDigest;
|
174
|
+
function getSignatureDigest(tx, inIndex, prevOutScript, value, hashType) {
|
175
|
+
// https://zips.z.cash/zip-0244#id13
|
176
|
+
return getDigest(tx, {
|
177
|
+
inIndex,
|
178
|
+
prevOutScript,
|
179
|
+
value,
|
180
|
+
hashType,
|
181
|
+
});
|
182
|
+
}
|
183
|
+
exports.getSignatureDigest = getSignatureDigest;
|
184
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGFzaFppcDAyNDQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYml0Z28vemNhc2gvaGFzaFppcDAy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bGl6YXRpb24ud3JpdGVTbGljZShCdWZmZXIuZnJvbSh0YWcpKTtcbiAgcGVyc29uYWxpemF0aW9uLndyaXRlVUludDMyKHR4LmNvbnNlbnN1c0JyYW5jaElkKTtcbiAgcmV0dXJuIGdldEJsYWtlMmJIYXNoKHdyaXRlci5lbmQoKSwgcGVyc29uYWxpemF0aW9uLmVuZCgpKTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIGdldFR4aWREaWdlc3Q8VE51bWJlciBleHRlbmRzIG51bWJlciB8IGJpZ2ludD4odHg6IFpjYXNoVHJhbnNhY3Rpb248VE51bWJlcj4pOiBCdWZmZXIge1xuICAvLyBodHRwczovL3ppcHMuei5jYXNoL3ppcC0wMjQ0I2lkNFxuICByZXR1cm4gZ2V0RGlnZXN0KHR4KTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIGdldFNpZ25hdHVyZURpZ2VzdDxUTnVtYmVyIGV4dGVuZHMgbnVtYmVyIHwgYmlnaW50PihcbiAgdHg6IFpjYXNoVHJhbnNhY3Rpb248VE51bWJlcj4sXG4gIGluSW5kZXg6IG51bWJlciB8IHVuZGVmaW5lZCxcbiAgcHJldk91dFNjcmlwdDogQnVmZmVyLFxuICB2YWx1ZTogVE51bWJlcixcbiAgaGFzaFR5cGU6IG51bWJlclxuKTogQnVmZmVyIHtcbiAgLy8gaHR0cHM6Ly96aXBzLnouY2FzaC96aXAtMDI0NCNpZDEzXG4gIHJldHVybiBnZXREaWdlc3QodHgsIHtcbiAgICBpbkluZGV4LFxuICAgIHByZXZPdXRTY3JpcHQsXG4gICAgdmFsdWUsXG4gICAgaGFzaFR5cGUsXG4gIH0pO1xufVxuIl19
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/bitgo/zcash/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC"}
|
@@ -0,0 +1,16 @@
|
|
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("./ZcashPsbt"), exports);
|
14
|
+
__exportStar(require("./ZcashTransaction"), exports);
|
15
|
+
__exportStar(require("./ZcashTransactionBuilder"), exports);
|
16
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYml0Z28vemNhc2gvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7O0FBQUEsOENBQTRCO0FBQzVCLHFEQUFtQztBQUNuQyw0REFBMEMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgKiBmcm9tICcuL1pjYXNoUHNidCc7XG5leHBvcnQgKiBmcm9tICcuL1pjYXNoVHJhbnNhY3Rpb24nO1xuZXhwb3J0ICogZnJvbSAnLi9aY2FzaFRyYW5zYWN0aW9uQnVpbGRlcic7XG4iXX0=
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
declare const types: {
|
3
|
+
P2MS: string;
|
4
|
+
NONSTANDARD: string;
|
5
|
+
NULLDATA: string;
|
6
|
+
P2PK: string;
|
7
|
+
P2PKH: string;
|
8
|
+
P2SH: string;
|
9
|
+
P2WPKH: string;
|
10
|
+
P2WSH: string;
|
11
|
+
P2TR: string;
|
12
|
+
P2TR_NS: string;
|
13
|
+
WITNESS_COMMITMENT: string;
|
14
|
+
};
|
15
|
+
declare function classifyOutput(script: Buffer): string;
|
16
|
+
declare function classifyInput(script: Buffer, allowIncomplete?: boolean): string;
|
17
|
+
declare function classifyWitness(script: Buffer[], allowIncomplete?: boolean): string;
|
18
|
+
export { classifyInput as input, classifyOutput as output, classifyWitness as witness, types };
|
19
|
+
//# sourceMappingURL=classify.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"classify.d.ts","sourceRoot":"","sources":["../../src/classify.ts"],"names":[],"mappings":";AAYA,QAAA,MAAM,KAAK;;;;;;;;;;;;CAYV,CAAC;AAEF,iBAAS,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAkB9C;AAED,iBAAS,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,CAYxE;AAED,iBAAS,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,CAU5E;AAED,OAAO,EAAE,aAAa,IAAI,KAAK,EAAE,cAAc,IAAI,MAAM,EAAE,eAAe,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC"}
|