@ledgerhq/hw-app-btc 6.24.2-monorepo.4 → 6.27.1
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/LICENSE +202 -0
- package/lib/bip32.d.ts.map +1 -1
- package/lib/bip32.js.map +1 -1
- package/lib/getTrustedInput.d.ts.map +1 -1
- package/lib/getTrustedInput.js.map +1 -1
- package/lib/newops/appClient.d.ts.map +1 -1
- package/lib/newops/appClient.js +4 -1
- package/lib/newops/appClient.js.map +1 -1
- package/lib/newops/psbtv2.d.ts.map +1 -1
- package/lib/newops/psbtv2.js.map +1 -1
- package/lib-es/Btc.js.flow +280 -0
- package/lib-es/bip32.d.ts.map +1 -1
- package/lib-es/bip32.js.flow +13 -0
- package/lib-es/bip32.js.map +1 -1
- package/lib-es/compressPublicKey.js.flow +8 -0
- package/lib-es/constants.js.flow +13 -0
- package/lib-es/createTransaction.js.flow +419 -0
- package/lib-es/debug.js.flow +41 -0
- package/lib-es/finalizeInput.js.flow +38 -0
- package/lib-es/getAppAndVersion.js.flow +19 -0
- package/lib-es/getTrustedInput.d.ts.map +1 -1
- package/lib-es/getTrustedInput.js.flow +163 -0
- package/lib-es/getTrustedInput.js.map +1 -1
- package/lib-es/getTrustedInputBIP143.js.flow +37 -0
- package/lib-es/getWalletPublicKey.js.flow +51 -0
- package/lib-es/hashPublicKey.js.flow +8 -0
- package/lib-es/newops/appClient.d.ts.map +1 -1
- package/lib-es/newops/appClient.js +4 -1
- package/lib-es/newops/appClient.js.map +1 -1
- package/lib-es/newops/psbtv2.d.ts.map +1 -1
- package/lib-es/newops/psbtv2.js.map +1 -1
- package/lib-es/serializeTransaction.js.flow +77 -0
- package/lib-es/shouldUseTrustedInputForSegwit.js.flow +15 -0
- package/lib-es/signMessage.js.flow +67 -0
- package/lib-es/signP2SHTransaction.js.flow +170 -0
- package/lib-es/signTransaction.js.flow +40 -0
- package/lib-es/splitTransaction.js.flow +145 -0
- package/lib-es/startUntrustedHashTransactionInput.js.flow +136 -0
- package/lib-es/types.js.flow +31 -0
- package/lib-es/varint.js.flow +43 -0
- package/package.json +6 -15
- package/src/bip32.ts +3 -5
- package/src/getTrustedInput.ts +8 -2
- package/src/newops/appClient.ts +4 -8
- package/src/newops/psbtv2.ts +9 -13
- package/.turbo/turbo-build.log +0 -5
- package/CHANGELOG.md +0 -46
- package/jest.config.ts +0 -6
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { log } from "@ledgerhq/logs";
|
|
3
|
+
import type { Transaction } from "./types";
|
|
4
|
+
import { getVarint } from "./varint";
|
|
5
|
+
import { formatTransactionDebug } from "./debug";
|
|
6
|
+
|
|
7
|
+
export function splitTransaction(
|
|
8
|
+
transactionHex: string,
|
|
9
|
+
isSegwitSupported: ?boolean = false,
|
|
10
|
+
hasTimestamp?: boolean = false,
|
|
11
|
+
hasExtraData?: boolean = false,
|
|
12
|
+
additionals: Array<string> = []
|
|
13
|
+
): Transaction {
|
|
14
|
+
const inputs = [];
|
|
15
|
+
const outputs = [];
|
|
16
|
+
var witness = false;
|
|
17
|
+
let offset = 0;
|
|
18
|
+
let timestamp = Buffer.alloc(0);
|
|
19
|
+
let nExpiryHeight = Buffer.alloc(0);
|
|
20
|
+
let nVersionGroupId = Buffer.alloc(0);
|
|
21
|
+
let extraData = Buffer.alloc(0);
|
|
22
|
+
const isDecred = additionals.includes("decred");
|
|
23
|
+
const transaction = Buffer.from(transactionHex, "hex");
|
|
24
|
+
const version = transaction.slice(offset, offset + 4);
|
|
25
|
+
const overwinter =
|
|
26
|
+
version.equals(Buffer.from([0x03, 0x00, 0x00, 0x80])) ||
|
|
27
|
+
version.equals(Buffer.from([0x04, 0x00, 0x00, 0x80]));
|
|
28
|
+
offset += 4;
|
|
29
|
+
if (
|
|
30
|
+
!hasTimestamp &&
|
|
31
|
+
isSegwitSupported &&
|
|
32
|
+
transaction[offset] === 0 &&
|
|
33
|
+
transaction[offset + 1] !== 0
|
|
34
|
+
) {
|
|
35
|
+
offset += 2;
|
|
36
|
+
witness = true;
|
|
37
|
+
}
|
|
38
|
+
if (hasTimestamp) {
|
|
39
|
+
timestamp = transaction.slice(offset, 4 + offset);
|
|
40
|
+
offset += 4;
|
|
41
|
+
}
|
|
42
|
+
if (overwinter) {
|
|
43
|
+
nVersionGroupId = transaction.slice(offset, 4 + offset);
|
|
44
|
+
offset += 4;
|
|
45
|
+
}
|
|
46
|
+
let varint = getVarint(transaction, offset);
|
|
47
|
+
const numberInputs = varint[0];
|
|
48
|
+
offset += varint[1];
|
|
49
|
+
for (let i = 0; i < numberInputs; i++) {
|
|
50
|
+
const prevout = transaction.slice(offset, offset + 36);
|
|
51
|
+
offset += 36;
|
|
52
|
+
let script = Buffer.alloc(0);
|
|
53
|
+
let tree = Buffer.alloc(0);
|
|
54
|
+
//No script for decred, it has a witness
|
|
55
|
+
if (!isDecred) {
|
|
56
|
+
varint = getVarint(transaction, offset);
|
|
57
|
+
offset += varint[1];
|
|
58
|
+
script = transaction.slice(offset, offset + varint[0]);
|
|
59
|
+
offset += varint[0];
|
|
60
|
+
} else {
|
|
61
|
+
//Tree field
|
|
62
|
+
tree = transaction.slice(offset, offset + 1);
|
|
63
|
+
offset += 1;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const sequence = transaction.slice(offset, offset + 4);
|
|
67
|
+
offset += 4;
|
|
68
|
+
inputs.push({ prevout, script, sequence, tree });
|
|
69
|
+
}
|
|
70
|
+
varint = getVarint(transaction, offset);
|
|
71
|
+
const numberOutputs = varint[0];
|
|
72
|
+
offset += varint[1];
|
|
73
|
+
for (let i = 0; i < numberOutputs; i++) {
|
|
74
|
+
const amount = transaction.slice(offset, offset + 8);
|
|
75
|
+
offset += 8;
|
|
76
|
+
|
|
77
|
+
if (isDecred) {
|
|
78
|
+
//Script version
|
|
79
|
+
offset += 2;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
varint = getVarint(transaction, offset);
|
|
83
|
+
offset += varint[1];
|
|
84
|
+
const script = transaction.slice(offset, offset + varint[0]);
|
|
85
|
+
offset += varint[0];
|
|
86
|
+
outputs.push({ amount, script });
|
|
87
|
+
}
|
|
88
|
+
let witnessScript, locktime;
|
|
89
|
+
if (witness) {
|
|
90
|
+
witnessScript = transaction.slice(offset, -4);
|
|
91
|
+
locktime = transaction.slice(transaction.length - 4);
|
|
92
|
+
} else {
|
|
93
|
+
locktime = transaction.slice(offset, offset + 4);
|
|
94
|
+
}
|
|
95
|
+
offset += 4;
|
|
96
|
+
if (overwinter || isDecred) {
|
|
97
|
+
nExpiryHeight = transaction.slice(offset, offset + 4);
|
|
98
|
+
offset += 4;
|
|
99
|
+
}
|
|
100
|
+
if (hasExtraData) {
|
|
101
|
+
extraData = transaction.slice(offset);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//Get witnesses for Decred
|
|
105
|
+
if (isDecred) {
|
|
106
|
+
varint = getVarint(transaction, offset);
|
|
107
|
+
offset += varint[1];
|
|
108
|
+
if (varint[0] !== numberInputs) {
|
|
109
|
+
throw new Error("splitTransaction: incoherent number of witnesses");
|
|
110
|
+
}
|
|
111
|
+
for (let i = 0; i < numberInputs; i++) {
|
|
112
|
+
//amount
|
|
113
|
+
offset += 8;
|
|
114
|
+
//block height
|
|
115
|
+
offset += 4;
|
|
116
|
+
//block index
|
|
117
|
+
offset += 4;
|
|
118
|
+
//Script size
|
|
119
|
+
varint = getVarint(transaction, offset);
|
|
120
|
+
offset += varint[1];
|
|
121
|
+
const script = transaction.slice(offset, offset + varint[0]);
|
|
122
|
+
offset += varint[0];
|
|
123
|
+
inputs[i].script = script;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const t: Transaction = {
|
|
128
|
+
version,
|
|
129
|
+
inputs,
|
|
130
|
+
outputs,
|
|
131
|
+
locktime,
|
|
132
|
+
witness: witnessScript,
|
|
133
|
+
timestamp,
|
|
134
|
+
nVersionGroupId,
|
|
135
|
+
nExpiryHeight,
|
|
136
|
+
extraData,
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
log(
|
|
140
|
+
"btc",
|
|
141
|
+
`splitTransaction ${transactionHex}:\n${formatTransactionDebug(t)}`
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
return t;
|
|
145
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import type Transport from "@ledgerhq/hw-transport";
|
|
3
|
+
import type { Transaction } from "./types";
|
|
4
|
+
import { createVarint } from "./varint";
|
|
5
|
+
import { MAX_SCRIPT_BLOCK } from "./constants";
|
|
6
|
+
|
|
7
|
+
export function startUntrustedHashTransactionInputRaw(
|
|
8
|
+
transport: Transport<*>,
|
|
9
|
+
newTransaction: boolean,
|
|
10
|
+
firstRound: boolean,
|
|
11
|
+
transactionData: Buffer,
|
|
12
|
+
bip143?: boolean = false,
|
|
13
|
+
overwinter?: boolean = false,
|
|
14
|
+
additionals: Array<string> = []
|
|
15
|
+
) {
|
|
16
|
+
const p2 = additionals.includes("cashaddr")
|
|
17
|
+
? 0x03
|
|
18
|
+
: bip143
|
|
19
|
+
? additionals.includes("sapling")
|
|
20
|
+
? 0x05
|
|
21
|
+
: overwinter
|
|
22
|
+
? 0x04
|
|
23
|
+
: 0x02
|
|
24
|
+
: 0x00;
|
|
25
|
+
return transport.send(
|
|
26
|
+
0xe0,
|
|
27
|
+
0x44,
|
|
28
|
+
firstRound ? 0x00 : 0x80,
|
|
29
|
+
newTransaction ? p2 : 0x80,
|
|
30
|
+
transactionData
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function startUntrustedHashTransactionInput(
|
|
35
|
+
transport: Transport<*>,
|
|
36
|
+
newTransaction: boolean,
|
|
37
|
+
transaction: Transaction,
|
|
38
|
+
inputs: Array<{ trustedInput: boolean, value: Buffer }>,
|
|
39
|
+
bip143?: boolean = false,
|
|
40
|
+
overwinter?: boolean = false,
|
|
41
|
+
additionals: Array<string> = [],
|
|
42
|
+
useTrustedInputForSegwit?: boolean = false
|
|
43
|
+
) {
|
|
44
|
+
let data = Buffer.concat([
|
|
45
|
+
transaction.version,
|
|
46
|
+
transaction.timestamp || Buffer.alloc(0),
|
|
47
|
+
transaction.nVersionGroupId || Buffer.alloc(0),
|
|
48
|
+
createVarint(transaction.inputs.length),
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
await startUntrustedHashTransactionInputRaw(
|
|
52
|
+
transport,
|
|
53
|
+
newTransaction,
|
|
54
|
+
true,
|
|
55
|
+
data,
|
|
56
|
+
bip143,
|
|
57
|
+
overwinter,
|
|
58
|
+
additionals
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
let i = 0;
|
|
62
|
+
const isDecred = additionals.includes("decred");
|
|
63
|
+
|
|
64
|
+
for (let input of transaction.inputs) {
|
|
65
|
+
let prefix;
|
|
66
|
+
let inputValue = inputs[i].value;
|
|
67
|
+
if (bip143) {
|
|
68
|
+
if (useTrustedInputForSegwit && inputs[i].trustedInput) {
|
|
69
|
+
prefix = Buffer.from([0x01, inputValue.length]);
|
|
70
|
+
} else {
|
|
71
|
+
prefix = Buffer.from([0x02]);
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
if (inputs[i].trustedInput) {
|
|
75
|
+
prefix = Buffer.from([0x01, inputs[i].value.length]);
|
|
76
|
+
} else {
|
|
77
|
+
prefix = Buffer.from([0x00]);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
data = Buffer.concat([
|
|
81
|
+
prefix,
|
|
82
|
+
inputValue,
|
|
83
|
+
isDecred ? Buffer.from([0x00]) : Buffer.alloc(0),
|
|
84
|
+
createVarint(input.script.length),
|
|
85
|
+
]);
|
|
86
|
+
|
|
87
|
+
await startUntrustedHashTransactionInputRaw(
|
|
88
|
+
transport,
|
|
89
|
+
newTransaction,
|
|
90
|
+
false,
|
|
91
|
+
data,
|
|
92
|
+
bip143,
|
|
93
|
+
overwinter,
|
|
94
|
+
additionals
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
let scriptBlocks = [];
|
|
98
|
+
let offset = 0;
|
|
99
|
+
|
|
100
|
+
if (input.script.length === 0) {
|
|
101
|
+
scriptBlocks.push(input.sequence);
|
|
102
|
+
} else {
|
|
103
|
+
while (offset !== input.script.length) {
|
|
104
|
+
let blockSize =
|
|
105
|
+
input.script.length - offset > MAX_SCRIPT_BLOCK
|
|
106
|
+
? MAX_SCRIPT_BLOCK
|
|
107
|
+
: input.script.length - offset;
|
|
108
|
+
if (offset + blockSize !== input.script.length) {
|
|
109
|
+
scriptBlocks.push(input.script.slice(offset, offset + blockSize));
|
|
110
|
+
} else {
|
|
111
|
+
scriptBlocks.push(
|
|
112
|
+
Buffer.concat([
|
|
113
|
+
input.script.slice(offset, offset + blockSize),
|
|
114
|
+
input.sequence,
|
|
115
|
+
])
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
offset += blockSize;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
for (let scriptBlock of scriptBlocks) {
|
|
123
|
+
await startUntrustedHashTransactionInputRaw(
|
|
124
|
+
transport,
|
|
125
|
+
newTransaction,
|
|
126
|
+
false,
|
|
127
|
+
scriptBlock,
|
|
128
|
+
bip143,
|
|
129
|
+
overwinter,
|
|
130
|
+
additionals
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
i++;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*/
|
|
5
|
+
export type TransactionInput = {
|
|
6
|
+
prevout: Buffer,
|
|
7
|
+
script: Buffer,
|
|
8
|
+
sequence: Buffer,
|
|
9
|
+
tree?: Buffer,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*/
|
|
14
|
+
export type TransactionOutput = {
|
|
15
|
+
amount: Buffer,
|
|
16
|
+
script: Buffer,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
*/
|
|
21
|
+
export type Transaction = {
|
|
22
|
+
version: Buffer,
|
|
23
|
+
inputs: TransactionInput[],
|
|
24
|
+
outputs?: TransactionOutput[],
|
|
25
|
+
locktime?: Buffer,
|
|
26
|
+
witness?: Buffer,
|
|
27
|
+
timestamp?: Buffer,
|
|
28
|
+
nVersionGroupId?: Buffer,
|
|
29
|
+
nExpiryHeight?: Buffer,
|
|
30
|
+
extraData?: Buffer,
|
|
31
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
export function getVarint(data: Buffer, offset: number): [number, number] {
|
|
4
|
+
if (data[offset] < 0xfd) {
|
|
5
|
+
return [data[offset], 1];
|
|
6
|
+
}
|
|
7
|
+
if (data[offset] === 0xfd) {
|
|
8
|
+
return [(data[offset + 2] << 8) + data[offset + 1], 3];
|
|
9
|
+
}
|
|
10
|
+
if (data[offset] === 0xfe) {
|
|
11
|
+
return [
|
|
12
|
+
(data[offset + 4] << 24) +
|
|
13
|
+
(data[offset + 3] << 16) +
|
|
14
|
+
(data[offset + 2] << 8) +
|
|
15
|
+
data[offset + 1],
|
|
16
|
+
5,
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
throw new Error("getVarint called with unexpected parameters");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function createVarint(value: number): Buffer {
|
|
24
|
+
if (value < 0xfd) {
|
|
25
|
+
const buffer = Buffer.alloc(1);
|
|
26
|
+
buffer[0] = value;
|
|
27
|
+
return buffer;
|
|
28
|
+
}
|
|
29
|
+
if (value <= 0xffff) {
|
|
30
|
+
const buffer = Buffer.alloc(3);
|
|
31
|
+
buffer[0] = 0xfd;
|
|
32
|
+
buffer[1] = value & 0xff;
|
|
33
|
+
buffer[2] = (value >> 8) & 0xff;
|
|
34
|
+
return buffer;
|
|
35
|
+
}
|
|
36
|
+
const buffer = Buffer.alloc(5);
|
|
37
|
+
buffer[0] = 0xfe;
|
|
38
|
+
buffer[1] = value & 0xff;
|
|
39
|
+
buffer[2] = (value >> 8) & 0xff;
|
|
40
|
+
buffer[3] = (value >> 16) & 0xff;
|
|
41
|
+
buffer[4] = (value >> 24) & 0xff;
|
|
42
|
+
return buffer;
|
|
43
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/hw-app-btc",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.27.1",
|
|
4
4
|
"description": "Ledger Hardware Wallet Bitcoin Application API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -27,12 +27,11 @@
|
|
|
27
27
|
"types": "lib/Btc.d.ts",
|
|
28
28
|
"license": "Apache-2.0",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@ledgerhq/hw-transport": "^6.
|
|
31
|
-
"@ledgerhq/logs": "^6.10.
|
|
30
|
+
"@ledgerhq/hw-transport": "^6.27.1",
|
|
31
|
+
"@ledgerhq/logs": "^6.10.0",
|
|
32
32
|
"bip32-path": "^0.4.2",
|
|
33
33
|
"bitcoinjs-lib": "^5.2.0",
|
|
34
34
|
"bs58": "^4.0.1",
|
|
35
|
-
"bs58check": "^2.1.2",
|
|
36
35
|
"invariant": "^2.2.4",
|
|
37
36
|
"ripemd160": "2",
|
|
38
37
|
"semver": "^7.3.5",
|
|
@@ -40,19 +39,11 @@
|
|
|
40
39
|
"tiny-secp256k1": "1.1.6",
|
|
41
40
|
"varuint-bitcoin": "1.1.2"
|
|
42
41
|
},
|
|
43
|
-
"devDependencies": {
|
|
44
|
-
"@ledgerhq/hw-transport-mocker": "^6.24.2-monorepo.4",
|
|
45
|
-
"@ledgerhq/hw-transport-node-speculos": "^6.24.2-monorepo.4",
|
|
46
|
-
"axios": "^0.25.0"
|
|
47
|
-
},
|
|
48
|
-
"gitHead": "dd0dea64b58e5a9125c8a422dcffd29e5ef6abec",
|
|
49
42
|
"scripts": {
|
|
50
43
|
"clean": "bash ../../script/clean.sh",
|
|
51
44
|
"build": "bash ../../script/build.sh",
|
|
52
45
|
"watch": "bash ../../script/watch.sh",
|
|
53
|
-
"doc": "bash ../../script/doc.sh"
|
|
54
|
-
"lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx",
|
|
55
|
-
"test": "jest"
|
|
46
|
+
"doc": "bash ../../script/doc.sh"
|
|
56
47
|
},
|
|
57
|
-
"readme": "<img src=\"https://user-images.githubusercontent.com/211411/34776833-6f1ef4da-f618-11e7-8b13-f0697901d6a8.png\" height=\"100\" />\n\n[Github](https://github.com/LedgerHQ/ledgerjs/),\n[Ledger Devs Slack](https://ledger-dev.slack.com/)\n\n## @ledgerhq/hw-app-btc\n\nLedger Hardware Wallet BTC JavaScript bindings. Also supports many altcoins.\n\n## API\n\n<!-- Generated by documentation.js. Update this documentation by updating the source code. -->\n\n#### Table of Contents\n\n* [Btc](#btc)\n * [Parameters](#parameters)\n * [Examples](#examples)\n * [getWalletXpub](#getwalletxpub)\n * [Parameters](#parameters-1)\n * [getWalletPublicKey](#getwalletpublickey)\n * [Parameters](#parameters-2)\n * [Examples](#examples-1)\n * [signMessageNew](#signmessagenew)\n * [Parameters](#parameters-3)\n * [Examples](#examples-2)\n * [createPaymentTransactionNew](#createpaymenttransactionnew)\n * [Parameters](#parameters-4)\n * [Examples](#examples-3)\n * [signP2SHTransaction](#signp2shtransaction)\n * [Parameters](#parameters-5)\n * [Examples](#examples-4)\n * [splitTransaction](#splittransaction)\n * [Parameters](#parameters-6)\n * [Examples](#examples-5)\n * [serializeTransactionOutputs](#serializetransactionoutputs)\n * [Parameters](#parameters-7)\n * [Examples](#examples-6)\n* [impl](#impl)\n* [BtcNew](#btcnew)\n * [Parameters](#parameters-8)\n * [getWalletXpub](#getwalletxpub-1)\n * [Parameters](#parameters-9)\n * [getWalletPublicKey](#getwalletpublickey-1)\n * [Parameters](#parameters-10)\n * [createPaymentTransactionNew](#createpaymenttransactionnew-1)\n * [Parameters](#parameters-11)\n* [BtcOld](#btcold)\n * [Parameters](#parameters-12)\n * [Examples](#examples-7)\n * [getWalletPublicKey](#getwalletpublickey-2)\n * [Parameters](#parameters-13)\n * [Examples](#examples-8)\n * [signMessageNew](#signmessagenew-1)\n * [Parameters](#parameters-14)\n * [Examples](#examples-9)\n * [createPaymentTransactionNew](#createpaymenttransactionnew-2)\n * [Parameters](#parameters-15)\n * [Examples](#examples-10)\n * [signP2SHTransaction](#signp2shtransaction-1)\n * [Parameters](#parameters-16)\n * [Examples](#examples-11)\n* [CreateTransactionArg](#createtransactionarg)\n * [Properties](#properties)\n* [AddressFormat](#addressformat)\n* [AccountType](#accounttype)\n * [spendingCondition](#spendingcondition)\n * [Parameters](#parameters-17)\n * [setInput](#setinput)\n * [Parameters](#parameters-18)\n * [setOwnOutput](#setownoutput)\n * [Parameters](#parameters-19)\n * [getDescriptorTemplate](#getdescriptortemplate)\n* [SingleKeyAccount](#singlekeyaccount)\n* [getTaprootOutputKey](#gettaprootoutputkey)\n * [Parameters](#parameters-20)\n* [AppClient](#appclient)\n * [Parameters](#parameters-21)\n* [ClientCommandInterpreter](#clientcommandinterpreter)\n * [Parameters](#parameters-22)\n* [MerkelizedPsbt](#merkelizedpsbt)\n * [Parameters](#parameters-23)\n* [Merkle](#merkle)\n * [Parameters](#parameters-24)\n* [MerkleMap](#merklemap)\n * [Parameters](#parameters-25)\n* [WalletPolicy](#walletpolicy)\n * [Parameters](#parameters-26)\n* [extract](#extract)\n * [Parameters](#parameters-27)\n* [finalize](#finalize)\n * [Parameters](#parameters-28)\n* [clearFinalizedInput](#clearfinalizedinput)\n * [Parameters](#parameters-29)\n* [writePush](#writepush)\n * [Parameters](#parameters-30)\n* [PsbtV2](#psbtv2)\n* [serializeTransactionOutputs](#serializetransactionoutputs-1)\n * [Parameters](#parameters-31)\n * [Examples](#examples-12)\n* [SignP2SHTransactionArg](#signp2shtransactionarg)\n * [Properties](#properties-1)\n* [TransactionInput](#transactioninput)\n* [TransactionOutput](#transactionoutput)\n* [Transaction](#transaction)\n\n### Btc\n\nBitcoin API.\n\n#### Parameters\n\n* `transport` **Transport** \n* `scrambleKey` (optional, default `\"BTC\"`)\n\n#### Examples\n\n```javascript\nimport Btc from \"@ledgerhq/hw-app-btc\";\nconst btc = new Btc(transport)\n```\n\n#### getWalletXpub\n\nGet an XPUB with a ledger device\n\n##### Parameters\n\n* `arg` **{path: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), xpubVersion: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)}** derivation parameter* path: a BIP 32 path of the account level. e.g. `84'/0'/0'`\n * xpubVersion: the XPUBVersion of the coin used. (use @ledgerhq/currencies if needed)\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** XPUB of the account\n\n#### getWalletPublicKey\n\n##### Parameters\n\n* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a BIP 32 path\n* `opts` **{verify: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, format: [AddressFormat](#addressformat)?}?** \n* `options` an object with optional these fields:* verify (boolean) will ask user to confirm the address on the device\n\n * format (\"legacy\" | \"p2sh\" | \"bech32\" | \"bech32m\" | \"cashaddr\") to use different bitcoin address formatter.NB The normal usage is to use:* legacy format with 44' paths\n\n * p2sh format with 49' paths\n\n * bech32 format with 84' paths\n\n * cashaddr in case of Bitcoin Cash\n\n##### Examples\n\n```javascript\nbtc.getWalletPublicKey(\"44'/0'/0'/0/0\").then(o => o.bitcoinAddress)\nbtc.getWalletPublicKey(\"49'/0'/0'/0/0\", { format: \"p2sh\" }).then(o => o.bitcoinAddress)\n```\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{publicKey: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), bitcoinAddress: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), chainCode: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>** \n\n#### signMessageNew\n\nYou can sign a message according to the Bitcoin Signature format and retrieve v, r, s given the message and the BIP 32 path of the account to sign.\n\n##### Parameters\n\n* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n* `messageHex` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n\n##### Examples\n\n```javascript\nbtc.signMessageNew_async(\"44'/60'/0'/0'/0\", Buffer.from(\"test\").toString(\"hex\")).then(function(result) {\nvar v = result['v'] + 27 + 4;\nvar signature = Buffer.from(v.toString(16) + result['r'] + result['s'], 'hex').toString('base64');\nconsole.log(\"Signature : \" + signature);\n}).catch(function(ex) {console.log(ex);});\n```\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{v: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), r: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), s: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>** \n\n#### createPaymentTransactionNew\n\nTo sign a transaction involving standard (P2PKH) inputs, call createTransaction with the following parameters\n\n##### Parameters\n\n* `arg` **[CreateTransactionArg](#createtransactionarg)** \n* `inputs` is an array of \\[ transaction, output_index, optional redeem script, optional sequence ] where* transaction is the previously computed transaction object for this UTXO\n * output_index is the output in the transaction used as input for this UTXO (counting from 0)\n * redeem script is the optional redeem script to use when consuming a Segregated Witness input\n * sequence is the sequence number to use for this input (when using RBF), or non present\n* `associatedKeysets` is an array of BIP 32 paths pointing to the path to the private key used for each UTXO\n* `changePath` is an optional BIP 32 path pointing to the path to the public key used to compute the change address\n* `outputScriptHex` is the hexadecimal serialized outputs of the transaction to sign, including leading vararg voutCount\n* `lockTime` is the optional lockTime of the transaction to sign, or default (0)\n* `sigHashType` is the hash type of the transaction to sign, or default (all)\n* `segwit` is an optional boolean indicating wether to use segwit or not. This includes wrapped segwit.\n* `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)\n* `additionals` list of additionnal options* \"bech32\" for spending native segwit outputs\n * \"bech32m\" for spending segwit v1+ outputs\n * \"abc\" for bch\n * \"gold\" for btg\n * \"bipxxx\" for using BIPxxx\n * \"sapling\" to indicate a zec transaction is supporting sapling (to be set over block 419200)\n* `expiryHeight` is an optional Buffer for zec overwinter / sapling Txs\n* `useTrustedInputForSegwit` trust inputs for segwit transactions. If app version >= 1.4.0 this should be true.\n\n##### Examples\n\n```javascript\nbtc.createTransaction({\ninputs: [ [tx1, 1] ],\nassociatedKeysets: [\"0'/0/0\"],\noutputScriptHex: \"01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac\"\n}).then(res => ...);\n```\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** the signed transaction ready to be broadcast\n\n#### signP2SHTransaction\n\nTo obtain the signature of multisignature (P2SH) inputs, call signP2SHTransaction_async with the folowing parameters\n\n##### Parameters\n\n* `arg` **[SignP2SHTransactionArg](#signp2shtransactionarg)** \n* `inputs` is an array of \\[ transaction, output_index, redeem script, optional sequence ] where* transaction is the previously computed transaction object for this UTXO\n * output_index is the output in the transaction used as input for this UTXO (counting from 0)\n * redeem script is the mandatory redeem script associated to the current P2SH input\n * sequence is the sequence number to use for this input (when using RBF), or non present\n* `associatedKeysets` is an array of BIP 32 paths pointing to the path to the private key used for each UTXO\n* `outputScriptHex` is the hexadecimal serialized outputs of the transaction to sign\n* `lockTime` is the optional lockTime of the transaction to sign, or default (0)\n* `sigHashType` is the hash type of the transaction to sign, or default (all)\n\n##### Examples\n\n```javascript\nbtc.signP2SHTransaction({\ninputs: [ [tx, 1, \"52210289b4a3ad52a919abd2bdd6920d8a6879b1e788c38aa76f0440a6f32a9f1996d02103a3393b1439d1693b063482c04bd40142db97bdf139eedd1b51ffb7070a37eac321030b9a409a1e476b0d5d17b804fcdb81cf30f9b99c6f3ae1178206e08bc500639853ae\"] ],\nassociatedKeysets: [\"0'/0/0\"],\noutputScriptHex: \"01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac\"\n}).then(result => ...);\n```\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>>** the signed transaction ready to be broadcast\n\n#### splitTransaction\n\nFor each UTXO included in your transaction, create a transaction object from the raw serialized version of the transaction used in this UTXO.\n\n##### Parameters\n\n* `transactionHex` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n* `isSegwitSupported` **([boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))** (optional, default `false`)\n* `hasTimestamp` (optional, default `false`)\n* `hasExtraData` (optional, default `false`)\n* `additionals` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** (optional, default `[]`)\n\n##### Examples\n\n```javascript\nconst tx1 = btc.splitTransaction(\"01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000\");\n```\n\nReturns **[Transaction](#transaction)** \n\n#### serializeTransactionOutputs\n\n##### Parameters\n\n* `t` **[Transaction](#transaction)** \n\n##### Examples\n\n```javascript\nconst tx1 = btc.splitTransaction(\"01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000\");\nconst outputScript = btc.serializeTransactionOutputs(tx1).toString('hex');\n```\n\nReturns **[Buffer](https://nodejs.org/api/buffer.html)** \n\n### impl\n\nDefinition: A \"normal path\" is a prefix of a standard path where all\nthe hardened steps of the standard path are included. For example, the\npaths m/44'/1'/17' and m/44'/1'/17'/1 are normal paths, but m/44'/1'\nis not. m/'199/1'/17'/0/1 is not a normal path either.\n\nThere's a compatiblity issue between old and new app: When exporting\nthe key of a non-normal path with verify=false, the new app would\nreturn an error, whereas the old app would return the key.\n\nSee\n<https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md#get_extended_pubkey>\n\nIf format bech32m is used, we'll not use old, because it doesn't\nsupport it.\n\nWhen to use new (given the app supports it)\n\n* format is bech32m or\n* path is normal or\n* verify is true\n\nOtherwise use old.\n\n### BtcNew\n\nThis class implements the same interface as BtcOld (formerly\nnamed Btc), but interacts with Bitcoin hardware app version 2+\nwhich uses a totally new APDU protocol. This new\nprotocol is documented at\n<https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md>\n\nSince the interface must remain compatible with BtcOld, the methods\nof this class are quite clunky, because it needs to adapt legacy\ninput data into the PSBT process. In the future, a new interface should\nbe developed that exposes PSBT to the outer world, which would render\na much cleaner implementation.\n\n#### Parameters\n\n* `` \n\n#### getWalletXpub\n\nThis is a new method that allow users to get an xpub at a standard path.\nStandard paths are described at\n<https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md#description>\n\nThis boils down to paths (N=0 for Bitcoin, N=1 for Testnet):\nM/44'/N'/x'/\\*\\*\nM/48'/N'/x'/y'/\\*\\*\nM/49'/N'/x'/\\*\\*\nM/84'/N'/x'/\\*\\*\nM/86'/N'/x'/\\*\\*\n\nThe method was added because of added security in the hardware app v2+. The\nnew hardware app will allow export of any xpub up to and including the\ndeepest hardened key of standard derivation paths, whereas the old app\nwould allow export of any key.\n\nThis caused an issue for callers of this class, who only had\ngetWalletPublicKey() to call which means they have to constuct xpub\nthemselves:\n\nSuppose a user of this class wants to create an account xpub on a standard\npath, M/44'/0'/Z'. The user must get the parent key fingerprint (see BIP32)\nby requesting the parent key M/44'/0'. The new app won't allow that, because\nit only allows exporting deepest level hardened path. So the options are to\nallow requesting M/44'/0' from the app, or to add a new function\n\"getWalletXpub\".\n\nWe opted for adding a new function, which can greatly simplify client code.\n\n##### Parameters\n\n* `$0` **{path: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), xpubVersion: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)}** \n\n * `$0.path` \n * `$0.xpubVersion` \n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** \n\n#### getWalletPublicKey\n\nThis method returns a public key, a bitcoin address, and and a chaincode\nfor a specific derivation path.\n\nLimitation: If the path is not a leaf node of a standard path, the address\nwill be the empty string \"\", see this.getWalletAddress() for details.\n\n##### Parameters\n\n* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n* `opts` **{verify: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, format: [AddressFormat](#addressformat)?}?** \n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{publicKey: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), bitcoinAddress: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), chainCode: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>** \n\n#### createPaymentTransactionNew\n\nBuild and sign a transaction. See Btc.createPaymentTransactionNew for\ndetails on how to use this method.\n\nThis method will convert the legacy arguments, CreateTransactionArg, into\na psbt which is finally signed and finalized, and the extracted fully signed\ntransaction is returned.\n\n##### Parameters\n\n* `arg` **[CreateTransactionArg](#createtransactionarg)** \n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** \n\n### BtcOld\n\nBitcoin API.\n\n#### Parameters\n\n* `` \n\n#### Examples\n\n```javascript\nimport Btc from \"@ledgerhq/hw-app-btc\";\nconst btc = new Btc(transport)\n```\n\n#### getWalletPublicKey\n\n##### Parameters\n\n* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a BIP 32 path\n* `opts` **{verify: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, format: [AddressFormat](#addressformat)?}?** \n* `options` an object with optional these fields:* verify (boolean) will ask user to confirm the address on the device\n\n * format (\"legacy\" | \"p2sh\" | \"bech32\" | \"cashaddr\") to use different bitcoin address formatter.NB The normal usage is to use:* legacy format with 44' paths\n\n * p2sh format with 49' paths\n\n * bech32 format with 173' paths\n\n * cashaddr in case of Bitcoin Cash\n\n##### Examples\n\n```javascript\nbtc.getWalletPublicKey(\"44'/0'/0'/0/0\").then(o => o.bitcoinAddress)\nbtc.getWalletPublicKey(\"49'/0'/0'/0/0\", { format: \"p2sh\" }).then(o => o.bitcoinAddress)\n```\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{publicKey: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), bitcoinAddress: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), chainCode: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>** \n\n#### signMessageNew\n\nYou can sign a message according to the Bitcoin Signature format and retrieve v, r, s given the message and the BIP 32 path of the account to sign.\n\n##### Parameters\n\n* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n* `messageHex` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n\n##### Examples\n\n```javascript\nbtc.signMessageNew_async(\"44'/60'/0'/0'/0\", Buffer.from(\"test\").toString(\"hex\")).then(function(result) {\nvar v = result['v'] + 27 + 4;\nvar signature = Buffer.from(v.toString(16) + result['r'] + result['s'], 'hex').toString('base64');\nconsole.log(\"Signature : \" + signature);\n}).catch(function(ex) {console.log(ex);});\n```\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{v: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), r: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), s: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>** \n\n#### createPaymentTransactionNew\n\nTo sign a transaction involving standard (P2PKH) inputs, call createTransaction with the following parameters\n\n##### Parameters\n\n* `arg` **[CreateTransactionArg](#createtransactionarg)** \n* `inputs` is an array of \\[ transaction, output_index, optional redeem script, optional sequence ] where* transaction is the previously computed transaction object for this UTXO\n * output_index is the output in the transaction used as input for this UTXO (counting from 0)\n * redeem script is the optional redeem script to use when consuming a Segregated Witness input\n * sequence is the sequence number to use for this input (when using RBF), or non present\n* `associatedKeysets` is an array of BIP 32 paths pointing to the path to the private key used for each UTXO\n* `changePath` is an optional BIP 32 path pointing to the path to the public key used to compute the change address\n* `outputScriptHex` is the hexadecimal serialized outputs of the transaction to sign\n* `lockTime` is the optional lockTime of the transaction to sign, or default (0)\n* `sigHashType` is the hash type of the transaction to sign, or default (all)\n* `segwit` is an optional boolean indicating wether to use segwit or not\n* `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)\n* `additionals` list of additionnal options* \"bech32\" for spending native segwit outputs\n * \"abc\" for bch\n * \"gold\" for btg\n * \"bipxxx\" for using BIPxxx\n * \"sapling\" to indicate a zec transaction is supporting sapling (to be set over block 419200)\n* `expiryHeight` is an optional Buffer for zec overwinter / sapling Txs\n* `useTrustedInputForSegwit` trust inputs for segwit transactions\n\n##### Examples\n\n```javascript\nbtc.createTransaction({\ninputs: [ [tx1, 1] ],\nassociatedKeysets: [\"0'/0/0\"],\noutputScriptHex: \"01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac\"\n}).then(res => ...);\n```\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** the signed transaction ready to be broadcast\n\n#### signP2SHTransaction\n\nTo obtain the signature of multisignature (P2SH) inputs, call signP2SHTransaction_async with the folowing parameters\n\n##### Parameters\n\n* `arg` **[SignP2SHTransactionArg](#signp2shtransactionarg)** \n* `inputs` is an array of \\[ transaction, output_index, redeem script, optional sequence ] where* transaction is the previously computed transaction object for this UTXO\n * output_index is the output in the transaction used as input for this UTXO (counting from 0)\n * redeem script is the mandatory redeem script associated to the current P2SH input\n * sequence is the sequence number to use for this input (when using RBF), or non present\n* `associatedKeysets` is an array of BIP 32 paths pointing to the path to the private key used for each UTXO\n* `outputScriptHex` is the hexadecimal serialized outputs of the transaction to sign\n* `lockTime` is the optional lockTime of the transaction to sign, or default (0)\n* `sigHashType` is the hash type of the transaction to sign, or default (all)\n\n##### Examples\n\n```javascript\nbtc.signP2SHTransaction({\ninputs: [ [tx, 1, \"52210289b4a3ad52a919abd2bdd6920d8a6879b1e788c38aa76f0440a6f32a9f1996d02103a3393b1439d1693b063482c04bd40142db97bdf139eedd1b51ffb7070a37eac321030b9a409a1e476b0d5d17b804fcdb81cf30f9b99c6f3ae1178206e08bc500639853ae\"] ],\nassociatedKeysets: [\"0'/0/0\"],\noutputScriptHex: \"01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac\"\n}).then(result => ...);\n```\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>>** the signed transaction ready to be broadcast\n\n### CreateTransactionArg\n\nType: {inputs: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<\\[[Transaction](#transaction), [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), ([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)), ([number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))]>, associatedKeysets: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>, changePath: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, outputScriptHex: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), lockTime: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?, sigHashType: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?, segwit: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, initialTimestamp: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?, additionals: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>, expiryHeight: [Buffer](https://nodejs.org/api/buffer.html)?, useTrustedInputForSegwit: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, onDeviceStreaming: function (arg0: {progress: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), total: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), index: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)}): void?, onDeviceSignatureRequested: function (): void?, onDeviceSignatureGranted: function (): void?}\n\n#### Properties\n\n* `inputs` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<\\[[Transaction](#transaction), [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), ([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)), ([number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))]>** \n* `associatedKeysets` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** \n* `changePath` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** \n* `outputScriptHex` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n* `lockTime` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** \n* `sigHashType` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** \n* `segwit` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** \n* `initialTimestamp` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** \n* `additionals` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** \n* `expiryHeight` **[Buffer](https://nodejs.org/api/buffer.html)?** \n* `useTrustedInputForSegwit` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** \n* `onDeviceStreaming` **function (arg0: {progress: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), total: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), index: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)}): void?** \n* `onDeviceSignatureRequested` **function (): void?** \n* `onDeviceSignatureGranted` **function (): void?** \n\n### AddressFormat\n\naddress format is one of legacy | p2sh | bech32 | cashaddr\n\nType: (`\"legacy\"` | `\"p2sh\"` | `\"bech32\"` | `\"bech32m\"` | `\"cashaddr\"`)\n\n### AccountType\n\nEncapsulates differences between account types, for example p2wpkh,\np2wpkhWrapped, p2tr.\n\n#### spendingCondition\n\nGenerates a scriptPubKey (output script) from a list of public keys. If a\np2sh redeemScript or a p2wsh witnessScript is needed it will also be set on\nthe returned SpendingCondition.\n\nThe pubkeys are expected to be 33 byte ecdsa compressed pubkeys.\n\n##### Parameters\n\n* `pubkeys` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Buffer](https://nodejs.org/api/buffer.html)>** \n\nReturns **SpendingCondition** \n\n#### setInput\n\nPopulates the psbt with account type-specific data for an input.\n\n##### Parameters\n\n* `i` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The index of the input map to populate\n* `inputTx` **([Buffer](https://nodejs.org/api/buffer.html) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))** The full transaction containing the spent output. This may\n be omitted for taproot.\n* `spentOutput` **SpentOutput** The amount and spending condition of the spent output\n* `pubkeys` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Buffer](https://nodejs.org/api/buffer.html)>** The 33 byte ecdsa compressed public keys involved in the input\n* `pathElems` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>>** The paths corresponding to the pubkeys, in same order.\n\nReturns **void** \n\n#### setOwnOutput\n\nPopulates the psbt with account type-specific data for an output. This is typically\ndone for change outputs and other outputs that goes to the same account as\nbeing spent from.\n\n##### Parameters\n\n* `i` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** The index of the output map to populate\n* `cond` **SpendingCondition** The spending condition for this output\n* `pubkeys` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Buffer](https://nodejs.org/api/buffer.html)>** The 33 byte ecdsa compressed public keys involved in this output\n* `paths` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>>** The paths corresponding to the pubkeys, in same order.\n\nReturns **void** \n\n#### getDescriptorTemplate\n\nReturns the descriptor template for this account type. Currently only\nDefaultDescriptorTemplates are allowed, but that might be changed in the\nfuture. See class WalletPolicy for more information on descriptor\ntemplates.\n\nReturns **DefaultDescriptorTemplate** \n\n### SingleKeyAccount\n\n**Extends BaseAccount**\n\nSuperclass for single signature accounts. This will make sure that the pubkey\narrays and path arrays in the method arguments contains exactly one element\nand calls an abstract method to do the actual work.\n\n### getTaprootOutputKey\n\nCalculates a taproot output key from an internal key. This output key will be\nused as witness program in a taproot output. The internal key is tweaked\naccording to recommendation in BIP341:\n<https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#cite_ref-22-0>\n\n#### Parameters\n\n* `internalPubkey` **[Buffer](https://nodejs.org/api/buffer.html)** A 32 byte x-only taproot internal key\n\nReturns **[Buffer](https://nodejs.org/api/buffer.html)** The output key\n\n### AppClient\n\nThis class encapsulates the APDU protocol documented at\n<https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md>\n\n#### Parameters\n\n* `transport` **Transport** \n\n### ClientCommandInterpreter\n\nThis class will dispatch a client command coming from the hardware device to\nthe appropriate client command implementation. Those client commands\ntypically requests data from a merkle tree or merkelized maps.\n\nA ClientCommandInterpreter is prepared by adding the merkle trees and\nmerkelized maps it should be able to serve to the hardware device. This class\ndoesn't know anything about the semantics of the data it holds, it just\nserves merkle data. It doesn't even know in what context it is being\nexecuted, ie SignPsbt, getWalletAddress, etc.\n\nIf the command yelds results to the client, as signPsbt does, the yielded\ndata will be accessible after the command completed by calling getYielded(),\nwhich will return the yields in the same order as they came in.\n\n#### Parameters\n\n* `progressCallback` **function (): void** \n\n### MerkelizedPsbt\n\n**Extends PsbtV2**\n\nThis class merkelizes a PSBTv2, by merkelizing the different\nmaps of the psbt. This is used during the transaction signing process,\nwhere the hardware app can request specific parts of the psbt from the\nclient code and be sure that the response data actually belong to the psbt.\nThe reason for this is the limited amount of memory available to the app,\nso it can't always store the full psbt in memory.\n\nThe signing process is documented at\n<https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md#sign_psbt>\n\n#### Parameters\n\n* `psbt` **[PsbtV2](#psbtv2)** \n\n### Merkle\n\nThis class implements the merkle tree used by Ledger Bitcoin app v2+,\nwhich is documented at\n<https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/merkle.md>\n\n#### Parameters\n\n* `leaves` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Buffer](https://nodejs.org/api/buffer.html)>** \n* `hasher` **function (buf: [Buffer](https://nodejs.org/api/buffer.html)): [Buffer](https://nodejs.org/api/buffer.html)** (optional, default `crypto.sha256`)\n\n### MerkleMap\n\nThis implements \"Merkelized Maps\", documented at\n<https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/merkle.md#merkleized-maps>\n\nA merkelized map consist of two merkle trees, one for the keys of\na map and one for the values of the same map, thus the two merkle\ntrees have the same shape. The commitment is the number elements\nin the map followed by the keys' merkle root followed by the\nvalues' merkle root.\n\n#### Parameters\n\n* `keys` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Buffer](https://nodejs.org/api/buffer.html)>** Sorted list of (unhashed) keys\n* `values` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Buffer](https://nodejs.org/api/buffer.html)>** values, in corresponding order as the keys, and of equal length\n\n### WalletPolicy\n\nThe Bitcon hardware app uses a descriptors-like thing to describe\nhow to construct output scripts from keys. A \"Wallet Policy\" consists\nof a \"Descriptor Template\" and a list of \"keys\". A key is basically\na serialized BIP32 extended public key with some added derivation path\ninformation. This is documented at\n<https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/wallet.md>\n\n#### Parameters\n\n* `descriptorTemplate` **DefaultDescriptorTemplate** \n* `key` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n\n### extract\n\nThis implements the \"Transaction Extractor\" role of BIP370 (PSBTv2\n<https://github.com/bitcoin/bips/blob/master/bip-0370.mediawiki#transaction-extractor>). However\nthe role is partially documented in BIP174 (PSBTv0\n<https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#transaction-extractor>).\n\n#### Parameters\n\n* `psbt` **[PsbtV2](#psbtv2)** \n\nReturns **[Buffer](https://nodejs.org/api/buffer.html)** \n\n### finalize\n\nThis roughly implements the \"input finalizer\" role of BIP370 (PSBTv2\n<https://github.com/bitcoin/bips/blob/master/bip-0370.mediawiki>). However\nthe role is documented in BIP174 (PSBTv0\n<https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki>).\n\nVerify that all inputs have a signature, and set inputFinalScriptwitness\nand/or inputFinalScriptSig depending on the type of the spent outputs. Clean\nfields that aren't useful anymore, partial signatures, redeem script and\nderivation paths.\n\n#### Parameters\n\n* `psbt` **[PsbtV2](#psbtv2)** The psbt with all signatures added as partial sigs, either\n through PSBT_IN_PARTIAL_SIG or PSBT_IN_TAP_KEY_SIG\n\nReturns **void** \n\n### clearFinalizedInput\n\nDeletes fields that are no longer neccesary from the psbt.\n\nNote, the spec doesn't say anything about removing ouput fields\nlike PSBT_OUT_BIP32\\_DERIVATION_PATH and others, so we keep them\nwithout actually knowing why. I think we should remove them too.\n\n#### Parameters\n\n* `psbt` **[PsbtV2](#psbtv2)** \n* `inputIndex` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** \n\n### writePush\n\nWrites a script push operation to buf, which looks different\ndepending on the size of the data. See\n<https://en.bitcoin.it/wiki/Script#Constants>\n\n#### Parameters\n\n* `buf` **BufferWriter** the BufferWriter to write to\n* `data` **[Buffer](https://nodejs.org/api/buffer.html)** the Buffer to be pushed.\n\n### PsbtV2\n\nImplements Partially Signed Bitcoin Transaction version 2, BIP370, as\ndocumented at <https://github.com/bitcoin/bips/blob/master/bip-0370.mediawiki>\nand <https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki>\n\nA psbt is a data structure that can carry all relevant information about a\ntransaction through all stages of the signing process. From constructing an\nunsigned transaction to extracting the final serialized transaction ready for\nbroadcast.\n\nThis implementation is limited to what's needed in ledgerjs to carry out its\nduties, which means that support for features like multisig or taproot script\npath spending are not implemented. Specifically, it supports p2pkh,\np2wpkhWrappedInP2sh, p2wpkh and p2tr key path spending.\n\nThis class is made purposefully dumb, so it's easy to add support for\ncomplemantary fields as needed in the future.\n\n### serializeTransactionOutputs\n\n#### Parameters\n\n* `$0` **[Transaction](#transaction)** \n\n * `$0.outputs` \n\n#### Examples\n\n```javascript\nconst tx1 = btc.splitTransaction(\"01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000\");\nconst outputScript = btc.serializeTransactionOutputs(tx1).toString('hex');\n```\n\nReturns **[Buffer](https://nodejs.org/api/buffer.html)** \n\n### SignP2SHTransactionArg\n\nType: {inputs: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<\\[[Transaction](#transaction), [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), ([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)), ([number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))]>, associatedKeysets: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>, outputScriptHex: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), lockTime: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?, sigHashType: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?, segwit: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, transactionVersion: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?}\n\n#### Properties\n\n* `inputs` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<\\[[Transaction](#transaction), [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), ([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)), ([number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))]>** \n* `associatedKeysets` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** \n* `outputScriptHex` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** \n* `lockTime` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** \n* `sigHashType` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** \n* `segwit` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** \n* `transactionVersion` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** \n\n### TransactionInput\n\n### TransactionOutput\n\n### Transaction\n"
|
|
58
|
-
}
|
|
48
|
+
"gitHead": "9639f96a970e1f46e9e39d0c2c361ce2289923be"
|
|
49
|
+
}
|
package/src/bip32.ts
CHANGED
|
@@ -31,11 +31,9 @@ export function pubkeyFromXpub(xpub: string): Buffer {
|
|
|
31
31
|
return xpubBuf.slice(xpubBuf.length - 33);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export function getXpubComponents(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
version: number;
|
|
38
|
-
} {
|
|
34
|
+
export function getXpubComponents(
|
|
35
|
+
xpub: string
|
|
36
|
+
): { chaincode: Buffer; pubkey: Buffer; version: number } {
|
|
39
37
|
const xpubBuf: Buffer = bs58check.decode(xpub);
|
|
40
38
|
return {
|
|
41
39
|
chaincode: xpubBuf.slice(13, 13 + 32),
|
package/src/getTrustedInput.ts
CHANGED
|
@@ -36,8 +36,14 @@ export async function getTrustedInput(
|
|
|
36
36
|
transaction: Transaction,
|
|
37
37
|
additionals: Array<string> = []
|
|
38
38
|
): Promise<string> {
|
|
39
|
-
const {
|
|
40
|
-
|
|
39
|
+
const {
|
|
40
|
+
version,
|
|
41
|
+
inputs,
|
|
42
|
+
outputs,
|
|
43
|
+
locktime,
|
|
44
|
+
nExpiryHeight,
|
|
45
|
+
extraData,
|
|
46
|
+
} = transaction;
|
|
41
47
|
|
|
42
48
|
if (!outputs || !locktime) {
|
|
43
49
|
throw new Error("getTrustedInput: locktime & outputs is expected");
|
package/src/newops/appClient.ts
CHANGED
|
@@ -39,14 +39,10 @@ export class AppClient {
|
|
|
39
39
|
data: Buffer,
|
|
40
40
|
cci?: ClientCommandInterpreter
|
|
41
41
|
): Promise<Buffer> {
|
|
42
|
-
let response: Buffer = await this.transport.send(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
0,
|
|
47
|
-
data,
|
|
48
|
-
[0x9000, 0xe000]
|
|
49
|
-
);
|
|
42
|
+
let response: Buffer = await this.transport.send(CLA_BTC, ins, 0, 0, data, [
|
|
43
|
+
0x9000,
|
|
44
|
+
0xe000,
|
|
45
|
+
]);
|
|
50
46
|
while (response.readUInt16BE(response.length - 2) === 0xe000) {
|
|
51
47
|
if (!cci) {
|
|
52
48
|
throw new Error("Unexpected SW_INTERRUPTED_EXECUTION");
|
package/src/newops/psbtv2.ts
CHANGED
|
@@ -427,10 +427,9 @@ export class PsbtV2 {
|
|
|
427
427
|
this.writeBip32Derivation(buf, masterFingerprint, path);
|
|
428
428
|
return buf.buffer();
|
|
429
429
|
}
|
|
430
|
-
private decodeBip32Derivation(
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
} {
|
|
430
|
+
private decodeBip32Derivation(
|
|
431
|
+
buffer: Buffer
|
|
432
|
+
): { masterFingerprint: Buffer; path: number[] } {
|
|
434
433
|
const buf = new BufferReader(buffer);
|
|
435
434
|
return this.readBip32Derivation(buf);
|
|
436
435
|
}
|
|
@@ -444,10 +443,9 @@ export class PsbtV2 {
|
|
|
444
443
|
buf.writeUInt32(element);
|
|
445
444
|
});
|
|
446
445
|
}
|
|
447
|
-
private readBip32Derivation(
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
} {
|
|
446
|
+
private readBip32Derivation(
|
|
447
|
+
buf: BufferReader
|
|
448
|
+
): { masterFingerprint: Buffer; path: number[] } {
|
|
451
449
|
const masterFingerprint = buf.readSlice(4);
|
|
452
450
|
const path: number[] = [];
|
|
453
451
|
while (buf.offset < buf.buffer.length) {
|
|
@@ -468,11 +466,9 @@ export class PsbtV2 {
|
|
|
468
466
|
this.writeBip32Derivation(buf, masterFingerprint, path);
|
|
469
467
|
return buf.buffer();
|
|
470
468
|
}
|
|
471
|
-
private decodeTapBip32Derivation(
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
path: number[];
|
|
475
|
-
} {
|
|
469
|
+
private decodeTapBip32Derivation(
|
|
470
|
+
buffer: Buffer
|
|
471
|
+
): { hashes: Buffer[]; masterFingerprint: Buffer; path: number[] } {
|
|
476
472
|
const buf = new BufferReader(buffer);
|
|
477
473
|
const hashCount = buf.readVarInt();
|
|
478
474
|
const hashes: Buffer[] = [];
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
@ledgerhq/hw-app-btc:build: cache hit, replaying output 35b2dc24fb93f7bd
|
|
2
|
-
@ledgerhq/hw-app-btc:build:
|
|
3
|
-
@ledgerhq/hw-app-btc:build: > @ledgerhq/hw-app-btc@6.24.2-monorepo.4 build /home/runner/work/ledger-live/ledger-live/libs/ledgerjs/packages/hw-app-btc
|
|
4
|
-
@ledgerhq/hw-app-btc:build: > bash ../../script/build.sh
|
|
5
|
-
@ledgerhq/hw-app-btc:build:
|
package/CHANGELOG.md
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# @ledgerhq/hw-app-btc
|
|
2
|
-
|
|
3
|
-
## 6.24.2-monorepo.4
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- f6cb87454: test prerelease
|
|
8
|
-
- Updated dependencies [f6cb87454]
|
|
9
|
-
- @ledgerhq/hw-transport@6.24.2-monorepo.4
|
|
10
|
-
- @ledgerhq/logs@6.10.1-monorepo.4
|
|
11
|
-
|
|
12
|
-
## 6.24.2-monorepo.3
|
|
13
|
-
|
|
14
|
-
### Patch Changes
|
|
15
|
-
|
|
16
|
-
- 7f4a91716: clean pnpm-lock file
|
|
17
|
-
- Updated dependencies [7f4a91716]
|
|
18
|
-
- @ledgerhq/hw-transport@6.24.2-monorepo.3
|
|
19
|
-
- @ledgerhq/logs@6.10.1-monorepo.3
|
|
20
|
-
|
|
21
|
-
## 6.24.2-monorepo.2
|
|
22
|
-
|
|
23
|
-
### Patch Changes
|
|
24
|
-
|
|
25
|
-
- a439963a7: test prerelease
|
|
26
|
-
- Updated dependencies [a439963a7]
|
|
27
|
-
- @ledgerhq/hw-transport@6.24.2-monorepo.2
|
|
28
|
-
- @ledgerhq/logs@6.10.1-monorepo.2
|
|
29
|
-
|
|
30
|
-
## 6.24.2-monorepo.1
|
|
31
|
-
|
|
32
|
-
### Patch Changes
|
|
33
|
-
|
|
34
|
-
- 1b6fec9db: monorepo prelease 2
|
|
35
|
-
- Updated dependencies [1b6fec9db]
|
|
36
|
-
- @ledgerhq/hw-transport@6.24.2-monorepo.1
|
|
37
|
-
- @ledgerhq/logs@6.10.1-monorepo.1
|
|
38
|
-
|
|
39
|
-
## 6.24.2-monorepo.0
|
|
40
|
-
|
|
41
|
-
### Patch Changes
|
|
42
|
-
|
|
43
|
-
- test prerelease
|
|
44
|
-
- Updated dependencies
|
|
45
|
-
- @ledgerhq/hw-transport@6.24.2-monorepo.0
|
|
46
|
-
- @ledgerhq/logs@6.10.1-monorepo.0
|