@ledgerhq/hw-app-btc 6.10.0 → 6.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +384 -60
- package/lib/Btc.d.ts +9 -6
- package/lib/Btc.d.ts.map +1 -1
- package/lib/Btc.js +73 -8
- package/lib/Btc.js.map +1 -1
- package/lib/BtcNew.d.ts +79 -32
- package/lib/BtcNew.d.ts.map +1 -1
- package/lib/BtcNew.js +168 -207
- package/lib/BtcNew.js.map +1 -1
- package/lib/newops/accounttype.d.ts +110 -0
- package/lib/newops/accounttype.d.ts.map +1 -0
- package/lib/newops/accounttype.js +233 -0
- package/lib/newops/accounttype.js.map +1 -0
- package/lib/newops/appClient.d.ts +6 -2
- package/lib/newops/appClient.d.ts.map +1 -1
- package/lib/newops/appClient.js +8 -4
- package/lib/newops/appClient.js.map +1 -1
- package/lib/newops/clientCommands.d.ts +18 -2
- package/lib/newops/clientCommands.d.ts.map +1 -1
- package/lib/newops/clientCommands.js +34 -12
- package/lib/newops/clientCommands.js.map +1 -1
- package/lib/newops/merkelizedPsbt.d.ts +11 -0
- package/lib/newops/merkelizedPsbt.d.ts.map +1 -1
- package/lib/newops/merkelizedPsbt.js +11 -0
- package/lib/newops/merkelizedPsbt.js.map +1 -1
- package/lib/newops/merkle.d.ts +5 -0
- package/lib/newops/merkle.d.ts.map +1 -1
- package/lib/newops/merkle.js +5 -0
- package/lib/newops/merkle.js.map +1 -1
- package/lib/newops/merkleMap.d.ts +10 -0
- package/lib/newops/merkleMap.d.ts.map +1 -1
- package/lib/newops/merkleMap.js +10 -0
- package/lib/newops/merkleMap.js.map +1 -1
- package/lib/newops/policy.d.ts +8 -0
- package/lib/newops/policy.d.ts.map +1 -1
- package/lib/newops/policy.js +9 -1
- package/lib/newops/policy.js.map +1 -1
- package/lib/newops/psbtExtractor.d.ts +6 -0
- package/lib/newops/psbtExtractor.d.ts.map +1 -1
- package/lib/newops/psbtExtractor.js +6 -0
- package/lib/newops/psbtExtractor.js.map +1 -1
- package/lib/newops/psbtFinalizer.d.ts +11 -1
- package/lib/newops/psbtFinalizer.d.ts.map +1 -1
- package/lib/newops/psbtFinalizer.js +26 -1
- package/lib/newops/psbtFinalizer.js.map +1 -1
- package/lib/newops/psbtv2.d.ts +22 -2
- package/lib/newops/psbtv2.d.ts.map +1 -1
- package/lib/newops/psbtv2.js +33 -8
- package/lib/newops/psbtv2.js.map +1 -1
- package/lib-es/Btc.d.ts +9 -6
- package/lib-es/Btc.d.ts.map +1 -1
- package/lib-es/Btc.js +73 -8
- package/lib-es/Btc.js.map +1 -1
- package/lib-es/BtcNew.d.ts +79 -32
- package/lib-es/BtcNew.d.ts.map +1 -1
- package/lib-es/BtcNew.js +170 -209
- package/lib-es/BtcNew.js.map +1 -1
- package/lib-es/newops/accounttype.d.ts +110 -0
- package/lib-es/newops/accounttype.d.ts.map +1 -0
- package/lib-es/newops/accounttype.js +230 -0
- package/lib-es/newops/accounttype.js.map +1 -0
- package/lib-es/newops/appClient.d.ts +6 -2
- package/lib-es/newops/appClient.d.ts.map +1 -1
- package/lib-es/newops/appClient.js +8 -4
- package/lib-es/newops/appClient.js.map +1 -1
- package/lib-es/newops/clientCommands.d.ts +18 -2
- package/lib-es/newops/clientCommands.d.ts.map +1 -1
- package/lib-es/newops/clientCommands.js +34 -12
- package/lib-es/newops/clientCommands.js.map +1 -1
- package/lib-es/newops/merkelizedPsbt.d.ts +11 -0
- package/lib-es/newops/merkelizedPsbt.d.ts.map +1 -1
- package/lib-es/newops/merkelizedPsbt.js +11 -0
- package/lib-es/newops/merkelizedPsbt.js.map +1 -1
- package/lib-es/newops/merkle.d.ts +5 -0
- package/lib-es/newops/merkle.d.ts.map +1 -1
- package/lib-es/newops/merkle.js +5 -0
- package/lib-es/newops/merkle.js.map +1 -1
- package/lib-es/newops/merkleMap.d.ts +10 -0
- package/lib-es/newops/merkleMap.d.ts.map +1 -1
- package/lib-es/newops/merkleMap.js +10 -0
- package/lib-es/newops/merkleMap.js.map +1 -1
- package/lib-es/newops/policy.d.ts +8 -0
- package/lib-es/newops/policy.d.ts.map +1 -1
- package/lib-es/newops/policy.js +10 -2
- package/lib-es/newops/policy.js.map +1 -1
- package/lib-es/newops/psbtExtractor.d.ts +6 -0
- package/lib-es/newops/psbtExtractor.d.ts.map +1 -1
- package/lib-es/newops/psbtExtractor.js +6 -0
- package/lib-es/newops/psbtExtractor.js.map +1 -1
- package/lib-es/newops/psbtFinalizer.d.ts +11 -1
- package/lib-es/newops/psbtFinalizer.d.ts.map +1 -1
- package/lib-es/newops/psbtFinalizer.js +26 -1
- package/lib-es/newops/psbtFinalizer.js.map +1 -1
- package/lib-es/newops/psbtv2.d.ts +22 -2
- package/lib-es/newops/psbtv2.d.ts.map +1 -1
- package/lib-es/newops/psbtv2.js +33 -8
- package/lib-es/newops/psbtv2.js.map +1 -1
- package/package.json +3 -3
- package/src/Btc.ts +111 -9
- package/src/BtcNew.ts +204 -209
- package/src/newops/accounttype.ts +370 -0
- package/src/newops/appClient.ts +12 -4
- package/src/newops/clientCommands.ts +34 -12
- package/src/newops/merkelizedPsbt.ts +11 -0
- package/src/newops/merkle.ts +5 -0
- package/src/newops/merkleMap.ts +10 -0
- package/src/newops/policy.ts +10 -2
- package/src/newops/psbtExtractor.ts +6 -0
- package/src/newops/psbtFinalizer.ts +26 -1
- package/src/newops/psbtv2.ts +34 -14
- package/tests/Btc.test.ts +89 -0
- package/tests/newops/BtcNew.test.ts +48 -21
- package/tests/newops/integrationtools.ts +47 -36
- package/tests/newops/testtx.ts +0 -55
package/lib/BtcNew.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -52,27 +41,69 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
52
41
|
exports.__esModule = true;
|
|
53
42
|
exports.canSupportApp = void 0;
|
|
54
43
|
var bitcoinjs_lib_1 = require("bitcoinjs-lib");
|
|
55
|
-
var tiny_secp256k1_1 = require("tiny-secp256k1");
|
|
56
44
|
var semver_1 = __importDefault(require("semver"));
|
|
45
|
+
var tiny_secp256k1_1 = require("tiny-secp256k1");
|
|
57
46
|
var bip32_1 = require("./bip32");
|
|
58
47
|
var buffertools_1 = require("./buffertools");
|
|
59
|
-
var
|
|
48
|
+
var accounttype_1 = require("./newops/accounttype");
|
|
60
49
|
var policy_1 = require("./newops/policy");
|
|
61
50
|
var psbtExtractor_1 = require("./newops/psbtExtractor");
|
|
62
51
|
var psbtFinalizer_1 = require("./newops/psbtFinalizer");
|
|
63
52
|
var psbtv2_1 = require("./newops/psbtv2");
|
|
64
53
|
var serializeTransaction_1 = require("./serializeTransaction");
|
|
65
|
-
var constants_1 = require("./constants");
|
|
66
54
|
var newSupportedApps = ["Bitcoin", "Bitcoin Test"];
|
|
67
55
|
function canSupportApp(appAndVersion) {
|
|
68
56
|
return (newSupportedApps.includes(appAndVersion.name) &&
|
|
69
57
|
semver_1["default"].major(appAndVersion.version) >= 2);
|
|
70
58
|
}
|
|
71
59
|
exports.canSupportApp = canSupportApp;
|
|
60
|
+
/**
|
|
61
|
+
* This class implements the same interface as BtcOld (formerly
|
|
62
|
+
* named Btc), but interacts with Bitcoin hardware app version 2+
|
|
63
|
+
* which uses a totally new APDU protocol. This new
|
|
64
|
+
* protocol is documented at
|
|
65
|
+
* https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md
|
|
66
|
+
*
|
|
67
|
+
* Since the interface must remain compatible with BtcOld, the methods
|
|
68
|
+
* of this class are quite clunky, because it needs to adapt legacy
|
|
69
|
+
* input data into the PSBT process. In the future, a new interface should
|
|
70
|
+
* be developed that exposes PSBT to the outer world, which would render
|
|
71
|
+
* a much cleaner implementation.
|
|
72
|
+
*/
|
|
72
73
|
var BtcNew = /** @class */ (function () {
|
|
73
74
|
function BtcNew(client) {
|
|
74
75
|
this.client = client;
|
|
75
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* This is a new method that allow users to get an xpub at a standard path.
|
|
79
|
+
* Standard paths are described at
|
|
80
|
+
* https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md#description
|
|
81
|
+
*
|
|
82
|
+
* This boils down to paths (N=0 for Bitcoin, N=1 for Testnet):
|
|
83
|
+
* M/44'/N'/x'/**
|
|
84
|
+
* M/48'/N'/x'/y'/**
|
|
85
|
+
* M/49'/N'/x'/**
|
|
86
|
+
* M/84'/N'/x'/**
|
|
87
|
+
* M/86'/N'/x'/**
|
|
88
|
+
*
|
|
89
|
+
* The method was added because of added security in the hardware app v2+. The
|
|
90
|
+
* new hardware app will allow export of any xpub up to and including the
|
|
91
|
+
* deepest hardened key of standard derivation paths, whereas the old app
|
|
92
|
+
* would allow export of any key.
|
|
93
|
+
*
|
|
94
|
+
* This caused an issue for callers of this class, who only had
|
|
95
|
+
* getWalletPublicKey() to call which means they have to constuct xpub
|
|
96
|
+
* themselves:
|
|
97
|
+
*
|
|
98
|
+
* Suppose a user of this class wants to create an account xpub on a standard
|
|
99
|
+
* path, M/44'/0'/Z'. The user must get the parent key fingerprint (see BIP32)
|
|
100
|
+
* by requesting the parent key M/44'/0'. The new app won't allow that, because
|
|
101
|
+
* it only allows exporting deepest level hardened path. So the options are to
|
|
102
|
+
* allow requesting M/44'/0' from the app, or to add a new function
|
|
103
|
+
* "getWalletXpub".
|
|
104
|
+
*
|
|
105
|
+
* We opted for adding a new function, which can greatly simplify client code.
|
|
106
|
+
*/
|
|
76
107
|
BtcNew.prototype.getWalletXpub = function (_a) {
|
|
77
108
|
var path = _a.path, xpubVersion = _a.xpubVersion;
|
|
78
109
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -81,7 +112,7 @@ var BtcNew = /** @class */ (function () {
|
|
|
81
112
|
switch (_b.label) {
|
|
82
113
|
case 0:
|
|
83
114
|
pathElements = (0, bip32_1.pathStringToArray)(path);
|
|
84
|
-
return [4 /*yield*/, this.client.
|
|
115
|
+
return [4 /*yield*/, this.client.getExtendedPubkey(false, pathElements)];
|
|
85
116
|
case 1:
|
|
86
117
|
xpub = _b.sent();
|
|
87
118
|
xpubComponents = (0, bip32_1.getXpubComponents)(xpub);
|
|
@@ -93,6 +124,13 @@ var BtcNew = /** @class */ (function () {
|
|
|
93
124
|
});
|
|
94
125
|
});
|
|
95
126
|
};
|
|
127
|
+
/**
|
|
128
|
+
* This method returns a public key, a bitcoin address, and and a chaincode
|
|
129
|
+
* for a specific derivation path.
|
|
130
|
+
*
|
|
131
|
+
* Limitation: If the path is not a leaf node of a standard path, the address
|
|
132
|
+
* will be the empty string "", see this.getWalletAddress() for details.
|
|
133
|
+
*/
|
|
96
134
|
BtcNew.prototype.getWalletPublicKey = function (path, opts) {
|
|
97
135
|
var _a, _b;
|
|
98
136
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -101,11 +139,11 @@ var BtcNew = /** @class */ (function () {
|
|
|
101
139
|
switch (_c.label) {
|
|
102
140
|
case 0:
|
|
103
141
|
pathElements = (0, bip32_1.pathStringToArray)(path);
|
|
104
|
-
return [4 /*yield*/, this.client.
|
|
142
|
+
return [4 /*yield*/, this.client.getExtendedPubkey(false, pathElements)];
|
|
105
143
|
case 1:
|
|
106
144
|
xpub = _c.sent();
|
|
107
145
|
display = (_a = opts === null || opts === void 0 ? void 0 : opts.verify) !== null && _a !== void 0 ? _a : false;
|
|
108
|
-
return [4 /*yield*/, this.getWalletAddress(pathElements,
|
|
146
|
+
return [4 /*yield*/, this.getWalletAddress(pathElements, descrTemplFrom((_b = opts === null || opts === void 0 ? void 0 : opts.format) !== null && _b !== void 0 ? _b : "legacy"), display)];
|
|
109
147
|
case 2:
|
|
110
148
|
address = _c.sent();
|
|
111
149
|
components = (0, bip32_1.getXpubComponents)(xpub);
|
|
@@ -128,13 +166,13 @@ var BtcNew = /** @class */ (function () {
|
|
|
128
166
|
*
|
|
129
167
|
* If display is false we *could* generate the address ourselves, but chose to
|
|
130
168
|
* get it from the device to save development time. However, it shouldn't take
|
|
131
|
-
*
|
|
169
|
+
* too much time to implement local address generation.
|
|
132
170
|
*
|
|
133
171
|
* Moreover, if the path is not for a leaf, ie accountPath+/X/Y, there is no
|
|
134
172
|
* way to get the address from the device. In this case we have to create it
|
|
135
173
|
* ourselves, but we don't at this time, and instead return an empty ("") address.
|
|
136
174
|
*/
|
|
137
|
-
BtcNew.prototype.getWalletAddress = function (pathElements,
|
|
175
|
+
BtcNew.prototype.getWalletAddress = function (pathElements, descrTempl, display) {
|
|
138
176
|
return __awaiter(this, void 0, void 0, function () {
|
|
139
177
|
var accountPath, accountXpub, masterFingerprint, policy, changeAndIndex;
|
|
140
178
|
return __generator(this, function (_a) {
|
|
@@ -144,13 +182,13 @@ var BtcNew = /** @class */ (function () {
|
|
|
144
182
|
if (accountPath.length + 2 != pathElements.length) {
|
|
145
183
|
return [2 /*return*/, ""];
|
|
146
184
|
}
|
|
147
|
-
return [4 /*yield*/, this.client.
|
|
185
|
+
return [4 /*yield*/, this.client.getExtendedPubkey(false, accountPath)];
|
|
148
186
|
case 1:
|
|
149
187
|
accountXpub = _a.sent();
|
|
150
188
|
return [4 /*yield*/, this.client.getMasterFingerprint()];
|
|
151
189
|
case 2:
|
|
152
190
|
masterFingerprint = _a.sent();
|
|
153
|
-
policy = new policy_1.WalletPolicy(
|
|
191
|
+
policy = new policy_1.WalletPolicy(descrTempl, (0, policy_1.createKey)(masterFingerprint, accountPath, accountXpub));
|
|
154
192
|
changeAndIndex = pathElements.slice(-2, pathElements.length);
|
|
155
193
|
return [2 /*return*/, this.client.getWalletAddress(policy, Buffer.alloc(32, 0), changeAndIndex[0], changeAndIndex[1], display)];
|
|
156
194
|
}
|
|
@@ -158,75 +196,62 @@ var BtcNew = /** @class */ (function () {
|
|
|
158
196
|
});
|
|
159
197
|
};
|
|
160
198
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
* * transaction is the previously computed transaction object for this UTXO
|
|
165
|
-
* * output_index is the output in the transaction used as input for this UTXO (counting from 0)
|
|
166
|
-
* * redeem script is the optional redeem script to use when consuming a Segregated Witness input
|
|
167
|
-
* * sequence is the sequence number to use for this input (when using RBF), or non present
|
|
168
|
-
* @param associatedKeysets is an array of BIP 32 paths pointing to the path to the private key used for each UTXO
|
|
169
|
-
* @param changePath is an optional BIP 32 path pointing to the path to the public key used to compute the change address
|
|
170
|
-
* @param outputScriptHex is the hexadecimal serialized outputs of the transaction to sign, including leading vararg voutCount
|
|
171
|
-
* @param lockTime is the optional lockTime of the transaction to sign, or default (0)
|
|
172
|
-
* @param sigHashType is the hash type of the transaction to sign, or default (all)
|
|
173
|
-
* @param segwit is an optional boolean indicating wether to use segwit or not. This includes wrapped segwit.
|
|
174
|
-
* @param initialTimestamp is an optional timestamp of the function call to use for coins that necessitate timestamps only, (not the one that the tx will include)
|
|
175
|
-
* @param additionals list of additionnal options
|
|
199
|
+
* Build and sign a transaction. See Btc.createPaymentTransactionNew for
|
|
200
|
+
* details on how to use this method.
|
|
176
201
|
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
* - "gold" for btg
|
|
181
|
-
* - "bipxxx" for using BIPxxx
|
|
182
|
-
* - "sapling" to indicate a zec transaction is supporting sapling (to be set over block 419200)
|
|
183
|
-
* @param expiryHeight is an optional Buffer for zec overwinter / sapling Txs
|
|
184
|
-
* @param useTrustedInputForSegwit trust inputs for segwit transactions. If app version >= 1.4.0 this should be true.
|
|
185
|
-
* @return the signed transaction ready to be broadcast
|
|
186
|
-
* @example
|
|
187
|
-
btc.createTransaction({
|
|
188
|
-
inputs: [ [tx1, 1] ],
|
|
189
|
-
associatedKeysets: ["0'/0/0"],
|
|
190
|
-
outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
|
|
191
|
-
}).then(res => ...);
|
|
202
|
+
* This method will convert the legacy arguments, CreateTransactionArg, into
|
|
203
|
+
* a psbt which is finally signed and finalized, and the extracted fully signed
|
|
204
|
+
* transaction is returned.
|
|
192
205
|
*/
|
|
193
206
|
BtcNew.prototype.createPaymentTransactionNew = function (arg) {
|
|
194
207
|
return __awaiter(this, void 0, void 0, function () {
|
|
195
|
-
var psbt, accountType,
|
|
208
|
+
var inputCount, psbt, masterFp, accountType, notifyCount, progress, accountXpub, accountPath, i, pathElems, outputsConcat, outputsBufferReader, outputCount, changeData, changeFound, i, amount, outputScript, isChange, changePath, pubkey, key, p, firstSigned, progressCallback, serializedTx;
|
|
196
209
|
return __generator(this, function (_a) {
|
|
197
210
|
switch (_a.label) {
|
|
198
211
|
case 0:
|
|
199
|
-
|
|
212
|
+
inputCount = arg.inputs.length;
|
|
213
|
+
if (inputCount == 0) {
|
|
200
214
|
throw Error("No inputs");
|
|
201
215
|
}
|
|
202
216
|
psbt = new psbtv2_1.PsbtV2();
|
|
203
|
-
|
|
204
|
-
|
|
217
|
+
return [4 /*yield*/, this.client.getMasterFingerprint()];
|
|
218
|
+
case 1:
|
|
219
|
+
masterFp = _a.sent();
|
|
220
|
+
accountType = accountTypeFromArg(arg, psbt, masterFp);
|
|
205
221
|
if (arg.lockTime) {
|
|
222
|
+
// The signer will assume locktime 0 if unset
|
|
206
223
|
psbt.setGlobalFallbackLocktime(arg.lockTime);
|
|
207
224
|
}
|
|
208
|
-
psbt.setGlobalInputCount(
|
|
225
|
+
psbt.setGlobalInputCount(inputCount);
|
|
209
226
|
psbt.setGlobalPsbtVersion(2);
|
|
210
227
|
psbt.setGlobalTxVersion(2);
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
228
|
+
notifyCount = 0;
|
|
229
|
+
progress = function () {
|
|
230
|
+
if (!arg.onDeviceStreaming)
|
|
231
|
+
return;
|
|
232
|
+
arg.onDeviceStreaming({
|
|
233
|
+
total: 2 * inputCount,
|
|
234
|
+
index: notifyCount,
|
|
235
|
+
progress: ++notifyCount / (2 * inputCount)
|
|
236
|
+
});
|
|
237
|
+
};
|
|
214
238
|
accountXpub = "";
|
|
215
239
|
accountPath = [];
|
|
216
240
|
i = 0;
|
|
217
241
|
_a.label = 2;
|
|
218
242
|
case 2:
|
|
219
|
-
if (!(i <
|
|
243
|
+
if (!(i < inputCount)) return [3 /*break*/, 7];
|
|
244
|
+
progress();
|
|
220
245
|
pathElems = (0, bip32_1.pathStringToArray)(arg.associatedKeysets[i]);
|
|
221
246
|
if (!(accountXpub == "")) return [3 /*break*/, 4];
|
|
222
247
|
// We assume all inputs belong to the same account so we set
|
|
223
248
|
// the account xpub and path based on the first input.
|
|
224
249
|
accountPath = pathElems.slice(0, -2);
|
|
225
|
-
return [4 /*yield*/, this.client.
|
|
250
|
+
return [4 /*yield*/, this.client.getExtendedPubkey(false, accountPath)];
|
|
226
251
|
case 3:
|
|
227
252
|
accountXpub = _a.sent();
|
|
228
253
|
_a.label = 4;
|
|
229
|
-
case 4: return [4 /*yield*/, this.setInput(psbt, i, arg.inputs[i], pathElems, accountType, masterFp)];
|
|
254
|
+
case 4: return [4 /*yield*/, this.setInput(psbt, i, arg.inputs[i], pathElems, accountType, masterFp, arg.sigHashType)];
|
|
230
255
|
case 5:
|
|
231
256
|
_a.sent();
|
|
232
257
|
_a.label = 6;
|
|
@@ -237,52 +262,63 @@ var BtcNew = /** @class */ (function () {
|
|
|
237
262
|
outputsConcat = Buffer.from(arg.outputScriptHex, "hex");
|
|
238
263
|
outputsBufferReader = new buffertools_1.BufferReader(outputsConcat);
|
|
239
264
|
outputCount = outputsBufferReader.readVarInt();
|
|
265
|
+
psbt.setGlobalOutputCount(outputCount);
|
|
240
266
|
return [4 /*yield*/, this.outputScriptAt(accountPath, accountType, arg.changePath)];
|
|
241
267
|
case 8:
|
|
242
268
|
changeData = _a.sent();
|
|
243
|
-
psbt.setGlobalOutputCount(outputCount);
|
|
244
269
|
changeFound = !changeData;
|
|
245
270
|
for (i = 0; i < outputCount; i++) {
|
|
246
271
|
amount = Number(outputsBufferReader.readUInt64());
|
|
247
272
|
outputScript = outputsBufferReader.readVarSlice();
|
|
248
|
-
|
|
273
|
+
psbt.setOutputAmount(i, amount);
|
|
274
|
+
psbt.setOutputScript(i, outputScript);
|
|
275
|
+
isChange = changeData && outputScript.equals(changeData === null || changeData === void 0 ? void 0 : changeData.cond.scriptPubKey);
|
|
249
276
|
if (isChange) {
|
|
250
277
|
changeFound = true;
|
|
251
278
|
changePath = (0, bip32_1.pathStringToArray)(arg.changePath);
|
|
252
279
|
pubkey = changeData.pubkey;
|
|
253
|
-
|
|
254
|
-
psbt.setOutputBip32Derivation(i, pubkey, masterFp, changePath);
|
|
255
|
-
}
|
|
256
|
-
else if (accountType == AccountType.p2wpkh) {
|
|
257
|
-
psbt.setOutputBip32Derivation(i, pubkey, masterFp, changePath);
|
|
258
|
-
}
|
|
259
|
-
else if (accountType == AccountType.p2wpkhWrapped) {
|
|
260
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
261
|
-
psbt.setOutputRedeemScript(i, changeData.redeemScript);
|
|
262
|
-
psbt.setOutputBip32Derivation(i, pubkey, masterFp, changePath);
|
|
263
|
-
}
|
|
264
|
-
else if (accountType == AccountType.p2tr) {
|
|
265
|
-
psbt.setOutputTapBip32Derivation(i, pubkey, [], masterFp, changePath);
|
|
266
|
-
}
|
|
280
|
+
accountType.setOwnOutput(i, changeData.cond, [pubkey], [changePath]);
|
|
267
281
|
}
|
|
268
|
-
psbt.setOutputAmount(i, amount);
|
|
269
|
-
psbt.setOutputScript(i, outputScript);
|
|
270
282
|
}
|
|
271
283
|
if (!changeFound) {
|
|
272
284
|
throw new Error("Change script not found among outputs! " +
|
|
273
|
-
(changeData === null || changeData === void 0 ? void 0 : changeData.
|
|
285
|
+
(changeData === null || changeData === void 0 ? void 0 : changeData.cond.scriptPubKey.toString("hex")));
|
|
274
286
|
}
|
|
275
287
|
key = (0, policy_1.createKey)(masterFp, accountPath, accountXpub);
|
|
276
|
-
p = new policy_1.WalletPolicy(accountType, key);
|
|
277
|
-
|
|
278
|
-
|
|
288
|
+
p = new policy_1.WalletPolicy(accountType.getDescriptorTemplate(), key);
|
|
289
|
+
// This is cheating, because it's not actually requested on the
|
|
290
|
+
// device yet, but it will be, soonish.
|
|
291
|
+
if (arg.onDeviceSignatureRequested)
|
|
292
|
+
arg.onDeviceSignatureRequested();
|
|
293
|
+
firstSigned = false;
|
|
294
|
+
progressCallback = function () {
|
|
295
|
+
if (!firstSigned) {
|
|
296
|
+
firstSigned = true;
|
|
297
|
+
arg.onDeviceSignatureGranted && arg.onDeviceSignatureGranted();
|
|
298
|
+
}
|
|
299
|
+
progress();
|
|
300
|
+
};
|
|
301
|
+
return [4 /*yield*/, this.signPsbt(psbt, p, progressCallback)];
|
|
302
|
+
case 9:
|
|
303
|
+
_a.sent();
|
|
304
|
+
(0, psbtFinalizer_1.finalize)(psbt);
|
|
305
|
+
serializedTx = (0, psbtExtractor_1.extract)(psbt);
|
|
306
|
+
return [2 /*return*/, serializedTx.toString("hex")];
|
|
279
307
|
}
|
|
280
308
|
});
|
|
281
309
|
});
|
|
282
310
|
};
|
|
311
|
+
/**
|
|
312
|
+
* Calculates an output script along with public key and possible redeemScript
|
|
313
|
+
* from a path and accountType. The accountPath must be a prefix of path.
|
|
314
|
+
*
|
|
315
|
+
* @returns an object with output script (property "script"), redeemScript (if
|
|
316
|
+
* wrapped p2wpkh), and pubkey at provided path. The values of these three
|
|
317
|
+
* properties depend on the accountType used.
|
|
318
|
+
*/
|
|
283
319
|
BtcNew.prototype.outputScriptAt = function (accountPath, accountType, path) {
|
|
284
320
|
return __awaiter(this, void 0, void 0, function () {
|
|
285
|
-
var pathElems, i, xpub, pubkey,
|
|
321
|
+
var pathElems, i, xpub, pubkey, cond;
|
|
286
322
|
return __generator(this, function (_a) {
|
|
287
323
|
switch (_a.label) {
|
|
288
324
|
case 0:
|
|
@@ -296,68 +332,52 @@ var BtcNew = /** @class */ (function () {
|
|
|
296
332
|
throw new Error("Path " + path + " not in account " + (0, bip32_1.pathArrayToString)(accountPath));
|
|
297
333
|
}
|
|
298
334
|
}
|
|
299
|
-
return [4 /*yield*/, this.client.
|
|
335
|
+
return [4 /*yield*/, this.client.getExtendedPubkey(false, pathElems)];
|
|
300
336
|
case 1:
|
|
301
337
|
xpub = _a.sent();
|
|
302
338
|
pubkey = (0, bip32_1.pubkeyFromXpub)(xpub);
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
script = outputScriptOf(pubkey, accountType);
|
|
307
|
-
return [2 /*return*/, __assign(__assign({}, script), { pubkey: pubkey })];
|
|
339
|
+
cond = accountType.spendingCondition([pubkey]);
|
|
340
|
+
return [2 /*return*/, { cond: cond, pubkey: pubkey }];
|
|
308
341
|
}
|
|
309
342
|
});
|
|
310
343
|
});
|
|
311
344
|
};
|
|
312
|
-
|
|
345
|
+
/**
|
|
346
|
+
* Adds relevant data about an input to the psbt. This includes sequence,
|
|
347
|
+
* previous txid, output index, spent UTXO, redeem script for wrapped p2wpkh,
|
|
348
|
+
* public key and its derivation path.
|
|
349
|
+
*/
|
|
350
|
+
BtcNew.prototype.setInput = function (psbt, i, input, pathElements, accountType, masterFP, sigHashType) {
|
|
313
351
|
return __awaiter(this, void 0, void 0, function () {
|
|
314
|
-
var inputTx, spentOutputIndex, redeemScript, sequence, inputTxBuffer, inputTxid, xpubBase58, pubkey,
|
|
352
|
+
var inputTx, spentOutputIndex, redeemScript, sequence, inputTxBuffer, inputTxid, xpubBase58, pubkey, spentTxOutput, spendCondition, spentOutput;
|
|
315
353
|
return __generator(this, function (_a) {
|
|
316
354
|
switch (_a.label) {
|
|
317
355
|
case 0:
|
|
318
356
|
inputTx = input[0];
|
|
319
357
|
spentOutputIndex = input[1];
|
|
320
|
-
redeemScript = input[2];
|
|
358
|
+
redeemScript = input[2] ? Buffer.from(input[2], "hex") : undefined;
|
|
321
359
|
sequence = input[3];
|
|
322
360
|
if (sequence) {
|
|
323
361
|
psbt.setInputSequence(i, sequence);
|
|
324
362
|
}
|
|
363
|
+
if (sigHashType) {
|
|
364
|
+
psbt.setInputSighashType(i, sigHashType);
|
|
365
|
+
}
|
|
325
366
|
inputTxBuffer = (0, serializeTransaction_1.serializeTransaction)(inputTx, true);
|
|
326
367
|
inputTxid = bitcoinjs_lib_1.crypto.hash256(inputTxBuffer);
|
|
327
|
-
return [4 /*yield*/, this.client.
|
|
368
|
+
return [4 /*yield*/, this.client.getExtendedPubkey(false, pathElements)];
|
|
328
369
|
case 1:
|
|
329
370
|
xpubBase58 = _a.sent();
|
|
330
371
|
pubkey = (0, bip32_1.pubkeyFromXpub)(xpubBase58);
|
|
331
372
|
if (!inputTx.outputs)
|
|
332
373
|
throw Error("Missing outputs array in transaction to sign");
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
psbt.setInputBip32Derivation(i, pubkey, masterFP, pathElements);
|
|
341
|
-
psbt.setInputWitnessUtxo(i, spentOutput.amount, spentOutput.script);
|
|
342
|
-
}
|
|
343
|
-
else if (accountType == AccountType.p2wpkhWrapped) {
|
|
344
|
-
psbt.setInputNonWitnessUtxo(i, inputTxBuffer);
|
|
345
|
-
psbt.setInputBip32Derivation(i, pubkey, masterFP, pathElements);
|
|
346
|
-
if (!redeemScript) {
|
|
347
|
-
throw new Error("Missing redeemScript for p2wpkhWrapped input");
|
|
348
|
-
}
|
|
349
|
-
expectedRedeemScript = createRedeemScript(pubkey);
|
|
350
|
-
if (redeemScript != expectedRedeemScript.toString("hex")) {
|
|
351
|
-
throw new Error("Unexpected redeemScript");
|
|
352
|
-
}
|
|
353
|
-
psbt.setInputRedeemScript(i, expectedRedeemScript);
|
|
354
|
-
psbt.setInputWitnessUtxo(i, spentOutput.amount, spentOutput.script);
|
|
355
|
-
}
|
|
356
|
-
else if (accountType == AccountType.p2tr) {
|
|
357
|
-
xonly = pubkey.slice(1);
|
|
358
|
-
psbt.setInputTapBip32Derivation(i, xonly, [], masterFP, pathElements);
|
|
359
|
-
psbt.setInputWitnessUtxo(i, spentOutput.amount, spentOutput.script);
|
|
360
|
-
}
|
|
374
|
+
spentTxOutput = inputTx.outputs[spentOutputIndex];
|
|
375
|
+
spendCondition = {
|
|
376
|
+
scriptPubKey: spentTxOutput.script,
|
|
377
|
+
redeemScript: redeemScript
|
|
378
|
+
};
|
|
379
|
+
spentOutput = { cond: spendCondition, amount: spentTxOutput.amount };
|
|
380
|
+
accountType.setInput(i, inputTxBuffer, spentOutput, [pubkey], [pathElements]);
|
|
361
381
|
psbt.setInputPreviousTxId(i, inputTxid);
|
|
362
382
|
psbt.setInputOutputIndex(i, spentOutputIndex);
|
|
363
383
|
return [2 /*return*/];
|
|
@@ -365,17 +385,26 @@ var BtcNew = /** @class */ (function () {
|
|
|
365
385
|
});
|
|
366
386
|
});
|
|
367
387
|
};
|
|
368
|
-
|
|
388
|
+
/**
|
|
389
|
+
* This implements the "Signer" role of the BIP370 transaction signing
|
|
390
|
+
* process.
|
|
391
|
+
*
|
|
392
|
+
* It ssks the hardware device to sign the a psbt using the specified wallet
|
|
393
|
+
* policy. This method assumes BIP32 derived keys are used for all inputs, see
|
|
394
|
+
* comment in-line. The signatures returned from the hardware device is added
|
|
395
|
+
* to the appropriate input fields of the PSBT.
|
|
396
|
+
*/
|
|
397
|
+
BtcNew.prototype.signPsbt = function (psbt, walletPolicy, progressCallback) {
|
|
369
398
|
return __awaiter(this, void 0, void 0, function () {
|
|
370
|
-
var sigs
|
|
399
|
+
var sigs;
|
|
371
400
|
return __generator(this, function (_a) {
|
|
372
401
|
switch (_a.label) {
|
|
373
|
-
case 0: return [4 /*yield*/, this.client.signPsbt(psbt, walletPolicy, Buffer.alloc(32, 0))];
|
|
402
|
+
case 0: return [4 /*yield*/, this.client.signPsbt(psbt, walletPolicy, Buffer.alloc(32, 0), progressCallback)];
|
|
374
403
|
case 1:
|
|
375
404
|
sigs = _a.sent();
|
|
376
405
|
sigs.forEach(function (v, k) {
|
|
377
|
-
// Note: Looking at BIP32 derivation does not work in the generic case
|
|
378
|
-
// some inputs might not have a BIP32-derived pubkey.
|
|
406
|
+
// Note: Looking at BIP32 derivation does not work in the generic case,
|
|
407
|
+
// since some inputs might not have a BIP32-derived pubkey.
|
|
379
408
|
var pubkeys = psbt.getInputKeyDatas(k, psbtv2_1.psbtIn.BIP32_DERIVATION);
|
|
380
409
|
var pubkey;
|
|
381
410
|
if (pubkeys.length != 1) {
|
|
@@ -391,9 +420,7 @@ var BtcNew = /** @class */ (function () {
|
|
|
391
420
|
psbt.setInputPartialSig(k, pubkey, v);
|
|
392
421
|
}
|
|
393
422
|
});
|
|
394
|
-
|
|
395
|
-
serializedTx = (0, psbtExtractor_1.extract)(psbt);
|
|
396
|
-
return [2 /*return*/, serializedTx.toString("hex")];
|
|
423
|
+
return [2 /*return*/];
|
|
397
424
|
}
|
|
398
425
|
});
|
|
399
426
|
});
|
|
@@ -401,90 +428,24 @@ var BtcNew = /** @class */ (function () {
|
|
|
401
428
|
return BtcNew;
|
|
402
429
|
}());
|
|
403
430
|
exports["default"] = BtcNew;
|
|
404
|
-
|
|
405
|
-
(function (AccountType) {
|
|
406
|
-
AccountType["p2pkh"] = "pkh(@0)";
|
|
407
|
-
AccountType["p2wpkh"] = "wpkh(@0)";
|
|
408
|
-
AccountType["p2wpkhWrapped"] = "sh(wpkh(@0))";
|
|
409
|
-
AccountType["p2tr"] = "tr(@0)";
|
|
410
|
-
})(AccountType || (AccountType = {}));
|
|
411
|
-
function createRedeemScript(pubkey) {
|
|
412
|
-
var pubkeyHash = (0, hashPublicKey_1.hashPublicKey)(pubkey);
|
|
413
|
-
return Buffer.concat([Buffer.from("0014", "hex"), pubkeyHash]);
|
|
414
|
-
}
|
|
415
|
-
function outputScriptOf(pubkey, accountType) {
|
|
416
|
-
var buf = new buffertools_1.BufferWriter();
|
|
417
|
-
var pubkeyHash = (0, hashPublicKey_1.hashPublicKey)(pubkey);
|
|
418
|
-
var redeemScript;
|
|
419
|
-
if (accountType == AccountType.p2pkh) {
|
|
420
|
-
buf.writeSlice(Buffer.of(constants_1.OP_DUP, constants_1.OP_HASH160, constants_1.HASH_SIZE));
|
|
421
|
-
buf.writeSlice(pubkeyHash);
|
|
422
|
-
buf.writeSlice(Buffer.of(constants_1.OP_EQUALVERIFY, constants_1.OP_CHECKSIG));
|
|
423
|
-
}
|
|
424
|
-
else if (accountType == AccountType.p2wpkhWrapped) {
|
|
425
|
-
redeemScript = createRedeemScript(pubkey);
|
|
426
|
-
var scriptHash = (0, hashPublicKey_1.hashPublicKey)(redeemScript);
|
|
427
|
-
buf.writeSlice(Buffer.of(constants_1.OP_HASH160, constants_1.HASH_SIZE));
|
|
428
|
-
buf.writeSlice(scriptHash);
|
|
429
|
-
buf.writeUInt8(constants_1.OP_EQUAL);
|
|
430
|
-
}
|
|
431
|
-
else if (accountType == AccountType.p2wpkh) {
|
|
432
|
-
buf.writeSlice(Buffer.of(0, constants_1.HASH_SIZE));
|
|
433
|
-
buf.writeSlice(pubkeyHash);
|
|
434
|
-
}
|
|
435
|
-
else if (accountType == AccountType.p2tr) {
|
|
436
|
-
console.log("Internal key: " + pubkey.toString("hex"));
|
|
437
|
-
var outputKey = getTaprootOutputKey(pubkey);
|
|
438
|
-
buf.writeSlice(Buffer.of(0x51, 32)); // push1, pubkeylen
|
|
439
|
-
buf.writeSlice(outputKey);
|
|
440
|
-
}
|
|
441
|
-
return { script: buf.buffer(), redeemScript: redeemScript };
|
|
442
|
-
}
|
|
443
|
-
function accountTypeFrom(addressFormat) {
|
|
431
|
+
function descrTemplFrom(addressFormat) {
|
|
444
432
|
if (addressFormat == "legacy")
|
|
445
|
-
return
|
|
433
|
+
return "pkh(@0)";
|
|
446
434
|
if (addressFormat == "p2sh")
|
|
447
|
-
return
|
|
435
|
+
return "sh(wpkh(@0))";
|
|
448
436
|
if (addressFormat == "bech32")
|
|
449
|
-
return
|
|
437
|
+
return "wpkh(@0)";
|
|
450
438
|
if (addressFormat == "bech32m")
|
|
451
|
-
return
|
|
439
|
+
return "tr(@0)";
|
|
452
440
|
throw new Error("Unsupported address format " + addressFormat);
|
|
453
441
|
}
|
|
454
|
-
function accountTypeFromArg(arg) {
|
|
442
|
+
function accountTypeFromArg(arg, psbt, masterFp) {
|
|
455
443
|
if (arg.additionals.includes("bech32m"))
|
|
456
|
-
return
|
|
444
|
+
return new accounttype_1.p2tr(psbt, masterFp);
|
|
457
445
|
if (arg.additionals.includes("bech32"))
|
|
458
|
-
return
|
|
446
|
+
return new accounttype_1.p2wpkh(psbt, masterFp);
|
|
459
447
|
if (arg.segwit)
|
|
460
|
-
return
|
|
461
|
-
return
|
|
462
|
-
}
|
|
463
|
-
/*
|
|
464
|
-
The following two functions are copied from wallet-btc and adapte.
|
|
465
|
-
They should be moved to a library to avoid code reuse.
|
|
466
|
-
*/
|
|
467
|
-
function hashTapTweak(x) {
|
|
468
|
-
// hash_tag(x) = SHA256(SHA256(tag) || SHA256(tag) || x), see BIP340
|
|
469
|
-
// See https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki#specification
|
|
470
|
-
var h = bitcoinjs_lib_1.crypto.sha256(Buffer.from("TapTweak", "utf-8"));
|
|
471
|
-
return bitcoinjs_lib_1.crypto.sha256(Buffer.concat([h, h, x]));
|
|
472
|
-
}
|
|
473
|
-
function getTaprootOutputKey(internalPubkey) {
|
|
474
|
-
if (internalPubkey.length != 32) {
|
|
475
|
-
throw new Error("Expected 32 byte pubkey. Got " + internalPubkey.length);
|
|
476
|
-
}
|
|
477
|
-
// A BIP32 derived key can be converted to a schnorr pubkey by dropping
|
|
478
|
-
// the first byte, which represent the oddness/evenness. In schnorr all
|
|
479
|
-
// pubkeys are even.
|
|
480
|
-
// https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki#public-key-conversion
|
|
481
|
-
var evenEcdsaPubkey = Buffer.concat([Buffer.of(0x02), internalPubkey]);
|
|
482
|
-
var tweak = hashTapTweak(internalPubkey);
|
|
483
|
-
// Q = P + int(hash_TapTweak(bytes(P)))G
|
|
484
|
-
var outputEcdsaKey = Buffer.from((0, tiny_secp256k1_1.pointAddScalar)(evenEcdsaPubkey, tweak));
|
|
485
|
-
// Convert to schnorr.
|
|
486
|
-
var outputSchnorrKey = outputEcdsaKey.slice(1);
|
|
487
|
-
// Create address
|
|
488
|
-
return outputSchnorrKey;
|
|
448
|
+
return new accounttype_1.p2wpkhWrapped(psbt, masterFp);
|
|
449
|
+
return new accounttype_1.p2pkh(psbt, masterFp);
|
|
489
450
|
}
|
|
490
451
|
//# sourceMappingURL=BtcNew.js.map
|
package/lib/BtcNew.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BtcNew.js","sourceRoot":"","sources":["../src/BtcNew.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAuC;AACvC,iDAA+D;AAC/D,kDAA4B;AAC5B,iCAMiB;AACjB,6CAA2D;AAG3D,iDAAgD;AAEhD,0CAA0D;AAC1D,wDAAiD;AACjD,wDAAkD;AAClD,0CAAiD;AACjD,+DAA8D;AAE9D,yCAOqB;AAGrB,IAAM,gBAAgB,GAAG,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;AAErD,SAAgB,aAAa,CAAC,aAA4B;IACxD,OAA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