@ledgerhq/hw-app-btc 10.0.4 → 10.0.5-next.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/CHANGELOG.md +7 -0
- package/lib/Btc.d.ts.map +1 -1
- package/lib/Btc.js +6 -8
- package/lib/Btc.js.map +1 -1
- package/lib/BtcNew.d.ts +1 -1
- package/lib/BtcNew.d.ts.map +1 -1
- package/lib/BtcNew.js +5 -6
- package/lib/BtcNew.js.map +1 -1
- package/lib/BtcOld.d.ts +1 -1
- package/lib/BtcOld.d.ts.map +1 -1
- package/lib/BtcOld.js +2 -5
- package/lib/BtcOld.js.map +1 -1
- package/lib/buffertools.js +3 -3
- package/lib/buffertools.js.map +1 -1
- package/lib/createTransaction.d.ts +1 -6
- package/lib/createTransaction.d.ts.map +1 -1
- package/lib/createTransaction.js +5 -13
- package/lib/createTransaction.js.map +1 -1
- package/lib/finalizeInput.d.ts.map +1 -1
- package/lib/finalizeInput.js.map +1 -1
- package/lib/getAppAndVersion.d.ts.map +1 -1
- package/lib/getAppAndVersion.js.map +1 -1
- package/lib/getTrustedInput.d.ts.map +1 -1
- package/lib/getTrustedInput.js +5 -12
- package/lib/getTrustedInput.js.map +1 -1
- package/lib/getTrustedInputBIP143.d.ts.map +1 -1
- package/lib/getTrustedInputBIP143.js.map +1 -1
- package/lib/getWalletPublicKey.d.ts.map +1 -1
- package/lib/getWalletPublicKey.js.map +1 -1
- package/lib/newops/accounttype.d.ts.map +1 -1
- package/lib/newops/accounttype.js +2 -6
- package/lib/newops/accounttype.js.map +1 -1
- package/lib/newops/appClient.d.ts.map +1 -1
- package/lib/newops/appClient.js +7 -14
- package/lib/newops/appClient.js.map +1 -1
- package/lib/newops/clientCommands.d.ts.map +1 -1
- package/lib/newops/clientCommands.js +2 -2
- package/lib/newops/clientCommands.js.map +1 -1
- package/lib/newops/merkelizedPsbt.d.ts.map +1 -1
- package/lib/newops/merkelizedPsbt.js +4 -4
- package/lib/newops/merkelizedPsbt.js.map +1 -1
- package/lib/newops/merkle.d.ts.map +1 -1
- package/lib/newops/merkle.js.map +1 -1
- package/lib/newops/merkleMap.js +2 -2
- package/lib/newops/merkleMap.js.map +1 -1
- package/lib/newops/policy.d.ts.map +1 -1
- package/lib/newops/policy.js +2 -2
- package/lib/newops/policy.js.map +1 -1
- package/lib/newops/psbtFinalizer.d.ts.map +1 -1
- package/lib/newops/psbtFinalizer.js.map +1 -1
- package/lib/newops/psbtv2.d.ts.map +1 -1
- package/lib/newops/psbtv2.js +6 -6
- package/lib/newops/psbtv2.js.map +1 -1
- package/lib/serializeTransaction.d.ts.map +1 -1
- package/lib/serializeTransaction.js +3 -4
- package/lib/serializeTransaction.js.map +1 -1
- package/lib/signMessage.d.ts.map +1 -1
- package/lib/signMessage.js +2 -6
- package/lib/signMessage.js.map +1 -1
- package/lib/signP2SHTransaction.d.ts +1 -6
- package/lib/signP2SHTransaction.d.ts.map +1 -1
- package/lib/signP2SHTransaction.js +2 -6
- package/lib/signP2SHTransaction.js.map +1 -1
- package/lib/signTransaction.d.ts.map +1 -1
- package/lib/signTransaction.js +2 -7
- package/lib/signTransaction.js.map +1 -1
- package/lib/splitTransaction.d.ts.map +1 -1
- package/lib/splitTransaction.js.map +1 -1
- package/lib/startUntrustedHashTransactionInput.d.ts.map +1 -1
- package/lib/startUntrustedHashTransactionInput.js +1 -4
- package/lib/startUntrustedHashTransactionInput.js.map +1 -1
- package/lib-es/Btc.d.ts.map +1 -1
- package/lib-es/Btc.js +6 -8
- package/lib-es/Btc.js.map +1 -1
- package/lib-es/BtcNew.d.ts +1 -1
- package/lib-es/BtcNew.d.ts.map +1 -1
- package/lib-es/BtcNew.js +6 -7
- package/lib-es/BtcNew.js.map +1 -1
- package/lib-es/BtcOld.d.ts +1 -1
- package/lib-es/BtcOld.d.ts.map +1 -1
- package/lib-es/BtcOld.js +2 -5
- package/lib-es/BtcOld.js.map +1 -1
- package/lib-es/buffertools.js +3 -3
- package/lib-es/buffertools.js.map +1 -1
- package/lib-es/createTransaction.d.ts +1 -6
- package/lib-es/createTransaction.d.ts.map +1 -1
- package/lib-es/createTransaction.js +5 -13
- package/lib-es/createTransaction.js.map +1 -1
- package/lib-es/finalizeInput.d.ts.map +1 -1
- package/lib-es/finalizeInput.js.map +1 -1
- package/lib-es/getAppAndVersion.d.ts.map +1 -1
- package/lib-es/getAppAndVersion.js.map +1 -1
- package/lib-es/getTrustedInput.d.ts.map +1 -1
- package/lib-es/getTrustedInput.js +5 -12
- package/lib-es/getTrustedInput.js.map +1 -1
- package/lib-es/getTrustedInputBIP143.d.ts.map +1 -1
- package/lib-es/getTrustedInputBIP143.js.map +1 -1
- package/lib-es/getWalletPublicKey.d.ts.map +1 -1
- package/lib-es/getWalletPublicKey.js.map +1 -1
- package/lib-es/newops/accounttype.d.ts.map +1 -1
- package/lib-es/newops/accounttype.js +3 -7
- package/lib-es/newops/accounttype.js.map +1 -1
- package/lib-es/newops/appClient.d.ts.map +1 -1
- package/lib-es/newops/appClient.js +7 -14
- package/lib-es/newops/appClient.js.map +1 -1
- package/lib-es/newops/clientCommands.d.ts.map +1 -1
- package/lib-es/newops/clientCommands.js +2 -2
- package/lib-es/newops/clientCommands.js.map +1 -1
- package/lib-es/newops/merkelizedPsbt.d.ts.map +1 -1
- package/lib-es/newops/merkelizedPsbt.js +4 -4
- package/lib-es/newops/merkelizedPsbt.js.map +1 -1
- package/lib-es/newops/merkle.d.ts.map +1 -1
- package/lib-es/newops/merkle.js.map +1 -1
- package/lib-es/newops/merkleMap.js +2 -2
- package/lib-es/newops/merkleMap.js.map +1 -1
- package/lib-es/newops/policy.d.ts.map +1 -1
- package/lib-es/newops/policy.js +2 -2
- package/lib-es/newops/policy.js.map +1 -1
- package/lib-es/newops/psbtFinalizer.d.ts.map +1 -1
- package/lib-es/newops/psbtFinalizer.js.map +1 -1
- package/lib-es/newops/psbtv2.d.ts.map +1 -1
- package/lib-es/newops/psbtv2.js +7 -7
- package/lib-es/newops/psbtv2.js.map +1 -1
- package/lib-es/serializeTransaction.d.ts.map +1 -1
- package/lib-es/serializeTransaction.js +3 -4
- package/lib-es/serializeTransaction.js.map +1 -1
- package/lib-es/signMessage.d.ts.map +1 -1
- package/lib-es/signMessage.js +2 -6
- package/lib-es/signMessage.js.map +1 -1
- package/lib-es/signP2SHTransaction.d.ts +1 -6
- package/lib-es/signP2SHTransaction.d.ts.map +1 -1
- package/lib-es/signP2SHTransaction.js +3 -7
- package/lib-es/signP2SHTransaction.js.map +1 -1
- package/lib-es/signTransaction.d.ts.map +1 -1
- package/lib-es/signTransaction.js +2 -7
- package/lib-es/signTransaction.js.map +1 -1
- package/lib-es/splitTransaction.d.ts.map +1 -1
- package/lib-es/splitTransaction.js.map +1 -1
- package/lib-es/startUntrustedHashTransactionInput.d.ts.map +1 -1
- package/lib-es/startUntrustedHashTransactionInput.js +1 -4
- package/lib-es/startUntrustedHashTransactionInput.js.map +1 -1
- package/package.json +5 -5
- package/src/Btc.ts +17 -31
- package/src/BtcNew.ts +27 -62
- package/src/BtcOld.ts +8 -19
- package/src/buffertools.ts +3 -3
- package/src/createTransaction.ts +20 -52
- package/src/finalizeInput.ts +2 -5
- package/src/getAppAndVersion.ts +2 -6
- package/src/getTrustedInput.ts +12 -32
- package/src/getTrustedInputBIP143.ts +2 -4
- package/src/getWalletPublicKey.ts +3 -11
- package/src/newops/accounttype.ts +21 -76
- package/src/newops/appClient.ts +17 -39
- package/src/newops/clientCommands.ts +7 -16
- package/src/newops/merkelizedPsbt.ts +6 -14
- package/src/newops/merkle.ts +3 -10
- package/src/newops/merkleMap.ts +2 -2
- package/src/newops/policy.ts +5 -15
- package/src/newops/psbtFinalizer.ts +3 -8
- package/src/newops/psbtv2.ts +32 -85
- package/src/serializeTransaction.ts +5 -9
- package/src/signMessage.ts +5 -16
- package/src/signP2SHTransaction.ts +11 -34
- package/src/signTransaction.ts +3 -8
- package/src/splitTransaction.ts +3 -7
- package/src/startUntrustedHashTransactionInput.ts +7 -10
package/src/Btc.ts
CHANGED
|
@@ -47,7 +47,7 @@ export default class Btc {
|
|
|
47
47
|
"getTrustedInput",
|
|
48
48
|
"getTrustedInputBIP143",
|
|
49
49
|
],
|
|
50
|
-
scrambleKey
|
|
50
|
+
scrambleKey,
|
|
51
51
|
);
|
|
52
52
|
// new APDU (nano app API) for bitcoin and old APDU for altcoin
|
|
53
53
|
if (currency === "bitcoin" || currency === "bitcoin_testnet") {
|
|
@@ -65,7 +65,7 @@ export default class Btc {
|
|
|
65
65
|
* @returns XPUB of the account
|
|
66
66
|
*/
|
|
67
67
|
getWalletXpub(arg: { path: string; xpubVersion: number }): Promise<string> {
|
|
68
|
-
return this.changeImplIfNecessary().then(
|
|
68
|
+
return this.changeImplIfNecessary().then(impl => {
|
|
69
69
|
return impl.getWalletXpub(arg);
|
|
70
70
|
});
|
|
71
71
|
}
|
|
@@ -97,7 +97,7 @@ export default class Btc {
|
|
|
97
97
|
opts?: {
|
|
98
98
|
verify?: boolean;
|
|
99
99
|
format?: AddressFormat;
|
|
100
|
-
}
|
|
100
|
+
},
|
|
101
101
|
): Promise<{
|
|
102
102
|
publicKey: string;
|
|
103
103
|
bitcoinAddress: string;
|
|
@@ -106,7 +106,7 @@ export default class Btc {
|
|
|
106
106
|
let options;
|
|
107
107
|
if (arguments.length > 2 || typeof opts === "boolean") {
|
|
108
108
|
console.warn(
|
|
109
|
-
"btc.getWalletPublicKey deprecated signature used. Please switch to getWalletPublicKey(path, { format, verify })"
|
|
109
|
+
"btc.getWalletPublicKey deprecated signature used. Please switch to getWalletPublicKey(path, { format, verify })",
|
|
110
110
|
);
|
|
111
111
|
options = {
|
|
112
112
|
verify: !!opts,
|
|
@@ -116,7 +116,7 @@ export default class Btc {
|
|
|
116
116
|
} else {
|
|
117
117
|
options = opts || {};
|
|
118
118
|
}
|
|
119
|
-
return this.changeImplIfNecessary().then(
|
|
119
|
+
return this.changeImplIfNecessary().then(impl => {
|
|
120
120
|
return impl.getWalletPublicKey(path, options);
|
|
121
121
|
});
|
|
122
122
|
}
|
|
@@ -132,13 +132,13 @@ export default class Btc {
|
|
|
132
132
|
*/
|
|
133
133
|
signMessage(
|
|
134
134
|
path: string,
|
|
135
|
-
messageHex: string
|
|
135
|
+
messageHex: string,
|
|
136
136
|
): Promise<{
|
|
137
137
|
v: number;
|
|
138
138
|
r: string;
|
|
139
139
|
s: string;
|
|
140
140
|
}> {
|
|
141
|
-
return this.changeImplIfNecessary().then(
|
|
141
|
+
return this.changeImplIfNecessary().then(impl => {
|
|
142
142
|
return impl.signMessage({
|
|
143
143
|
path,
|
|
144
144
|
messageHex,
|
|
@@ -182,10 +182,10 @@ export default class Btc {
|
|
|
182
182
|
createPaymentTransaction(arg: CreateTransactionArg): Promise<string> {
|
|
183
183
|
if (arguments.length > 1) {
|
|
184
184
|
throw new Error(
|
|
185
|
-
"@ledgerhq/hw-app-btc: createPaymentTransaction multi argument signature is deprecated. please switch to named parameters."
|
|
185
|
+
"@ledgerhq/hw-app-btc: createPaymentTransaction multi argument signature is deprecated. please switch to named parameters.",
|
|
186
186
|
);
|
|
187
187
|
}
|
|
188
|
-
return this.changeImplIfNecessary().then(
|
|
188
|
+
return this.changeImplIfNecessary().then(impl => {
|
|
189
189
|
return impl.createPaymentTransaction(arg);
|
|
190
190
|
});
|
|
191
191
|
}
|
|
@@ -223,14 +223,14 @@ export default class Btc {
|
|
|
223
223
|
isSegwitSupported: boolean | null | undefined = false,
|
|
224
224
|
hasTimestamp = false,
|
|
225
225
|
hasExtraData = false,
|
|
226
|
-
additionals: Array<string> = []
|
|
226
|
+
additionals: Array<string> = [],
|
|
227
227
|
): Transaction {
|
|
228
228
|
return splitTransaction(
|
|
229
229
|
transactionHex,
|
|
230
230
|
isSegwitSupported,
|
|
231
231
|
hasTimestamp,
|
|
232
232
|
hasExtraData,
|
|
233
|
-
additionals
|
|
233
|
+
additionals,
|
|
234
234
|
);
|
|
235
235
|
}
|
|
236
236
|
|
|
@@ -246,27 +246,17 @@ export default class Btc {
|
|
|
246
246
|
getTrustedInput(
|
|
247
247
|
indexLookup: number,
|
|
248
248
|
transaction: Transaction,
|
|
249
|
-
additionals: Array<string> = []
|
|
249
|
+
additionals: Array<string> = [],
|
|
250
250
|
): Promise<string> {
|
|
251
|
-
return getTrustedInput(
|
|
252
|
-
this._transport,
|
|
253
|
-
indexLookup,
|
|
254
|
-
transaction,
|
|
255
|
-
additionals
|
|
256
|
-
);
|
|
251
|
+
return getTrustedInput(this._transport, indexLookup, transaction, additionals);
|
|
257
252
|
}
|
|
258
253
|
|
|
259
254
|
getTrustedInputBIP143(
|
|
260
255
|
indexLookup: number,
|
|
261
256
|
transaction: Transaction,
|
|
262
|
-
additionals: Array<string> = []
|
|
257
|
+
additionals: Array<string> = [],
|
|
263
258
|
): string {
|
|
264
|
-
return getTrustedInputBIP143(
|
|
265
|
-
this._transport,
|
|
266
|
-
indexLookup,
|
|
267
|
-
transaction,
|
|
268
|
-
additionals
|
|
269
|
-
);
|
|
259
|
+
return getTrustedInputBIP143(this._transport, indexLookup, transaction, additionals);
|
|
270
260
|
}
|
|
271
261
|
|
|
272
262
|
async changeImplIfNecessary(): Promise<BtcOld | BtcNew> {
|
|
@@ -276,14 +266,10 @@ export default class Btc {
|
|
|
276
266
|
const appAndVersion = await getAppAndVersion(this._transport);
|
|
277
267
|
let isBtcLegacy = true; // default for all altcoins
|
|
278
268
|
|
|
279
|
-
if (
|
|
280
|
-
appAndVersion.name === "Bitcoin" ||
|
|
281
|
-
appAndVersion.name === "Bitcoin Test"
|
|
282
|
-
) {
|
|
269
|
+
if (appAndVersion.name === "Bitcoin" || appAndVersion.name === "Bitcoin Test") {
|
|
283
270
|
const [major, minor] = appAndVersion.version.split(".");
|
|
284
271
|
// we use the legacy protocol for versions below 2.1.0 of the Bitcoin app.
|
|
285
|
-
isBtcLegacy =
|
|
286
|
-
parseInt(major) <= 1 || (parseInt(major) == 2 && parseInt(minor) == 0);
|
|
272
|
+
isBtcLegacy = parseInt(major) <= 1 || (parseInt(major) == 2 && parseInt(minor) == 0);
|
|
287
273
|
} else if (
|
|
288
274
|
appAndVersion.name === "Bitcoin Legacy" ||
|
|
289
275
|
appAndVersion.name === "Bitcoin Test Legacy"
|
package/src/BtcNew.ts
CHANGED
|
@@ -19,11 +19,7 @@ import {
|
|
|
19
19
|
SpendingCondition,
|
|
20
20
|
} from "./newops/accounttype";
|
|
21
21
|
import { AppClient as Client } from "./newops/appClient";
|
|
22
|
-
import {
|
|
23
|
-
createKey,
|
|
24
|
-
DefaultDescriptorTemplate,
|
|
25
|
-
WalletPolicy,
|
|
26
|
-
} from "./newops/policy";
|
|
22
|
+
import { createKey, DefaultDescriptorTemplate, WalletPolicy } from "./newops/policy";
|
|
27
23
|
import { extract } from "./newops/psbtExtractor";
|
|
28
24
|
import { finalize } from "./newops/psbtFinalizer";
|
|
29
25
|
import { psbtIn, PsbtV2 } from "./newops/psbtv2";
|
|
@@ -88,7 +84,7 @@ export default class BtcNew {
|
|
|
88
84
|
const xpubComponents = getXpubComponents(xpub);
|
|
89
85
|
if (xpubComponents.version != xpubVersion) {
|
|
90
86
|
throw new Error(
|
|
91
|
-
`Expected xpub version ${xpubVersion} doesn't match the xpub version from the device ${xpubComponents.version}
|
|
87
|
+
`Expected xpub version ${xpubVersion} doesn't match the xpub version from the device ${xpubComponents.version}`,
|
|
92
88
|
);
|
|
93
89
|
}
|
|
94
90
|
return xpub;
|
|
@@ -106,7 +102,7 @@ export default class BtcNew {
|
|
|
106
102
|
opts?: {
|
|
107
103
|
verify?: boolean;
|
|
108
104
|
format?: AddressFormat;
|
|
109
|
-
}
|
|
105
|
+
},
|
|
110
106
|
): Promise<{
|
|
111
107
|
publicKey: string;
|
|
112
108
|
bitcoinAddress: string;
|
|
@@ -123,12 +119,10 @@ export default class BtcNew {
|
|
|
123
119
|
const address = await this.getWalletAddress(
|
|
124
120
|
pathElements,
|
|
125
121
|
descrTemplFrom(opts?.format ?? "legacy"),
|
|
126
|
-
display
|
|
122
|
+
display,
|
|
127
123
|
);
|
|
128
124
|
const components = getXpubComponents(xpub);
|
|
129
|
-
const uncompressedPubkey = Buffer.from(
|
|
130
|
-
pointCompress(components.pubkey, false)
|
|
131
|
-
);
|
|
125
|
+
const uncompressedPubkey = Buffer.from(pointCompress(components.pubkey, false));
|
|
132
126
|
return {
|
|
133
127
|
publicKey: uncompressedPubkey.toString("hex"),
|
|
134
128
|
bitcoinAddress: address,
|
|
@@ -154,7 +148,7 @@ export default class BtcNew {
|
|
|
154
148
|
private async getWalletAddress(
|
|
155
149
|
pathElements: number[],
|
|
156
150
|
descrTempl: DefaultDescriptorTemplate,
|
|
157
|
-
display: boolean
|
|
151
|
+
display: boolean,
|
|
158
152
|
): Promise<string> {
|
|
159
153
|
const accountPath = hardenedPathOf(pathElements);
|
|
160
154
|
if (accountPath.length + 2 != pathElements.length) {
|
|
@@ -164,7 +158,7 @@ export default class BtcNew {
|
|
|
164
158
|
const masterFingerprint = await this.client.getMasterFingerprint();
|
|
165
159
|
const policy = new WalletPolicy(
|
|
166
160
|
descrTempl,
|
|
167
|
-
createKey(masterFingerprint, accountPath, accountXpub)
|
|
161
|
+
createKey(masterFingerprint, accountPath, accountXpub),
|
|
168
162
|
);
|
|
169
163
|
const changeAndIndex = pathElements.slice(-2, pathElements.length);
|
|
170
164
|
return this.client.getWalletAddress(
|
|
@@ -172,7 +166,7 @@ export default class BtcNew {
|
|
|
172
166
|
Buffer.alloc(32, 0),
|
|
173
167
|
changeAndIndex[0],
|
|
174
168
|
changeAndIndex[1],
|
|
175
|
-
display
|
|
169
|
+
display,
|
|
176
170
|
);
|
|
177
171
|
}
|
|
178
172
|
|
|
@@ -232,7 +226,7 @@ export default class BtcNew {
|
|
|
232
226
|
pathElems,
|
|
233
227
|
accountType,
|
|
234
228
|
masterFp,
|
|
235
|
-
arg.sigHashType
|
|
229
|
+
arg.sigHashType,
|
|
236
230
|
);
|
|
237
231
|
}
|
|
238
232
|
|
|
@@ -240,11 +234,7 @@ export default class BtcNew {
|
|
|
240
234
|
const outputsBufferReader = new BufferReader(outputsConcat);
|
|
241
235
|
const outputCount = outputsBufferReader.readVarInt();
|
|
242
236
|
psbt.setGlobalOutputCount(outputCount);
|
|
243
|
-
const changeData = await this.outputScriptAt(
|
|
244
|
-
accountPath,
|
|
245
|
-
accountType,
|
|
246
|
-
arg.changePath
|
|
247
|
-
);
|
|
237
|
+
const changeData = await this.outputScriptAt(accountPath, accountType, arg.changePath);
|
|
248
238
|
// If the caller supplied a changePath, we must make sure there actually is
|
|
249
239
|
// a change output. If no change output found, we'll throw an error.
|
|
250
240
|
let changeFound = !changeData;
|
|
@@ -257,8 +247,7 @@ export default class BtcNew {
|
|
|
257
247
|
// We won't know if we're paying to ourselves, because there's no
|
|
258
248
|
// information in arg to support multiple "change paths". One exception is
|
|
259
249
|
// if there are multiple outputs to the change address.
|
|
260
|
-
const isChange =
|
|
261
|
-
changeData && outputScript.equals(changeData?.cond.scriptPubKey);
|
|
250
|
+
const isChange = changeData && outputScript.equals(changeData?.cond.scriptPubKey);
|
|
262
251
|
if (isChange) {
|
|
263
252
|
changeFound = true;
|
|
264
253
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -270,8 +259,7 @@ export default class BtcNew {
|
|
|
270
259
|
}
|
|
271
260
|
if (!changeFound) {
|
|
272
261
|
throw new Error(
|
|
273
|
-
"Change script not found among outputs! " +
|
|
274
|
-
changeData?.cond.scriptPubKey.toString("hex")
|
|
262
|
+
"Change script not found among outputs! " + changeData?.cond.scriptPubKey.toString("hex"),
|
|
275
263
|
);
|
|
276
264
|
}
|
|
277
265
|
|
|
@@ -302,13 +290,7 @@ export default class BtcNew {
|
|
|
302
290
|
* the provided derivation path according to the Bitcoin Signature format
|
|
303
291
|
* and returns v, r, s.
|
|
304
292
|
*/
|
|
305
|
-
async signMessage({
|
|
306
|
-
path,
|
|
307
|
-
messageHex,
|
|
308
|
-
}: {
|
|
309
|
-
path: string;
|
|
310
|
-
messageHex: string;
|
|
311
|
-
}): Promise<{
|
|
293
|
+
async signMessage({ path, messageHex }: { path: string; messageHex: string }): Promise<{
|
|
312
294
|
v: number;
|
|
313
295
|
r: string;
|
|
314
296
|
s: string;
|
|
@@ -340,7 +322,7 @@ export default class BtcNew {
|
|
|
340
322
|
private async outputScriptAt(
|
|
341
323
|
accountPath: number[],
|
|
342
324
|
accountType: AccountType,
|
|
343
|
-
path: string | undefined
|
|
325
|
+
path: string | undefined,
|
|
344
326
|
): Promise<{ cond: SpendingCondition; pubkey: Buffer } | undefined> {
|
|
345
327
|
if (!path) return undefined;
|
|
346
328
|
const pathElems = pathStringToArray(path);
|
|
@@ -348,9 +330,7 @@ export default class BtcNew {
|
|
|
348
330
|
// going on.
|
|
349
331
|
for (let i = 0; i < accountPath.length; i++) {
|
|
350
332
|
if (accountPath[i] != pathElems[i]) {
|
|
351
|
-
throw new Error(
|
|
352
|
-
`Path ${path} not in account ${pathArrayToString(accountPath)}`
|
|
353
|
-
);
|
|
333
|
+
throw new Error(`Path ${path} not in account ${pathArrayToString(accountPath)}`);
|
|
354
334
|
}
|
|
355
335
|
}
|
|
356
336
|
const xpub = await this.client.getExtendedPubkey(false, pathElems);
|
|
@@ -367,16 +347,11 @@ export default class BtcNew {
|
|
|
367
347
|
private async setInput(
|
|
368
348
|
psbt: PsbtV2,
|
|
369
349
|
i: number,
|
|
370
|
-
input: [
|
|
371
|
-
Transaction,
|
|
372
|
-
number,
|
|
373
|
-
string | null | undefined,
|
|
374
|
-
number | null | undefined
|
|
375
|
-
],
|
|
350
|
+
input: [Transaction, number, string | null | undefined, number | null | undefined],
|
|
376
351
|
pathElements: number[],
|
|
377
352
|
accountType: AccountType,
|
|
378
353
|
masterFP: Buffer,
|
|
379
|
-
sigHashType?: number
|
|
354
|
+
sigHashType?: number,
|
|
380
355
|
): Promise<void> {
|
|
381
356
|
const inputTx = input[0];
|
|
382
357
|
const spentOutputIndex = input[1];
|
|
@@ -395,21 +370,14 @@ export default class BtcNew {
|
|
|
395
370
|
const xpubBase58 = await this.client.getExtendedPubkey(false, pathElements);
|
|
396
371
|
|
|
397
372
|
const pubkey = pubkeyFromXpub(xpubBase58);
|
|
398
|
-
if (!inputTx.outputs)
|
|
399
|
-
throw Error("Missing outputs array in transaction to sign");
|
|
373
|
+
if (!inputTx.outputs) throw Error("Missing outputs array in transaction to sign");
|
|
400
374
|
const spentTxOutput = inputTx.outputs[spentOutputIndex];
|
|
401
375
|
const spendCondition: SpendingCondition = {
|
|
402
376
|
scriptPubKey: spentTxOutput.script,
|
|
403
377
|
redeemScript: redeemScript,
|
|
404
378
|
};
|
|
405
379
|
const spentOutput = { cond: spendCondition, amount: spentTxOutput.amount };
|
|
406
|
-
accountType.setInput(
|
|
407
|
-
i,
|
|
408
|
-
inputTxBuffer,
|
|
409
|
-
spentOutput,
|
|
410
|
-
[pubkey],
|
|
411
|
-
[pathElements]
|
|
412
|
-
);
|
|
380
|
+
accountType.setInput(i, inputTxBuffer, spentOutput, [pubkey], [pathElements]);
|
|
413
381
|
|
|
414
382
|
psbt.setInputPreviousTxId(i, inputTxid);
|
|
415
383
|
psbt.setInputOutputIndex(i, spentOutputIndex);
|
|
@@ -427,13 +395,13 @@ export default class BtcNew {
|
|
|
427
395
|
private async signPsbt(
|
|
428
396
|
psbt: PsbtV2,
|
|
429
397
|
walletPolicy: WalletPolicy,
|
|
430
|
-
progressCallback: () => void
|
|
398
|
+
progressCallback: () => void,
|
|
431
399
|
): Promise<void> {
|
|
432
400
|
const sigs: Map<number, Buffer> = await this.client.signPsbt(
|
|
433
401
|
psbt,
|
|
434
402
|
walletPolicy,
|
|
435
403
|
Buffer.alloc(32, 0),
|
|
436
|
-
progressCallback
|
|
404
|
+
progressCallback,
|
|
437
405
|
);
|
|
438
406
|
sigs.forEach((v, k) => {
|
|
439
407
|
// Note: Looking at BIP32 derivation does not work in the generic case,
|
|
@@ -455,9 +423,7 @@ export default class BtcNew {
|
|
|
455
423
|
}
|
|
456
424
|
}
|
|
457
425
|
|
|
458
|
-
function descrTemplFrom(
|
|
459
|
-
addressFormat: AddressFormat
|
|
460
|
-
): DefaultDescriptorTemplate {
|
|
426
|
+
function descrTemplFrom(addressFormat: AddressFormat): DefaultDescriptorTemplate {
|
|
461
427
|
if (addressFormat == "legacy") return "pkh(@0)";
|
|
462
428
|
if (addressFormat == "p2sh") return "sh(wpkh(@0))";
|
|
463
429
|
if (addressFormat == "bech32") return "wpkh(@0)";
|
|
@@ -468,7 +434,7 @@ function descrTemplFrom(
|
|
|
468
434
|
function accountTypeFromArg(
|
|
469
435
|
arg: CreateTransactionArg,
|
|
470
436
|
psbt: PsbtV2,
|
|
471
|
-
masterFp: Buffer
|
|
437
|
+
masterFp: Buffer,
|
|
472
438
|
): AccountType {
|
|
473
439
|
if (arg.additionals.includes("bech32m")) return new p2tr(psbt, masterFp);
|
|
474
440
|
if (arg.additionals.includes("bech32")) return new p2wpkh(psbt, masterFp);
|
|
@@ -502,14 +468,13 @@ function isPathNormal(path: string): boolean {
|
|
|
502
468
|
|
|
503
469
|
const hard = (n: number) => n >= h;
|
|
504
470
|
const soft = (n: number | undefined) => n === undefined || n < h;
|
|
505
|
-
const change = (n: number | undefined) =>
|
|
506
|
-
n === undefined || n === 0 || n === 1;
|
|
471
|
+
const change = (n: number | undefined) => n === undefined || n === 0 || n === 1;
|
|
507
472
|
|
|
508
473
|
if (
|
|
509
474
|
pathElems.length >= 3 &&
|
|
510
475
|
pathElems.length <= 5 &&
|
|
511
|
-
[44 + h, 49 + h, 84 + h, 86 + h].some(
|
|
512
|
-
[0 + h, 1 + h].some(
|
|
476
|
+
[44 + h, 49 + h, 84 + h, 86 + h].some(v => v == pathElems[0]) &&
|
|
477
|
+
[0 + h, 1 + h].some(v => v == pathElems[1]) &&
|
|
513
478
|
hard(pathElems[2]) &&
|
|
514
479
|
change(pathElems[3]) &&
|
|
515
480
|
soft(pathElems[4])
|
|
@@ -520,7 +485,7 @@ function isPathNormal(path: string): boolean {
|
|
|
520
485
|
pathElems.length >= 4 &&
|
|
521
486
|
pathElems.length <= 6 &&
|
|
522
487
|
48 + h == pathElems[0] &&
|
|
523
|
-
[0 + h, 1 + h].some(
|
|
488
|
+
[0 + h, 1 + h].some(v => v == pathElems[1]) &&
|
|
524
489
|
hard(pathElems[2]) &&
|
|
525
490
|
hard(pathElems[3]) &&
|
|
526
491
|
change(pathElems[4]) &&
|
package/src/BtcOld.ts
CHANGED
|
@@ -40,12 +40,10 @@ export default class BtcOld {
|
|
|
40
40
|
}): Promise<string> {
|
|
41
41
|
const pathElements = pathStringToArray(path);
|
|
42
42
|
const parentPath = pathElements.slice(0, -1);
|
|
43
|
-
const parentDerivation = await this.derivatePath(
|
|
44
|
-
pathArrayToString(parentPath)
|
|
45
|
-
);
|
|
43
|
+
const parentDerivation = await this.derivatePath(pathArrayToString(parentPath));
|
|
46
44
|
const accountDerivation = await this.derivatePath(path);
|
|
47
45
|
const fingerprint = makeFingerprint(
|
|
48
|
-
compressPublicKeySECP256(Buffer.from(parentDerivation.publicKey, "hex"))
|
|
46
|
+
compressPublicKeySECP256(Buffer.from(parentDerivation.publicKey, "hex")),
|
|
49
47
|
);
|
|
50
48
|
const xpub = makeXpub(
|
|
51
49
|
xpubVersion,
|
|
@@ -53,7 +51,7 @@ export default class BtcOld {
|
|
|
53
51
|
fingerprint,
|
|
54
52
|
pathElements[pathElements.length - 1],
|
|
55
53
|
Buffer.from(accountDerivation.chainCode, "hex"),
|
|
56
|
-
compressPublicKeySECP256(Buffer.from(accountDerivation.publicKey, "hex"))
|
|
54
|
+
compressPublicKeySECP256(Buffer.from(accountDerivation.publicKey, "hex")),
|
|
57
55
|
);
|
|
58
56
|
return xpub;
|
|
59
57
|
}
|
|
@@ -85,7 +83,7 @@ export default class BtcOld {
|
|
|
85
83
|
opts?: {
|
|
86
84
|
verify?: boolean;
|
|
87
85
|
format?: AddressFormat;
|
|
88
|
-
}
|
|
86
|
+
},
|
|
89
87
|
): Promise<{
|
|
90
88
|
publicKey: string;
|
|
91
89
|
bitcoinAddress: string;
|
|
@@ -132,19 +130,13 @@ export default class BtcOld {
|
|
|
132
130
|
createPaymentTransaction(arg: CreateTransactionArg): Promise<string> {
|
|
133
131
|
if (arguments.length > 1) {
|
|
134
132
|
throw new Error(
|
|
135
|
-
"@ledgerhq/hw-app-btc: createPaymentTransaction multi argument signature is deprecated. please switch to named parameters."
|
|
133
|
+
"@ledgerhq/hw-app-btc: createPaymentTransaction multi argument signature is deprecated. please switch to named parameters.",
|
|
136
134
|
);
|
|
137
135
|
}
|
|
138
136
|
return createTransaction(this.transport, arg);
|
|
139
137
|
}
|
|
140
138
|
|
|
141
|
-
async signMessage({
|
|
142
|
-
path,
|
|
143
|
-
messageHex,
|
|
144
|
-
}: {
|
|
145
|
-
path: string;
|
|
146
|
-
messageHex: string;
|
|
147
|
-
}): Promise<{
|
|
139
|
+
async signMessage({ path, messageHex }: { path: string; messageHex: string }): Promise<{
|
|
148
140
|
v: number;
|
|
149
141
|
r: string;
|
|
150
142
|
s: string;
|
|
@@ -167,10 +159,7 @@ function asBufferUInt32BE(n: number): Buffer {
|
|
|
167
159
|
}
|
|
168
160
|
|
|
169
161
|
const compressPublicKeySECP256 = (publicKey: Buffer) =>
|
|
170
|
-
Buffer.concat([
|
|
171
|
-
Buffer.from([0x02 + (publicKey[64] & 0x01)]),
|
|
172
|
-
publicKey.slice(1, 33),
|
|
173
|
-
]);
|
|
162
|
+
Buffer.concat([Buffer.from([0x02 + (publicKey[64] & 0x01)]), publicKey.slice(1, 33)]);
|
|
174
163
|
|
|
175
164
|
function makeXpub(
|
|
176
165
|
version: number,
|
|
@@ -178,7 +167,7 @@ function makeXpub(
|
|
|
178
167
|
parentFingerprint: Buffer,
|
|
179
168
|
index: number,
|
|
180
169
|
chainCode: Buffer,
|
|
181
|
-
pubKey: Buffer
|
|
170
|
+
pubKey: Buffer,
|
|
182
171
|
) {
|
|
183
172
|
const indexBuffer = asBufferUInt32BE(index);
|
|
184
173
|
indexBuffer[0] |= 0x80;
|
package/src/buffertools.ts
CHANGED
|
@@ -41,15 +41,15 @@ export class BufferWriter {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
writeUInt8(i: number): void {
|
|
44
|
-
this.write(1,
|
|
44
|
+
this.write(1, b => b.writeUInt8(i, 0));
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
writeInt32(i: number): void {
|
|
48
|
-
this.write(4,
|
|
48
|
+
this.write(4, b => b.writeInt32LE(i, 0));
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
writeUInt32(i: number): void {
|
|
52
|
-
this.write(4,
|
|
52
|
+
this.write(4, b => b.writeUInt32LE(i, 0));
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
writeUInt64(i: number): void {
|
package/src/createTransaction.ts
CHANGED
|
@@ -29,7 +29,7 @@ const defaultsSignTransaction = {
|
|
|
29
29
|
sigHashType: SIGHASH_ALL,
|
|
30
30
|
segwit: false,
|
|
31
31
|
additionals: [],
|
|
32
|
-
onDeviceStreaming:
|
|
32
|
+
onDeviceStreaming: _e => {},
|
|
33
33
|
onDeviceSignatureGranted: () => {},
|
|
34
34
|
onDeviceSignatureRequested: () => {},
|
|
35
35
|
};
|
|
@@ -38,9 +38,7 @@ const defaultsSignTransaction = {
|
|
|
38
38
|
*
|
|
39
39
|
*/
|
|
40
40
|
export type CreateTransactionArg = {
|
|
41
|
-
inputs: Array<
|
|
42
|
-
[Transaction, number, string | null | undefined, number | null | undefined]
|
|
43
|
-
>;
|
|
41
|
+
inputs: Array<[Transaction, number, string | null | undefined, number | null | undefined]>;
|
|
44
42
|
associatedKeysets: string[];
|
|
45
43
|
changePath?: string;
|
|
46
44
|
outputScriptHex: string;
|
|
@@ -51,17 +49,13 @@ export type CreateTransactionArg = {
|
|
|
51
49
|
additionals: Array<string>;
|
|
52
50
|
expiryHeight?: Buffer;
|
|
53
51
|
useTrustedInputForSegwit?: boolean;
|
|
54
|
-
onDeviceStreaming?: (arg0: {
|
|
55
|
-
progress: number;
|
|
56
|
-
total: number;
|
|
57
|
-
index: number;
|
|
58
|
-
}) => void;
|
|
52
|
+
onDeviceStreaming?: (arg0: { progress: number; total: number; index: number }) => void;
|
|
59
53
|
onDeviceSignatureRequested?: () => void;
|
|
60
54
|
onDeviceSignatureGranted?: () => void;
|
|
61
55
|
};
|
|
62
56
|
export async function createTransaction(
|
|
63
57
|
transport: Transport,
|
|
64
|
-
arg: CreateTransactionArg
|
|
58
|
+
arg: CreateTransactionArg,
|
|
65
59
|
): Promise<string> {
|
|
66
60
|
const signTx = { ...defaultsSignTransaction, ...arg };
|
|
67
61
|
const {
|
|
@@ -133,10 +127,7 @@ export async function createTransaction(
|
|
|
133
127
|
const nullPrevout = Buffer.alloc(0);
|
|
134
128
|
const defaultVersion = Buffer.alloc(4);
|
|
135
129
|
!!expiryHeight && !isDecred
|
|
136
|
-
? defaultVersion.writeUInt32LE(
|
|
137
|
-
isZcash ? 0x80000005 : sapling ? 0x80000004 : 0x80000003,
|
|
138
|
-
0
|
|
139
|
-
) // v5 format for zcash refer to https://zips.z.cash/zip-0225
|
|
130
|
+
? defaultVersion.writeUInt32LE(isZcash ? 0x80000005 : sapling ? 0x80000004 : 0x80000003, 0) // v5 format for zcash refer to https://zips.z.cash/zip-0225
|
|
140
131
|
: isXST
|
|
141
132
|
? defaultVersion.writeUInt32LE(2, 0)
|
|
142
133
|
: defaultVersion.writeUInt32LE(1, 0);
|
|
@@ -153,27 +144,18 @@ export async function createTransaction(
|
|
|
153
144
|
timestamp: Buffer.alloc(0),
|
|
154
145
|
};
|
|
155
146
|
const getTrustedInputCall =
|
|
156
|
-
useBip143 && !useTrustedInputForSegwit
|
|
157
|
-
? getTrustedInputBIP143
|
|
158
|
-
: getTrustedInput;
|
|
147
|
+
useBip143 && !useTrustedInputForSegwit ? getTrustedInputBIP143 : getTrustedInput;
|
|
159
148
|
const outputScript = Buffer.from(outputScriptHex, "hex");
|
|
160
149
|
notify(0, 0);
|
|
161
150
|
// first pass on inputs to get trusted inputs
|
|
162
151
|
for (const input of inputs) {
|
|
163
152
|
if (!resuming) {
|
|
164
|
-
const trustedInput = await getTrustedInputCall(
|
|
165
|
-
transport,
|
|
166
|
-
input[1],
|
|
167
|
-
input[0],
|
|
168
|
-
additionals
|
|
169
|
-
);
|
|
153
|
+
const trustedInput = await getTrustedInputCall(transport, input[1], input[0], additionals);
|
|
170
154
|
log("hw", "got trustedInput=" + trustedInput);
|
|
171
155
|
const sequence = Buffer.alloc(4);
|
|
172
156
|
sequence.writeUInt32LE(
|
|
173
|
-
input.length >= 4 && typeof input[3] === "number"
|
|
174
|
-
|
|
175
|
-
: DEFAULT_SEQUENCE,
|
|
176
|
-
0
|
|
157
|
+
input.length >= 4 && typeof input[3] === "number" ? input[3] : DEFAULT_SEQUENCE,
|
|
158
|
+
0,
|
|
177
159
|
);
|
|
178
160
|
trustedInputs.push({
|
|
179
161
|
trustedInput: true,
|
|
@@ -196,15 +178,13 @@ export async function createTransaction(
|
|
|
196
178
|
? [0x0a, 0x27, 0xa7, 0x26]
|
|
197
179
|
: sapling
|
|
198
180
|
? [0x85, 0x20, 0x2f, 0x89]
|
|
199
|
-
: [0x70, 0x82, 0xc4, 0x03]
|
|
181
|
+
: [0x70, 0x82, 0xc4, 0x03],
|
|
200
182
|
);
|
|
201
183
|
targetTransaction.nExpiryHeight = expiryHeight;
|
|
202
184
|
// For sapling : valueBalance (8), nShieldedSpend (1), nShieldedOutput (1), nJoinSplit (1)
|
|
203
185
|
// Overwinter : use nJoinSplit (1)
|
|
204
186
|
targetTransaction.extraData = Buffer.from(
|
|
205
|
-
sapling
|
|
206
|
-
? [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
|
207
|
-
: [0x00]
|
|
187
|
+
sapling ? [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] : [0x00],
|
|
208
188
|
);
|
|
209
189
|
} else if (isDecred) {
|
|
210
190
|
targetTransaction.nExpiryHeight = expiryHeight;
|
|
@@ -214,10 +194,8 @@ export async function createTransaction(
|
|
|
214
194
|
targetTransaction.inputs = inputs.map((input, idx) => {
|
|
215
195
|
const sequence = Buffer.alloc(4);
|
|
216
196
|
sequence.writeUInt32LE(
|
|
217
|
-
input.length >= 4 && typeof input[3] === "number"
|
|
218
|
-
|
|
219
|
-
: DEFAULT_SEQUENCE,
|
|
220
|
-
0
|
|
197
|
+
input.length >= 4 && typeof input[3] === "number" ? input[3] : DEFAULT_SEQUENCE,
|
|
198
|
+
0,
|
|
221
199
|
);
|
|
222
200
|
return {
|
|
223
201
|
script: isZcash ? regularOutputs[idx].script : nullScript,
|
|
@@ -243,9 +221,7 @@ export async function createTransaction(
|
|
|
243
221
|
}
|
|
244
222
|
|
|
245
223
|
for (let i = 0; i < result.length; i++) {
|
|
246
|
-
publicKeys.push(
|
|
247
|
-
compressPublicKey(Buffer.from(result[i].publicKey, "hex"))
|
|
248
|
-
);
|
|
224
|
+
publicKeys.push(compressPublicKey(Buffer.from(result[i].publicKey, "hex")));
|
|
249
225
|
}
|
|
250
226
|
}
|
|
251
227
|
|
|
@@ -253,7 +229,7 @@ export async function createTransaction(
|
|
|
253
229
|
targetTransaction.timestamp = Buffer.alloc(4);
|
|
254
230
|
targetTransaction.timestamp.writeUInt32LE(
|
|
255
231
|
Math.floor(initialTimestamp + (Date.now() - startTime) / 1000),
|
|
256
|
-
0
|
|
232
|
+
0,
|
|
257
233
|
);
|
|
258
234
|
}
|
|
259
235
|
|
|
@@ -269,7 +245,7 @@ export async function createTransaction(
|
|
|
269
245
|
true,
|
|
270
246
|
!!expiryHeight,
|
|
271
247
|
additionals,
|
|
272
|
-
useTrustedInputForSegwit
|
|
248
|
+
useTrustedInputForSegwit,
|
|
273
249
|
);
|
|
274
250
|
|
|
275
251
|
if (!resuming && changePath) {
|
|
@@ -313,7 +289,7 @@ export async function createTransaction(
|
|
|
313
289
|
useBip143,
|
|
314
290
|
!!expiryHeight && !isDecred,
|
|
315
291
|
additionals,
|
|
316
|
-
useTrustedInputForSegwit
|
|
292
|
+
useTrustedInputForSegwit,
|
|
317
293
|
);
|
|
318
294
|
|
|
319
295
|
if (!useBip143) {
|
|
@@ -335,7 +311,7 @@ export async function createTransaction(
|
|
|
335
311
|
lockTime,
|
|
336
312
|
sigHashType,
|
|
337
313
|
expiryHeight,
|
|
338
|
-
additionals
|
|
314
|
+
additionals,
|
|
339
315
|
);
|
|
340
316
|
notify(1, i + 1);
|
|
341
317
|
signatures.push(signature);
|
|
@@ -371,19 +347,11 @@ export async function createTransaction(
|
|
|
371
347
|
}
|
|
372
348
|
|
|
373
349
|
const offset = useBip143 && !useTrustedInputForSegwit ? 0 : 4;
|
|
374
|
-
targetTransaction.inputs[i].prevout = trustedInputs[i].value.slice(
|
|
375
|
-
offset,
|
|
376
|
-
offset + 0x24
|
|
377
|
-
);
|
|
350
|
+
targetTransaction.inputs[i].prevout = trustedInputs[i].value.slice(offset, offset + 0x24);
|
|
378
351
|
}
|
|
379
352
|
targetTransaction.locktime = lockTimeBuffer;
|
|
380
353
|
let result = Buffer.concat([
|
|
381
|
-
serializeTransaction(
|
|
382
|
-
targetTransaction,
|
|
383
|
-
false,
|
|
384
|
-
targetTransaction.timestamp,
|
|
385
|
-
additionals
|
|
386
|
-
),
|
|
354
|
+
serializeTransaction(targetTransaction, false, targetTransaction.timestamp, additionals),
|
|
387
355
|
outputScript,
|
|
388
356
|
]);
|
|
389
357
|
|
package/src/finalizeInput.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import Transport from "@ledgerhq/hw-transport";
|
|
2
2
|
import { bip32asBuffer } from "./bip32";
|
|
3
3
|
import { MAX_SCRIPT_BLOCK } from "./constants";
|
|
4
|
-
export function provideOutputFullChangePath(
|
|
5
|
-
transport: Transport,
|
|
6
|
-
path: string
|
|
7
|
-
): Promise<Buffer> {
|
|
4
|
+
export function provideOutputFullChangePath(transport: Transport, path: string): Promise<Buffer> {
|
|
8
5
|
const buffer = bip32asBuffer(path);
|
|
9
6
|
return transport.send(0xe0, 0x4a, 0xff, 0x00, buffer);
|
|
10
7
|
}
|
|
11
8
|
export async function hashOutputFull(
|
|
12
9
|
transport: Transport,
|
|
13
10
|
outputScript: Buffer,
|
|
14
|
-
additionals: Array<string> = []
|
|
11
|
+
additionals: Array<string> = [],
|
|
15
12
|
): Promise<Buffer | void> {
|
|
16
13
|
let offset = 0;
|
|
17
14
|
const p1 = Number(0x80);
|