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
package/dist/src/bitgo/Musig2.js
DELETED
@@ -1,175 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.setMusig2Nonces = exports.createTapOutputKey = exports.createTapInternalKey = exports.decodePsbtMusig2ParticipantsKeyValData = exports.encodePsbtMusig2PubNonceKeyValData = exports.encodePsbtMusig2ParticipantsKeyValData = void 0;
|
4
|
-
const UtxoPsbt_1 = require("./UtxoPsbt");
|
5
|
-
const outputScripts_1 = require("./outputScripts");
|
6
|
-
const noble_ecc_1 = require("../noble_ecc");
|
7
|
-
const taproot_1 = require("../taproot");
|
8
|
-
const utils_1 = require("bip174/src/lib/utils");
|
9
|
-
/**
|
10
|
-
* Psbt proprietary key val util function for participants pub keys. SubType is 0x01
|
11
|
-
* Ref: https://gist.github.com/sanket1729/4b525c6049f4d9e034d27368c49f28a6
|
12
|
-
* @return x-only tapOutputKey||tapInternalKey as sub keydata, plain sigining participant keys as valuedata
|
13
|
-
*/
|
14
|
-
function encodePsbtMusig2ParticipantsKeyValData(participantsKeyValData) {
|
15
|
-
const keydata = [participantsKeyValData.tapOutputKey, participantsKeyValData.tapInternalKey].map((pubkey) => outputScripts_1.checkXOnlyPublicKey(pubkey));
|
16
|
-
const value = participantsKeyValData.participantPubKeys.map((pubkey) => outputScripts_1.checkPlainPublicKey(pubkey));
|
17
|
-
const key = {
|
18
|
-
identifier: UtxoPsbt_1.PSBT_PROPRIETARY_IDENTIFIER,
|
19
|
-
subtype: UtxoPsbt_1.ProprietaryKeySubtype.MUSIG2_PARTICIPANT_PUB_KEYS,
|
20
|
-
keydata: Buffer.concat(keydata),
|
21
|
-
};
|
22
|
-
return { key, value: Buffer.concat(value) };
|
23
|
-
}
|
24
|
-
exports.encodePsbtMusig2ParticipantsKeyValData = encodePsbtMusig2ParticipantsKeyValData;
|
25
|
-
/**
|
26
|
-
* Psbt proprietary key val util function for pub nonce. SubType is 0x02
|
27
|
-
* Ref: https://gist.github.com/sanket1729/4b525c6049f4d9e034d27368c49f28a6
|
28
|
-
* @return plain-participantPubKey||x-only-tapOutputKey as sub keydata, 66 bytes of 2 pub nonces as valuedata
|
29
|
-
*/
|
30
|
-
function encodePsbtMusig2PubNonceKeyValData(noncesKeyValueData) {
|
31
|
-
if (noncesKeyValueData.pubNonces.length !== 66) {
|
32
|
-
throw new Error(`Invalid pubNonces length ${noncesKeyValueData.pubNonces.length}`);
|
33
|
-
}
|
34
|
-
const keydata = Buffer.concat([
|
35
|
-
outputScripts_1.checkPlainPublicKey(noncesKeyValueData.participantPubKey),
|
36
|
-
outputScripts_1.checkXOnlyPublicKey(noncesKeyValueData.tapOutputKey),
|
37
|
-
]);
|
38
|
-
const key = {
|
39
|
-
identifier: UtxoPsbt_1.PSBT_PROPRIETARY_IDENTIFIER,
|
40
|
-
subtype: UtxoPsbt_1.ProprietaryKeySubtype.MUSIG2_PUB_NONCE,
|
41
|
-
keydata,
|
42
|
-
};
|
43
|
-
return { key, value: noncesKeyValueData.pubNonces };
|
44
|
-
}
|
45
|
-
exports.encodePsbtMusig2PubNonceKeyValData = encodePsbtMusig2PubNonceKeyValData;
|
46
|
-
/**
|
47
|
-
* Decodes proprietary key value data for participant pub keys
|
48
|
-
* @param kv
|
49
|
-
*/
|
50
|
-
function decodePsbtMusig2ParticipantsKeyValData(kv) {
|
51
|
-
if (kv.key.identifier !== UtxoPsbt_1.PSBT_PROPRIETARY_IDENTIFIER ||
|
52
|
-
kv.key.subtype !== UtxoPsbt_1.ProprietaryKeySubtype.MUSIG2_PARTICIPANT_PUB_KEYS) {
|
53
|
-
throw new Error(`Invalid identifier ${kv.key.identifier} or subtype ${kv.key.subtype} for participants pub keys`);
|
54
|
-
}
|
55
|
-
const key = kv.key.keydata;
|
56
|
-
if (key.length !== 64) {
|
57
|
-
throw new Error(`Invalid keydata size ${key.length} for participant pub keys`);
|
58
|
-
}
|
59
|
-
const value = kv.value;
|
60
|
-
if (value.length !== 66) {
|
61
|
-
throw new Error(`Invalid valuedata size ${value.length} for participant pub keys`);
|
62
|
-
}
|
63
|
-
const participantPubKeys = [value.subarray(0, 33), value.subarray(33)];
|
64
|
-
if (participantPubKeys[0].equals(participantPubKeys[1])) {
|
65
|
-
throw new Error(`Duplicate participant pub keys found`);
|
66
|
-
}
|
67
|
-
return { tapOutputKey: key.subarray(0, 32), tapInternalKey: key.subarray(32), participantPubKeys };
|
68
|
-
}
|
69
|
-
exports.decodePsbtMusig2ParticipantsKeyValData = decodePsbtMusig2ParticipantsKeyValData;
|
70
|
-
function createTapInternalKey(plainPubKeys) {
|
71
|
-
plainPubKeys.forEach((pubKey) => outputScripts_1.checkPlainPublicKey(pubKey));
|
72
|
-
return Buffer.from(noble_ecc_1.musig.getXOnlyPubkey(noble_ecc_1.musig.keyAgg(noble_ecc_1.musig.keySort(plainPubKeys))));
|
73
|
-
}
|
74
|
-
exports.createTapInternalKey = createTapInternalKey;
|
75
|
-
function createTapOutputKey(internalPubKey, tapTreeRoot) {
|
76
|
-
if (tapTreeRoot.length !== 32) {
|
77
|
-
throw new Error(`Invalid tapTreeRoot size ${tapTreeRoot.length}`);
|
78
|
-
}
|
79
|
-
return Buffer.from(taproot_1.tapTweakPubkey(noble_ecc_1.ecc, outputScripts_1.toXOnlyPublicKey(internalPubKey), tapTreeRoot).xOnlyPubkey);
|
80
|
-
}
|
81
|
-
exports.createTapOutputKey = createTapOutputKey;
|
82
|
-
function deriveWalletPubKey(tapBip32Derivations, rootWalletKey) {
|
83
|
-
const myDerivations = tapBip32Derivations.filter((bipDv) => {
|
84
|
-
return bipDv.masterFingerprint.equals(rootWalletKey.fingerprint);
|
85
|
-
});
|
86
|
-
if (!myDerivations.length) {
|
87
|
-
throw new Error('Need one tapBip32Derivation masterFingerprint to match the rootWalletKey fingerprint');
|
88
|
-
}
|
89
|
-
const myDerivation = myDerivations.filter((bipDv) => {
|
90
|
-
const publicKey = rootWalletKey.derivePath(bipDv.path).publicKey;
|
91
|
-
return bipDv.pubkey.equals(outputScripts_1.toXOnlyPublicKey(publicKey));
|
92
|
-
});
|
93
|
-
if (myDerivation.length !== 1) {
|
94
|
-
throw new Error('root wallet key should derive one tapBip32Derivation');
|
95
|
-
}
|
96
|
-
return rootWalletKey.derivePath(myDerivation[0].path).publicKey;
|
97
|
-
}
|
98
|
-
function getMusig2NonceKeyValueData(psbt, inputIndex, rootWalletKey, sessionId) {
|
99
|
-
var _a;
|
100
|
-
const input = utils_1.checkForInput(psbt.data.inputs, inputIndex);
|
101
|
-
if (!input.tapInternalKey) {
|
102
|
-
return;
|
103
|
-
}
|
104
|
-
if (!input.tapMerkleRoot) {
|
105
|
-
throw new Error('tapMerkleRoot is required to generate nonce');
|
106
|
-
}
|
107
|
-
if (!((_a = input.tapBip32Derivation) === null || _a === void 0 ? void 0 : _a.length)) {
|
108
|
-
throw new Error('tapBip32Derivation is required to generate nonce');
|
109
|
-
}
|
110
|
-
const participantsKeyVals = psbt.getProprietaryKeyVals(inputIndex, {
|
111
|
-
identifier: UtxoPsbt_1.PSBT_PROPRIETARY_IDENTIFIER,
|
112
|
-
subtype: UtxoPsbt_1.ProprietaryKeySubtype.MUSIG2_PARTICIPANT_PUB_KEYS,
|
113
|
-
});
|
114
|
-
if (participantsKeyVals.length !== 1) {
|
115
|
-
throw new Error(`Found ${participantsKeyVals.length} matching participant key value instead of 1`);
|
116
|
-
}
|
117
|
-
const participantKeyValData = decodePsbtMusig2ParticipantsKeyValData(participantsKeyVals[0]);
|
118
|
-
const participantPubKeys = participantKeyValData.participantPubKeys;
|
119
|
-
const tapInternalKey = createTapInternalKey(participantPubKeys);
|
120
|
-
if (!tapInternalKey.equals(participantKeyValData.tapInternalKey)) {
|
121
|
-
throw new Error('Invalid participants keyata tapInternalKey');
|
122
|
-
}
|
123
|
-
const tapOutputKey = createTapOutputKey(tapInternalKey, input.tapMerkleRoot);
|
124
|
-
if (!tapOutputKey.equals(participantKeyValData.tapOutputKey)) {
|
125
|
-
throw new Error('Invalid participants keyata tapOutputKey');
|
126
|
-
}
|
127
|
-
if (!tapInternalKey.equals(input.tapInternalKey)) {
|
128
|
-
throw new Error('tapInternalKey and aggregated participant pub keys does not match');
|
129
|
-
}
|
130
|
-
const derivedPubKey = deriveWalletPubKey(input.tapBip32Derivation, rootWalletKey);
|
131
|
-
const participantPubKey = participantPubKeys.find((pubKey) => pubKey.equals(derivedPubKey));
|
132
|
-
if (!Buffer.isBuffer(participantPubKey)) {
|
133
|
-
throw new Error('participant plain pub key should match one tapBip32Derivation plain pub key');
|
134
|
-
}
|
135
|
-
const { hash } = psbt.getTaprootHashForSigChecked(inputIndex);
|
136
|
-
const nonceGenArgs = {
|
137
|
-
sessionId,
|
138
|
-
publicKey: participantPubKey,
|
139
|
-
xOnlyPublicKey: tapOutputKey,
|
140
|
-
msg: hash,
|
141
|
-
secretKey: rootWalletKey.privateKey,
|
142
|
-
};
|
143
|
-
const pubNonces = Buffer.from(noble_ecc_1.musig.nonceGen(nonceGenArgs));
|
144
|
-
return encodePsbtMusig2PubNonceKeyValData({
|
145
|
-
participantPubKey,
|
146
|
-
tapOutputKey,
|
147
|
-
pubNonces,
|
148
|
-
});
|
149
|
-
}
|
150
|
-
/**
|
151
|
-
* Generates and sets Musig2 nonces to p2trMusig2 key path spending inputs.
|
152
|
-
* tapInternalkey, tapMerkleRoot, tapBip32Derivation for rootWalletKey are required per p2trMusig2 key path input.
|
153
|
-
* Also participant keys are required from psbt proprietary key values.
|
154
|
-
* Ref: https://gist.github.com/sanket1729/4b525c6049f4d9e034d27368c49f28a6
|
155
|
-
* @param psbt
|
156
|
-
* @param rootWalletKey
|
157
|
-
* @param sessionId If provided it must either be a counter unique to this secret key,
|
158
|
-
* (converted to an array of 32 bytes), or 32 uniformly random bytes.
|
159
|
-
*/
|
160
|
-
function setMusig2Nonces(psbt, rootWalletKey, sessionId) {
|
161
|
-
if (rootWalletKey.isNeutered()) {
|
162
|
-
throw new Error('private key is required to generate nonce');
|
163
|
-
}
|
164
|
-
if (Buffer.isBuffer(sessionId) && sessionId.length !== 32) {
|
165
|
-
throw new Error(`Invalid sessionId size ${sessionId.length}`);
|
166
|
-
}
|
167
|
-
psbt.data.inputs.forEach((input, inputIndex) => {
|
168
|
-
const noncesKeyValueData = getMusig2NonceKeyValueData(psbt, inputIndex, rootWalletKey, sessionId);
|
169
|
-
if (noncesKeyValueData) {
|
170
|
-
psbt.addProprietaryKeyValToInput(inputIndex, noncesKeyValueData);
|
171
|
-
}
|
172
|
-
});
|
173
|
-
}
|
174
|
-
exports.setMusig2Nonces = setMusig2Nonces;
|
175
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTXVzaWcyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2JpdGdvL011c2lnMi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSx5Q0FBbUg7QUFDbkgsbURBQTZGO0FBRTdGLDRDQUEwQztBQUUxQyx3Q0FBNEM7QUFFNUMsZ0RBQXFEO0FBb0JyRDs7OztHQUlHO0FBQ0gsU0FBZ0Isc0NBQXNDLENBQ3BELHNCQUEwRDtJQUUxRCxNQUFNLE9BQU8sR0FBRyxDQUFDLHNCQUFzQixDQUFDLFlBQVksRUFBRSxzQkFBc0IsQ0FBQyxjQUFjLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxNQUFNLEVBQUUsRUFBRSxDQUMxRyxtQ0FBbUIsQ0FBQyxNQUFNLENBQUMsQ0FDNUIsQ0FBQztJQUNGLE1BQU0sS0FBSyxHQUFHLHNCQUFz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TXVzaWcyTm9uY2VzKHBzYnQ6IFV0eG9Qc2J0LCByb290V2FsbGV0S2V5OiBCSVAzMkludGVyZmFjZSwgc2Vzc2lvbklkPzogQnVmZmVyKTogdm9pZCB7XG4gIGlmIChyb290V2FsbGV0S2V5LmlzTmV1dGVyZWQoKSkge1xuICAgIHRocm93IG5ldyBFcnJvcigncHJpdmF0ZSBrZXkgaXMgcmVxdWlyZWQgdG8gZ2VuZXJhdGUgbm9uY2UnKTtcbiAgfVxuICBpZiAoQnVmZmVyLmlzQnVmZmVyKHNlc3Npb25JZCkgJiYgc2Vzc2lvbklkLmxlbmd0aCAhPT0gMzIpIHtcbiAgICB0aHJvdyBuZXcgRXJyb3IoYEludmFsaWQgc2Vzc2lvbklkIHNpemUgJHtzZXNzaW9uSWQubGVuZ3RofWApO1xuICB9XG4gIHBzYnQuZGF0YS5pbnB1dHMuZm9yRWFjaCgoaW5wdXQsIGlucHV0SW5kZXgpID0+IHtcbiAgICBjb25zdCBub25jZXNLZXlWYWx1ZURhdGEgPSBnZXRNdXNpZzJOb25jZUtleVZhbHVlRGF0YShwc2J0LCBpbnB1dEluZGV4LCByb290V2FsbGV0S2V5LCBzZXNzaW9uSWQpO1xuICAgIGlmIChub25jZXNLZXlWYWx1ZURhdGEpIHtcbiAgICAgIHBzYnQuYWRkUHJvcHJpZXRhcnlLZXlWYWxUb0lucHV0KGlucHV0SW5kZXgsIG5vbmNlc0tleVZhbHVlRGF0YSk7XG4gICAgfVxuICB9KTtcbn1cbiJdfQ==
|
@@ -1,95 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
import { TxOutput } from 'bitcoinjs-lib';
|
3
|
-
import { Network } from '..';
|
4
|
-
import { UtxoTransactionBuilder } from './UtxoTransactionBuilder';
|
5
|
-
import { UtxoTransaction } from './UtxoTransaction';
|
6
|
-
/**
|
7
|
-
* Public unspent data in BitGo-specific representation.
|
8
|
-
*/
|
9
|
-
export interface Unspent<TNumber extends number | bigint = number> {
|
10
|
-
/**
|
11
|
-
* Format: ${txid}:${vout}.
|
12
|
-
* Use `parseOutputId(id)` to parse.
|
13
|
-
*/
|
14
|
-
id: string;
|
15
|
-
/**
|
16
|
-
* The network-specific encoded address.
|
17
|
-
* Use `toOutputScript(address, network)` to obtain scriptPubKey.
|
18
|
-
*/
|
19
|
-
address: string;
|
20
|
-
/**
|
21
|
-
* The amount in satoshi.
|
22
|
-
*/
|
23
|
-
value: TNumber;
|
24
|
-
}
|
25
|
-
export interface UnspentWithPrevTx<TNumber extends number | bigint = number> extends Unspent<TNumber> {
|
26
|
-
prevTx: Buffer;
|
27
|
-
}
|
28
|
-
export declare function isUnspentWithPrevTx<TNumber extends number | bigint, TUnspent extends Unspent<TNumber>>(u: Unspent<TNumber>): u is TUnspent & {
|
29
|
-
prevTx: Buffer;
|
30
|
-
};
|
31
|
-
/**
|
32
|
-
* @return TxOutput from Unspent
|
33
|
-
*/
|
34
|
-
export declare function toOutput<TNumber extends number | bigint>(u: Unspent<TNumber>, network: Network): TxOutput<TNumber>;
|
35
|
-
/**
|
36
|
-
* @return Unspent from TxOutput
|
37
|
-
*/
|
38
|
-
export declare function fromOutput<TNumber extends number | bigint>(tx: UtxoTransaction<TNumber>, vout: number): Unspent<TNumber>;
|
39
|
-
export declare function fromOutputWithPrevTx<TNumber extends number | bigint>(tx: UtxoTransaction<TNumber>, vout: number): UnspentWithPrevTx<TNumber>;
|
40
|
-
/**
|
41
|
-
* @param outputId
|
42
|
-
* @return TxOutPoint
|
43
|
-
*/
|
44
|
-
export declare function parseOutputId(outputId: string): TxOutPoint;
|
45
|
-
/**
|
46
|
-
* @param txid
|
47
|
-
* @param vout
|
48
|
-
* @return outputId
|
49
|
-
*/
|
50
|
-
export declare function formatOutputId({ txid, vout }: TxOutPoint): string;
|
51
|
-
export declare function getOutputIdForInput(i: {
|
52
|
-
hash: Buffer;
|
53
|
-
index: number;
|
54
|
-
}): TxOutPoint;
|
55
|
-
/**
|
56
|
-
* Reference to output of an existing transaction
|
57
|
-
*/
|
58
|
-
export declare type TxOutPoint = {
|
59
|
-
txid: string;
|
60
|
-
vout: number;
|
61
|
-
};
|
62
|
-
/**
|
63
|
-
* Output reference and script data.
|
64
|
-
* Suitable for use for `txb.addInput()`
|
65
|
-
*/
|
66
|
-
export declare type PrevOutput<TNumber extends number | bigint = number> = TxOutPoint & TxOutput<TNumber> & {
|
67
|
-
prevTx?: Buffer;
|
68
|
-
};
|
69
|
-
/**
|
70
|
-
* @return PrevOutput from Unspent
|
71
|
-
*/
|
72
|
-
export declare function toPrevOutput<TNumber extends number | bigint>(u: Unspent<TNumber>, network: Network): PrevOutput<TNumber>;
|
73
|
-
/**
|
74
|
-
* @return PrevOutput with prevTx from Unspent
|
75
|
-
*/
|
76
|
-
export declare function toPrevOutputWithPrevTx<TNumber extends number | bigint>(u: Unspent<TNumber> & {
|
77
|
-
prevTx?: unknown;
|
78
|
-
}, network: Network): PrevOutput<TNumber>;
|
79
|
-
/**
|
80
|
-
* @param txb
|
81
|
-
* @param u
|
82
|
-
* @param sequence - sequenceId
|
83
|
-
*/
|
84
|
-
export declare function addToTransactionBuilder<TNumber extends number | bigint>(txb: UtxoTransactionBuilder<TNumber>, u: Unspent<TNumber>, sequence?: number): void;
|
85
|
-
/**
|
86
|
-
* Sum the values of the unspents.
|
87
|
-
* Throws error if sum is not a safe integer value, or if unspent amount types do not match `amountType`
|
88
|
-
* @param unspents - array of unspents to sum
|
89
|
-
* @param amountType - expected value type of unspents
|
90
|
-
* @return unspentSum - type matches amountType
|
91
|
-
*/
|
92
|
-
export declare function unspentSum<TNumber extends number | bigint>(unspents: {
|
93
|
-
value: TNumber;
|
94
|
-
}[], amountType?: 'number' | 'bigint'): TNumber;
|
95
|
-
//# sourceMappingURL=Unspent.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"Unspent.d.ts","sourceRoot":"","sources":["../../../src/bitgo/Unspent.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,E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;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EACxD,QAAQ,EAAE;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,EAAE,EAC9B,UAAU,GAAE,QAAQ,GAAG,QAAmB,GACzC,OAAO,CAUT"}
|
@@ -1,138 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.unspentSum = exports.addToTransactionBuilder = exports.toPrevOutputWithPrevTx = exports.toPrevOutput = exports.getOutputIdForInput = exports.formatOutputId = exports.parseOutputId = exports.fromOutputWithPrevTx = exports.fromOutput = exports.toOutput = exports.isUnspentWithPrevTx = void 0;
|
4
|
-
const address_1 = require("../address");
|
5
|
-
function isUnspentWithPrevTx(u) {
|
6
|
-
return Buffer.isBuffer(u.prevTx);
|
7
|
-
}
|
8
|
-
exports.isUnspentWithPrevTx = isUnspentWithPrevTx;
|
9
|
-
/**
|
10
|
-
* @return TxOutput from Unspent
|
11
|
-
*/
|
12
|
-
function toOutput(u, network) {
|
13
|
-
return {
|
14
|
-
script: address_1.toOutputScript(u.address, network),
|
15
|
-
value: u.value,
|
16
|
-
};
|
17
|
-
}
|
18
|
-
exports.toOutput = toOutput;
|
19
|
-
/**
|
20
|
-
* @return Unspent from TxOutput
|
21
|
-
*/
|
22
|
-
function fromOutput(tx, vout) {
|
23
|
-
const o = tx.outs[vout];
|
24
|
-
if (!o) {
|
25
|
-
throw new Error(`invalid vout`);
|
26
|
-
}
|
27
|
-
return {
|
28
|
-
id: formatOutputId({ txid: tx.getId(), vout }),
|
29
|
-
address: address_1.fromOutputScript(o.script, tx.network),
|
30
|
-
value: o.value,
|
31
|
-
};
|
32
|
-
}
|
33
|
-
exports.fromOutput = fromOutput;
|
34
|
-
function fromOutputWithPrevTx(tx, vout) {
|
35
|
-
return {
|
36
|
-
...fromOutput(tx, vout),
|
37
|
-
prevTx: tx.toBuffer(),
|
38
|
-
};
|
39
|
-
}
|
40
|
-
exports.fromOutputWithPrevTx = fromOutputWithPrevTx;
|
41
|
-
/**
|
42
|
-
* @param outputId
|
43
|
-
* @return TxOutPoint
|
44
|
-
*/
|
45
|
-
function parseOutputId(outputId) {
|
46
|
-
const parts = outputId.split(':');
|
47
|
-
if (parts.length !== 2) {
|
48
|
-
throw new Error(`invalid outputId, must have format txid:vout`);
|
49
|
-
}
|
50
|
-
const [txid, voutStr] = parts;
|
51
|
-
const vout = Number(voutStr);
|
52
|
-
if (txid.length !== 64) {
|
53
|
-
throw new Error(`invalid txid ${txid} ${txid.length}`);
|
54
|
-
}
|
55
|
-
if (Number.isNaN(vout) || vout < 0 || !Number.isSafeInteger(vout)) {
|
56
|
-
throw new Error(`invalid vout: must be integer >= 0`);
|
57
|
-
}
|
58
|
-
return { txid, vout };
|
59
|
-
}
|
60
|
-
exports.parseOutputId = parseOutputId;
|
61
|
-
/**
|
62
|
-
* @param txid
|
63
|
-
* @param vout
|
64
|
-
* @return outputId
|
65
|
-
*/
|
66
|
-
function formatOutputId({ txid, vout }) {
|
67
|
-
return `${txid}:${vout}`;
|
68
|
-
}
|
69
|
-
exports.formatOutputId = formatOutputId;
|
70
|
-
function getOutputIdForInput(i) {
|
71
|
-
return {
|
72
|
-
txid: Buffer.from(i.hash).reverse().toString('hex'),
|
73
|
-
vout: i.index,
|
74
|
-
};
|
75
|
-
}
|
76
|
-
exports.getOutputIdForInput = getOutputIdForInput;
|
77
|
-
/**
|
78
|
-
* @return PrevOutput from Unspent
|
79
|
-
*/
|
80
|
-
function toPrevOutput(u, network) {
|
81
|
-
return {
|
82
|
-
...parseOutputId(u.id),
|
83
|
-
...toOutput(u, network),
|
84
|
-
};
|
85
|
-
}
|
86
|
-
exports.toPrevOutput = toPrevOutput;
|
87
|
-
/**
|
88
|
-
* @return PrevOutput with prevTx from Unspent
|
89
|
-
*/
|
90
|
-
function toPrevOutputWithPrevTx(u, network) {
|
91
|
-
let prevTx;
|
92
|
-
if (typeof u.prevTx === 'string') {
|
93
|
-
prevTx = Buffer.from(u.prevTx, 'hex');
|
94
|
-
}
|
95
|
-
else if (Buffer.isBuffer(u.prevTx)) {
|
96
|
-
prevTx = u.prevTx;
|
97
|
-
}
|
98
|
-
else if (u.prevTx !== undefined) {
|
99
|
-
throw new Error(`Invalid prevTx type for unspent ${u.prevTx}`);
|
100
|
-
}
|
101
|
-
return {
|
102
|
-
...parseOutputId(u.id),
|
103
|
-
...toOutput(u, network),
|
104
|
-
prevTx,
|
105
|
-
};
|
106
|
-
}
|
107
|
-
exports.toPrevOutputWithPrevTx = toPrevOutputWithPrevTx;
|
108
|
-
/**
|
109
|
-
* @param txb
|
110
|
-
* @param u
|
111
|
-
* @param sequence - sequenceId
|
112
|
-
*/
|
113
|
-
function addToTransactionBuilder(txb, u, sequence) {
|
114
|
-
const { txid, vout, script, value } = toPrevOutput(u, txb.network);
|
115
|
-
txb.addInput(txid, vout, sequence, script, value);
|
116
|
-
}
|
117
|
-
exports.addToTransactionBuilder = addToTransactionBuilder;
|
118
|
-
/**
|
119
|
-
* Sum the values of the unspents.
|
120
|
-
* Throws error if sum is not a safe integer value, or if unspent amount types do not match `amountType`
|
121
|
-
* @param unspents - array of unspents to sum
|
122
|
-
* @param amountType - expected value type of unspents
|
123
|
-
* @return unspentSum - type matches amountType
|
124
|
-
*/
|
125
|
-
function unspentSum(unspents, amountType = 'number') {
|
126
|
-
if (amountType === 'bigint') {
|
127
|
-
return unspents.reduce((sum, u) => sum + u.value, BigInt(0));
|
128
|
-
}
|
129
|
-
else {
|
130
|
-
const sum = unspents.reduce((sum, u) => sum + u.value, Number(0));
|
131
|
-
if (!Number.isSafeInteger(sum)) {
|
132
|
-
throw new Error('unspent sum is not a safe integer number, consider using bigint');
|
133
|
-
}
|
134
|
-
return sum;
|
135
|
-
}
|
136
|
-
}
|
137
|
-
exports.unspentSum = unspentSum;
|
138
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiV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xuIl19
|
@@ -1,132 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
import { Psbt as PsbtBase } from 'bip174';
|
3
|
-
import { HDSigner, Psbt, TxOutput, Network } from '..';
|
4
|
-
import { UtxoTransaction } from './UtxoTransaction';
|
5
|
-
import { ProprietaryKey } from 'bip174/src/lib/proprietaryKeyVal';
|
6
|
-
export declare const PSBT_PROPRIETARY_IDENTIFIER = "BITGO";
|
7
|
-
export declare enum ProprietaryKeySubtype {
|
8
|
-
ZEC_CONSENSUS_BRANCH_ID = 0,
|
9
|
-
MUSIG2_PARTICIPANT_PUB_KEYS = 1,
|
10
|
-
MUSIG2_PUB_NONCE = 2
|
11
|
-
}
|
12
|
-
export interface HDTaprootSigner extends HDSigner {
|
13
|
-
/**
|
14
|
-
* The path string must match /^m(\/\d+'?)+$/
|
15
|
-
* ex. m/44'/0'/0'/1/23 levels with ' must be hard derivations
|
16
|
-
*/
|
17
|
-
derivePath(path: string): HDTaprootSigner;
|
18
|
-
/**
|
19
|
-
* Input hash (the "message digest") for the signature algorithm
|
20
|
-
* Return a 64 byte signature (32 byte r and 32 byte s in that order)
|
21
|
-
*/
|
22
|
-
signSchnorr(hash: Buffer): Buffer;
|
23
|
-
}
|
24
|
-
export interface SchnorrSigner {
|
25
|
-
publicKey: Buffer;
|
26
|
-
signSchnorr(hash: Buffer): Buffer;
|
27
|
-
}
|
28
|
-
export interface TaprootSigner {
|
29
|
-
leafHashes: Buffer[];
|
30
|
-
signer: SchnorrSigner;
|
31
|
-
}
|
32
|
-
export interface PsbtOpts {
|
33
|
-
network: Network;
|
34
|
-
maximumFeeRate?: number;
|
35
|
-
bip32PathsAbsolute?: boolean;
|
36
|
-
}
|
37
|
-
/**
|
38
|
-
* Psbt proprietary keydata object.
|
39
|
-
* <compact size uint identifier length> <bytes identifier> <compact size uint subtype> <bytes subkeydata>
|
40
|
-
* => <bytes valuedata>
|
41
|
-
*/
|
42
|
-
export interface ProprietaryKeyValueData {
|
43
|
-
key: ProprietaryKey;
|
44
|
-
value: Buffer;
|
45
|
-
}
|
46
|
-
/**
|
47
|
-
* Psbt proprietary keydata object search fields.
|
48
|
-
* <compact size uint identifier length> <bytes identifier> <compact size uint subtype> <bytes subkeydata>
|
49
|
-
*/
|
50
|
-
export interface ProprietaryKeySearch {
|
51
|
-
identifier: string;
|
52
|
-
subtype: number;
|
53
|
-
keydata?: Buffer;
|
54
|
-
identifierEncoding?: BufferEncoding;
|
55
|
-
}
|
56
|
-
export declare class UtxoPsbt<Tx extends UtxoTransaction<bigint> = UtxoTransaction<bigint>> extends Psbt {
|
57
|
-
protected static transactionFromBuffer(buffer: Buffer, network: Network): UtxoTransaction<bigint>;
|
58
|
-
static createPsbt(opts: PsbtOpts, data?: PsbtBase): UtxoPsbt;
|
59
|
-
static fromBuffer(buffer: Buffer, opts: PsbtOpts): UtxoPsbt;
|
60
|
-
static fromHex(data: string, opts: PsbtOpts): UtxoPsbt;
|
61
|
-
get network(): Network;
|
62
|
-
toHex(): string;
|
63
|
-
/**
|
64
|
-
* @return true iff PSBT input is finalized
|
65
|
-
*/
|
66
|
-
isInputFinalized(inputIndex: number): boolean;
|
67
|
-
/**
|
68
|
-
* @return partialSig/tapScriptSig count iff input is not finalized
|
69
|
-
*/
|
70
|
-
getSignatureCount(inputIndex: number): number;
|
71
|
-
getNonWitnessPreviousTxids(): string[];
|
72
|
-
addNonWitnessUtxos(txBufs: Record<string, Buffer>): this;
|
73
|
-
static fromTransaction(transaction: UtxoTransaction<bigint>, prevOutputs: TxOutput<bigint>[]): UtxoPsbt;
|
74
|
-
getUnsignedTx(): UtxoTransaction<bigint>;
|
75
|
-
protected static newTransaction(network: Network): UtxoTransaction<bigint>;
|
76
|
-
protected get tx(): Tx;
|
77
|
-
protected checkForSignatures(propName?: string): void;
|
78
|
-
/**
|
79
|
-
* Mostly copied from bitcoinjs-lib/ts_src/psbt.ts
|
80
|
-
*/
|
81
|
-
finalizeAllInputs(): this;
|
82
|
-
finalizeTaprootInput(inputIndex: number): this;
|
83
|
-
finalizeTapInputWithSingleLeafScriptAndSignature(inputIndex: number): this;
|
84
|
-
/**
|
85
|
-
* Mostly copied from bitcoinjs-lib/ts_src/psbt.ts
|
86
|
-
*
|
87
|
-
* Unlike the function it overrides, this does not take a validator. In BitGo
|
88
|
-
* context, we know how we want to validate so we just hard code the right
|
89
|
-
* validator.
|
90
|
-
*/
|
91
|
-
validateSignaturesOfAllInputs(): boolean;
|
92
|
-
validateTaprootSignaturesOfInput(inputIndex: number, pubkey?: Buffer): boolean;
|
93
|
-
/**
|
94
|
-
* @return array of boolean values. True when corresponding index in `publicKeys` has signed the transaction.
|
95
|
-
* If no signature in the tx or no public key matching signature, the validation is considered as false.
|
96
|
-
*/
|
97
|
-
getSignatureValidationArray(inputIndex: number): boolean[];
|
98
|
-
/**
|
99
|
-
* Mostly copied from bitcoinjs-lib/ts_src/psbt.ts
|
100
|
-
*/
|
101
|
-
signAllInputsHD(hdKeyPair: HDTaprootSigner, sighashTypes?: number[]): this;
|
102
|
-
/**
|
103
|
-
* Mostly copied from bitcoinjs-lib/ts_src/psbt.ts:signInputHD
|
104
|
-
*/
|
105
|
-
signTaprootInputHD(inputIndex: number, hdKeyPair: HDTaprootSigner, sighashTypes?: number[]): this;
|
106
|
-
signTaprootInput(inputIndex: number, signer: SchnorrSigner, leafHashes: Buffer[], sighashTypes?: number[]): this;
|
107
|
-
private getTaprootHashForSig;
|
108
|
-
/**
|
109
|
-
* @retuns true iff the input is taproot.
|
110
|
-
*/
|
111
|
-
isTaprootInput(inputIndex: number): boolean;
|
112
|
-
/**
|
113
|
-
* @returns hash and hashType for taproot input at inputIndex
|
114
|
-
* @throws error if input at inputIndex is not a taproot input
|
115
|
-
*/
|
116
|
-
getTaprootHashForSigChecked(inputIndex: number, sighashTypes?: number[], leafHash?: Buffer): {
|
117
|
-
hash: Buffer;
|
118
|
-
sighashType: number;
|
119
|
-
};
|
120
|
-
/**
|
121
|
-
* Adds proprietary key value pair to PSBT input.
|
122
|
-
* Default identifierEncoding is utf-8 for identifier.
|
123
|
-
*/
|
124
|
-
addProprietaryKeyValToInput(inputIndex: number, keyValueData: ProprietaryKeyValueData): this;
|
125
|
-
/**
|
126
|
-
* To search any data from proprietary key value againts keydata.
|
127
|
-
* Default identifierEncoding is utf-8 for identifier.
|
128
|
-
*/
|
129
|
-
getProprietaryKeyVals(inputIndex: number, keySearch?: ProprietaryKeySearch): ProprietaryKeyValueData[];
|
130
|
-
clone(): this;
|
131
|
-
}
|
132
|
-
//# sourceMappingURL=UtxoPsbt.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"UtxoPsbt.d.ts","sourceRoot":"","sources":["../../../src/bitgo/UtxoPsbt.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAK1C,OAAO,EAEL,QAAQ,EACR,IAAI,EAGJ,QAAQ,EACR,OAAO,EAGR,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAQpD,OAAO,EAA8C,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAE9G,eAAO,MAAM,2BAA2B,UAAU,CAAC;AAEnD,oBAAY,qBAAqB;IAC/B,uBAAuB,IAAO;IAC9B,2BAA2B,IAAO;IAClC,gBAAgB,IAAO;CACxB;AAED,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C;;;OAGG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC;IAC1C;;;OAGG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACnC;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACnC;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE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