utxo-lib 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/src/address.d.ts.map +1 -1
- package/dist/src/address.js +1 -11
- package/dist/src/addressFormat.d.ts +1 -1
- package/dist/src/addressFormat.d.ts.map +1 -1
- package/dist/src/addressFormat.js +1 -1
- package/dist/src/bitgo/Musig2.d.ts +17 -115
- package/dist/src/bitgo/Musig2.d.ts.map +1 -1
- package/dist/src/bitgo/Musig2.js +101 -283
- package/dist/src/bitgo/UtxoPsbt.d.ts +49 -173
- package/dist/src/bitgo/UtxoPsbt.d.ts.map +1 -1
- package/dist/src/bitgo/UtxoPsbt.js +112 -634
- 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/{litecoin → bbc}/index.js +4 -4
- package/dist/src/bitgo/bitcoincash/address.js +2 -2
- package/dist/src/bitgo/index.d.ts +0 -10
- package/dist/src/bitgo/index.d.ts.map +1 -1
- package/dist/src/bitgo/index.js +2 -5
- package/dist/src/bitgo/outputScripts.d.ts +1 -3
- package/dist/src/bitgo/outputScripts.d.ts.map +1 -1
- package/dist/src/bitgo/outputScripts.js +10 -18
- package/dist/src/bitgo/parseInput.d.ts +20 -49
- package/dist/src/bitgo/parseInput.d.ts.map +1 -1
- package/dist/src/bitgo/parseInput.js +24 -108
- package/dist/src/bitgo/psbt/fromHalfSigned.d.ts.map +1 -1
- package/dist/src/bitgo/psbt/fromHalfSigned.js +6 -9
- package/dist/src/bitgo/signature.d.ts +3 -3
- package/dist/src/bitgo/signature.d.ts.map +1 -1
- package/dist/src/bitgo/signature.js +16 -48
- package/dist/src/bitgo/transaction.d.ts +3 -18
- package/dist/src/bitgo/transaction.d.ts.map +1 -1
- package/dist/src/bitgo/transaction.js +15 -28
- package/dist/src/bitgo/types.d.ts +0 -2
- package/dist/src/bitgo/types.d.ts.map +1 -1
- package/dist/src/bitgo/types.js +1 -1
- package/dist/src/bitgo/wallet/Psbt.d.ts +12 -90
- package/dist/src/bitgo/wallet/Psbt.d.ts.map +1 -1
- package/dist/src/bitgo/wallet/Psbt.js +71 -221
- package/dist/src/bitgo/wallet/Unspent.d.ts +0 -28
- package/dist/src/bitgo/wallet/Unspent.d.ts.map +1 -1
- package/dist/src/bitgo/wallet/Unspent.js +68 -173
- package/dist/src/bitgo/wallet/chains.d.ts +2 -2
- package/dist/src/bitgo/wallet/chains.d.ts.map +1 -1
- package/dist/src/bitgo/wallet/chains.js +1 -1
- package/dist/src/bitgo/zcash/ZcashPsbt.d.ts.map +1 -1
- package/dist/src/bitgo/zcash/ZcashPsbt.js +3 -4
- package/dist/src/networks.d.ts +2 -1
- package/dist/src/networks.d.ts.map +1 -1
- package/dist/src/networks.js +29 -22
- package/dist/src/noble_ecc.d.ts.map +1 -1
- package/dist/src/noble_ecc.js +2 -6
- package/dist/src/payments/p2tr.d.ts.map +1 -1
- package/dist/src/payments/p2tr.js +9 -15
- package/dist/src/taproot.d.ts +0 -16
- package/dist/src/taproot.d.ts.map +1 -1
- package/dist/src/taproot.js +2 -44
- package/dist/src/testutil/index.d.ts +0 -2
- package/dist/src/testutil/index.d.ts.map +1 -1
- package/dist/src/testutil/index.js +1 -3
- package/dist/src/testutil/mock.d.ts +1 -1
- package/dist/src/testutil/mock.d.ts.map +1 -1
- package/dist/src/testutil/mock.js +4 -12
- package/package.json +4 -6
- package/dist/src/bitgo/PsbtUtil.d.ts +0 -54
- package/dist/src/bitgo/PsbtUtil.d.ts.map +0 -1
- package/dist/src/bitgo/PsbtUtil.js +0 -79
- package/dist/src/bitgo/litecoin/LitecoinPsbt.d.ts +0 -10
- package/dist/src/bitgo/litecoin/LitecoinPsbt.d.ts.map +0 -1
- package/dist/src/bitgo/litecoin/LitecoinPsbt.js +0 -17
- package/dist/src/bitgo/litecoin/LitecoinTransaction.d.ts +0 -16
- package/dist/src/bitgo/litecoin/LitecoinTransaction.d.ts.map +0 -1
- package/dist/src/bitgo/litecoin/LitecoinTransaction.js +0 -46
- package/dist/src/bitgo/litecoin/LitecoinTransactionBuilder.d.ts +0 -10
- package/dist/src/bitgo/litecoin/LitecoinTransactionBuilder.d.ts.map +0 -1
- package/dist/src/bitgo/litecoin/LitecoinTransactionBuilder.js +0 -15
- package/dist/src/bitgo/litecoin/index.d.ts +0 -4
- package/dist/src/bitgo/litecoin/index.d.ts.map +0 -1
- package/dist/src/testutil/psbt.d.ts +0 -71
- package/dist/src/testutil/psbt.d.ts.map +0 -1
- package/dist/src/testutil/psbt.js +0 -147
- package/dist/src/testutil/transaction.d.ts +0 -61
- package/dist/src/testutil/transaction.d.ts.map +0 -1
- package/dist/src/testutil/transaction.js +0 -107
@@ -1,12 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.UtxoPsbt = void 0;
|
3
|
+
exports.UtxoPsbt = exports.ProprietaryKeySubtype = exports.PSBT_PROPRIETARY_IDENTIFIER = void 0;
|
4
4
|
const bip174_1 = require("bip174");
|
5
5
|
const utils_1 = require("bip174/src/lib/utils");
|
6
6
|
const bufferutils_1 = require("bitcoinjs-lib/src/bufferutils");
|
7
|
-
const bip32_1 = require("bip32");
|
8
|
-
const bs58check = require("bs58check");
|
9
|
-
const proprietaryKeyVal_1 = require("bip174/src/lib/proprietaryKeyVal");
|
10
7
|
const __1 = require("..");
|
11
8
|
const UtxoTransaction_1 = require("./UtxoTransaction");
|
12
9
|
const Unspent_1 = require("./Unspent");
|
@@ -14,43 +11,20 @@ const scriptTypes_1 = require("./psbt/scriptTypes");
|
|
14
11
|
const fromHalfSigned_1 = require("./psbt/fromHalfSigned");
|
15
12
|
const outputScripts_1 = require("./outputScripts");
|
16
13
|
const parseInput_1 = require("./parseInput");
|
17
|
-
const
|
18
|
-
const
|
19
|
-
const
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
case __1.networks.ecash:
|
28
|
-
return [...sighashTypes, ...sighashTypes.map((s) => s | UtxoTransaction_1.UtxoTransaction.SIGHASH_FORKID)];
|
29
|
-
default:
|
30
|
-
return sighashTypes;
|
31
|
-
}
|
32
|
-
}
|
33
|
-
function toSignatureParams(network, v) {
|
34
|
-
if (Array.isArray(v))
|
35
|
-
return toSignatureParams(network, { sighashTypes: v });
|
36
|
-
return { deterministic: false, sighashTypes: defaultSighashTypes(network), ...v };
|
37
|
-
}
|
38
|
-
/**
|
39
|
-
* @param a
|
40
|
-
* @param b
|
41
|
-
* @returns true if the two public keys are equal ignoring the y coordinate.
|
42
|
-
*/
|
43
|
-
function equalPublicKeyIgnoreY(a, b) {
|
44
|
-
return outputScripts_1.toXOnlyPublicKey(a).equals(outputScripts_1.toXOnlyPublicKey(b));
|
45
|
-
}
|
14
|
+
const bip32_1 = require("bip32");
|
15
|
+
const bs58check = require("bs58check");
|
16
|
+
const proprietaryKeyVal_1 = require("bip174/src/lib/proprietaryKeyVal");
|
17
|
+
exports.PSBT_PROPRIETARY_IDENTIFIER = 'BITGO';
|
18
|
+
var ProprietaryKeySubtype;
|
19
|
+
(function (ProprietaryKeySubtype) {
|
20
|
+
ProprietaryKeySubtype[ProprietaryKeySubtype["ZEC_CONSENSUS_BRANCH_ID"] = 0] = "ZEC_CONSENSUS_BRANCH_ID";
|
21
|
+
ProprietaryKeySubtype[ProprietaryKeySubtype["MUSIG2_PARTICIPANT_PUB_KEYS"] = 1] = "MUSIG2_PARTICIPANT_PUB_KEYS";
|
22
|
+
ProprietaryKeySubtype[ProprietaryKeySubtype["MUSIG2_PUB_NONCE"] = 2] = "MUSIG2_PUB_NONCE";
|
23
|
+
})(ProprietaryKeySubtype = exports.ProprietaryKeySubtype || (exports.ProprietaryKeySubtype = {}));
|
46
24
|
// TODO: upstream does `checkInputsForPartialSigs` before doing things like
|
47
25
|
// `setVersion`. Our inputs could have tapscriptsigs (or in future tapkeysigs)
|
48
26
|
// and not fail that check. Do we want to do anything about that?
|
49
27
|
class UtxoPsbt extends __1.Psbt {
|
50
|
-
constructor() {
|
51
|
-
super(...arguments);
|
52
|
-
this.nonceStore = new Musig2_1.Musig2NonceStore();
|
53
|
-
}
|
54
28
|
static transactionFromBuffer(buffer, network) {
|
55
29
|
return UtxoTransaction_1.UtxoTransaction.fromBuffer(buffer, false, 'bigint', network);
|
56
30
|
}
|
@@ -72,47 +46,29 @@ class UtxoPsbt extends __1.Psbt {
|
|
72
46
|
static fromHex(data, opts) {
|
73
47
|
return this.fromBuffer(Buffer.from(data, 'hex'), opts);
|
74
48
|
}
|
75
|
-
/**
|
76
|
-
* @param parent - Parent key. Matched with `bip32Derivations` using `fingerprint` property.
|
77
|
-
* @param bip32Derivations - possible derivations for input or output
|
78
|
-
* @param ignoreY - when true, ignore the y coordinate when matching public keys
|
79
|
-
* @return derived bip32 node if matching derivation is found, undefined if none is found
|
80
|
-
* @throws Error if more than one match is found
|
81
|
-
*/
|
82
|
-
static deriveKeyPair(parent, bip32Derivations, { ignoreY }) {
|
83
|
-
const matchingDerivations = bip32Derivations.filter((bipDv) => {
|
84
|
-
return bipDv.masterFingerprint.equals(parent.fingerprint);
|
85
|
-
});
|
86
|
-
if (!matchingDerivations.length) {
|
87
|
-
// No fingerprint match
|
88
|
-
return undefined;
|
89
|
-
}
|
90
|
-
if (matchingDerivations.length !== 1) {
|
91
|
-
throw new Error(`more than one matching derivation for fingerprint ${parent.fingerprint.toString('hex')}: ${matchingDerivations.length}`);
|
92
|
-
}
|
93
|
-
const [derivation] = matchingDerivations;
|
94
|
-
const node = parent.derivePath(derivation.path);
|
95
|
-
if (!node.publicKey.equals(derivation.pubkey)) {
|
96
|
-
if (!ignoreY || !equalPublicKeyIgnoreY(node.publicKey, derivation.pubkey)) {
|
97
|
-
throw new Error('pubkey did not match bip32Derivation');
|
98
|
-
}
|
99
|
-
}
|
100
|
-
return node;
|
101
|
-
}
|
102
|
-
static deriveKeyPairForInput(bip32, input) {
|
103
|
-
var _a, _b, _c, _d;
|
104
|
-
return ((_a = input.tapBip32Derivation) === null || _a === void 0 ? void 0 : _a.length)
|
105
|
-
? (_b = UtxoPsbt.deriveKeyPair(bip32, input.tapBip32Derivation, { ignoreY: true })) === null || _b === void 0 ? void 0 : _b.publicKey
|
106
|
-
: ((_c = input.bip32Derivation) === null || _c === void 0 ? void 0 : _c.length)
|
107
|
-
? (_d = UtxoPsbt.deriveKeyPair(bip32, input.bip32Derivation, { ignoreY: false })) === null || _d === void 0 ? void 0 : _d.publicKey
|
108
|
-
: bip32 === null || bip32 === void 0 ? void 0 : bip32.publicKey;
|
109
|
-
}
|
110
49
|
get network() {
|
111
50
|
return this.tx.network;
|
112
51
|
}
|
113
52
|
toHex() {
|
114
53
|
return this.toBuffer().toString('hex');
|
115
54
|
}
|
55
|
+
/**
|
56
|
+
* @return true iff PSBT input is finalized
|
57
|
+
*/
|
58
|
+
isInputFinalized(inputIndex) {
|
59
|
+
const input = utils_1.checkForInput(this.data.inputs, inputIndex);
|
60
|
+
return Buffer.isBuffer(input.finalScriptSig) || Buffer.isBuffer(input.finalScriptWitness);
|
61
|
+
}
|
62
|
+
/**
|
63
|
+
* @return partialSig/tapScriptSig count iff input is not finalized
|
64
|
+
*/
|
65
|
+
getSignatureCount(inputIndex) {
|
66
|
+
if (this.isInputFinalized(inputIndex)) {
|
67
|
+
throw new Error('Input is already finalized');
|
68
|
+
}
|
69
|
+
const input = utils_1.checkForInput(this.data.inputs, inputIndex);
|
70
|
+
return Math.max(Array.isArray(input.partialSig) ? input.partialSig.length : 0, Array.isArray(input.tapScriptSig) ? input.tapScriptSig.length : 0);
|
71
|
+
}
|
116
72
|
getNonWitnessPreviousTxids() {
|
117
73
|
const txInputs = this.txInputs; // These are somewhat costly to extract
|
118
74
|
const txidSet = new Set();
|
@@ -175,99 +131,14 @@ class UtxoPsbt extends __1.Psbt {
|
|
175
131
|
}
|
176
132
|
});
|
177
133
|
}
|
178
|
-
/**
|
179
|
-
* @returns true if the input at inputIndex is a taproot key path.
|
180
|
-
* Checks for presence of minimum required key path input fields and absence of any script path only input fields.
|
181
|
-
*/
|
182
|
-
isTaprootKeyPathInput(inputIndex) {
|
183
|
-
var _a, _b, _c;
|
184
|
-
const input = utils_1.checkForInput(this.data.inputs, inputIndex);
|
185
|
-
return (!!input.tapInternalKey &&
|
186
|
-
!!input.tapMerkleRoot &&
|
187
|
-
!(((_a = input.tapLeafScript) === null || _a === void 0 ? void 0 : _a.length) ||
|
188
|
-
((_b = input.tapScriptSig) === null || _b === void 0 ? void 0 : _b.length) ||
|
189
|
-
((_c = input.tapBip32Derivation) === null || _c === void 0 ? void 0 : _c.some((v) => v.leafHashes.length))));
|
190
|
-
}
|
191
|
-
/**
|
192
|
-
* @returns true if the input at inputIndex is a taproot script path.
|
193
|
-
* Checks for presence of minimum required script path input fields and absence of any key path only input fields.
|
194
|
-
*/
|
195
|
-
isTaprootScriptPathInput(inputIndex) {
|
196
|
-
var _a;
|
197
|
-
const input = utils_1.checkForInput(this.data.inputs, inputIndex);
|
198
|
-
return (!!((_a = input.tapLeafScript) === null || _a === void 0 ? void 0 : _a.length) &&
|
199
|
-
!(this.getProprietaryKeyVals(inputIndex, {
|
200
|
-
identifier: PsbtUtil_1.PSBT_PROPRIETARY_IDENTIFIER,
|
201
|
-
subtype: PsbtUtil_1.ProprietaryKeySubtype.MUSIG2_PARTICIPANT_PUB_KEYS,
|
202
|
-
}).length ||
|
203
|
-
this.getProprietaryKeyVals(inputIndex, {
|
204
|
-
identifier: PsbtUtil_1.PSBT_PROPRIETARY_IDENTIFIER,
|
205
|
-
subtype: PsbtUtil_1.ProprietaryKeySubtype.MUSIG2_PUB_NONCE,
|
206
|
-
}).length ||
|
207
|
-
this.getProprietaryKeyVals(inputIndex, {
|
208
|
-
identifier: PsbtUtil_1.PSBT_PROPRIETARY_IDENTIFIER,
|
209
|
-
subtype: PsbtUtil_1.ProprietaryKeySubtype.MUSIG2_PARTIAL_SIG,
|
210
|
-
}).length));
|
211
|
-
}
|
212
|
-
/**
|
213
|
-
* @returns true if the input at inputIndex is a taproot
|
214
|
-
*/
|
215
|
-
isTaprootInput(inputIndex) {
|
216
|
-
var _a, _b, _c;
|
217
|
-
const input = utils_1.checkForInput(this.data.inputs, inputIndex);
|
218
|
-
const isP2TR = (script) => {
|
219
|
-
try {
|
220
|
-
taproot_1.getTaprootOutputKey(script);
|
221
|
-
return true;
|
222
|
-
}
|
223
|
-
catch (e) {
|
224
|
-
return false;
|
225
|
-
}
|
226
|
-
};
|
227
|
-
return !!(input.tapInternalKey ||
|
228
|
-
input.tapMerkleRoot ||
|
229
|
-
((_a = input.tapLeafScript) === null || _a === void 0 ? void 0 : _a.length) ||
|
230
|
-
((_b = input.tapBip32Derivation) === null || _b === void 0 ? void 0 : _b.length) ||
|
231
|
-
((_c = input.tapScriptSig) === null || _c === void 0 ? void 0 : _c.length) ||
|
232
|
-
this.getProprietaryKeyVals(inputIndex, {
|
233
|
-
identifier: PsbtUtil_1.PSBT_PROPRIETARY_IDENTIFIER,
|
234
|
-
subtype: PsbtUtil_1.ProprietaryKeySubtype.MUSIG2_PARTICIPANT_PUB_KEYS,
|
235
|
-
}).length ||
|
236
|
-
this.getProprietaryKeyVals(inputIndex, {
|
237
|
-
identifier: PsbtUtil_1.PSBT_PROPRIETARY_IDENTIFIER,
|
238
|
-
subtype: PsbtUtil_1.ProprietaryKeySubtype.MUSIG2_PUB_NONCE,
|
239
|
-
}).length ||
|
240
|
-
this.getProprietaryKeyVals(inputIndex, {
|
241
|
-
identifier: PsbtUtil_1.PSBT_PROPRIETARY_IDENTIFIER,
|
242
|
-
subtype: PsbtUtil_1.ProprietaryKeySubtype.MUSIG2_PARTIAL_SIG,
|
243
|
-
}).length ||
|
244
|
-
(input.witnessUtxo && isP2TR(input.witnessUtxo.script)));
|
245
|
-
}
|
246
134
|
/**
|
247
135
|
* Mostly copied from bitcoinjs-lib/ts_src/psbt.ts
|
248
136
|
*/
|
249
137
|
finalizeAllInputs() {
|
250
|
-
const isMultisigTaprootScript = (script) => {
|
251
|
-
try {
|
252
|
-
parseInput_1.parsePubScript2Of3(script, 'taprootScriptPathSpend');
|
253
|
-
return true;
|
254
|
-
}
|
255
|
-
catch (e) {
|
256
|
-
return false;
|
257
|
-
}
|
258
|
-
};
|
259
138
|
utils_1.checkForInput(this.data.inputs, 0); // making sure we have at least one
|
260
139
|
this.data.inputs.map((input, idx) => {
|
261
140
|
var _a;
|
262
|
-
|
263
|
-
return isMultisigTaprootScript(input.tapLeafScript[0].script)
|
264
|
-
? this.finalizeTaprootInput(idx)
|
265
|
-
: this.finalizeTapInputWithSingleLeafScriptAndSignature(idx);
|
266
|
-
}
|
267
|
-
else if (this.isTaprootKeyPathInput(idx)) {
|
268
|
-
return this.finalizeTaprootMusig2Input(idx);
|
269
|
-
}
|
270
|
-
return this.finalizeInput(idx);
|
141
|
+
return ((_a = input.tapScriptSig) === null || _a === void 0 ? void 0 : _a.length) ? this.finalizeTaprootInput(idx) : this.finalizeInput(idx);
|
271
142
|
});
|
272
143
|
return this;
|
273
144
|
}
|
@@ -280,9 +151,9 @@ class UtxoPsbt extends __1.Psbt {
|
|
280
151
|
}
|
281
152
|
const { controlBlock, script } = input.tapLeafScript[0];
|
282
153
|
const witness = [script, controlBlock];
|
283
|
-
const [pubkey1, pubkey2] = parseInput_1.
|
154
|
+
const [pubkey1, pubkey2] = parseInput_1.parsePubScript(script, 'p2tr').publicKeys;
|
284
155
|
for (const pk of [pubkey1, pubkey2]) {
|
285
|
-
const sig = (_b = input.tapScriptSig) === null || _b === void 0 ? void 0 : _b.find(({ pubkey }) =>
|
156
|
+
const sig = (_b = input.tapScriptSig) === null || _b === void 0 ? void 0 : _b.find(({ pubkey }) => pubkey.equals(pk));
|
286
157
|
if (!sig) {
|
287
158
|
throw new Error('Could not find signatures in Script Sig.');
|
288
159
|
}
|
@@ -296,30 +167,6 @@ class UtxoPsbt extends __1.Psbt {
|
|
296
167
|
this.data.clearFinalizedInput(inputIndex);
|
297
168
|
return this;
|
298
169
|
}
|
299
|
-
/**
|
300
|
-
* Finalizes a taproot musig2 input by aggregating all partial sigs.
|
301
|
-
* IMPORTANT: Always call validate* function before finalizing.
|
302
|
-
*/
|
303
|
-
finalizeTaprootMusig2Input(inputIndex) {
|
304
|
-
const input = utils_1.checkForInput(this.data.inputs, inputIndex);
|
305
|
-
const partialSigs = Musig2_1.parsePsbtMusig2PartialSigs(input);
|
306
|
-
if ((partialSigs === null || partialSigs === void 0 ? void 0 : partialSigs.length) !== 2) {
|
307
|
-
throw new Error(`invalid number of partial signatures ${partialSigs ? partialSigs.length : 0} to finalize`);
|
308
|
-
}
|
309
|
-
const { partialSigs: pSigs, sigHashType } = Musig2_1.getSigHashTypeFromSigs(partialSigs);
|
310
|
-
const { sessionKey } = this.getMusig2SessionKey(inputIndex, sigHashType);
|
311
|
-
const aggSig = Musig2_1.musig2AggregateSigs(pSigs.map((pSig) => pSig.partialSig), sessionKey);
|
312
|
-
const sig = sigHashType === __1.Transaction.SIGHASH_DEFAULT ? aggSig : Buffer.concat([aggSig, Buffer.of(sigHashType)]);
|
313
|
-
// single signature with 64/65 bytes size is script witness for key path spend
|
314
|
-
const bufferWriter = bufferutils_1.BufferWriter.withCapacity(1 + bufferutils_1.varuint.encodingLength(sig.length) + sig.length);
|
315
|
-
bufferWriter.writeVector([sig]);
|
316
|
-
const finalScriptWitness = bufferWriter.end();
|
317
|
-
this.data.updateInput(inputIndex, { finalScriptWitness });
|
318
|
-
this.data.clearFinalizedInput(inputIndex);
|
319
|
-
// deleting only BitGo proprietary key values.
|
320
|
-
this.deleteProprietaryKeyVals(inputIndex, { identifier: PsbtUtil_1.PSBT_PROPRIETARY_IDENTIFIER });
|
321
|
-
return this;
|
322
|
-
}
|
323
170
|
finalizeTapInputWithSingleLeafScriptAndSignature(inputIndex) {
|
324
171
|
var _a, _b;
|
325
172
|
const input = utils_1.checkForInput(this.data.inputs, inputIndex);
|
@@ -349,97 +196,13 @@ class UtxoPsbt extends __1.Psbt {
|
|
349
196
|
validateSignaturesOfAllInputs() {
|
350
197
|
utils_1.checkForInput(this.data.inputs, 0); // making sure we have at least one
|
351
198
|
const results = this.data.inputs.map((input, idx) => {
|
352
|
-
|
199
|
+
var _a;
|
200
|
+
return ((_a = input.tapScriptSig) === null || _a === void 0 ? void 0 : _a.length)
|
201
|
+
? this.validateTaprootSignaturesOfInput(idx)
|
202
|
+
: this.validateSignaturesOfInput(idx, (p, m, s) => __1.ecc.verify(m, p, s));
|
353
203
|
});
|
354
204
|
return results.reduce((final, res) => res && final, true);
|
355
205
|
}
|
356
|
-
/**
|
357
|
-
* @returns true iff any matching valid signature is found for a derived pub key from given HD key pair.
|
358
|
-
*/
|
359
|
-
validateSignaturesOfInputHD(inputIndex, hdKeyPair) {
|
360
|
-
const input = utils_1.checkForInput(this.data.inputs, inputIndex);
|
361
|
-
const pubKey = UtxoPsbt.deriveKeyPairForInput(hdKeyPair, input);
|
362
|
-
if (!pubKey) {
|
363
|
-
throw new Error('can not derive from HD key pair');
|
364
|
-
}
|
365
|
-
return this.validateSignaturesOfInputCommon(inputIndex, pubKey);
|
366
|
-
}
|
367
|
-
/**
|
368
|
-
* @returns true iff any valid signature(s) are found from bip32 data of PSBT or for given pub key.
|
369
|
-
*/
|
370
|
-
validateSignaturesOfInputCommon(inputIndex, pubkey) {
|
371
|
-
try {
|
372
|
-
if (this.isTaprootScriptPathInput(inputIndex)) {
|
373
|
-
return this.validateTaprootSignaturesOfInput(inputIndex, pubkey);
|
374
|
-
}
|
375
|
-
else if (this.isTaprootKeyPathInput(inputIndex)) {
|
376
|
-
return this.validateTaprootMusig2SignaturesOfInput(inputIndex, pubkey);
|
377
|
-
}
|
378
|
-
return this.validateSignaturesOfInput(inputIndex, (p, m, s) => __1.ecc.verify(m, p, s, true), pubkey);
|
379
|
-
}
|
380
|
-
catch (err) {
|
381
|
-
// Not an elegant solution. Might need upstream changes like custom error types.
|
382
|
-
if (err.message === 'No signatures for this pubkey') {
|
383
|
-
return false;
|
384
|
-
}
|
385
|
-
throw err;
|
386
|
-
}
|
387
|
-
}
|
388
|
-
getMusig2SessionKey(inputIndex, sigHashType) {
|
389
|
-
const input = utils_1.checkForInput(this.data.inputs, inputIndex);
|
390
|
-
if (!input.tapInternalKey || !input.tapMerkleRoot) {
|
391
|
-
throw new Error('both tapInternalKey and tapMerkleRoot are required');
|
392
|
-
}
|
393
|
-
const participants = this.getMusig2Participants(inputIndex, input.tapInternalKey, input.tapMerkleRoot);
|
394
|
-
const nonces = this.getMusig2Nonces(inputIndex, participants);
|
395
|
-
const { hash } = this.getTaprootHashForSig(inputIndex, [sigHashType]);
|
396
|
-
const sessionKey = Musig2_1.createMusig2SigningSession({
|
397
|
-
pubNonces: [nonces[0].pubNonce, nonces[1].pubNonce],
|
398
|
-
pubKeys: participants.participantPubKeys,
|
399
|
-
txHash: hash,
|
400
|
-
internalPubKey: input.tapInternalKey,
|
401
|
-
tapTreeRoot: input.tapMerkleRoot,
|
402
|
-
});
|
403
|
-
return { participants, nonces, hash, sessionKey };
|
404
|
-
}
|
405
|
-
/**
|
406
|
-
* @returns true for following cases.
|
407
|
-
* If valid musig2 partial signatures exists for both 2 keys, it will also verify aggregated sig
|
408
|
-
* for aggregated tweaked key (output key), otherwise only verifies partial sig.
|
409
|
-
* If pubkey is passed in input, it will check sig only for that pubkey,
|
410
|
-
* if no sig exits for such key, throws error.
|
411
|
-
* For invalid state of input data, it will throw errors.
|
412
|
-
*/
|
413
|
-
validateTaprootMusig2SignaturesOfInput(inputIndex, pubkey) {
|
414
|
-
const input = utils_1.checkForInput(this.data.inputs, inputIndex);
|
415
|
-
const partialSigs = Musig2_1.parsePsbtMusig2PartialSigs(input);
|
416
|
-
if (!partialSigs) {
|
417
|
-
throw new Error(`No signatures to validate`);
|
418
|
-
}
|
419
|
-
let myPartialSigs = partialSigs;
|
420
|
-
if (pubkey) {
|
421
|
-
myPartialSigs = partialSigs.filter((kv) => equalPublicKeyIgnoreY(kv.participantPubKey, pubkey));
|
422
|
-
if ((myPartialSigs === null || myPartialSigs === void 0 ? void 0 : myPartialSigs.length) < 1) {
|
423
|
-
throw new Error('No signatures for this pubkey');
|
424
|
-
}
|
425
|
-
}
|
426
|
-
const { partialSigs: mySigs, sigHashType } = Musig2_1.getSigHashTypeFromSigs(myPartialSigs);
|
427
|
-
const { participants, nonces, hash, sessionKey } = this.getMusig2SessionKey(inputIndex, sigHashType);
|
428
|
-
const results = mySigs.map((mySig) => {
|
429
|
-
const myNonce = nonces.find((kv) => equalPublicKeyIgnoreY(kv.participantPubKey, mySig.participantPubKey));
|
430
|
-
if (!myNonce) {
|
431
|
-
throw new Error('Found no pub nonce for pubkey');
|
432
|
-
}
|
433
|
-
return Musig2_1.musig2PartialSigVerify(mySig.partialSig, mySig.participantPubKey, myNonce.pubNonce, sessionKey);
|
434
|
-
});
|
435
|
-
// For valid single sig or 1 or 2 failure sigs, no need to validate aggregated sig. So skip.
|
436
|
-
const result = results.every((res) => res);
|
437
|
-
if (!result || mySigs.length < 2) {
|
438
|
-
return result;
|
439
|
-
}
|
440
|
-
const aggSig = Musig2_1.musig2AggregateSigs(mySigs.map((mySig) => mySig.partialSig), sessionKey);
|
441
|
-
return __1.ecc.verifySchnorr(hash, participants.tapOutputKey, aggSig);
|
442
|
-
}
|
443
206
|
validateTaprootSignaturesOfInput(inputIndex, pubkey) {
|
444
207
|
const input = this.data.inputs[inputIndex];
|
445
208
|
const tapSigs = (input || {}).tapScriptSig;
|
@@ -448,7 +211,8 @@ class UtxoPsbt extends __1.Psbt {
|
|
448
211
|
}
|
449
212
|
let mySigs;
|
450
213
|
if (pubkey) {
|
451
|
-
|
214
|
+
const xOnlyPubkey = outputScripts_1.toXOnlyPublicKey(pubkey);
|
215
|
+
mySigs = tapSigs.filter((sig) => sig.pubkey.equals(xOnlyPubkey));
|
452
216
|
if (mySigs.length < 1) {
|
453
217
|
throw new Error('No signatures for this pubkey');
|
454
218
|
}
|
@@ -472,40 +236,34 @@ class UtxoPsbt extends __1.Psbt {
|
|
472
236
|
const { hash } = this.getTaprootHashForSig(inputIndex, [sigHashType], leafHash);
|
473
237
|
results.push(__1.ecc.verifySchnorr(hash, pubkey, sig));
|
474
238
|
}
|
475
|
-
return results.every((res) => res);
|
239
|
+
return results.every((res) => res === true);
|
476
240
|
}
|
477
241
|
/**
|
478
|
-
* @param inputIndex
|
479
|
-
* @param rootNodes optional input root bip32 nodes to verify with. If it is not provided, globalXpub will be used.
|
480
242
|
* @return array of boolean values. True when corresponding index in `publicKeys` has signed the transaction.
|
481
243
|
* If no signature in the tx or no public key matching signature, the validation is considered as false.
|
482
244
|
*/
|
483
|
-
getSignatureValidationArray(inputIndex
|
484
|
-
var _a
|
485
|
-
|
486
|
-
throw new Error('Cannot get signature validation array without 3 global xpubs');
|
487
|
-
}
|
488
|
-
const bip32s = rootNodes
|
489
|
-
? rootNodes
|
490
|
-
: (_b = this.data.globalMap.globalXpub) === null || _b === void 0 ? void 0 : _b.map((xpub) => bip32_1.BIP32Factory(__1.ecc).fromBase58(bs58check.encode(xpub.extendedPubkey)));
|
491
|
-
if (!bip32s) {
|
492
|
-
throw new Error('either globalMap or rootNodes is required');
|
493
|
-
}
|
245
|
+
getSignatureValidationArray(inputIndex) {
|
246
|
+
var _a;
|
247
|
+
const noSigErrorMessages = ['No signatures to validate', 'No signatures for this pubkey'];
|
494
248
|
const input = utils_1.checkForInput(this.data.inputs, inputIndex);
|
495
|
-
|
496
|
-
|
249
|
+
const isP2tr = (_a = input.tapScriptSig) === null || _a === void 0 ? void 0 : _a.length;
|
250
|
+
if (!this.data.globalMap.globalXpub) {
|
251
|
+
throw new Error('Cannot get signature validation array without global xpubs');
|
497
252
|
}
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
}
|
253
|
+
if (this.data.globalMap.globalXpub.length !== 3) {
|
254
|
+
throw new Error(`There must be 3 global xpubs and there are ${this.data.globalMap.globalXpub.length}`);
|
255
|
+
}
|
256
|
+
return this.data.globalMap.globalXpub.map((xpub) => {
|
257
|
+
// const bip32 = ECPair.fromPublicKey(xpub.extendedPubkey, { network: (this as any).opts.network });
|
258
|
+
const bip32 = bip32_1.BIP32Factory(__1.ecc).fromBase58(bs58check.encode(xpub.extendedPubkey));
|
503
259
|
try {
|
504
|
-
return
|
260
|
+
return isP2tr
|
261
|
+
? this.validateTaprootSignaturesOfInput(inputIndex, bip32.publicKey)
|
262
|
+
: this.validateSignaturesOfInput(inputIndex, (p, m, s) => __1.ecc.verify(m, p, s), bip32.publicKey);
|
505
263
|
}
|
506
264
|
catch (err) {
|
507
265
|
// Not an elegant solution. Might need upstream changes like custom error types.
|
508
|
-
if (err.message
|
266
|
+
if (noSigErrorMessages.includes(err.message)) {
|
509
267
|
return false;
|
510
268
|
}
|
511
269
|
throw err;
|
@@ -515,22 +273,27 @@ class UtxoPsbt extends __1.Psbt {
|
|
515
273
|
/**
|
516
274
|
* Mostly copied from bitcoinjs-lib/ts_src/psbt.ts
|
517
275
|
*/
|
518
|
-
signAllInputsHD(hdKeyPair,
|
276
|
+
signAllInputsHD(hdKeyPair, sighashTypes = [__1.Transaction.SIGHASH_DEFAULT, __1.Transaction.SIGHASH_ALL]) {
|
277
|
+
var _a;
|
519
278
|
if (!hdKeyPair || !hdKeyPair.publicKey || !hdKeyPair.fingerprint) {
|
520
279
|
throw new Error('Need HDSigner to sign input');
|
521
280
|
}
|
522
|
-
const { sighashTypes, deterministic } = toSignatureParams(this.network, params);
|
523
281
|
const results = [];
|
524
282
|
for (let i = 0; i < this.data.inputs.length; i++) {
|
525
283
|
try {
|
526
|
-
this.
|
284
|
+
if ((_a = this.data.inputs[i].tapBip32Derivation) === null || _a === void 0 ? void 0 : _a.length) {
|
285
|
+
this.signTaprootInputHD(i, hdKeyPair, sighashTypes);
|
286
|
+
}
|
287
|
+
else {
|
288
|
+
this.signInputHD(i, hdKeyPair, sighashTypes);
|
289
|
+
}
|
527
290
|
results.push(true);
|
528
291
|
}
|
529
292
|
catch (err) {
|
530
293
|
results.push(false);
|
531
294
|
}
|
532
295
|
}
|
533
|
-
if (results.every((v) =>
|
296
|
+
if (results.every((v) => v === false)) {
|
534
297
|
throw new Error('No inputs were signed');
|
535
298
|
}
|
536
299
|
return this;
|
@@ -538,11 +301,7 @@ class UtxoPsbt extends __1.Psbt {
|
|
538
301
|
/**
|
539
302
|
* Mostly copied from bitcoinjs-lib/ts_src/psbt.ts:signInputHD
|
540
303
|
*/
|
541
|
-
signTaprootInputHD(inputIndex, hdKeyPair,
|
542
|
-
var _a, _b;
|
543
|
-
if (!this.isTaprootInput(inputIndex)) {
|
544
|
-
throw new Error('not a taproot input');
|
545
|
-
}
|
304
|
+
signTaprootInputHD(inputIndex, hdKeyPair, sighashTypes = [__1.Transaction.SIGHASH_DEFAULT, __1.Transaction.SIGHASH_ALL]) {
|
546
305
|
if (!hdKeyPair || !hdKeyPair.publicKey || !hdKeyPair.fingerprint) {
|
547
306
|
throw new Error('Need HDSigner to sign input');
|
548
307
|
}
|
@@ -560,137 +319,25 @@ class UtxoPsbt extends __1.Psbt {
|
|
560
319
|
if (myDerivations.length === 0) {
|
561
320
|
throw new Error('Need one tapBip32Derivation masterFingerprint to match the HDSigner fingerprint');
|
562
321
|
}
|
563
|
-
|
322
|
+
const signers = myDerivations.map((bipDv) => {
|
564
323
|
const node = hdKeyPair.derivePath(bipDv.path);
|
565
|
-
if (!
|
324
|
+
if (!bipDv.pubkey.equals(node.publicKey.slice(1))) {
|
566
325
|
throw new Error('pubkey did not match tapBip32Derivation');
|
567
326
|
}
|
568
|
-
return node;
|
569
|
-
}
|
570
|
-
if ((_a = input.tapLeafScript) === null || _a === void 0 ? void 0 : _a.length) {
|
571
|
-
const signers = myDerivations.map((bipDv) => {
|
572
|
-
const signer = getDerivedNode(bipDv);
|
573
|
-
if (!('signSchnorr' in signer)) {
|
574
|
-
throw new Error('signSchnorr function is required to sign p2tr');
|
575
|
-
}
|
576
|
-
return { signer, leafHashes: bipDv.leafHashes };
|
577
|
-
});
|
578
|
-
signers.forEach(({ signer, leafHashes }) => this.signTaprootInput(inputIndex, signer, leafHashes, sighashTypes));
|
579
|
-
}
|
580
|
-
else if ((_b = input.tapInternalKey) === null || _b === void 0 ? void 0 : _b.length) {
|
581
|
-
const signers = myDerivations.map((bipDv) => {
|
582
|
-
const signer = getDerivedNode(bipDv);
|
583
|
-
if (!('privateKey' in signer) || !signer.privateKey) {
|
584
|
-
throw new Error('privateKey is required to sign p2tr musig2');
|
585
|
-
}
|
586
|
-
return signer;
|
587
|
-
});
|
588
|
-
signers.forEach((signer) => this.signTaprootMusig2Input(inputIndex, signer, { sighashTypes, deterministic }));
|
589
|
-
}
|
590
|
-
return this;
|
591
|
-
}
|
592
|
-
signInputHD(inputIndex, hdKeyPair, params) {
|
593
|
-
const { sighashTypes, deterministic } = toSignatureParams(this.network, params);
|
594
|
-
if (this.isTaprootInput(inputIndex)) {
|
595
|
-
return this.signTaprootInputHD(inputIndex, hdKeyPair, { sighashTypes, deterministic });
|
596
|
-
}
|
597
|
-
else {
|
598
|
-
return super.signInputHD(inputIndex, hdKeyPair, sighashTypes);
|
599
|
-
}
|
600
|
-
}
|
601
|
-
getMusig2Participants(inputIndex, tapInternalKey, tapMerkleRoot) {
|
602
|
-
const participantsKeyValData = Musig2_1.parsePsbtMusig2Participants(this.data.inputs[inputIndex]);
|
603
|
-
if (!participantsKeyValData) {
|
604
|
-
throw new Error(`Found 0 matching participant key value instead of 1`);
|
605
|
-
}
|
606
|
-
Musig2_1.assertPsbtMusig2Participants(participantsKeyValData, tapInternalKey, tapMerkleRoot);
|
607
|
-
return participantsKeyValData;
|
608
|
-
}
|
609
|
-
getMusig2Nonces(inputIndex, participantsKeyValData) {
|
610
|
-
const noncesKeyValsData = Musig2_1.parsePsbtMusig2Nonces(this.data.inputs[inputIndex]);
|
611
|
-
if (!noncesKeyValsData || !types_1.isTuple(noncesKeyValsData)) {
|
612
|
-
throw new Error(`Found ${(noncesKeyValsData === null || noncesKeyValsData === void 0 ? void 0 : noncesKeyValsData.length) ? noncesKeyValsData.length : 0} matching nonce key value instead of 2`);
|
613
|
-
}
|
614
|
-
Musig2_1.assertPsbtMusig2Nonces(noncesKeyValsData, participantsKeyValData);
|
615
|
-
return noncesKeyValsData;
|
616
|
-
}
|
617
|
-
/**
|
618
|
-
* Signs p2tr musig2 key path input with 2 aggregated keys.
|
619
|
-
*
|
620
|
-
* Note: Only can sign deterministically as the cosigner
|
621
|
-
* @param inputIndex
|
622
|
-
* @param signer - XY public key and private key are required
|
623
|
-
* @param sighashTypes
|
624
|
-
* @param deterministic If true, sign the musig input deterministically
|
625
|
-
*/
|
626
|
-
signTaprootMusig2Input(inputIndex, signer, { sighashTypes = [__1.Transaction.SIGHASH_DEFAULT, __1.Transaction.SIGHASH_ALL], deterministic = false } = {}) {
|
627
|
-
if (!this.isTaprootKeyPathInput(inputIndex)) {
|
628
|
-
throw new Error('not a taproot musig2 input');
|
629
|
-
}
|
630
|
-
const input = this.data.inputs[inputIndex];
|
631
|
-
if (!input.tapInternalKey || !input.tapMerkleRoot) {
|
632
|
-
throw new Error('missing required input data');
|
633
|
-
}
|
634
|
-
// Retrieve and check that we have two participant nonces
|
635
|
-
const participants = this.getMusig2Participants(inputIndex, input.tapInternalKey, input.tapMerkleRoot);
|
636
|
-
const { tapOutputKey, participantPubKeys } = participants;
|
637
|
-
const signerPubKey = participantPubKeys.find((pubKey) => equalPublicKeyIgnoreY(pubKey, signer.publicKey));
|
638
|
-
if (!signerPubKey) {
|
639
|
-
throw new Error('signer pub key should match one of participant pub keys');
|
640
|
-
}
|
641
|
-
const nonces = this.getMusig2Nonces(inputIndex, participants);
|
642
|
-
const { hash, sighashType } = this.getTaprootHashForSig(inputIndex, sighashTypes);
|
643
|
-
let partialSig;
|
644
|
-
if (deterministic) {
|
645
|
-
if (!equalPublicKeyIgnoreY(signerPubKey, participantPubKeys[1])) {
|
646
|
-
throw new Error('can only add a deterministic signature on the cosigner');
|
647
|
-
}
|
648
|
-
const firstSignerNonce = nonces.find((n) => equalPublicKeyIgnoreY(n.participantPubKey, participantPubKeys[0]));
|
649
|
-
if (!firstSignerNonce) {
|
650
|
-
throw new Error('could not find the user nonce');
|
651
|
-
}
|
652
|
-
partialSig = Musig2_1.musig2DeterministicSign({
|
653
|
-
privateKey: signer.privateKey,
|
654
|
-
otherNonce: firstSignerNonce.pubNonce,
|
655
|
-
publicKeys: participantPubKeys,
|
656
|
-
internalPubKey: input.tapInternalKey,
|
657
|
-
tapTreeRoot: input.tapMerkleRoot,
|
658
|
-
hash,
|
659
|
-
}).sig;
|
660
|
-
}
|
661
|
-
else {
|
662
|
-
const sessionKey = Musig2_1.createMusig2SigningSession({
|
663
|
-
pubNonces: [nonces[0].pubNonce, nonces[1].pubNonce],
|
664
|
-
pubKeys: participantPubKeys,
|
665
|
-
txHash: hash,
|
666
|
-
internalPubKey: input.tapInternalKey,
|
667
|
-
tapTreeRoot: input.tapMerkleRoot,
|
668
|
-
});
|
669
|
-
const signerNonce = nonces.find((kv) => equalPublicKeyIgnoreY(kv.participantPubKey, signerPubKey));
|
670
|
-
if (!signerNonce) {
|
671
|
-
throw new Error('pubNonce is missing. retry signing process');
|
672
|
-
}
|
673
|
-
partialSig = Musig2_1.musig2PartialSign(signer.privateKey, signerNonce.pubNonce, sessionKey, this.nonceStore);
|
674
|
-
}
|
675
|
-
if (sighashType !== __1.Transaction.SIGHASH_DEFAULT) {
|
676
|
-
partialSig = Buffer.concat([partialSig, Buffer.of(sighashType)]);
|
677
|
-
}
|
678
|
-
const sig = Musig2_1.encodePsbtMusig2PartialSig({
|
679
|
-
participantPubKey: signerPubKey,
|
680
|
-
tapOutputKey,
|
681
|
-
partialSig: partialSig,
|
327
|
+
return { signer: node, leafHashes: bipDv.leafHashes };
|
682
328
|
});
|
683
|
-
this.
|
329
|
+
signers.forEach(({ signer, leafHashes }) => this.signTaprootInput(inputIndex, signer, leafHashes, sighashTypes));
|
684
330
|
return this;
|
685
331
|
}
|
686
332
|
signTaprootInput(inputIndex, signer, leafHashes, sighashTypes = [__1.Transaction.SIGHASH_DEFAULT, __1.Transaction.SIGHASH_ALL]) {
|
687
333
|
var _a;
|
334
|
+
const pubkey = outputScripts_1.toXOnlyPublicKey(signer.publicKey);
|
688
335
|
const input = utils_1.checkForInput(this.data.inputs, inputIndex);
|
689
336
|
// Figure out if this is script path or not, if not, tweak the private key
|
690
337
|
if (!((_a = input.tapLeafScript) === null || _a === void 0 ? void 0 : _a.length)) {
|
691
|
-
|
338
|
+
// See BitGo/BitGoJS/modules/utxo_lib/src/transaction_builder.ts:trySign for how to support it.
|
339
|
+
throw new Error('Taproot key path signing is not supported.');
|
692
340
|
}
|
693
|
-
const pubkey = outputScripts_1.toXOnlyPublicKey(signer.publicKey);
|
694
341
|
if (input.tapLeafScript.length !== 1) {
|
695
342
|
throw new Error('Only one leaf script supported for signing');
|
696
343
|
}
|
@@ -720,27 +367,7 @@ class UtxoPsbt extends __1.Psbt {
|
|
720
367
|
});
|
721
368
|
return this;
|
722
369
|
}
|
723
|
-
getTaprootOutputScript(inputIndex) {
|
724
|
-
var _a;
|
725
|
-
const input = utils_1.checkForInput(this.data.inputs, inputIndex);
|
726
|
-
if ((_a = input.tapLeafScript) === null || _a === void 0 ? void 0 : _a.length) {
|
727
|
-
return __1.taproot.createTaprootOutputScript({
|
728
|
-
controlBlock: input.tapLeafScript[0].controlBlock,
|
729
|
-
leafScript: input.tapLeafScript[0].script,
|
730
|
-
});
|
731
|
-
}
|
732
|
-
else if (input.tapInternalKey && input.tapMerkleRoot) {
|
733
|
-
return __1.taproot.createTaprootOutputScript({
|
734
|
-
internalPubKey: input.tapInternalKey,
|
735
|
-
taptreeRoot: input.tapMerkleRoot,
|
736
|
-
});
|
737
|
-
}
|
738
|
-
throw new Error('not a taproot input');
|
739
|
-
}
|
740
370
|
getTaprootHashForSig(inputIndex, sighashTypes, leafHash) {
|
741
|
-
if (!this.isTaprootInput(inputIndex)) {
|
742
|
-
throw new Error('not a taproot input');
|
743
|
-
}
|
744
371
|
const sighashType = this.data.inputs[inputIndex].sighashType || __1.Transaction.SIGHASH_DEFAULT;
|
745
372
|
if (sighashTypes && sighashTypes.indexOf(sighashType) < 0) {
|
746
373
|
throw new Error(`Sighash type is not allowed. Retry the sign method passing the ` +
|
@@ -772,220 +399,71 @@ class UtxoPsbt extends __1.Psbt {
|
|
772
399
|
prevoutScripts.push(prevout.script);
|
773
400
|
prevoutValues.push(prevout.value);
|
774
401
|
});
|
775
|
-
const outputScript = this.getTaprootOutputScript(inputIndex);
|
776
|
-
if (!outputScript.equals(prevoutScripts[inputIndex])) {
|
777
|
-
throw new Error(`Witness script for input #${inputIndex} doesn't match the scriptPubKey in the prevout`);
|
778
|
-
}
|
779
402
|
const hash = this.tx.hashForWitnessV1(inputIndex, prevoutScripts, prevoutValues, sighashType, leafHash);
|
780
403
|
return { hash, sighashType };
|
781
404
|
}
|
782
405
|
/**
|
783
|
-
*
|
784
|
-
* Default identifierEncoding is utf-8 for identifier.
|
406
|
+
* @retuns true iff the input is taproot.
|
785
407
|
*/
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
408
|
+
isTaprootInput(inputIndex) {
|
409
|
+
const input = utils_1.checkForInput(this.data.inputs, inputIndex);
|
410
|
+
function isP2tr(output) {
|
411
|
+
try {
|
412
|
+
__1.p2trPayments.p2tr({ output }, { eccLib: __1.ecc });
|
413
|
+
return true;
|
414
|
+
}
|
415
|
+
catch (err) {
|
416
|
+
return false;
|
417
|
+
}
|
418
|
+
}
|
419
|
+
return !!(input.tapInternalKey ||
|
420
|
+
input.tapMerkleRoot ||
|
421
|
+
(input.tapLeafScript && input.tapLeafScript.length) ||
|
422
|
+
(input.tapBip32Derivation && input.tapBip32Derivation.length) ||
|
423
|
+
(input.witnessUtxo && isP2tr(input.witnessUtxo.script)));
|
791
424
|
}
|
792
425
|
/**
|
793
|
-
*
|
794
|
-
*
|
426
|
+
* @returns hash and hashType for taproot input at inputIndex
|
427
|
+
* @throws error if input at inputIndex is not a taproot input
|
795
428
|
*/
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
const key = proprietaryKeyVal_1.encodeProprietaryKey(keyValueData.key);
|
800
|
-
const { value } = keyValueData;
|
801
|
-
if ((_a = input.unknownKeyVals) === null || _a === void 0 ? void 0 : _a.length) {
|
802
|
-
const ukvIndex = input.unknownKeyVals.findIndex((ukv) => ukv.key.equals(key));
|
803
|
-
if (ukvIndex > -1) {
|
804
|
-
input.unknownKeyVals[ukvIndex] = { key, value };
|
805
|
-
return this;
|
806
|
-
}
|
429
|
+
getTaprootHashForSigChecked(inputIndex, sighashTypes = [__1.Transaction.SIGHASH_DEFAULT, __1.Transaction.SIGHASH_ALL], leafHash) {
|
430
|
+
if (!this.isTaprootInput(inputIndex)) {
|
431
|
+
throw new Error(`${inputIndex} input is not a taproot type to take taproot tx hash`);
|
807
432
|
}
|
808
|
-
this.
|
809
|
-
key,
|
810
|
-
value,
|
811
|
-
});
|
812
|
-
return this;
|
433
|
+
return this.getTaprootHashForSig(inputIndex, sighashTypes, leafHash);
|
813
434
|
}
|
814
435
|
/**
|
815
|
-
*
|
436
|
+
* Adds proprietary key value pair to PSBT input.
|
816
437
|
* Default identifierEncoding is utf-8 for identifier.
|
817
438
|
*/
|
818
|
-
|
819
|
-
|
820
|
-
|
439
|
+
addProprietaryKeyValToInput(inputIndex, keyValueData) {
|
440
|
+
return this.addUnknownKeyValToInput(inputIndex, {
|
441
|
+
key: proprietaryKeyVal_1.encodeProprietaryKey(keyValueData.key),
|
442
|
+
value: keyValueData.value,
|
443
|
+
});
|
821
444
|
}
|
822
445
|
/**
|
823
|
-
* To
|
446
|
+
* To search any data from proprietary key value againts keydata.
|
824
447
|
* Default identifierEncoding is utf-8 for identifier.
|
825
448
|
*/
|
826
|
-
|
827
|
-
var _a;
|
449
|
+
getProprietaryKeyVals(inputIndex, keySearch) {
|
828
450
|
const input = utils_1.checkForInput(this.data.inputs, inputIndex);
|
829
|
-
if (!
|
830
|
-
return
|
831
|
-
}
|
832
|
-
if (keysToDelete && keysToDelete.subtype === undefined && Buffer.isBuffer(keysToDelete.keydata)) {
|
833
|
-
throw new Error('invalid proprietary key search filter combination. subtype is required');
|
451
|
+
if (!input.unknownKeyVals || input.unknownKeyVals.length === 0) {
|
452
|
+
return [];
|
834
453
|
}
|
835
|
-
|
836
|
-
|
837
|
-
return !(keysToDelete === undefined ||
|
838
|
-
(keysToDelete.identifier === key.identifier &&
|
839
|
-
(keysToDelete.subtype === undefined ||
|
840
|
-
(keysToDelete.subtype === key.subtype &&
|
841
|
-
(!Buffer.isBuffer(keysToDelete.keydata) || keysToDelete.keydata.equals(key.keydata))))));
|
454
|
+
const keyVals = input.unknownKeyVals.map(({ key, value }, i) => {
|
455
|
+
return { key: proprietaryKeyVal_1.decodeProprietaryKey(key), value };
|
842
456
|
});
|
843
|
-
return
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
throw new Error('tapInternalKey is required to create nonce');
|
849
|
-
}
|
850
|
-
if (!input.tapMerkleRoot) {
|
851
|
-
throw new Error('tapMerkleRoot is required to create nonce');
|
852
|
-
}
|
853
|
-
const getDerivedKeyPair = () => {
|
854
|
-
var _a;
|
855
|
-
if (!((_a = input.tapBip32Derivation) === null || _a === void 0 ? void 0 : _a.length)) {
|
856
|
-
throw new Error('tapBip32Derivation is required to create nonce');
|
857
|
-
}
|
858
|
-
const derived = UtxoPsbt.deriveKeyPair(keyPair, input.tapBip32Derivation, { ignoreY: true });
|
859
|
-
if (!derived) {
|
860
|
-
throw new Error('No bip32Derivation masterFingerprint matched the HD keyPair fingerprint');
|
861
|
-
}
|
862
|
-
return derived;
|
863
|
-
};
|
864
|
-
const derivedKeyPair = keyType === 'root' ? getDerivedKeyPair() : keyPair;
|
865
|
-
if (!derivedKeyPair.privateKey) {
|
866
|
-
throw new Error('privateKey is required to create nonce');
|
867
|
-
}
|
868
|
-
const participants = Musig2_1.parsePsbtMusig2Participants(input);
|
869
|
-
if (!participants) {
|
870
|
-
throw new Error(`Found 0 matching participant key value instead of 1`);
|
871
|
-
}
|
872
|
-
Musig2_1.assertPsbtMusig2Participants(participants, input.tapInternalKey, input.tapMerkleRoot);
|
873
|
-
const { tapOutputKey, participantPubKeys } = participants;
|
874
|
-
const participantPubKey = participantPubKeys.find((pubKey) => equalPublicKeyIgnoreY(pubKey, derivedKeyPair.publicKey));
|
875
|
-
if (!Buffer.isBuffer(participantPubKey)) {
|
876
|
-
throw new Error('participant plain pub key should match one bip32Derivation plain pub key');
|
877
|
-
}
|
878
|
-
const { hash } = this.getTaprootHashForSig(inputIndex);
|
879
|
-
let pubNonce;
|
880
|
-
if (params.deterministic) {
|
881
|
-
if (params.sessionId) {
|
882
|
-
throw new Error('Cannot add extra entropy when generating a deterministic nonce');
|
883
|
-
}
|
884
|
-
// There must be only 2 participant pubKeys if it got to this point
|
885
|
-
if (!equalPublicKeyIgnoreY(participantPubKey, participantPubKeys[1])) {
|
886
|
-
throw new Error(`Only the cosigner's nonce can be set deterministically`);
|
887
|
-
}
|
888
|
-
const nonces = Musig2_1.parsePsbtMusig2Nonces(input);
|
889
|
-
if (!nonces) {
|
890
|
-
throw new Error(`No nonces found on input #${inputIndex}`);
|
891
|
-
}
|
892
|
-
if (nonces.length > 2) {
|
893
|
-
throw new Error(`Cannot have more than 2 nonces`);
|
894
|
-
}
|
895
|
-
const firstSignerNonce = nonces.find((kv) => equalPublicKeyIgnoreY(kv.participantPubKey, participantPubKeys[0]));
|
896
|
-
if (!firstSignerNonce) {
|
897
|
-
throw new Error('signer nonce must be set if cosigner nonce is to be derived deterministically');
|
898
|
-
}
|
899
|
-
pubNonce = Musig2_1.createMusig2DeterministicNonce({
|
900
|
-
privateKey: derivedKeyPair.privateKey,
|
901
|
-
otherNonce: firstSignerNonce.pubNonce,
|
902
|
-
publicKeys: participantPubKeys,
|
903
|
-
internalPubKey: input.tapInternalKey,
|
904
|
-
tapTreeRoot: input.tapMerkleRoot,
|
905
|
-
hash,
|
906
|
-
});
|
907
|
-
}
|
908
|
-
else {
|
909
|
-
pubNonce = Buffer.from(this.nonceStore.createMusig2Nonce(derivedKeyPair.privateKey, participantPubKey, tapOutputKey, hash, params.sessionId));
|
910
|
-
}
|
911
|
-
return { tapOutputKey, participantPubKey, pubNonce };
|
912
|
-
}
|
913
|
-
setMusig2NoncesInner(keyPair, keyType, inputIndex, params = { deterministic: false }) {
|
914
|
-
if (keyPair.isNeutered()) {
|
915
|
-
throw new Error('private key is required to generate nonce');
|
916
|
-
}
|
917
|
-
if (Buffer.isBuffer(params.sessionId) && params.sessionId.length !== 32) {
|
918
|
-
throw new Error(`Invalid sessionId size ${params.sessionId.length}`);
|
919
|
-
}
|
920
|
-
const inputIndexes = inputIndex === undefined ? [...Array(this.inputCount).keys()] : [inputIndex];
|
921
|
-
inputIndexes.forEach((index) => {
|
922
|
-
if (!this.isTaprootKeyPathInput(index)) {
|
923
|
-
return;
|
924
|
-
}
|
925
|
-
const nonce = this.createMusig2NonceForInput(index, keyPair, keyType, params);
|
926
|
-
this.addOrUpdateProprietaryKeyValToInput(index, Musig2_1.encodePsbtMusig2PubNonce(nonce));
|
457
|
+
return keyVals.filter((keyVal) => {
|
458
|
+
return (keySearch === undefined ||
|
459
|
+
(keySearch.identifier === keyVal.key.identifier &&
|
460
|
+
keySearch.subtype === keyVal.key.subtype &&
|
461
|
+
(!Buffer.isBuffer(keySearch.keydata) || keySearch.keydata.equals(keyVal.key.keydata))));
|
927
462
|
});
|
928
|
-
return this;
|
929
|
-
}
|
930
|
-
/**
|
931
|
-
* Generates and sets MuSig2 nonce to taproot key path input at inputIndex.
|
932
|
-
* If input is not a taproot key path, no action.
|
933
|
-
*
|
934
|
-
* @param inputIndex input index
|
935
|
-
* @param keyPair derived key pair
|
936
|
-
* @param sessionId Optional extra entropy. If provided it must either be a counter unique to this secret key,
|
937
|
-
* (converted to an array of 32 bytes), or 32 uniformly random bytes.
|
938
|
-
* @param deterministic If true, set the cosigner nonce deterministically
|
939
|
-
*/
|
940
|
-
setInputMusig2Nonce(inputIndex, derivedKeyPair, params = { deterministic: false }) {
|
941
|
-
return this.setMusig2NoncesInner(derivedKeyPair, 'derived', inputIndex, params);
|
942
|
-
}
|
943
|
-
/**
|
944
|
-
* Generates and sets MuSig2 nonce to taproot key path input at inputIndex.
|
945
|
-
* If input is not a taproot key path, no action.
|
946
|
-
*
|
947
|
-
* @param inputIndex input index
|
948
|
-
* @param keyPair HD root key pair
|
949
|
-
* @param sessionId Optional extra entropy. If provided it must either be a counter unique to this secret key,
|
950
|
-
* (converted to an array of 32 bytes), or 32 uniformly random bytes.
|
951
|
-
* @param deterministic If true, set the cosigner nonce deterministically
|
952
|
-
*/
|
953
|
-
setInputMusig2NonceHD(inputIndex, keyPair, params = { deterministic: false }) {
|
954
|
-
utils_1.checkForInput(this.data.inputs, inputIndex);
|
955
|
-
return this.setMusig2NoncesInner(keyPair, 'root', inputIndex, params);
|
956
|
-
}
|
957
|
-
/**
|
958
|
-
* Generates and sets MuSig2 nonce to all taproot key path inputs. Other inputs will be skipped.
|
959
|
-
*
|
960
|
-
* @param inputIndex input index
|
961
|
-
* @param keyPair derived key pair
|
962
|
-
* @param sessionId Optional extra entropy. If provided it must either be a counter unique to this secret key,
|
963
|
-
* (converted to an array of 32 bytes), or 32 uniformly random bytes.
|
964
|
-
*/
|
965
|
-
setAllInputsMusig2Nonce(keyPair, params = { deterministic: false }) {
|
966
|
-
return this.setMusig2NoncesInner(keyPair, 'derived', undefined, params);
|
967
|
-
}
|
968
|
-
/**
|
969
|
-
* Generates and sets MuSig2 nonce to all taproot key path inputs. Other inputs will be skipped.
|
970
|
-
*
|
971
|
-
* @param inputIndex input index
|
972
|
-
* @param keyPair HD root key pair
|
973
|
-
* @param sessionId Optional extra entropy. If provided it must either be a counter unique to this secret key,
|
974
|
-
* (converted to an array of 32 bytes), or 32 uniformly random bytes.
|
975
|
-
*/
|
976
|
-
setAllInputsMusig2NonceHD(keyPair, params = { deterministic: false }) {
|
977
|
-
return this.setMusig2NoncesInner(keyPair, 'root', undefined, params);
|
978
463
|
}
|
979
464
|
clone() {
|
980
465
|
return super.clone();
|
981
466
|
}
|
982
|
-
extractTransaction(disableFeeCheck) {
|
983
|
-
const tx = super.extractTransaction(disableFeeCheck);
|
984
|
-
if (tx instanceof UtxoTransaction_1.UtxoTransaction) {
|
985
|
-
return tx;
|
986
|
-
}
|
987
|
-
throw new Error('extractTransaction did not return instace of UtxoTransaction');
|
988
|
-
}
|
989
467
|
}
|
990
468
|
exports.UtxoPsbt = UtxoPsbt;
|
991
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiVXR4b1BzYnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYml0Z28vVXR4b1BzYnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsbUNBQTBDO0FBUTFDLGdEQUFxRDtBQUNyRCwrREFBc0U7QUFFdEUsaUNBQXFEO0FBQ3JELHVDQUF1QztBQUN2Qyx3RUFBOEY7QUFFOUYsMEJBV1k7QUFDWix1REFBb0Q7QUFDcEQsdUNBQWdEO0FBQ2hELG9EQUE4QztBQUM5QywwREFBK0M7QUFDL0MsbURBQW1EO0FBQ25ELDZDQUFrRDtBQUNsRCxxQ0FrQmtCO0FBQ2xCLG1DQUEyRDtBQUMzRCx3Q0F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1xuICAgICAgICBwcml2YXRlS2V5OiBzaWduZXIucHJpdmF0ZUtleSxcbiAgICAgICAgb3RoZXJOb25jZTogZmlyc3RTaWduZXJOb25jZS5wdWJOb25jZSxcbiAgICAgICAgcHVibGljS2V5czogcGFydGljaXBhbnRQdWJLZXlzLFxuICAgICAgICBpbnRlcm5hbFB1YktleTogaW5wdXQudGFwSW50ZXJuYWxLZXksXG4gICAgICAgIHRhcFRyZWVSb290OiBpbnB1dC50YXBNZXJrbGVSb290LFxuICAgICAgICBoYXNoLFxuICAgICAgfSkuc2lnO1xuICAgIH0gZWxzZSB7XG4gICAgICBjb25zdCBzZXNzaW9uS2V5ID0gY3JlYXRlTXVzaWcyU2lnbmluZ1Nlc3Npb24oe1xuICAgICAgICBwdWJOb25jZXM6IFtub25jZXNbMF0ucHViTm9uY2UsIG5vbmNlc1sxXS5wdWJOb25jZV0sXG4gICAgICAgIHB1YktleXM6IHBhcnRpY2lwYW50UHViS2V5cyxcbiAgICAgICAgdHhIYXNoOiBoYXNoLFxuICAgICAgICBpbnRlcm5hbFB1YktleTogaW5wdXQudGFwSW50ZXJuYWxLZXksXG4gICAgICAgIHRhcFRyZWVSb290OiBpbnB1dC50YXBNZXJrbGVSb290LFxuICAgICAgfSk7XG5cbiAgICAgIGNvbnN0IHNpZ25lck5vbmNlID0gbm9uY2VzLmZpbmQoKGt2KSA9PiBlcXVhbFB1YmxpY0tleUlnbm9yZVkoa3YucGFydGljaXBhbnRQdWJLZXksIHNpZ25lclB1YktleSkpO1xuICAgICAgaWYgKCFzaWduZXJOb25jZSkge1xuICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ3B1Yk5vbmNlIGlzIG1pc3NpbmcuIHJldHJ5IHNpZ25pbmcgcHJvY2VzcycpO1xuICAgICAgfVxuICAgICAgcGFydGlhbFNpZyA9IG11c2lnMlBhcnRpYWxTaWduKHNpZ25lci5wcml2YXRlS2V5LCBzaWduZXJOb25jZS5wdWJOb25jZSwgc2Vzc2lvbktleS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