@ledgerhq/hw-app-btc 8.1.2-nightly.1 → 9.0.0-nightly.2
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +6 -0
- package/README.md +33 -111
- package/lib/Btc.d.ts +11 -13
- package/lib/Btc.d.ts.map +1 -1
- package/lib/Btc.js +31 -191
- package/lib/Btc.js.map +1 -1
- package/lib/BtcNew.d.ts +2 -4
- package/lib/BtcNew.d.ts.map +1 -1
- package/lib/BtcNew.js +54 -13
- package/lib/BtcNew.js.map +1 -1
- package/lib/BtcOld.d.ts +2 -37
- package/lib/BtcOld.d.ts.map +1 -1
- package/lib/BtcOld.js +3 -45
- package/lib/BtcOld.js.map +1 -1
- package/lib-es/Btc.d.ts +11 -13
- package/lib-es/Btc.d.ts.map +1 -1
- package/lib-es/Btc.js +31 -168
- package/lib-es/Btc.js.map +1 -1
- package/lib-es/BtcNew.d.ts +2 -4
- package/lib-es/BtcNew.d.ts.map +1 -1
- package/lib-es/BtcNew.js +54 -8
- package/lib-es/BtcNew.js.map +1 -1
- package/lib-es/BtcOld.d.ts +2 -37
- package/lib-es/BtcOld.d.ts.map +1 -1
- package/lib-es/BtcOld.js +3 -45
- package/lib-es/BtcOld.js.map +1 -1
- package/package.json +1 -1
- package/src/Btc.ts +41 -151
- package/src/BtcNew.ts +60 -15
- package/src/BtcOld.ts +4 -59
- package/tests/Btc.test.ts +16 -132
- package/tests/newops/BtcNew.test.ts +0 -5
- package/tests/newops/integrationtools.ts +4 -4
- package/tests/parseTx.test.ts +1 -1
- package/tests/trustedInputs.test.ts +6 -8
package/src/BtcOld.ts
CHANGED
|
@@ -6,9 +6,6 @@ import type { CreateTransactionArg } from "./createTransaction";
|
|
|
6
6
|
import { createTransaction } from "./createTransaction";
|
|
7
7
|
import type { AddressFormat } from "./getWalletPublicKey";
|
|
8
8
|
import { getWalletPublicKey } from "./getWalletPublicKey";
|
|
9
|
-
import { signMessage } from "./signMessage";
|
|
10
|
-
import type { SignP2SHTransactionArg } from "./signP2SHTransaction";
|
|
11
|
-
import { signP2SHTransaction } from "./signP2SHTransaction";
|
|
12
9
|
import { pathArrayToString, pathStringToArray } from "./bip32";
|
|
13
10
|
export type { AddressFormat };
|
|
14
11
|
|
|
@@ -17,7 +14,7 @@ export type { AddressFormat };
|
|
|
17
14
|
*
|
|
18
15
|
* @example
|
|
19
16
|
* import Btc from "@ledgerhq/hw-app-btc";
|
|
20
|
-
* const btc = new Btc(transport)
|
|
17
|
+
* const btc = new Btc({ transport, currency: "zcash" });
|
|
21
18
|
*/
|
|
22
19
|
|
|
23
20
|
export default class BtcOld {
|
|
@@ -99,29 +96,6 @@ export default class BtcOld {
|
|
|
99
96
|
return getWalletPublicKey(this.transport, { ...opts, path });
|
|
100
97
|
}
|
|
101
98
|
|
|
102
|
-
/**
|
|
103
|
-
* You 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.
|
|
104
|
-
* @example
|
|
105
|
-
btc.signMessageNew_async("44'/60'/0'/0'/0", Buffer.from("test").toString("hex")).then(function(result) {
|
|
106
|
-
var v = result['v'] + 27 + 4;
|
|
107
|
-
var signature = Buffer.from(v.toString(16) + result['r'] + result['s'], 'hex').toString('base64');
|
|
108
|
-
console.log("Signature : " + signature);
|
|
109
|
-
}).catch(function(ex) {console.log(ex);});
|
|
110
|
-
*/
|
|
111
|
-
signMessageNew(
|
|
112
|
-
path: string,
|
|
113
|
-
messageHex: string
|
|
114
|
-
): Promise<{
|
|
115
|
-
v: number;
|
|
116
|
-
r: string;
|
|
117
|
-
s: string;
|
|
118
|
-
}> {
|
|
119
|
-
return signMessage(this.transport, {
|
|
120
|
-
path,
|
|
121
|
-
messageHex,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
99
|
/**
|
|
126
100
|
* To sign a transaction involving standard (P2PKH) inputs, call createTransaction with the following parameters
|
|
127
101
|
* @param inputs is an array of [ transaction, output_index, optional redeem script, optional sequence ] where
|
|
@@ -154,43 +128,14 @@ export default class BtcOld {
|
|
|
154
128
|
outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
|
|
155
129
|
}).then(res => ...);
|
|
156
130
|
*/
|
|
157
|
-
|
|
131
|
+
createPaymentTransaction(arg: CreateTransactionArg): Promise<string> {
|
|
158
132
|
if (arguments.length > 1) {
|
|
159
|
-
|
|
160
|
-
"@ledgerhq/hw-app-btc:
|
|
133
|
+
throw new Error(
|
|
134
|
+
"@ledgerhq/hw-app-btc: createPaymentTransaction multi argument signature is deprecated. please switch to named parameters."
|
|
161
135
|
);
|
|
162
136
|
}
|
|
163
137
|
return createTransaction(this.transport, arg);
|
|
164
138
|
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* To obtain the signature of multisignature (P2SH) inputs, call signP2SHTransaction_async with the folowing parameters
|
|
168
|
-
* @param inputs is an array of [ transaction, output_index, redeem script, optional sequence ] where
|
|
169
|
-
* * transaction is the previously computed transaction object for this UTXO
|
|
170
|
-
* * output_index is the output in the transaction used as input for this UTXO (counting from 0)
|
|
171
|
-
* * redeem script is the mandatory redeem script associated to the current P2SH input
|
|
172
|
-
* * sequence is the sequence number to use for this input (when using RBF), or non present
|
|
173
|
-
* @param associatedKeysets is an array of BIP 32 paths pointing to the path to the private key used for each UTXO
|
|
174
|
-
* @param outputScriptHex is the hexadecimal serialized outputs of the transaction to sign
|
|
175
|
-
* @param lockTime is the optional lockTime of the transaction to sign, or default (0)
|
|
176
|
-
* @param sigHashType is the hash type of the transaction to sign, or default (all)
|
|
177
|
-
* @return the signed transaction ready to be broadcast
|
|
178
|
-
* @example
|
|
179
|
-
btc.signP2SHTransaction({
|
|
180
|
-
inputs: [ [tx, 1, "52210289b4a3ad52a919abd2bdd6920d8a6879b1e788c38aa76f0440a6f32a9f1996d02103a3393b1439d1693b063482c04bd40142db97bdf139eedd1b51ffb7070a37eac321030b9a409a1e476b0d5d17b804fcdb81cf30f9b99c6f3ae1178206e08bc500639853ae"] ],
|
|
181
|
-
associatedKeysets: ["0'/0/0"],
|
|
182
|
-
outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
|
|
183
|
-
}).then(result => ...);
|
|
184
|
-
*/
|
|
185
|
-
signP2SHTransaction(arg: SignP2SHTransactionArg): Promise<string[]> {
|
|
186
|
-
if (arguments.length > 1) {
|
|
187
|
-
console.warn(
|
|
188
|
-
"@ledgerhq/hw-app-btc: signP2SHTransaction multi argument signature is deprecated. please switch to named parameters."
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return signP2SHTransaction(this.transport, arg);
|
|
193
|
-
}
|
|
194
139
|
}
|
|
195
140
|
|
|
196
141
|
function makeFingerprint(compressedPubKey) {
|
package/tests/Btc.test.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import Transport from "@ledgerhq/hw-transport";
|
|
2
1
|
import {
|
|
3
2
|
openTransportReplayer,
|
|
4
3
|
RecordStore,
|
|
5
4
|
} from "@ledgerhq/hw-transport-mocker";
|
|
6
5
|
import Btc from "../src/Btc";
|
|
7
|
-
import BtcNew from "../src/BtcNew";
|
|
8
|
-
import BtcOld, { AddressFormat } from "../src/BtcOld";
|
|
9
|
-
import { AppAndVersion, getAppAndVersion } from "../src/getAppAndVersion";
|
|
10
|
-
import { TestingClient } from "./newops/integrationtools";
|
|
11
6
|
|
|
12
7
|
test("btc.getWalletXpub", async () => {
|
|
13
8
|
/*
|
|
@@ -18,7 +13,6 @@ pub: 0x0488b21e = 76067358
|
|
|
18
13
|
Testnet:
|
|
19
14
|
prv: 0x04358394 = 70615956
|
|
20
15
|
pub: 0x043587cf = 70617039
|
|
21
|
-
|
|
22
16
|
versionpriv=70615956
|
|
23
17
|
versionpub=70617039
|
|
24
18
|
seed=be388c569b4a6846c847e882e09f000000000000000000000000e255bcd17cb8
|
|
@@ -31,7 +25,6 @@ M_44h_0h_17h=`bx hd-to-public -v $versionpub $m_44h_0h_17h`
|
|
|
31
25
|
echo "M_44h_0h_17h xpub: $M_44h_0h_17h"
|
|
32
26
|
echo "M_44h_0h: `bx base58check-decode $M_44h_0h`"
|
|
33
27
|
echo "M_44h_0h_17h: `bx base58check-decode $M_44h_0h_17h`"
|
|
34
|
-
|
|
35
28
|
Output (note that version (4) should be prepended to payload):
|
|
36
29
|
M_44h_0h_17h xpub: tpubDDn3XrB65rhCzRh4fsD8gogX9gFvGcEmP3jZtGbdxK7Mn25gipFB68vLFyqZ43i4e5Z7p6rki7THyb2PeH1D3NkLm5EUFzbUzyafp872GKa
|
|
37
30
|
M_44h_0h: wrapper
|
|
@@ -48,7 +41,6 @@ M_44h_0h_17h: wrapper
|
|
|
48
41
|
aac5fdd59102250dfdfb84c1efd160ed0e10ebac845d0e4b04277174630ba56de96bbd3afb21
|
|
49
42
|
version 4
|
|
50
43
|
}
|
|
51
|
-
|
|
52
44
|
The xpub bytes (from bip32) are
|
|
53
45
|
4 byte: version bytes (mainnet: 0x0488B21E public, 0x0488ADE4 private; testnet: 0x043587CF public, 0x04358394 private)
|
|
54
46
|
1 byte: depth: 0x00 for master nodes, 0x01 for level-1 derived keys, ....
|
|
@@ -56,7 +48,6 @@ The xpub bytes (from bip32) are
|
|
|
56
48
|
4 bytes: child number. This is ser32(i) for i in xi = xpar/i, with xi the key being serialized. (0x00000000 if master key)
|
|
57
49
|
32 bytes: the chain code
|
|
58
50
|
33 bytes: the public key or private key data (serP(K) for public keys, 0x00 || ser256(k) for private keys)
|
|
59
|
-
|
|
60
51
|
M_44h_0h_17h:
|
|
61
52
|
043587cf
|
|
62
53
|
03
|
|
@@ -64,7 +55,6 @@ ee6e81fd
|
|
|
64
55
|
80000011
|
|
65
56
|
c071c6f2d05cbc9ea9a04951b238086ce1608cf00020c3cab85b36aac5fdd591
|
|
66
57
|
02250dfdfb84c1efd160ed0e10ebac845d0e4b04277174630ba56de96bbd3afb21
|
|
67
|
-
|
|
68
58
|
M_44h_0h:
|
|
69
59
|
043587cf
|
|
70
60
|
02
|
|
@@ -72,7 +62,6 @@ M_44h_0h:
|
|
|
72
62
|
80000000
|
|
73
63
|
8bd937d416de7020952cc8e2c99ce9ac7e01265e31ceb8e47bf9c37f46f8abbd
|
|
74
64
|
035d4a72237572a91e13818fa38cedabe6174569cc9a319012f75150d5c0a0639d
|
|
75
|
-
|
|
76
65
|
Uncompress (a bit covoluted, but works):
|
|
77
66
|
prv=`bx hd-to-ec -p $versionpriv $m_44h_0h_17h`
|
|
78
67
|
bx ec-to-public -u ${prv:2}
|
|
@@ -80,24 +69,20 @@ bx ec-to-public -u ${prv:2}
|
|
|
80
69
|
pubCompr=`bx ec-to-public ${prv:2}`
|
|
81
70
|
bx ec-to-address $pubCompr
|
|
82
71
|
16Y97ByhyboePhTYMMmFj1tq5Cy1bDq8jT
|
|
83
|
-
|
|
84
72
|
prv=`bx hd-to-ec -p $versionpriv $m_44h_0h`
|
|
85
73
|
bx ec-to-public -u ${prv:2}
|
|
86
74
|
045d4a72237572a91e13818fa38cedabe6174569cc9a319012f75150d5c0a0639d54eafd13a68d079b7a67764800c6a981825ef52384f08c3925109188ab21bc09
|
|
87
75
|
pubCompr=`bx ec-to-public ${prv:2}`
|
|
88
76
|
bx ec-to-address $pubCompr
|
|
89
77
|
1NjiCsVBuKDT62LmaUd7WZZZBK2gPAkisb
|
|
90
|
-
|
|
91
78
|
These translates to
|
|
92
79
|
pubkeylen(1) || pubkeyuncompressed(65) || addrLen(1) || address || chaincode(32)
|
|
93
|
-
|
|
94
80
|
Expected response for m/44'/0'/17':
|
|
95
81
|
41
|
|
96
82
|
04250dfdfb84c1efd160ed0e10ebac845d0e4b04277174630ba56de96bbd3afb21fc6c04ce0d5a0cbd784fdabc99d16269c27cf3842fe8440f1f21b8af900f0eaa
|
|
97
83
|
22
|
|
98
84
|
ascii(16Y97ByhyboePhTYMMmFj1tq5Cy1bDq8jT)
|
|
99
85
|
c071c6f2d05cbc9ea9a04951b238086ce1608cf00020c3cab85b36aac5fdd591
|
|
100
|
-
|
|
101
86
|
Expected response for m/44'/0':
|
|
102
87
|
41
|
|
103
88
|
045d4a72237572a91e13818fa38cedabe6174569cc9a319012f75150d5c0a0639d54eafd13a68d079b7a67764800c6a981825ef52384f08c3925109188ab21bc09
|
|
@@ -128,15 +113,14 @@ ascii(1NjiCsVBuKDT62LmaUd7WZZZBK2gPAkisb)
|
|
|
128
113
|
const responseAcc = `41${pubkeyAcc}22${addrAcc}${ccAcc}`;
|
|
129
114
|
const transport = await openTransportReplayer(
|
|
130
115
|
RecordStore.fromString(`
|
|
131
|
-
=> b001000000
|
|
132
|
-
<= 0107426974636f696e06312e332e323301029000
|
|
133
116
|
=> e040000009028000002c80000000
|
|
134
117
|
<= ${responseParent}9000
|
|
135
118
|
=> e04000000d038000002c8000000080000011
|
|
136
119
|
<= ${responseAcc}9000
|
|
137
120
|
`)
|
|
138
121
|
);
|
|
139
|
-
|
|
122
|
+
// This test covers the old bitcoin Nano app 1.6 API, before the breaking changes that occurred in v2.1.0 of the app
|
|
123
|
+
const btc = new Btc({ transport, currency: "oldbitcoin" });
|
|
140
124
|
const result = await btc.getWalletXpub({
|
|
141
125
|
path: "44'/0'/17'",
|
|
142
126
|
xpubVersion: 0x043587cf, // mainnet
|
|
@@ -149,13 +133,12 @@ ascii(1NjiCsVBuKDT62LmaUd7WZZZBK2gPAkisb)
|
|
|
149
133
|
test("btc.getWalletPublicKey", async () => {
|
|
150
134
|
const transport = await openTransportReplayer(
|
|
151
135
|
RecordStore.fromString(`
|
|
152
|
-
=> b001000000
|
|
153
|
-
<= 0107426974636f696e06312e332e323301029000
|
|
154
136
|
=> e040000011048000002c800000008000000000000000
|
|
155
137
|
<= 410486b865b52b753d0a84d09bc20063fab5d8453ec33c215d4019a5801c9c6438b917770b2782e29a9ecc6edb67cd1f0fbf05ec4c1236884b6d686d6be3b1588abb2231334b453654666641724c683466564d36756f517a7673597135767765744a63564dbce80dd580792cd18af542790e56aa813178dc28644bb5f03dbd44c85f2d2e7a9000
|
|
156
138
|
`)
|
|
157
139
|
);
|
|
158
|
-
|
|
140
|
+
// This test covers the old bitcoin Nano app 1.6 API, before the breaking changes that occurred in v2.1.0 of the app
|
|
141
|
+
const btc = new Btc({ transport, currency: "oldbitcoin" });
|
|
159
142
|
const result = await btc.getWalletPublicKey("44'/0'/0'/0");
|
|
160
143
|
expect(result).toEqual({
|
|
161
144
|
bitcoinAddress: "13KE6TffArLh4fVM6uoQzvsYq5vwetJcVM",
|
|
@@ -171,8 +154,6 @@ test("btc 2", async () => {
|
|
|
171
154
|
RecordStore.fromString(`
|
|
172
155
|
=> b001000000
|
|
173
156
|
<= 0107426974636f696e06312e332e323301029000
|
|
174
|
-
=> b001000000
|
|
175
|
-
<= 0107426974636f696e06312e332e323301029000
|
|
176
157
|
=> e042000009000000010100000001
|
|
177
158
|
<= 9000
|
|
178
159
|
=> e0428000254ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a
|
|
@@ -205,11 +186,12 @@ test("btc 2", async () => {
|
|
|
205
186
|
<= 3145022100ff492ad0b3a634aa7751761f7e063bf6ef4148cd44ef8930164580d5ba93a17802206fac94b32e296549e2e478ce806b58d61cfacbfed35ac4ceca26ac531f92b20a019000
|
|
206
187
|
`)
|
|
207
188
|
);
|
|
208
|
-
|
|
189
|
+
// This test covers the old bitcoin Nano app 1.6 API, before the breaking changes that occurred in v2.1.0 of the app
|
|
190
|
+
const btc = new Btc({ transport, currency: "oldbitcoin" });
|
|
209
191
|
const tx1 = btc.splitTransaction(
|
|
210
192
|
"01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000"
|
|
211
193
|
);
|
|
212
|
-
const result = await btc.
|
|
194
|
+
const result = await btc.createPaymentTransaction({
|
|
213
195
|
inputs: [[tx1, 1, undefined, undefined]],
|
|
214
196
|
associatedKeysets: ["0'/0/0"],
|
|
215
197
|
changePath: undefined,
|
|
@@ -259,7 +241,7 @@ test("btc 3", async () => {
|
|
|
259
241
|
<= 3045022100b5b1813992282b9a1fdd957b9751d79dc21018abc6586336e272212cc89cfe84022053765a1da0bdb5a0631a9866f1fd4c583589d5188b11cfa302fc20cd2611a71e019000
|
|
260
242
|
`)
|
|
261
243
|
);
|
|
262
|
-
const btc = new Btc(transport);
|
|
244
|
+
const btc = new Btc({ transport });
|
|
263
245
|
const tx1 = btc.splitTransaction(
|
|
264
246
|
"01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000"
|
|
265
247
|
);
|
|
@@ -290,8 +272,8 @@ test("btc 4", async () => {
|
|
|
290
272
|
<= 3045022100e32b32b8a6b4228155ba4d1a536d8fed9900606663fbbf4ea420ed8e944f9c18022053c97c74d2f6d8620d060584dc7886f5f3003684bb249508eb7066215172281a9000
|
|
291
273
|
`)
|
|
292
274
|
);
|
|
293
|
-
const btc = new Btc(transport);
|
|
294
|
-
const result = await btc.
|
|
275
|
+
const btc = new Btc({ transport });
|
|
276
|
+
const result = await btc.signMessage(
|
|
295
277
|
"44'/0'/0'/0",
|
|
296
278
|
Buffer.from("test").toString("hex")
|
|
297
279
|
);
|
|
@@ -306,8 +288,6 @@ test("btc seg multi", async () => {
|
|
|
306
288
|
const transport = await openTransportReplayer(
|
|
307
289
|
RecordStore.fromString(`
|
|
308
290
|
=> b001000000
|
|
309
|
-
<= 0107426974636f696e06312e332e323301029000
|
|
310
|
-
=> b001000000
|
|
311
291
|
<= 0107426974636f696e06312e332e323201029000
|
|
312
292
|
=> e040000015058000003180000001800000050000000000000000
|
|
313
293
|
<= 4104f004370a593b3cde1511801a1151c86dd09a2f246a3f9ac3ef0b0240c0aeb506feddb0a785f5039c3e3e829db9692364e333256284d0fe312177cb12b88551162131764a4336523431416334685a61704a7863334c5a6e69334e7169445837514562141c248b44b74cbe35a3a92801cfebaf895df8d65f5830264097260c863fc1e59000
|
|
@@ -343,7 +323,8 @@ test("btc seg multi", async () => {
|
|
|
343
323
|
<= 3145022100c820c90ce84c6567617733cd6409c4b8f7469b863d811a3cdc73bf3fa43912bc0220320b7fd259939a6821d371f2b49a755d1ca588bffb1476fbb2da68907427b54b019000
|
|
344
324
|
`)
|
|
345
325
|
);
|
|
346
|
-
|
|
326
|
+
// This test covers the old bitcoin Nano app 1.6 API, before the breaking changes that occurred in v2.1.0 of the app
|
|
327
|
+
const btc = new Btc({ transport, currency: "oldbitcoin" });
|
|
347
328
|
const tx1 = btc.splitTransaction(
|
|
348
329
|
"0100000000010130992c1559a43de1457f23380fefada09124d22594bbeb46ab6e9356e8407d39010000001716001417507f91a6594df7367a0561e4d3df376a829e1fffffffff02c03b47030000000017a9142397c9bb7a3b8a08368a72b3e58c7bb850555792875f810acf0900000017a914813a2e6c7538f0d0afbdeb5db38608804f5d76ab8702483045022100e09ca8a5357623438daee5b7804e73c9209de7c645efd405f13f83420157c48402207d3e4a30f362e062e361967c7afdd45e7f21878a067b661a6635669e620f99910121035606550fd51f6b063b69dc92bd182934a34463f773222743f300d3c7fd3ae47300000000",
|
|
349
330
|
true
|
|
@@ -352,7 +333,7 @@ test("btc seg multi", async () => {
|
|
|
352
333
|
"0100000000010176ef6abce7feecefbe1322da6cd21245f2d475a1836f13e99f56847bf7127f7c0100000017160014a4e29e297768fccd19cabc21cced93a6afc803eeffffffff0280778e060000000017a9142397c9bb7a3b8a08368a72b3e58c7bb8505557928795061b51b100000017a914c5cfa33e119f60c7cb40bd6b9cfe9e78b026eb6a8702473044022031f0c72683374275328ef0341ed1f233c55a37e21335f9c111c25645b50d0d4e0220670b833be0f688c237bf4466d2b94c99631ada3557c95a7d13bfbb9177125c340121020879f8616da54f8ac5476b97fbe0329c5a0e4cbd32e22e7348262bdfad99a44200000000",
|
|
353
334
|
true
|
|
354
335
|
);
|
|
355
|
-
const result = await btc.
|
|
336
|
+
const result = await btc.createPaymentTransaction({
|
|
356
337
|
inputs: [
|
|
357
338
|
[tx1, 0, undefined, undefined],
|
|
358
339
|
[tx2, 0, undefined, undefined],
|
|
@@ -392,7 +373,7 @@ test("btc sign p2sh seg", async () => {
|
|
|
392
373
|
<= 3045022100932934ee326c19c81b72fb03cec0fb79ff980a8076639f77c7edec35bd59da1e02205e4030e8e0fd2405f6db2fe044c49d3f191adbdc0e05ec7ed4dcc4c6fe7310e5019000
|
|
393
374
|
`)
|
|
394
375
|
);
|
|
395
|
-
const btc = new Btc(transport);
|
|
376
|
+
const btc = new Btc({ transport });
|
|
396
377
|
const tx1 = btc.splitTransaction(
|
|
397
378
|
"0100000001d3a05cd6e15582f40e68bb8b1559dc9e5b3e4f9f34d92c1217dc8c3355bc844e010000008a47304402207ab1a4768cbb036d4bce3c4a294c13cc5ae6076fc7bedce88c62aa80ae366da702204f8fea6923f8df36315c0c26cb42d8d7ab52ca4736776816e10d6ce51906d0600141044289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34cec320a0565fb7caf11b1ca2f445f9b7b012dda5718b3cface369ee3a034ded6ffffffff02102700000000000017a9141188cc3c265fbc01a025fc8adec9823effd0cef187185f9265170100001976a9140ae1441568d0d293764a347b191025c51556cecd88ac00000000",
|
|
398
379
|
true
|
|
@@ -425,8 +406,8 @@ test("signMessage", async () => {
|
|
|
425
406
|
<= 314402205eac720be544d3959a760d9bfd6a0e7c86d128fd1030038f06d85822608804e20220385d83273c9d03c469596292fb354b07d193034f83c2633a4c1f057838e12a5b9000
|
|
426
407
|
`)
|
|
427
408
|
);
|
|
428
|
-
const btc = new Btc(transport);
|
|
429
|
-
const res = await btc.
|
|
409
|
+
const btc = new Btc({ transport });
|
|
410
|
+
const res = await btc.signMessage(
|
|
430
411
|
"44'/0'/0'/0/0",
|
|
431
412
|
Buffer.from("foobar").toString("hex")
|
|
432
413
|
);
|
|
@@ -436,100 +417,3 @@ test("signMessage", async () => {
|
|
|
436
417
|
s: "385d83273c9d03c469596292fb354b07d193034f83c2633a4c1f057838e12a5b",
|
|
437
418
|
});
|
|
438
419
|
});
|
|
439
|
-
|
|
440
|
-
function testBackend(s: string): any {
|
|
441
|
-
return async () => {
|
|
442
|
-
return { publicKey: s, bitcoinAddress: "", chainCode: "" };
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
class TestBtc extends Btc {
|
|
447
|
-
n: BtcNew;
|
|
448
|
-
o: BtcOld;
|
|
449
|
-
constructor(public tr: Transport) {
|
|
450
|
-
super(tr);
|
|
451
|
-
this.n = new BtcNew(new TestingClient(tr));
|
|
452
|
-
this.n.getWalletPublicKey = testBackend("new");
|
|
453
|
-
this.o = new BtcOld(tr);
|
|
454
|
-
this.o.getWalletPublicKey = testBackend("old");
|
|
455
|
-
}
|
|
456
|
-
protected new(): BtcNew {
|
|
457
|
-
return this.n;
|
|
458
|
-
}
|
|
459
|
-
protected old(): BtcOld {
|
|
460
|
-
return this.o;
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
// test.each`
|
|
465
|
-
// a | b | expected
|
|
466
|
-
// ${1} | ${1} | ${2}
|
|
467
|
-
// ${1} | ${2} | ${3}
|
|
468
|
-
// ${2} | ${1} | ${3}
|
|
469
|
-
// `('returns $expected when $a is added $c', ({ a, c, expected }) => {
|
|
470
|
-
// expect(a + c).toBe(expected);
|
|
471
|
-
// });
|
|
472
|
-
|
|
473
|
-
test.each`
|
|
474
|
-
app | ver | path | format | display | exp
|
|
475
|
-
${"Bitcoin"} | ${"1.99.99"} | ${"m/44'/0'/1'"} | ${"bech32m"} | ${false} | ${""}
|
|
476
|
-
${"Bitcoin"} | ${"1.99.99"} | ${"m/44'/0'"} | ${"bech32m"} | ${false} | ${""}
|
|
477
|
-
${"Bitcoin"} | ${"2.0.0-alpha1"} | ${"m/44'/0'/1'"} | ${"bech32m"} | ${false} | ${"new"}
|
|
478
|
-
${"Bitcoin"} | ${"2.0.0-alpha1"} | ${"m/44'/0'"} | ${"bech32m"} | ${false} | ${"new"}
|
|
479
|
-
${"Bitcoin"} | ${"2.0.0-beta"} | ${"m/84'/1'/0'"} | ${"bech32"} | ${false} | ${"new"}
|
|
480
|
-
${"Bitcoin"} | ${"2.0.0-alpha1"} | ${"m/44'/0'/1'"} | ${"bech32"} | ${false} | ${"new"}
|
|
481
|
-
${"Bitcoin"} | ${"2.0.0-alpha1"} | ${"m/44'/0'"} | ${"bech32"} | ${undefined} | ${"old"}
|
|
482
|
-
${"Bitcoin"} | ${"2.0.0-alpha1"} | ${"m/44'/0'"} | ${"bech32"} | ${true} | ${"new"}
|
|
483
|
-
${"Bitcoin"} | ${"2.0.0-alpha1"} | ${"m/44'/0'/1'/0/0"} | ${"bech32"} | ${false} | ${"new"}
|
|
484
|
-
${"Bitcoin"} | ${"2.0.0-alpha1"} | ${"m/44'/0'/1'/1/0"} | ${"bech32"} | ${false} | ${"new"}
|
|
485
|
-
${"Bitcoin"} | ${"2.0.0-alpha1"} | ${"m/44'/0'/1'/1/0"} | ${"legacy"} | ${false} | ${"new"}
|
|
486
|
-
${"Bitcoin"} | ${"2.0.0-alpha1"} | ${"m/44'/0'/1'/1/0"} | ${"p2sh"} | ${false} | ${"new"}
|
|
487
|
-
${"Bitcoin"} | ${"2.0.0-alpha1"} | ${"m/44'/0'/1'/2/0"} | ${"bech32"} | ${false} | ${"old"}
|
|
488
|
-
`(
|
|
489
|
-
"dispatch $app $ver $path $format $display to $exp",
|
|
490
|
-
async ({ app, ver, path, format, display, exp }) => {
|
|
491
|
-
const appName = Buffer.from([app.length])
|
|
492
|
-
.toString("hex")
|
|
493
|
-
.concat(Buffer.from(app, "ascii").toString("hex"));
|
|
494
|
-
const appVersion = Buffer.from([ver.length])
|
|
495
|
-
.toString("hex")
|
|
496
|
-
.concat(Buffer.from(ver, "ascii").toString("hex"));
|
|
497
|
-
const resp = `01${appName}${appVersion}01029000`;
|
|
498
|
-
const tr = await openTransportReplayer(
|
|
499
|
-
RecordStore.fromString(`=> b001000000\n <= ${resp}`)
|
|
500
|
-
);
|
|
501
|
-
const btc = new TestBtc(tr);
|
|
502
|
-
try {
|
|
503
|
-
const key = await btc.getWalletPublicKey(path, {
|
|
504
|
-
format: format,
|
|
505
|
-
verify: display,
|
|
506
|
-
});
|
|
507
|
-
if (exp === "") {
|
|
508
|
-
expect(1).toEqual(0); // Allways fail. Don't know how to do that properly
|
|
509
|
-
}
|
|
510
|
-
expect(key.publicKey).toEqual(exp);
|
|
511
|
-
} catch (e: any) {
|
|
512
|
-
if (exp != "") {
|
|
513
|
-
throw e;
|
|
514
|
-
}
|
|
515
|
-
expect(exp).toEqual("");
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
);
|
|
519
|
-
|
|
520
|
-
// test("getWalletPublicKey compatibility for internal hardened keys", async () => {
|
|
521
|
-
// await testDispatch("Bitcoin", "1.99.99", "m/44'/0'/1'", "bech32m", "");
|
|
522
|
-
// await testDispatch("Bitcoin", "1.99.99", "m/44'/0'", "bech32m", "");
|
|
523
|
-
// await testDispatch("Bitcoin", "2.0.0-alpha1", "m/44'/0'/1'", "bech32m", "new");
|
|
524
|
-
// await testDispatch("Bitcoin", "2.0.0-alpha1", "m/44'/0'", "bech32m", "new");
|
|
525
|
-
// await testDispatch("Bitcoin", "2.0.0-alpha1", "m/44'/0'/1'", "bech32", "new");
|
|
526
|
-
// await testDispatch("Bitcoin", "2.0.0-alpha1", "m/44'/0'", "bech32", "old");
|
|
527
|
-
// });
|
|
528
|
-
|
|
529
|
-
async function testDispatch(
|
|
530
|
-
name: string,
|
|
531
|
-
version: string,
|
|
532
|
-
path: string,
|
|
533
|
-
addressFormat: AddressFormat | undefined,
|
|
534
|
-
exp: string
|
|
535
|
-
): Promise<void> {}
|
|
@@ -16,23 +16,18 @@ import { CoreInput, CoreTx, p2pkh, p2tr, p2wpkh, wrappedP2wpkh, wrappedP2wpkhTwo
|
|
|
16
16
|
test("getWalletPublicKey p2pkh", async () => {
|
|
17
17
|
await testGetWalletPublicKey("m/44'/1'/0'", "pkh(@0)");
|
|
18
18
|
await testGetWalletPublicKey("m/44'/0'/17'", "pkh(@0)");
|
|
19
|
-
await testGetWalletPublicKey("m/46'/0'/17'", "pkh(@0)");
|
|
20
|
-
await testGetWalletPublicKey("m/109'/0'/17'", "pkh(@0)");
|
|
21
19
|
});
|
|
22
20
|
test("getWalletPublicKey p2wpkh", async () => {
|
|
23
21
|
await testGetWalletPublicKey("m/84'/1'/0'", "wpkh(@0)");
|
|
24
22
|
await testGetWalletPublicKey("m/84'/0'/17'", "wpkh(@0)");
|
|
25
|
-
await testGetWalletPublicKey("m/2'/0'/17'", "wpkh(@0)");
|
|
26
23
|
});
|
|
27
24
|
test("getWalletPublicKey wrapped p2wpkh", async () => {
|
|
28
25
|
await testGetWalletPublicKey("m/49'/1'/0'", "sh(wpkh(@0))");
|
|
29
26
|
await testGetWalletPublicKey("m/49'/0'/17'", "sh(wpkh(@0))");
|
|
30
|
-
await testGetWalletPublicKey("m/9'/0'/17'", "sh(wpkh(@0))");
|
|
31
27
|
});
|
|
32
28
|
test("getWalletPublicKey p2tr", async () => {
|
|
33
29
|
await testGetWalletPublicKey("m/86'/1'/0'", "tr(@0)");
|
|
34
30
|
await testGetWalletPublicKey("m/86'/0'/17'", "tr(@0)");
|
|
35
|
-
await testGetWalletPublicKey("m/17'", "tr(@0)");
|
|
36
31
|
});
|
|
37
32
|
|
|
38
33
|
test("getWalletXpub normal path", async () => {
|
|
@@ -22,7 +22,7 @@ export async function runSignTransaction(
|
|
|
22
22
|
): Promise<string> {
|
|
23
23
|
const btcNew = new BtcNew(client);
|
|
24
24
|
// btc is needed to perform some functions like splitTransaction.
|
|
25
|
-
const btc = new Btc(transport);
|
|
25
|
+
const btc = new Btc({ transport });
|
|
26
26
|
const accountType = getAccountType(testTx.vin[0], btc);
|
|
27
27
|
const additionals: string[] = [];
|
|
28
28
|
if (accountType == StandardPurpose.p2wpkh) {
|
|
@@ -82,9 +82,9 @@ export async function runSignTransaction(
|
|
|
82
82
|
logCallback("CALLBACK: signature requested"),
|
|
83
83
|
onDeviceStreaming: (arg) => logCallback("CALLBACK: " + JSON.stringify(arg)),
|
|
84
84
|
};
|
|
85
|
-
logCallback("Start
|
|
86
|
-
const tx = await btcNew.
|
|
87
|
-
logCallback("Done
|
|
85
|
+
logCallback("Start createPaymentTransaction");
|
|
86
|
+
const tx = await btcNew.createPaymentTransaction(arg);
|
|
87
|
+
logCallback("Done createPaymentTransaction");
|
|
88
88
|
// console.log(callbacks);
|
|
89
89
|
return tx;
|
|
90
90
|
}
|
package/tests/parseTx.test.ts
CHANGED
|
@@ -35,7 +35,7 @@ test("transaction on btc – nano s 1.3.1 – native segwit", async () => {
|
|
|
35
35
|
<= 3045022100e4acf0eb3803a62399f53825d86aa30743fe999eefb01522d5f7ecd9eeec663d022063b90c512e207c2ac47d8759e1c73c6abeff58daec31c48905193470bc87f2d3019000
|
|
36
36
|
`)
|
|
37
37
|
);
|
|
38
|
-
const btc = new Btc(transport);
|
|
38
|
+
const btc = new Btc({ transport, currency: "zcash" });
|
|
39
39
|
const tx1 = btc.splitTransaction(
|
|
40
40
|
"fdffffff00289840f900000000003f76a91491842e1e3773b404b7acbde07bf6a8782f86320288ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4dd109c00000000003f76a914a16d376a7036816aea0dbac7d0a288b38690bc2288ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b40a2aa100000000003f76a914126e122dcc80505b9b4f00fd47606a5c2168f87488ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4aa6da901000000003f76a914ac3b0b75d17de9b66f6ce0b04c7b6df68d8c627f88ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4911a6110000000003f76a91412d85a4a2a000b5f0af5eb5c233c045bcb32237088ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b49640f900000000003f76a914f1555affa9e47423a5f07c55a22b6da90ea79c2c88ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4cb3ea800000000003f76a91438a904ca713c285a20959108c6087c9b97fc06bb88ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4c11ca700000000003f76a91476cd5b686b6c2e3535d488c376ffc4fa7e74490a88ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b46bedab00000000003f76a91431ec601f10fda75caf164edf18aa7a97b531b78c88ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b487ee9a00000000003f76a9144903ff43d006695400f033e399025daf8947d1c588ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b40b9caf00000000003f76a91443aa6dad34cff8f3e4db84f94b9c65e6fba79c8188ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4efc39d00000000003f76a91460b4b104b7e9bbc701abd3917949456c68f8522488ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4637b9d00000000003f76a91458c7adfd4b8f301dc9d65f3ff6a49d863cddec4b88ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4f21cd800000000003f76a9144e05aafd31d66a762bf7d937f613256a48d7574688ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b40d2aa100000000003f76a914defe35ddd78bc8918c1a54e540861c9c05b3e38788ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b46496f300000000003f76a91485bf80ae408b88bff15f7b708c421b9dd32fc47688ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b43fd4a600000000003f76a914558fd5741c64f869592cab94ae86a1bc63c1888988ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4b65c7605000000003f76a91449d8ced84fa86a98e552d9a2a118c0c7ac57d58688ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4752e9f00000000003f76a914525d5f215ccf943d028c862881dfba681db58f9d88ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4102db000000000003f76a91436902a202fd435b2fe115887d3c33882fa15bf1288ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b49175b000000000003f76a9149a7ca1397dac859774bd10759a80f2e36c84e74388ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b448f6a700000000003f76a914bbfd902d072ad91c6b32a7e2bff6fd340dffaa8688ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b465ceb900000000003f76a914696a361dbc20a39810133e33575a4fc7d3e8bdb688ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4a681ec00000000003f76a914e0b80dd3e6a7224ecf9e9acdcea4b6694d5255f588ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b413c03201000000003f76a914784fdee5cfc5c53c47df55f023f1ccc9dd612b1588ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b465080201000000003f76a9142dd6dc1e4f219dca7f69d973a2230779e6a582c888ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b49b25a300000000003f76a914fbe62338b092fd2c0973c27dd3d0482b89a6412388ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b456379b00000000003f76a9144d0c38f0a68f2240126f34a366251c9a8a931d1c88ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4e6b04f02000000003f76a9147df5a291502a857a7085263f92a66b5aa198302388ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b456379b00000000003f76a914f0e9b6e8973a5670e9be75c036455b45e6f3eeb288ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b41a4fb100000000003f76a914b34da261b708d61d354833f4e7f2b655af29e05588ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b49403a200000000003f76a9141b61c76511eda352b2d93638065ed61dffc1fa5788ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4ca3ea800000000003f76a914a3b72f15846e1377c54de250b96baf6f11858fc488ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b46bdbea01000000003f76a9148a74fe473eed123214029bc79270423e59b8708588ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b45a02e400000000003f76a9143bc0b5d39ceb0b9906e6b1a2c19236b0f245f04188ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b47e87d900000000003f76a9148369c5504ec06cb99a6ef34a64c32b3bbce323b888ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b41bdda200000000003f76a9146465e2df3a5f313bdb2e8f213e67362aafafa66688ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4a33b9900000000003f76a914da189d3e1fee6ec5f7e71b8dd0f0cb2cc63e706b88ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b411bba100000000003f76a91463dcb85ae2572d68177ea0664214a9b96c8a4a8388ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b49bbaa701000000003f76a914e254982595b3a9f27cef5e2dfffc190f682c29b688ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b400000000010000000000000000c6361b360000000009f8b468a5f89f6a651e5e0f4722634dfafeb9c06b5813991f1aeb593c691d8df11684326768947b1bca6276e3a81447fd1967a0361cba8421b95404b2ce6d5727139522e837d20bd94cc1c4d3179e35e2f662cbd8bbcb5e55ac5721a819a193c980c353cd4aa3ca6b73b2c970bfc662221cece4121ace898b92583dfdba8db5aa7942adc7e0c6669450a5f69c0a81ae92fd7f650dd25025c82107ce1611bcf3cabd2ee4bf6fcd2a4d510654383de08b434cfc58c2d6558c92a1d3a5ed64271f1d037a2fc07ae745e6cca7eb0803089b56d1edbd8b4913fd12d4e3cac095c70ca78a325f2f9a2fa409c43bdb02364bc53d2d1e351435a4c8af578cc3891ee8434f7f1a653e469b9213fecdb37548f78395f759578e2c735009090c21eef86398a2301bbfc7c87a3508eb0865119468a5f751eafa087260edaa7f0f7c2ba3e4bdc11bcb96e877b696798159606ac92768b860e15363edd98927f1466c6108c55fdfe123a88d42efa39288e8f8878da947813fa450d45c02458b33fc21a57141d109e145adaffce8c69da92b29bc3d9cee7a0fe44d26870323c37c74ae7a4711dd46fc23ffbdeff5df650c5076adb0103994f82ed876c3dcbc95499a5cdd89a8a3699196331f55db547d5d5311fae5c7b73a8396f6e68443aa4a623543fb1f8863ed9bb0def0f307be1c0f2114a3c95e452cc8627d0e8f7c9d0d75df49e92e5e2bccce8d76e96885163facc66728fddff2556e6547207c1ae8fd098d81486e7ad18f8b4b4cadb9cb801f14168bc9d63fb10c614b8011d59efe29bf316bbc2a7f96b06a583d658c82855a8d0bf7e40dc137c334c44fbfaedf3352c1a78b989e116e86ba0fc53e7ac8c215761c5bb36ae447d3a2f4357828a7882811ea61588f0afb1390b2c2148a6508430ba86e90457c42f531ea73d6f056756547d09d63282bab6b1d71cd055d60406e284a9e46a14625da76d1264161f9f561e7588a31ba86c9259309e816fa71c01c159cc84b28d59b7c446355c87fd9c7d0c983ebfa2849387a263f3a6a073e3d649c7829dab262aae5e5320e49609be50d4462acbcb3f7e6723bbcdb309c0f8fe76ea72f044678be352264677c4ad33796cbc52947fe8f1231e7a10f17f32cb9c91e0389a64da2c5a0dfbf04f9bbcb3d14b0c2c54f68547f63bc9bad03b4c2e32ea0fa70f6830dce279be920e90ebdaae44a0aeb8909640a1cd77970f47ccb6ae5aba42342a86d46b9177c4e461703eee28e9bad6720ab1a8033c454042f7d94441af413fd8a43a7651ea2c728d5666087bb28a1f74a071e345639f9947085bab77bab8272ac8228f8cacc397de4e1fb82e69dccb1a87cf28fbbd1febf3750053ab46a213a16cb4a178b621a0348ac522ddcc1ee876d8973c818617ed87db4f62ee68b3ff07f647d3ca5b368d428582126a5c94cff4d18261c8afd00917f738a8d5f87de8eff909ae038607402a947e156c048c0c8f0b2c23dbccd03aa49655fb458bb053b8751cc3abd1733a2df65a3220db75a73f68d5226ba133e58347e125abdde6111ec67a8add5a58dfd86d81218d9fbb33fb76811ab4bff7f98c4ab83bb14d9a93e4f66d976540797474ab0804228cbc0d2b06f4c252373d16d9b3e7b2aa2626f6caf04ed44cde1ca909e9e1133e724f043fcc793102d4952f4b66a900be292e19b8f24f4c17ac6a216f6d896a1e8610472a4b981b88517ca75653e49a0ebb1bf86e8f48f3e7872d33d312fe7333b12c76c3534440319daae7c4bff3ed8382a5c150f57d29a22269e931cfa03d3102135d0b64f38c4c6aabd89e85f310291e173854a0d5a8ec421aaaf0613870cdfa709bd6073a0f1616f32101b7838218e55a159873ba038647cd6172da138750b3c43b7eed2d32d1c02580fae152a407beb284404bd723c9f169b30d416f4898abb4e7a3e4b55f8b1ecae889a0c10ea1ab493f1d7ed15fd5eec475423be700d90b3bdc96ff8bbe3a51b6f1d97f3a5a11804baf2140afab032712712ea4e03000bb1fca1728a4e4ba3db64c614c2f0a432c9d2b23cd28ec4afa273412578c1248a945098380b48bdd8d4da265ae7834672d18428663da204f9d59fcb6cc57c3fb05131624a6f9bf022ea40269a38eff2085995fd43cb36d5105a8b13458aa131ff32978b7c474258e40659db516d01f79f3730a34c53a6acb5739d3da78f82eb8d45cc0beb1c77e104e7f4b3e255df37e6a522e79c3d377438a8025a29fc753a6900f3f5e65e50ed178a2abed7d5fe73cd1ef327f9bafc6872ab8e8b9aca4ad80d152062eb2cd3371d09a5c90ff20bb3c6b53ed68a2b9822891740c3b9bc92c2dbf4467ded45e325035bbde84cd50a99d9729a221ea9c0577ee818c05231a27637508221b9d711f883cef7743ac5cbb1cf0d36cda39b59625d784c38edb62ad663eece335178c4a8e79ddbe5dfea48f978d4990d1773648d7ddf4c938b31eebea90758ff5a251b0402c0d1b4c299508d459fabfe0ee7626e01",
|
|
41
41
|
true,
|
|
@@ -8,8 +8,6 @@ test("transaction on btc – nano s 1.3.1 – native segwit", async () => {
|
|
|
8
8
|
const transport = await openTransportReplayer(
|
|
9
9
|
RecordStore.fromString(`
|
|
10
10
|
=> b001000000
|
|
11
|
-
<= 0107426974636f696e06312e332e323301029000
|
|
12
|
-
=> b001000000
|
|
13
11
|
<= 6d00
|
|
14
12
|
=> e04000001505800000548000000080000000000000010000001b
|
|
15
13
|
<= 41042e00ef5ab04c270bf697e817c5fd433aa4509b063745d6f82c2157a59d59c1b7146956cee1b5ce1c7739a87fb59de3ad918872b14301af3f00b538934837b1382231354a707a787578426b6358384576465a6e6d4d736a74664771314d676e6d465356b9b92151a60d39e94e5be7a91003d0f43f03cafd69db00ebc60a65434d83e66d9000
|
|
@@ -35,12 +33,13 @@ test("transaction on btc – nano s 1.3.1 – native segwit", async () => {
|
|
|
35
33
|
<= 3045022100e4acf0eb3803a62399f53825d86aa30743fe999eefb01522d5f7ecd9eeec663d022063b90c512e207c2ac47d8759e1c73c6abeff58daec31c48905193470bc87f2d3019000
|
|
36
34
|
`)
|
|
37
35
|
);
|
|
38
|
-
|
|
36
|
+
// This test covers the old bitcoin Nano app 1.6 API, before the breaking changes that occurred in v2.1.0 of the app
|
|
37
|
+
const btc = new Btc({ transport, currency: "oldbitcoin" });
|
|
39
38
|
const tx1 = btc.splitTransaction(
|
|
40
39
|
"01000000000102b91a5eb409e1243dcc02440ad5709d57047946309a515902ffdba8b98ad9e9970000000000ffffff00b91a5eb409e1243dcc02440ad5709d57047946309a515902ffdba8b98ad9e9970100000000ffffff000250c300000000000016001449df9e8ba7e25dd4830579cb42fbea938497168bef8b0100000000001600142f3fa4710983519e4ae45dd80e72e70b79f25c5e0248304502210080ed332c269ae7d86fac26a143afcec0a634e1098fd1ee5ca43cbe0c66de861802204c804eceb4cc9ca397156fa683f46274d22bb5d95f8c8293dc595934899f7927012103cc39edf09d462b4de30cc9bf96b163f18dcee742e0a1ea6fad0274ae0b9d60330247304402203e277d48d19a01c33b45b8f102479eb10811d20991bbf060cab4ba79f0972e61022041e13ed7da2b266d20c36b01694f2d16cf144c1ff66863f26d7c332dc220bc1301210369f216ec068fb7ef17a46ad3ad4d7f0e04e8a3a16ae2da852d6e4b57c3bb972f00000000",
|
|
41
40
|
true
|
|
42
41
|
);
|
|
43
|
-
const result = await btc.
|
|
42
|
+
const result = await btc.createPaymentTransaction({
|
|
44
43
|
inputs: [[tx1, 1, undefined, 0xffffffff]],
|
|
45
44
|
associatedKeysets: ["84'/0'/0'/1/27"],
|
|
46
45
|
changePath: "84'/0'/0'/1/28",
|
|
@@ -59,8 +58,6 @@ test("transaction on btc – nano s 1.6.0 – native segwit", async () => {
|
|
|
59
58
|
const transport = await openTransportReplayer(
|
|
60
59
|
RecordStore.fromString(`
|
|
61
60
|
=> b001000000
|
|
62
|
-
<= 0107426974636f696e06312e332e323301029000
|
|
63
|
-
=> b001000000
|
|
64
61
|
<= 0107426974636f696e05312e342e3201029000
|
|
65
62
|
=> e042000009000000010100000002
|
|
66
63
|
<= 9000
|
|
@@ -104,12 +101,13 @@ test("transaction on btc – nano s 1.6.0 – native segwit", async () => {
|
|
|
104
101
|
<= 3045022100e4acf0eb3803a62399f53825d86aa30743fe999eefb01522d5f7ecd9eeec663d022063b90c512e207c2ac47d8759e1c73c6abeff58daec31c48905193470bc87f2d3019000
|
|
105
102
|
`)
|
|
106
103
|
);
|
|
107
|
-
|
|
104
|
+
// This test covers the old bitcoin Nano app 1.6 API, before the breaking changes that occurred in v2.1.0 of the app
|
|
105
|
+
const btc = new Btc({ transport, currency: "oldbitcoin" });
|
|
108
106
|
const tx1 = btc.splitTransaction(
|
|
109
107
|
"01000000000102b91a5eb409e1243dcc02440ad5709d57047946309a515902ffdba8b98ad9e9970000000000ffffff00b91a5eb409e1243dcc02440ad5709d57047946309a515902ffdba8b98ad9e9970100000000ffffff000250c300000000000016001449df9e8ba7e25dd4830579cb42fbea938497168bef8b0100000000001600142f3fa4710983519e4ae45dd80e72e70b79f25c5e0248304502210080ed332c269ae7d86fac26a143afcec0a634e1098fd1ee5ca43cbe0c66de861802204c804eceb4cc9ca397156fa683f46274d22bb5d95f8c8293dc595934899f7927012103cc39edf09d462b4de30cc9bf96b163f18dcee742e0a1ea6fad0274ae0b9d60330247304402203e277d48d19a01c33b45b8f102479eb10811d20991bbf060cab4ba79f0972e61022041e13ed7da2b266d20c36b01694f2d16cf144c1ff66863f26d7c332dc220bc1301210369f216ec068fb7ef17a46ad3ad4d7f0e04e8a3a16ae2da852d6e4b57c3bb972f00000000",
|
|
110
108
|
true
|
|
111
109
|
);
|
|
112
|
-
const result = await btc.
|
|
110
|
+
const result = await btc.createPaymentTransaction({
|
|
113
111
|
inputs: [[tx1, 1, undefined, 0xffffffff]],
|
|
114
112
|
associatedKeysets: ["84'/0'/0'/1/27"],
|
|
115
113
|
changePath: "84'/0'/0'/1/28",
|