@ledgerhq/hw-app-btc 9.0.0-nightly.4 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +5 -21
- package/README.md +111 -33
- package/lib/Btc.d.ts +13 -11
- package/lib/Btc.d.ts.map +1 -1
- package/lib/Btc.js +191 -31
- package/lib/Btc.js.map +1 -1
- package/lib/BtcNew.d.ts +4 -2
- package/lib/BtcNew.d.ts.map +1 -1
- package/lib/BtcNew.js +13 -54
- package/lib/BtcNew.js.map +1 -1
- package/lib/BtcOld.d.ts +37 -2
- package/lib/BtcOld.d.ts.map +1 -1
- package/lib/BtcOld.js +45 -3
- package/lib/BtcOld.js.map +1 -1
- package/lib-es/Btc.d.ts +13 -11
- package/lib-es/Btc.d.ts.map +1 -1
- package/lib-es/Btc.js +168 -31
- package/lib-es/Btc.js.map +1 -1
- package/lib-es/BtcNew.d.ts +4 -2
- package/lib-es/BtcNew.d.ts.map +1 -1
- package/lib-es/BtcNew.js +8 -54
- package/lib-es/BtcNew.js.map +1 -1
- package/lib-es/BtcOld.d.ts +37 -2
- package/lib-es/BtcOld.d.ts.map +1 -1
- package/lib-es/BtcOld.js +45 -3
- package/lib-es/BtcOld.js.map +1 -1
- package/package.json +4 -4
- package/src/Btc.ts +151 -41
- package/src/BtcNew.ts +15 -60
- package/src/BtcOld.ts +59 -4
- package/tests/Btc.test.ts +132 -16
- package/tests/newops/BtcNew.test.ts +5 -0
- package/tests/newops/integrationtools.ts +4 -4
- package/tests/parseTx.test.ts +1 -1
- package/tests/trustedInputs.test.ts +8 -6
package/src/BtcOld.ts
CHANGED
|
@@ -6,6 +6,9 @@ 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";
|
|
9
12
|
import { pathArrayToString, pathStringToArray } from "./bip32";
|
|
10
13
|
export type { AddressFormat };
|
|
11
14
|
|
|
@@ -14,7 +17,7 @@ export type { AddressFormat };
|
|
|
14
17
|
*
|
|
15
18
|
* @example
|
|
16
19
|
* import Btc from "@ledgerhq/hw-app-btc";
|
|
17
|
-
* const btc = new Btc(
|
|
20
|
+
* const btc = new Btc(transport)
|
|
18
21
|
*/
|
|
19
22
|
|
|
20
23
|
export default class BtcOld {
|
|
@@ -96,6 +99,29 @@ export default class BtcOld {
|
|
|
96
99
|
return getWalletPublicKey(this.transport, { ...opts, path });
|
|
97
100
|
}
|
|
98
101
|
|
|
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
|
+
|
|
99
125
|
/**
|
|
100
126
|
* To sign a transaction involving standard (P2PKH) inputs, call createTransaction with the following parameters
|
|
101
127
|
* @param inputs is an array of [ transaction, output_index, optional redeem script, optional sequence ] where
|
|
@@ -128,14 +154,43 @@ export default class BtcOld {
|
|
|
128
154
|
outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
|
|
129
155
|
}).then(res => ...);
|
|
130
156
|
*/
|
|
131
|
-
|
|
157
|
+
createPaymentTransactionNew(arg: CreateTransactionArg): Promise<string> {
|
|
132
158
|
if (arguments.length > 1) {
|
|
133
|
-
|
|
134
|
-
"@ledgerhq/hw-app-btc:
|
|
159
|
+
console.warn(
|
|
160
|
+
"@ledgerhq/hw-app-btc: createPaymentTransactionNew multi argument signature is deprecated. please switch to named parameters."
|
|
135
161
|
);
|
|
136
162
|
}
|
|
137
163
|
return createTransaction(this.transport, arg);
|
|
138
164
|
}
|
|
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
|
+
}
|
|
139
194
|
}
|
|
140
195
|
|
|
141
196
|
function makeFingerprint(compressedPubKey) {
|
package/tests/Btc.test.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import Transport from "@ledgerhq/hw-transport";
|
|
1
2
|
import {
|
|
2
3
|
openTransportReplayer,
|
|
3
4
|
RecordStore,
|
|
4
5
|
} from "@ledgerhq/hw-transport-mocker";
|
|
5
6
|
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";
|
|
6
11
|
|
|
7
12
|
test("btc.getWalletXpub", async () => {
|
|
8
13
|
/*
|
|
@@ -13,6 +18,7 @@ pub: 0x0488b21e = 76067358
|
|
|
13
18
|
Testnet:
|
|
14
19
|
prv: 0x04358394 = 70615956
|
|
15
20
|
pub: 0x043587cf = 70617039
|
|
21
|
+
|
|
16
22
|
versionpriv=70615956
|
|
17
23
|
versionpub=70617039
|
|
18
24
|
seed=be388c569b4a6846c847e882e09f000000000000000000000000e255bcd17cb8
|
|
@@ -25,6 +31,7 @@ M_44h_0h_17h=`bx hd-to-public -v $versionpub $m_44h_0h_17h`
|
|
|
25
31
|
echo "M_44h_0h_17h xpub: $M_44h_0h_17h"
|
|
26
32
|
echo "M_44h_0h: `bx base58check-decode $M_44h_0h`"
|
|
27
33
|
echo "M_44h_0h_17h: `bx base58check-decode $M_44h_0h_17h`"
|
|
34
|
+
|
|
28
35
|
Output (note that version (4) should be prepended to payload):
|
|
29
36
|
M_44h_0h_17h xpub: tpubDDn3XrB65rhCzRh4fsD8gogX9gFvGcEmP3jZtGbdxK7Mn25gipFB68vLFyqZ43i4e5Z7p6rki7THyb2PeH1D3NkLm5EUFzbUzyafp872GKa
|
|
30
37
|
M_44h_0h: wrapper
|
|
@@ -41,6 +48,7 @@ M_44h_0h_17h: wrapper
|
|
|
41
48
|
aac5fdd59102250dfdfb84c1efd160ed0e10ebac845d0e4b04277174630ba56de96bbd3afb21
|
|
42
49
|
version 4
|
|
43
50
|
}
|
|
51
|
+
|
|
44
52
|
The xpub bytes (from bip32) are
|
|
45
53
|
4 byte: version bytes (mainnet: 0x0488B21E public, 0x0488ADE4 private; testnet: 0x043587CF public, 0x04358394 private)
|
|
46
54
|
1 byte: depth: 0x00 for master nodes, 0x01 for level-1 derived keys, ....
|
|
@@ -48,6 +56,7 @@ The xpub bytes (from bip32) are
|
|
|
48
56
|
4 bytes: child number. This is ser32(i) for i in xi = xpar/i, with xi the key being serialized. (0x00000000 if master key)
|
|
49
57
|
32 bytes: the chain code
|
|
50
58
|
33 bytes: the public key or private key data (serP(K) for public keys, 0x00 || ser256(k) for private keys)
|
|
59
|
+
|
|
51
60
|
M_44h_0h_17h:
|
|
52
61
|
043587cf
|
|
53
62
|
03
|
|
@@ -55,6 +64,7 @@ ee6e81fd
|
|
|
55
64
|
80000011
|
|
56
65
|
c071c6f2d05cbc9ea9a04951b238086ce1608cf00020c3cab85b36aac5fdd591
|
|
57
66
|
02250dfdfb84c1efd160ed0e10ebac845d0e4b04277174630ba56de96bbd3afb21
|
|
67
|
+
|
|
58
68
|
M_44h_0h:
|
|
59
69
|
043587cf
|
|
60
70
|
02
|
|
@@ -62,6 +72,7 @@ M_44h_0h:
|
|
|
62
72
|
80000000
|
|
63
73
|
8bd937d416de7020952cc8e2c99ce9ac7e01265e31ceb8e47bf9c37f46f8abbd
|
|
64
74
|
035d4a72237572a91e13818fa38cedabe6174569cc9a319012f75150d5c0a0639d
|
|
75
|
+
|
|
65
76
|
Uncompress (a bit covoluted, but works):
|
|
66
77
|
prv=`bx hd-to-ec -p $versionpriv $m_44h_0h_17h`
|
|
67
78
|
bx ec-to-public -u ${prv:2}
|
|
@@ -69,20 +80,24 @@ bx ec-to-public -u ${prv:2}
|
|
|
69
80
|
pubCompr=`bx ec-to-public ${prv:2}`
|
|
70
81
|
bx ec-to-address $pubCompr
|
|
71
82
|
16Y97ByhyboePhTYMMmFj1tq5Cy1bDq8jT
|
|
83
|
+
|
|
72
84
|
prv=`bx hd-to-ec -p $versionpriv $m_44h_0h`
|
|
73
85
|
bx ec-to-public -u ${prv:2}
|
|
74
86
|
045d4a72237572a91e13818fa38cedabe6174569cc9a319012f75150d5c0a0639d54eafd13a68d079b7a67764800c6a981825ef52384f08c3925109188ab21bc09
|
|
75
87
|
pubCompr=`bx ec-to-public ${prv:2}`
|
|
76
88
|
bx ec-to-address $pubCompr
|
|
77
89
|
1NjiCsVBuKDT62LmaUd7WZZZBK2gPAkisb
|
|
90
|
+
|
|
78
91
|
These translates to
|
|
79
92
|
pubkeylen(1) || pubkeyuncompressed(65) || addrLen(1) || address || chaincode(32)
|
|
93
|
+
|
|
80
94
|
Expected response for m/44'/0'/17':
|
|
81
95
|
41
|
|
82
96
|
04250dfdfb84c1efd160ed0e10ebac845d0e4b04277174630ba56de96bbd3afb21fc6c04ce0d5a0cbd784fdabc99d16269c27cf3842fe8440f1f21b8af900f0eaa
|
|
83
97
|
22
|
|
84
98
|
ascii(16Y97ByhyboePhTYMMmFj1tq5Cy1bDq8jT)
|
|
85
99
|
c071c6f2d05cbc9ea9a04951b238086ce1608cf00020c3cab85b36aac5fdd591
|
|
100
|
+
|
|
86
101
|
Expected response for m/44'/0':
|
|
87
102
|
41
|
|
88
103
|
045d4a72237572a91e13818fa38cedabe6174569cc9a319012f75150d5c0a0639d54eafd13a68d079b7a67764800c6a981825ef52384f08c3925109188ab21bc09
|
|
@@ -113,14 +128,15 @@ ascii(1NjiCsVBuKDT62LmaUd7WZZZBK2gPAkisb)
|
|
|
113
128
|
const responseAcc = `41${pubkeyAcc}22${addrAcc}${ccAcc}`;
|
|
114
129
|
const transport = await openTransportReplayer(
|
|
115
130
|
RecordStore.fromString(`
|
|
131
|
+
=> b001000000
|
|
132
|
+
<= 0107426974636f696e06312e332e323301029000
|
|
116
133
|
=> e040000009028000002c80000000
|
|
117
134
|
<= ${responseParent}9000
|
|
118
135
|
=> e04000000d038000002c8000000080000011
|
|
119
136
|
<= ${responseAcc}9000
|
|
120
137
|
`)
|
|
121
138
|
);
|
|
122
|
-
|
|
123
|
-
const btc = new Btc({ transport, currency: "oldbitcoin" });
|
|
139
|
+
const btc = new Btc(transport);
|
|
124
140
|
const result = await btc.getWalletXpub({
|
|
125
141
|
path: "44'/0'/17'",
|
|
126
142
|
xpubVersion: 0x043587cf, // mainnet
|
|
@@ -133,12 +149,13 @@ ascii(1NjiCsVBuKDT62LmaUd7WZZZBK2gPAkisb)
|
|
|
133
149
|
test("btc.getWalletPublicKey", async () => {
|
|
134
150
|
const transport = await openTransportReplayer(
|
|
135
151
|
RecordStore.fromString(`
|
|
152
|
+
=> b001000000
|
|
153
|
+
<= 0107426974636f696e06312e332e323301029000
|
|
136
154
|
=> e040000011048000002c800000008000000000000000
|
|
137
155
|
<= 410486b865b52b753d0a84d09bc20063fab5d8453ec33c215d4019a5801c9c6438b917770b2782e29a9ecc6edb67cd1f0fbf05ec4c1236884b6d686d6be3b1588abb2231334b453654666641724c683466564d36756f517a7673597135767765744a63564dbce80dd580792cd18af542790e56aa813178dc28644bb5f03dbd44c85f2d2e7a9000
|
|
138
156
|
`)
|
|
139
157
|
);
|
|
140
|
-
|
|
141
|
-
const btc = new Btc({ transport, currency: "oldbitcoin" });
|
|
158
|
+
const btc = new Btc(transport);
|
|
142
159
|
const result = await btc.getWalletPublicKey("44'/0'/0'/0");
|
|
143
160
|
expect(result).toEqual({
|
|
144
161
|
bitcoinAddress: "13KE6TffArLh4fVM6uoQzvsYq5vwetJcVM",
|
|
@@ -154,6 +171,8 @@ test("btc 2", async () => {
|
|
|
154
171
|
RecordStore.fromString(`
|
|
155
172
|
=> b001000000
|
|
156
173
|
<= 0107426974636f696e06312e332e323301029000
|
|
174
|
+
=> b001000000
|
|
175
|
+
<= 0107426974636f696e06312e332e323301029000
|
|
157
176
|
=> e042000009000000010100000001
|
|
158
177
|
<= 9000
|
|
159
178
|
=> e0428000254ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a
|
|
@@ -186,12 +205,11 @@ test("btc 2", async () => {
|
|
|
186
205
|
<= 3145022100ff492ad0b3a634aa7751761f7e063bf6ef4148cd44ef8930164580d5ba93a17802206fac94b32e296549e2e478ce806b58d61cfacbfed35ac4ceca26ac531f92b20a019000
|
|
187
206
|
`)
|
|
188
207
|
);
|
|
189
|
-
|
|
190
|
-
const btc = new Btc({ transport, currency: "oldbitcoin" });
|
|
208
|
+
const btc = new Btc(transport);
|
|
191
209
|
const tx1 = btc.splitTransaction(
|
|
192
210
|
"01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000"
|
|
193
211
|
);
|
|
194
|
-
const result = await btc.
|
|
212
|
+
const result = await btc.createPaymentTransactionNew({
|
|
195
213
|
inputs: [[tx1, 1, undefined, undefined]],
|
|
196
214
|
associatedKeysets: ["0'/0/0"],
|
|
197
215
|
changePath: undefined,
|
|
@@ -241,7 +259,7 @@ test("btc 3", async () => {
|
|
|
241
259
|
<= 3045022100b5b1813992282b9a1fdd957b9751d79dc21018abc6586336e272212cc89cfe84022053765a1da0bdb5a0631a9866f1fd4c583589d5188b11cfa302fc20cd2611a71e019000
|
|
242
260
|
`)
|
|
243
261
|
);
|
|
244
|
-
const btc = new Btc(
|
|
262
|
+
const btc = new Btc(transport);
|
|
245
263
|
const tx1 = btc.splitTransaction(
|
|
246
264
|
"01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000"
|
|
247
265
|
);
|
|
@@ -272,8 +290,8 @@ test("btc 4", async () => {
|
|
|
272
290
|
<= 3045022100e32b32b8a6b4228155ba4d1a536d8fed9900606663fbbf4ea420ed8e944f9c18022053c97c74d2f6d8620d060584dc7886f5f3003684bb249508eb7066215172281a9000
|
|
273
291
|
`)
|
|
274
292
|
);
|
|
275
|
-
const btc = new Btc(
|
|
276
|
-
const result = await btc.
|
|
293
|
+
const btc = new Btc(transport);
|
|
294
|
+
const result = await btc.signMessageNew(
|
|
277
295
|
"44'/0'/0'/0",
|
|
278
296
|
Buffer.from("test").toString("hex")
|
|
279
297
|
);
|
|
@@ -288,6 +306,8 @@ test("btc seg multi", async () => {
|
|
|
288
306
|
const transport = await openTransportReplayer(
|
|
289
307
|
RecordStore.fromString(`
|
|
290
308
|
=> b001000000
|
|
309
|
+
<= 0107426974636f696e06312e332e323301029000
|
|
310
|
+
=> b001000000
|
|
291
311
|
<= 0107426974636f696e06312e332e323201029000
|
|
292
312
|
=> e040000015058000003180000001800000050000000000000000
|
|
293
313
|
<= 4104f004370a593b3cde1511801a1151c86dd09a2f246a3f9ac3ef0b0240c0aeb506feddb0a785f5039c3e3e829db9692364e333256284d0fe312177cb12b88551162131764a4336523431416334685a61704a7863334c5a6e69334e7169445837514562141c248b44b74cbe35a3a92801cfebaf895df8d65f5830264097260c863fc1e59000
|
|
@@ -323,8 +343,7 @@ test("btc seg multi", async () => {
|
|
|
323
343
|
<= 3145022100c820c90ce84c6567617733cd6409c4b8f7469b863d811a3cdc73bf3fa43912bc0220320b7fd259939a6821d371f2b49a755d1ca588bffb1476fbb2da68907427b54b019000
|
|
324
344
|
`)
|
|
325
345
|
);
|
|
326
|
-
|
|
327
|
-
const btc = new Btc({ transport, currency: "oldbitcoin" });
|
|
346
|
+
const btc = new Btc(transport);
|
|
328
347
|
const tx1 = btc.splitTransaction(
|
|
329
348
|
"0100000000010130992c1559a43de1457f23380fefada09124d22594bbeb46ab6e9356e8407d39010000001716001417507f91a6594df7367a0561e4d3df376a829e1fffffffff02c03b47030000000017a9142397c9bb7a3b8a08368a72b3e58c7bb850555792875f810acf0900000017a914813a2e6c7538f0d0afbdeb5db38608804f5d76ab8702483045022100e09ca8a5357623438daee5b7804e73c9209de7c645efd405f13f83420157c48402207d3e4a30f362e062e361967c7afdd45e7f21878a067b661a6635669e620f99910121035606550fd51f6b063b69dc92bd182934a34463f773222743f300d3c7fd3ae47300000000",
|
|
330
349
|
true
|
|
@@ -333,7 +352,7 @@ test("btc seg multi", async () => {
|
|
|
333
352
|
"0100000000010176ef6abce7feecefbe1322da6cd21245f2d475a1836f13e99f56847bf7127f7c0100000017160014a4e29e297768fccd19cabc21cced93a6afc803eeffffffff0280778e060000000017a9142397c9bb7a3b8a08368a72b3e58c7bb8505557928795061b51b100000017a914c5cfa33e119f60c7cb40bd6b9cfe9e78b026eb6a8702473044022031f0c72683374275328ef0341ed1f233c55a37e21335f9c111c25645b50d0d4e0220670b833be0f688c237bf4466d2b94c99631ada3557c95a7d13bfbb9177125c340121020879f8616da54f8ac5476b97fbe0329c5a0e4cbd32e22e7348262bdfad99a44200000000",
|
|
334
353
|
true
|
|
335
354
|
);
|
|
336
|
-
const result = await btc.
|
|
355
|
+
const result = await btc.createPaymentTransactionNew({
|
|
337
356
|
inputs: [
|
|
338
357
|
[tx1, 0, undefined, undefined],
|
|
339
358
|
[tx2, 0, undefined, undefined],
|
|
@@ -373,7 +392,7 @@ test("btc sign p2sh seg", async () => {
|
|
|
373
392
|
<= 3045022100932934ee326c19c81b72fb03cec0fb79ff980a8076639f77c7edec35bd59da1e02205e4030e8e0fd2405f6db2fe044c49d3f191adbdc0e05ec7ed4dcc4c6fe7310e5019000
|
|
374
393
|
`)
|
|
375
394
|
);
|
|
376
|
-
const btc = new Btc(
|
|
395
|
+
const btc = new Btc(transport);
|
|
377
396
|
const tx1 = btc.splitTransaction(
|
|
378
397
|
"0100000001d3a05cd6e15582f40e68bb8b1559dc9e5b3e4f9f34d92c1217dc8c3355bc844e010000008a47304402207ab1a4768cbb036d4bce3c4a294c13cc5ae6076fc7bedce88c62aa80ae366da702204f8fea6923f8df36315c0c26cb42d8d7ab52ca4736776816e10d6ce51906d0600141044289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34cec320a0565fb7caf11b1ca2f445f9b7b012dda5718b3cface369ee3a034ded6ffffffff02102700000000000017a9141188cc3c265fbc01a025fc8adec9823effd0cef187185f9265170100001976a9140ae1441568d0d293764a347b191025c51556cecd88ac00000000",
|
|
379
398
|
true
|
|
@@ -406,8 +425,8 @@ test("signMessage", async () => {
|
|
|
406
425
|
<= 314402205eac720be544d3959a760d9bfd6a0e7c86d128fd1030038f06d85822608804e20220385d83273c9d03c469596292fb354b07d193034f83c2633a4c1f057838e12a5b9000
|
|
407
426
|
`)
|
|
408
427
|
);
|
|
409
|
-
const btc = new Btc(
|
|
410
|
-
const res = await btc.
|
|
428
|
+
const btc = new Btc(transport);
|
|
429
|
+
const res = await btc.signMessageNew(
|
|
411
430
|
"44'/0'/0'/0/0",
|
|
412
431
|
Buffer.from("foobar").toString("hex")
|
|
413
432
|
);
|
|
@@ -417,3 +436,100 @@ test("signMessage", async () => {
|
|
|
417
436
|
s: "385d83273c9d03c469596292fb354b07d193034f83c2633a4c1f057838e12a5b",
|
|
418
437
|
});
|
|
419
438
|
});
|
|
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,18 +16,23 @@ 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)");
|
|
19
21
|
});
|
|
20
22
|
test("getWalletPublicKey p2wpkh", async () => {
|
|
21
23
|
await testGetWalletPublicKey("m/84'/1'/0'", "wpkh(@0)");
|
|
22
24
|
await testGetWalletPublicKey("m/84'/0'/17'", "wpkh(@0)");
|
|
25
|
+
await testGetWalletPublicKey("m/2'/0'/17'", "wpkh(@0)");
|
|
23
26
|
});
|
|
24
27
|
test("getWalletPublicKey wrapped p2wpkh", async () => {
|
|
25
28
|
await testGetWalletPublicKey("m/49'/1'/0'", "sh(wpkh(@0))");
|
|
26
29
|
await testGetWalletPublicKey("m/49'/0'/17'", "sh(wpkh(@0))");
|
|
30
|
+
await testGetWalletPublicKey("m/9'/0'/17'", "sh(wpkh(@0))");
|
|
27
31
|
});
|
|
28
32
|
test("getWalletPublicKey p2tr", async () => {
|
|
29
33
|
await testGetWalletPublicKey("m/86'/1'/0'", "tr(@0)");
|
|
30
34
|
await testGetWalletPublicKey("m/86'/0'/17'", "tr(@0)");
|
|
35
|
+
await testGetWalletPublicKey("m/17'", "tr(@0)");
|
|
31
36
|
});
|
|
32
37
|
|
|
33
38
|
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(
|
|
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 createPaymentTransactionNew");
|
|
86
|
+
const tx = await btcNew.createPaymentTransactionNew(arg);
|
|
87
|
+
logCallback("Done createPaymentTransactionNew");
|
|
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(
|
|
38
|
+
const btc = new Btc(transport);
|
|
39
39
|
const tx1 = btc.splitTransaction(
|
|
40
40
|
"fdffffff00289840f900000000003f76a91491842e1e3773b404b7acbde07bf6a8782f86320288ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4dd109c00000000003f76a914a16d376a7036816aea0dbac7d0a288b38690bc2288ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b40a2aa100000000003f76a914126e122dcc80505b9b4f00fd47606a5c2168f87488ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4aa6da901000000003f76a914ac3b0b75d17de9b66f6ce0b04c7b6df68d8c627f88ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4911a6110000000003f76a91412d85a4a2a000b5f0af5eb5c233c045bcb32237088ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b49640f900000000003f76a914f1555affa9e47423a5f07c55a22b6da90ea79c2c88ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4cb3ea800000000003f76a91438a904ca713c285a20959108c6087c9b97fc06bb88ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4c11ca700000000003f76a91476cd5b686b6c2e3535d488c376ffc4fa7e74490a88ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b46bedab00000000003f76a91431ec601f10fda75caf164edf18aa7a97b531b78c88ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b487ee9a00000000003f76a9144903ff43d006695400f033e399025daf8947d1c588ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b40b9caf00000000003f76a91443aa6dad34cff8f3e4db84f94b9c65e6fba79c8188ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4efc39d00000000003f76a91460b4b104b7e9bbc701abd3917949456c68f8522488ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4637b9d00000000003f76a91458c7adfd4b8f301dc9d65f3ff6a49d863cddec4b88ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4f21cd800000000003f76a9144e05aafd31d66a762bf7d937f613256a48d7574688ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b40d2aa100000000003f76a914defe35ddd78bc8918c1a54e540861c9c05b3e38788ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b46496f300000000003f76a91485bf80ae408b88bff15f7b708c421b9dd32fc47688ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b43fd4a600000000003f76a914558fd5741c64f869592cab94ae86a1bc63c1888988ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4b65c7605000000003f76a91449d8ced84fa86a98e552d9a2a118c0c7ac57d58688ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4752e9f00000000003f76a914525d5f215ccf943d028c862881dfba681db58f9d88ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4102db000000000003f76a91436902a202fd435b2fe115887d3c33882fa15bf1288ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b49175b000000000003f76a9149a7ca1397dac859774bd10759a80f2e36c84e74388ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b448f6a700000000003f76a914bbfd902d072ad91c6b32a7e2bff6fd340dffaa8688ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b465ceb900000000003f76a914696a361dbc20a39810133e33575a4fc7d3e8bdb688ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4a681ec00000000003f76a914e0b80dd3e6a7224ecf9e9acdcea4b6694d5255f588ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b413c03201000000003f76a914784fdee5cfc5c53c47df55f023f1ccc9dd612b1588ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b465080201000000003f76a9142dd6dc1e4f219dca7f69d973a2230779e6a582c888ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b49b25a300000000003f76a914fbe62338b092fd2c0973c27dd3d0482b89a6412388ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b456379b00000000003f76a9144d0c38f0a68f2240126f34a366251c9a8a931d1c88ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4e6b04f02000000003f76a9147df5a291502a857a7085263f92a66b5aa198302388ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b456379b00000000003f76a914f0e9b6e8973a5670e9be75c036455b45e6f3eeb288ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b41a4fb100000000003f76a914b34da261b708d61d354833f4e7f2b655af29e05588ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b49403a200000000003f76a9141b61c76511eda352b2d93638065ed61dffc1fa5788ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4ca3ea800000000003f76a914a3b72f15846e1377c54de250b96baf6f11858fc488ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b46bdbea01000000003f76a9148a74fe473eed123214029bc79270423e59b8708588ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b45a02e400000000003f76a9143bc0b5d39ceb0b9906e6b1a2c19236b0f245f04188ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b47e87d900000000003f76a9148369c5504ec06cb99a6ef34a64c32b3bbce323b888ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b41bdda200000000003f76a9146465e2df3a5f313bdb2e8f213e67362aafafa66688ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b4a33b9900000000003f76a914da189d3e1fee6ec5f7e71b8dd0f0cb2cc63e706b88ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b411bba100000000003f76a91463dcb85ae2572d68177ea0664214a9b96c8a4a8388ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b49bbaa701000000003f76a914e254982595b3a9f27cef5e2dfffc190f682c29b688ac20856d3881bce79d50886e1da8ddfedd0bc5b1002f31c8eebaf69e770400000000031da710b400000000010000000000000000c6361b360000000009f8b468a5f89f6a651e5e0f4722634dfafeb9c06b5813991f1aeb593c691d8df11684326768947b1bca6276e3a81447fd1967a0361cba8421b95404b2ce6d5727139522e837d20bd94cc1c4d3179e35e2f662cbd8bbcb5e55ac5721a819a193c980c353cd4aa3ca6b73b2c970bfc662221cece4121ace898b92583dfdba8db5aa7942adc7e0c6669450a5f69c0a81ae92fd7f650dd25025c82107ce1611bcf3cabd2ee4bf6fcd2a4d510654383de08b434cfc58c2d6558c92a1d3a5ed64271f1d037a2fc07ae745e6cca7eb0803089b56d1edbd8b4913fd12d4e3cac095c70ca78a325f2f9a2fa409c43bdb02364bc53d2d1e351435a4c8af578cc3891ee8434f7f1a653e469b9213fecdb37548f78395f759578e2c735009090c21eef86398a2301bbfc7c87a3508eb0865119468a5f751eafa087260edaa7f0f7c2ba3e4bdc11bcb96e877b696798159606ac92768b860e15363edd98927f1466c6108c55fdfe123a88d42efa39288e8f8878da947813fa450d45c02458b33fc21a57141d109e145adaffce8c69da92b29bc3d9cee7a0fe44d26870323c37c74ae7a4711dd46fc23ffbdeff5df650c5076adb0103994f82ed876c3dcbc95499a5cdd89a8a3699196331f55db547d5d5311fae5c7b73a8396f6e68443aa4a623543fb1f8863ed9bb0def0f307be1c0f2114a3c95e452cc8627d0e8f7c9d0d75df49e92e5e2bccce8d76e96885163facc66728fddff2556e6547207c1ae8fd098d81486e7ad18f8b4b4cadb9cb801f14168bc9d63fb10c614b8011d59efe29bf316bbc2a7f96b06a583d658c82855a8d0bf7e40dc137c334c44fbfaedf3352c1a78b989e116e86ba0fc53e7ac8c215761c5bb36ae447d3a2f4357828a7882811ea61588f0afb1390b2c2148a6508430ba86e90457c42f531ea73d6f056756547d09d63282bab6b1d71cd055d60406e284a9e46a14625da76d1264161f9f561e7588a31ba86c9259309e816fa71c01c159cc84b28d59b7c446355c87fd9c7d0c983ebfa2849387a263f3a6a073e3d649c7829dab262aae5e5320e49609be50d4462acbcb3f7e6723bbcdb309c0f8fe76ea72f044678be352264677c4ad33796cbc52947fe8f1231e7a10f17f32cb9c91e0389a64da2c5a0dfbf04f9bbcb3d14b0c2c54f68547f63bc9bad03b4c2e32ea0fa70f6830dce279be920e90ebdaae44a0aeb8909640a1cd77970f47ccb6ae5aba42342a86d46b9177c4e461703eee28e9bad6720ab1a8033c454042f7d94441af413fd8a43a7651ea2c728d5666087bb28a1f74a071e345639f9947085bab77bab8272ac8228f8cacc397de4e1fb82e69dccb1a87cf28fbbd1febf3750053ab46a213a16cb4a178b621a0348ac522ddcc1ee876d8973c818617ed87db4f62ee68b3ff07f647d3ca5b368d428582126a5c94cff4d18261c8afd00917f738a8d5f87de8eff909ae038607402a947e156c048c0c8f0b2c23dbccd03aa49655fb458bb053b8751cc3abd1733a2df65a3220db75a73f68d5226ba133e58347e125abdde6111ec67a8add5a58dfd86d81218d9fbb33fb76811ab4bff7f98c4ab83bb14d9a93e4f66d976540797474ab0804228cbc0d2b06f4c252373d16d9b3e7b2aa2626f6caf04ed44cde1ca909e9e1133e724f043fcc793102d4952f4b66a900be292e19b8f24f4c17ac6a216f6d896a1e8610472a4b981b88517ca75653e49a0ebb1bf86e8f48f3e7872d33d312fe7333b12c76c3534440319daae7c4bff3ed8382a5c150f57d29a22269e931cfa03d3102135d0b64f38c4c6aabd89e85f310291e173854a0d5a8ec421aaaf0613870cdfa709bd6073a0f1616f32101b7838218e55a159873ba038647cd6172da138750b3c43b7eed2d32d1c02580fae152a407beb284404bd723c9f169b30d416f4898abb4e7a3e4b55f8b1ecae889a0c10ea1ab493f1d7ed15fd5eec475423be700d90b3bdc96ff8bbe3a51b6f1d97f3a5a11804baf2140afab032712712ea4e03000bb1fca1728a4e4ba3db64c614c2f0a432c9d2b23cd28ec4afa273412578c1248a945098380b48bdd8d4da265ae7834672d18428663da204f9d59fcb6cc57c3fb05131624a6f9bf022ea40269a38eff2085995fd43cb36d5105a8b13458aa131ff32978b7c474258e40659db516d01f79f3730a34c53a6acb5739d3da78f82eb8d45cc0beb1c77e104e7f4b3e255df37e6a522e79c3d377438a8025a29fc753a6900f3f5e65e50ed178a2abed7d5fe73cd1ef327f9bafc6872ab8e8b9aca4ad80d152062eb2cd3371d09a5c90ff20bb3c6b53ed68a2b9822891740c3b9bc92c2dbf4467ded45e325035bbde84cd50a99d9729a221ea9c0577ee818c05231a27637508221b9d711f883cef7743ac5cbb1cf0d36cda39b59625d784c38edb62ad663eece335178c4a8e79ddbe5dfea48f978d4990d1773648d7ddf4c938b31eebea90758ff5a251b0402c0d1b4c299508d459fabfe0ee7626e01",
|
|
41
41
|
true,
|
|
@@ -8,6 +8,8 @@ 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
|
|
11
13
|
<= 6d00
|
|
12
14
|
=> e04000001505800000548000000080000000000000010000001b
|
|
13
15
|
<= 41042e00ef5ab04c270bf697e817c5fd433aa4509b063745d6f82c2157a59d59c1b7146956cee1b5ce1c7739a87fb59de3ad918872b14301af3f00b538934837b1382231354a707a787578426b6358384576465a6e6d4d736a74664771314d676e6d465356b9b92151a60d39e94e5be7a91003d0f43f03cafd69db00ebc60a65434d83e66d9000
|
|
@@ -33,13 +35,12 @@ test("transaction on btc – nano s 1.3.1 – native segwit", async () => {
|
|
|
33
35
|
<= 3045022100e4acf0eb3803a62399f53825d86aa30743fe999eefb01522d5f7ecd9eeec663d022063b90c512e207c2ac47d8759e1c73c6abeff58daec31c48905193470bc87f2d3019000
|
|
34
36
|
`)
|
|
35
37
|
);
|
|
36
|
-
|
|
37
|
-
const btc = new Btc({ transport, currency: "oldbitcoin" });
|
|
38
|
+
const btc = new Btc(transport);
|
|
38
39
|
const tx1 = btc.splitTransaction(
|
|
39
40
|
"01000000000102b91a5eb409e1243dcc02440ad5709d57047946309a515902ffdba8b98ad9e9970000000000ffffff00b91a5eb409e1243dcc02440ad5709d57047946309a515902ffdba8b98ad9e9970100000000ffffff000250c300000000000016001449df9e8ba7e25dd4830579cb42fbea938497168bef8b0100000000001600142f3fa4710983519e4ae45dd80e72e70b79f25c5e0248304502210080ed332c269ae7d86fac26a143afcec0a634e1098fd1ee5ca43cbe0c66de861802204c804eceb4cc9ca397156fa683f46274d22bb5d95f8c8293dc595934899f7927012103cc39edf09d462b4de30cc9bf96b163f18dcee742e0a1ea6fad0274ae0b9d60330247304402203e277d48d19a01c33b45b8f102479eb10811d20991bbf060cab4ba79f0972e61022041e13ed7da2b266d20c36b01694f2d16cf144c1ff66863f26d7c332dc220bc1301210369f216ec068fb7ef17a46ad3ad4d7f0e04e8a3a16ae2da852d6e4b57c3bb972f00000000",
|
|
40
41
|
true
|
|
41
42
|
);
|
|
42
|
-
const result = await btc.
|
|
43
|
+
const result = await btc.createPaymentTransactionNew({
|
|
43
44
|
inputs: [[tx1, 1, undefined, 0xffffffff]],
|
|
44
45
|
associatedKeysets: ["84'/0'/0'/1/27"],
|
|
45
46
|
changePath: "84'/0'/0'/1/28",
|
|
@@ -58,6 +59,8 @@ test("transaction on btc – nano s 1.6.0 – native segwit", async () => {
|
|
|
58
59
|
const transport = await openTransportReplayer(
|
|
59
60
|
RecordStore.fromString(`
|
|
60
61
|
=> b001000000
|
|
62
|
+
<= 0107426974636f696e06312e332e323301029000
|
|
63
|
+
=> b001000000
|
|
61
64
|
<= 0107426974636f696e05312e342e3201029000
|
|
62
65
|
=> e042000009000000010100000002
|
|
63
66
|
<= 9000
|
|
@@ -101,13 +104,12 @@ test("transaction on btc – nano s 1.6.0 – native segwit", async () => {
|
|
|
101
104
|
<= 3045022100e4acf0eb3803a62399f53825d86aa30743fe999eefb01522d5f7ecd9eeec663d022063b90c512e207c2ac47d8759e1c73c6abeff58daec31c48905193470bc87f2d3019000
|
|
102
105
|
`)
|
|
103
106
|
);
|
|
104
|
-
|
|
105
|
-
const btc = new Btc({ transport, currency: "oldbitcoin" });
|
|
107
|
+
const btc = new Btc(transport);
|
|
106
108
|
const tx1 = btc.splitTransaction(
|
|
107
109
|
"01000000000102b91a5eb409e1243dcc02440ad5709d57047946309a515902ffdba8b98ad9e9970000000000ffffff00b91a5eb409e1243dcc02440ad5709d57047946309a515902ffdba8b98ad9e9970100000000ffffff000250c300000000000016001449df9e8ba7e25dd4830579cb42fbea938497168bef8b0100000000001600142f3fa4710983519e4ae45dd80e72e70b79f25c5e0248304502210080ed332c269ae7d86fac26a143afcec0a634e1098fd1ee5ca43cbe0c66de861802204c804eceb4cc9ca397156fa683f46274d22bb5d95f8c8293dc595934899f7927012103cc39edf09d462b4de30cc9bf96b163f18dcee742e0a1ea6fad0274ae0b9d60330247304402203e277d48d19a01c33b45b8f102479eb10811d20991bbf060cab4ba79f0972e61022041e13ed7da2b266d20c36b01694f2d16cf144c1ff66863f26d7c332dc220bc1301210369f216ec068fb7ef17a46ad3ad4d7f0e04e8a3a16ae2da852d6e4b57c3bb972f00000000",
|
|
108
110
|
true
|
|
109
111
|
);
|
|
110
|
-
const result = await btc.
|
|
112
|
+
const result = await btc.createPaymentTransactionNew({
|
|
111
113
|
inputs: [[tx1, 1, undefined, 0xffffffff]],
|
|
112
114
|
associatedKeysets: ["84'/0'/0'/1/27"],
|
|
113
115
|
changePath: "84'/0'/0'/1/28",
|