@ledgerhq/coin-tester-bitcoin 1.1.0-nightly.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/.env.example +7 -0
- package/.eslintrc.js +23 -0
- package/.turbo/turbo-build.log +4 -0
- package/.unimportedrc.json +8 -0
- package/CHANGELOG.md +18 -0
- package/LICENSE.txt +21 -0
- package/README.md +30 -0
- package/jest.config.ts +19 -0
- package/lib/src/assert.d.ts +6 -0
- package/lib/src/assert.d.ts.map +1 -0
- package/lib/src/assert.js +29 -0
- package/lib/src/assert.js.map +1 -0
- package/lib/src/atlas.d.ts +3 -0
- package/lib/src/atlas.d.ts.map +1 -0
- package/lib/src/atlas.js +84 -0
- package/lib/src/atlas.js.map +1 -0
- package/lib/src/constants.d.ts +5 -0
- package/lib/src/constants.d.ts.map +1 -0
- package/lib/src/constants.js +5 -0
- package/lib/src/constants.js.map +1 -0
- package/lib/src/fixtures.d.ts +5 -0
- package/lib/src/fixtures.d.ts.map +1 -0
- package/lib/src/fixtures.js +61 -0
- package/lib/src/fixtures.js.map +1 -0
- package/lib/src/helpers.d.ts +11 -0
- package/lib/src/helpers.d.ts.map +1 -0
- package/lib/src/helpers.js +339 -0
- package/lib/src/helpers.js.map +1 -0
- package/lib/src/scenarii/bitcoin.d.ts +4 -0
- package/lib/src/scenarii/bitcoin.d.ts.map +1 -0
- package/lib/src/scenarii/bitcoin.js +258 -0
- package/lib/src/scenarii/bitcoin.js.map +1 -0
- package/lib/src/utils.d.ts +5 -0
- package/lib/src/utils.d.ts.map +1 -0
- package/lib/src/utils.js +48 -0
- package/lib/src/utils.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib-es/src/assert.d.ts +6 -0
- package/lib-es/src/assert.d.ts.map +1 -0
- package/lib-es/src/assert.js +23 -0
- package/lib-es/src/assert.js.map +1 -0
- package/lib-es/src/atlas.d.ts +3 -0
- package/lib-es/src/atlas.d.ts.map +1 -0
- package/lib-es/src/atlas.js +43 -0
- package/lib-es/src/atlas.js.map +1 -0
- package/lib-es/src/constants.d.ts +5 -0
- package/lib-es/src/constants.d.ts.map +1 -0
- package/lib-es/src/constants.js +2 -0
- package/lib-es/src/constants.js.map +1 -0
- package/lib-es/src/fixtures.d.ts +5 -0
- package/lib-es/src/fixtures.d.ts.map +1 -0
- package/lib-es/src/fixtures.js +54 -0
- package/lib-es/src/fixtures.js.map +1 -0
- package/lib-es/src/helpers.d.ts +11 -0
- package/lib-es/src/helpers.d.ts.map +1 -0
- package/lib-es/src/helpers.js +323 -0
- package/lib-es/src/helpers.js.map +1 -0
- package/lib-es/src/scenarii/bitcoin.d.ts +4 -0
- package/lib-es/src/scenarii/bitcoin.d.ts.map +1 -0
- package/lib-es/src/scenarii/bitcoin.js +252 -0
- package/lib-es/src/scenarii/bitcoin.js.map +1 -0
- package/lib-es/src/utils.d.ts +5 -0
- package/lib-es/src/utils.d.ts.map +1 -0
- package/lib-es/src/utils.js +40 -0
- package/lib-es/src/utils.js.map +1 -0
- package/lib-es/tsconfig.tsbuildinfo +1 -0
- package/package.json +83 -0
- package/src/assert.ts +34 -0
- package/src/atlas.ts +52 -0
- package/src/constants.ts +1 -0
- package/src/docker/atlas/bitcoin.conf +56 -0
- package/src/docker/atlas/pending.conf +36 -0
- package/src/docker/docker-compose.yml +76 -0
- package/src/docker/nginx/default.conf +31 -0
- package/src/docker/postgres/create-db.sh +9 -0
- package/src/fixtures.ts +66 -0
- package/src/helpers.ts +372 -0
- package/src/scenarii/bitcoin.ts +306 -0
- package/src/scenarii.test.ts +27 -0
- package/src/utils.ts +52 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import Client from "bitcoin-core";
|
|
2
|
+
// fetched from bitcoin.conf
|
|
3
|
+
const client = new Client({
|
|
4
|
+
version: "0.24.1",
|
|
5
|
+
username: "user",
|
|
6
|
+
password: "pass",
|
|
7
|
+
host: "http://localhost:18443",
|
|
8
|
+
});
|
|
9
|
+
export async function loadWallet(name) {
|
|
10
|
+
try {
|
|
11
|
+
// Try creating and loading the wallet
|
|
12
|
+
const res = await client.command("createwallet", name);
|
|
13
|
+
console.log(`✅ Wallet "${name}" created and loaded:`, res);
|
|
14
|
+
// Optionally verify that the wallet is accessible
|
|
15
|
+
await client.getBalance({ minconf: 0 });
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
const message = error?.message || "Unknown error";
|
|
20
|
+
// Wallet already exists → try loading it
|
|
21
|
+
if (message.includes("already exists")) {
|
|
22
|
+
console.log(`ℹ️ Wallet "${name}" already exists. Attempting to load...`);
|
|
23
|
+
return loadExistingWallet(name);
|
|
24
|
+
}
|
|
25
|
+
console.error(`❌ Failed to create wallet "${name}":`, message);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Attempt to load an existing wallet, handling "already loaded" gracefully.
|
|
30
|
+
*/
|
|
31
|
+
async function loadExistingWallet(name) {
|
|
32
|
+
try {
|
|
33
|
+
await client.command("loadwallet", name);
|
|
34
|
+
console.log(`✅ Wallet "${name}" loaded successfully.`);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
const message = error?.message || "Unknown error";
|
|
38
|
+
if (message.includes("already loaded")) {
|
|
39
|
+
console.log(`ℹ️ Wallet "${name}" is already loaded.`);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
console.error(`❌ Failed to load existing wallet "${name}":`, message);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export async function mineToWalletAddress(param) {
|
|
47
|
+
const address = await client.getNewAddress();
|
|
48
|
+
const nbBlocks = parseInt(param);
|
|
49
|
+
await client.generateToAddress({
|
|
50
|
+
nblocks: nbBlocks,
|
|
51
|
+
address,
|
|
52
|
+
});
|
|
53
|
+
console.log(`Mined ${nbBlocks} blocks to: ${address}`);
|
|
54
|
+
}
|
|
55
|
+
const FEES = 0.0001;
|
|
56
|
+
export const mineBlock = async (address) => {
|
|
57
|
+
await client.generateToAddress({
|
|
58
|
+
nblocks: 1,
|
|
59
|
+
address,
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
export const getCurrentBlock = async () => {
|
|
63
|
+
return await client.command("getblockcount");
|
|
64
|
+
};
|
|
65
|
+
/*
|
|
66
|
+
* Note that it sets the input sequence to 4294967293, <=0xFFFFFFFD — Replace By Fee (RBF).
|
|
67
|
+
*/
|
|
68
|
+
export const sendTo = async (recipientAddress, amount) => {
|
|
69
|
+
await client.getBalance({ minconf: 0 });
|
|
70
|
+
if (!recipientAddress || amount <= 0) {
|
|
71
|
+
console.error("Invalid parameters: Provide a valid recipient address and positive amount.");
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
console.log(`Sending ${amount} BTC to ${recipientAddress}...`);
|
|
75
|
+
try {
|
|
76
|
+
// Step 1: Send the specified amount to the recipient address
|
|
77
|
+
const txSendToAddress = await client
|
|
78
|
+
.sendToAddress({
|
|
79
|
+
address: recipientAddress,
|
|
80
|
+
amount: amount,
|
|
81
|
+
})
|
|
82
|
+
.then((txid) => txid);
|
|
83
|
+
// Step 2: Fetch transaction details
|
|
84
|
+
await client.getTransaction({
|
|
85
|
+
txid: txSendToAddress,
|
|
86
|
+
verbose: true,
|
|
87
|
+
});
|
|
88
|
+
// Step 4: Fetch updated transaction details after confirmation
|
|
89
|
+
await client.getTransaction({
|
|
90
|
+
txid: txSendToAddress,
|
|
91
|
+
verbose: true,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
console.error("Error in sendToAddress:", error.message);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
export const sendToMany = async (recipientAddress, amount, times) => {
|
|
99
|
+
// calls sendTo times times
|
|
100
|
+
for (let i = 0; i < times; i++) {
|
|
101
|
+
await sendTo(recipientAddress, amount);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
export const sendAutomatedRaw = async (destinationAddress, amount) => {
|
|
105
|
+
if (!destinationAddress || amount <= 0) {
|
|
106
|
+
console.error("Invalid parameters: Provide a valid address and positive amount.");
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
// Step 1: Create an unfinished raw transaction (no inputs, outputs only)
|
|
111
|
+
const unfinishedTx = await client.createRawTransaction({
|
|
112
|
+
inputs: [],
|
|
113
|
+
outputs: {
|
|
114
|
+
[destinationAddress]: amount,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
// Step 2: Fund the transaction (Bitcoin Core automatically selects UTXOs)
|
|
118
|
+
const fundedTx = await client.fundRawTransaction({
|
|
119
|
+
hexstring: unfinishedTx,
|
|
120
|
+
options: { replaceable: true }, // Set to true if RBF is needed
|
|
121
|
+
// if replaceable: false, sequence of vin set to 4294967294 (0xFFFFFFFE) // Locktime BUT non-rbf
|
|
122
|
+
// else, sets to: 4294967293 // Locktime & RBF
|
|
123
|
+
});
|
|
124
|
+
// Step 3: Decode the transaction for debugging
|
|
125
|
+
await client.decodeRawTransaction({
|
|
126
|
+
hexstring: fundedTx.hex,
|
|
127
|
+
});
|
|
128
|
+
// Step 4: Sign the transaction
|
|
129
|
+
const signedTxHex = await client.signRawTransactionWithWallet({
|
|
130
|
+
hexstring: fundedTx.hex,
|
|
131
|
+
});
|
|
132
|
+
// Step 5: Broadcast the transaction to the network
|
|
133
|
+
const transactionId = await client.sendRawTransaction({
|
|
134
|
+
hexstring: signedTxHex.hex,
|
|
135
|
+
});
|
|
136
|
+
console.log(`Transaction Broadcasted! TXID: ${transactionId}`);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
console.error("Error sending transaction:", error.message);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
/*
|
|
143
|
+
* https://learnmeabitcoin.com/technical/transaction/input/sequence/
|
|
144
|
+
* NOTE: You only need to set one of the sequence fields to enable locktime or RBF
|
|
145
|
+
* (even if you have multiple inputs and sequence fields in one transaction)
|
|
146
|
+
* However, relative locktime settings are specific to each input.
|
|
147
|
+
*
|
|
148
|
+
* If set to 0xFFFFFFFE (4294967294) → Locktime / Non-RBF
|
|
149
|
+
* If set to a number ≤ 0x0000FFFF (65535) → Blocks-based timelock.
|
|
150
|
+
* Sequence Effect
|
|
151
|
+
* 0xFFFFFFFE (4294967294) Default (Non-RBF): Cannot be replaced
|
|
152
|
+
* 0xFFFFFFFD (4294967293) Opt-in RBF: Can be replaced by a higher fee transaction
|
|
153
|
+
*
|
|
154
|
+
*
|
|
155
|
+
* Called like this as you've got more control over all the inputs
|
|
156
|
+
*/
|
|
157
|
+
export const sendRaw = async (recipientAddress, amount, sequence = 4294967294) => {
|
|
158
|
+
if (!recipientAddress || amount <= 0) {
|
|
159
|
+
console.error("Invalid parameters: Provide a valid address and positive amount.");
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
console.log(`Creating raw transaction: Sending ${amount} BTC to ${recipientAddress} with sequence=${sequence}...`);
|
|
163
|
+
try {
|
|
164
|
+
// Step 2: Get new addresses
|
|
165
|
+
const newAddress = await client.getNewAddress({ address_type: "legacy" });
|
|
166
|
+
const changeAddress = await client.getRawChangeAddress({
|
|
167
|
+
address_type: "legacy",
|
|
168
|
+
});
|
|
169
|
+
// Step 3: Get UTXO for spending
|
|
170
|
+
const unspents = await client.listUnspent({});
|
|
171
|
+
let id = 0;
|
|
172
|
+
let unspent = unspents[id];
|
|
173
|
+
while (unspent.amount < amount) {
|
|
174
|
+
console.warn("Insufficient funds. Picking another UTXO.");
|
|
175
|
+
id++;
|
|
176
|
+
unspent = unspents[id];
|
|
177
|
+
}
|
|
178
|
+
// Step 4: Calculate change
|
|
179
|
+
const changeAmountStr = Number(unspent.amount - amount - FEES).toFixed(6);
|
|
180
|
+
const changeAmount = Number(changeAmountStr);
|
|
181
|
+
if (changeAmount < 0) {
|
|
182
|
+
console.warn("Insufficient funds after fees.");
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
// Step 5: Create raw transaction
|
|
186
|
+
const rawTxHex = await client.createRawTransaction({
|
|
187
|
+
inputs: [
|
|
188
|
+
{
|
|
189
|
+
txid: unspent.txid,
|
|
190
|
+
vout: unspent.vout,
|
|
191
|
+
sequence: sequence,
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
outputs: {
|
|
195
|
+
[recipientAddress]: amount,
|
|
196
|
+
[changeAddress]: changeAmount,
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
await client.decodeRawTransaction({
|
|
200
|
+
hexstring: rawTxHex,
|
|
201
|
+
});
|
|
202
|
+
// Step 6: Sign the transaction
|
|
203
|
+
const signedTxHex = await client.signRawTransactionWithWallet({
|
|
204
|
+
hexstring: rawTxHex,
|
|
205
|
+
});
|
|
206
|
+
// Step 7: Broadcast the transaction
|
|
207
|
+
const txId = await client.sendRawTransaction({
|
|
208
|
+
hexstring: signedTxHex.hex,
|
|
209
|
+
});
|
|
210
|
+
// Step 8: Fetch transaction details
|
|
211
|
+
await client.getTransaction({ txid: txId, verbose: true });
|
|
212
|
+
// Step 9: Mine a block to confirm the transaction
|
|
213
|
+
await mineBlock(newAddress);
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
console.error("Error in sendRaw:", error.message);
|
|
217
|
+
console.error({ error });
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
export const sendToReplaceCurrentTx = async (recipientAddress, amount) => {
|
|
221
|
+
if (!recipientAddress || amount <= 0) {
|
|
222
|
+
console.error("Invalid parameters: Provide a valid address and positive amount.");
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
console.log(`Sending replaceable transaction to ${recipientAddress} with amount ${amount} BTC...`);
|
|
226
|
+
try {
|
|
227
|
+
// Step 1: Get an unspent UTXO
|
|
228
|
+
const unspent = await client.listUnspent({
|
|
229
|
+
query_options: { minimumSumAmount: amount },
|
|
230
|
+
});
|
|
231
|
+
if (!unspent.length) {
|
|
232
|
+
console.error("No suitable UTXOs available.");
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const utxo = unspent[0];
|
|
236
|
+
// Step 2: Create the replaceable transaction (RBF enabled)
|
|
237
|
+
const rawTx1 = await client.createRawTransaction({
|
|
238
|
+
inputs: [
|
|
239
|
+
{
|
|
240
|
+
txid: utxo.txid,
|
|
241
|
+
vout: utxo.vout,
|
|
242
|
+
sequence: 4294967293, // RBF enabled
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
outputs: {
|
|
246
|
+
[recipientAddress]: amount,
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
// Step 3: Fund & Sign the transaction
|
|
250
|
+
const fundedTx1 = await client.fundRawTransaction({
|
|
251
|
+
hexstring: rawTx1,
|
|
252
|
+
options: { feeRate: 0.0004 }, // Increase fee rate
|
|
253
|
+
});
|
|
254
|
+
const signedTx1 = await client.signRawTransactionWithWallet({
|
|
255
|
+
hexstring: fundedTx1.hex,
|
|
256
|
+
});
|
|
257
|
+
// Step 4: Broadcast the transaction
|
|
258
|
+
const txId1 = await client.sendRawTransaction({ hexstring: signedTx1.hex });
|
|
259
|
+
console.log(`Transaction sent (TXID: ${txId1}), waiting before replacing...`);
|
|
260
|
+
console.log(`If you need to, make a tx that sends funds to ${recipientAddress}`);
|
|
261
|
+
}
|
|
262
|
+
catch (error) {
|
|
263
|
+
console.error("Error in sendReplaceableTransaction:", error.message);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
export const sendReplaceableTransaction = async (recipientAddress, amount) => {
|
|
267
|
+
if (!recipientAddress || amount <= 0) {
|
|
268
|
+
console.error("Invalid parameters: Provide a valid address and positive amount.");
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
console.log(`Sending replaceable transaction to ${recipientAddress} with amount ${amount} BTC...`);
|
|
272
|
+
try {
|
|
273
|
+
// Step 1: Get an unspent UTXO
|
|
274
|
+
const unspent = await client.listUnspent({
|
|
275
|
+
query_options: { minimumSumAmount: amount },
|
|
276
|
+
});
|
|
277
|
+
if (!unspent.length) {
|
|
278
|
+
console.error("No suitable UTXOs available.");
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
const utxo = unspent[0];
|
|
282
|
+
// Step 2: Create the first replaceable transaction (RBF enabled)
|
|
283
|
+
const rawTx1 = await client.createRawTransaction({
|
|
284
|
+
inputs: [
|
|
285
|
+
{
|
|
286
|
+
txid: utxo.txid,
|
|
287
|
+
vout: utxo.vout,
|
|
288
|
+
sequence: 4294967293, // RBF enabled
|
|
289
|
+
},
|
|
290
|
+
],
|
|
291
|
+
outputs: {
|
|
292
|
+
[recipientAddress]: amount,
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
// Step 3: Fund & Sign the first transaction
|
|
296
|
+
const fundedTx1 = await client.fundRawTransaction({
|
|
297
|
+
hexstring: rawTx1,
|
|
298
|
+
options: { feeRate: 0.0002 }, // Increase fee rate
|
|
299
|
+
});
|
|
300
|
+
const signedTx1 = await client.signRawTransactionWithWallet({
|
|
301
|
+
hexstring: fundedTx1.hex,
|
|
302
|
+
});
|
|
303
|
+
// Step 4: Broadcast the first transaction
|
|
304
|
+
const txId1 = await client.sendRawTransaction({ hexstring: signedTx1.hex });
|
|
305
|
+
console.log(`First transaction sent (TXID: ${txId1}), waiting before replacing...`);
|
|
306
|
+
}
|
|
307
|
+
catch (error) {
|
|
308
|
+
console.error("Error in sendReplaceableTransaction:", error.message);
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
/*Available commands:
|
|
312
|
+
mineBlock <address> - Mine a block to the address
|
|
313
|
+
sendTo <address> <amount> - Send a transaction to an address
|
|
314
|
+
sendToMany <address> <amount> <times> - Send a transaction to an address
|
|
315
|
+
replaceTx <address> <amount> - Send a transaction and replace it using RBF
|
|
316
|
+
sendAutomatedRaw <address> <amount> - Send a raw transaction, automatically funded
|
|
317
|
+
sendRaw <address> <amount> [sequence] - Send a raw transaction with a custom sequence
|
|
318
|
+
sendRawTwoOutputs <address1> <address2> <amount> [sequence] - Send a raw transaction with a custom sequence to 2 addresses
|
|
319
|
+
# doubleSpend <address> - Attempt a double-spend attack
|
|
320
|
+
# dustTransaction <address> - Create a dust transaction
|
|
321
|
+
# multisig <address> - Test a multisig transaction`;
|
|
322
|
+
*/
|
|
323
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,cAAc,CAAC;AAElC,4BAA4B;AAC5B,MAAM,MAAM,GAAQ,IAAI,MAAM,CAAC;IAC7B,OAAO,EAAE,QAAQ;IACjB,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE,wBAAwB;CAC/B,CAAC,CAAC;AAEH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAY;IAC3C,IAAI,CAAC;QACH,sCAAsC;QACtC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;QACvD,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,uBAAuB,EAAE,GAAG,CAAC,CAAC;QAE3D,kDAAkD;QAClD,MAAM,MAAM,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;QACxC,OAAO;IACT,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,MAAM,OAAO,GAAG,KAAK,EAAE,OAAO,IAAI,eAAe,CAAC;QAElD,yCAAyC;QACzC,IAAI,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;YACvC,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,yCAAyC,CAAC,CAAC;YACzE,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAClC,CAAC;QAED,OAAO,CAAC,KAAK,CAAC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AA4C;QAC5C,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC;YAChD,SAAS,EAAE,MAAM;YACjB,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,oBAAoB;SACnD,CAAC,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,4BAA4B,CAAC;YAC1D,SAAS,EAAE,SAAS,CAAC,GAAG;SACzB,CAAC,CAAC;QAEH,0CAA0C;QAC1C,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC;QAC5E,OAAO,CAAC,GAAG,CAAC,iCAAiC,KAAK,gCAAgC,CAAC,CAAC;IACtF,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACvE,CAAC;AACH,CAAC,CAAC;AAEF;;;;;;;;;;;EAWE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitcoin.d.ts","sourceRoot":"","sources":["../../../src/scenarii/bitcoin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAuB,MAAM,4BAA4B,CAAC;AAG3E,OAAO,EAAE,cAAc,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAoN7F,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,cAAc,EAAE,cAAc,CA0FpE,CAAC"}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { killSpeculos, spawnSpeculos } from "@ledgerhq/coin-tester/signers/speculos";
|
|
2
|
+
import Btc from "@ledgerhq/hw-app-btc";
|
|
3
|
+
import { createBridges } from "@ledgerhq/coin-bitcoin/bridge/js";
|
|
4
|
+
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
|
5
|
+
import resolver from "@ledgerhq/coin-bitcoin/hw-getAddress";
|
|
6
|
+
import { LiveConfig } from "@ledgerhq/live-config/LiveConfig";
|
|
7
|
+
import { setCoinConfig } from "@ledgerhq/coin-bitcoin/config";
|
|
8
|
+
import { BigNumber } from "bignumber.js";
|
|
9
|
+
import { defaultNanoApp } from "../constants";
|
|
10
|
+
import { loadWallet, mineToWalletAddress, sendTo } from "../helpers";
|
|
11
|
+
import { makeAccount } from "../fixtures";
|
|
12
|
+
import { killAtlas, spawnAtlas } from "../atlas";
|
|
13
|
+
import { findNewUtxo, waitForExplorerSync } from "../utils";
|
|
14
|
+
import { assertCommonTxProperties, assertUtxoExcluded, assertUtxoSpent, getNewChangeUtxos, } from "../assert";
|
|
15
|
+
let firstUtxoHash = "";
|
|
16
|
+
let firstUtxoOutputIndex = 0;
|
|
17
|
+
let secondUtxoHash = "";
|
|
18
|
+
let secondUtxoOutputIndex = 0;
|
|
19
|
+
const makeScenarioTransactions = () => {
|
|
20
|
+
const scenarioExcludeTwoUtxos = {
|
|
21
|
+
name: "Send BTC excluding two UTXOs",
|
|
22
|
+
rbf: true,
|
|
23
|
+
utxoStrategy: {
|
|
24
|
+
strategy: 1, // Optimize size, for exemple
|
|
25
|
+
excludeUTXOs: [
|
|
26
|
+
{ hash: firstUtxoHash, outputIndex: firstUtxoOutputIndex },
|
|
27
|
+
{ hash: secondUtxoHash, outputIndex: secondUtxoOutputIndex },
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
amount: new BigNumber(1e8),
|
|
31
|
+
recipient: "bcrt1qajglhjtctn88f5l6rajzz52fy78fhxspjajjwz",
|
|
32
|
+
expect: (previousAccount, currentAccount) => {
|
|
33
|
+
assertCommonTxProperties(previousAccount, currentAccount);
|
|
34
|
+
assertUtxoExcluded(currentAccount, firstUtxoHash, firstUtxoOutputIndex);
|
|
35
|
+
assertUtxoExcluded(currentAccount, secondUtxoHash, secondUtxoOutputIndex);
|
|
36
|
+
const newChangeUtxo = findNewUtxo(previousAccount, currentAccount);
|
|
37
|
+
expect(newChangeUtxo).toBeDefined();
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
const scenarioExcludeOneUtxo = {
|
|
41
|
+
name: "Send BTC excluding second UTXO",
|
|
42
|
+
rbf: true,
|
|
43
|
+
utxoStrategy: {
|
|
44
|
+
strategy: 1,
|
|
45
|
+
excludeUTXOs: [{ hash: secondUtxoHash, outputIndex: secondUtxoOutputIndex }],
|
|
46
|
+
},
|
|
47
|
+
useAllAmount: true,
|
|
48
|
+
recipient: "bcrt1qajglhjtctn88f5l6rajzz52fy78fhxspjajjwz",
|
|
49
|
+
expect: (previousAccount, currentAccount) => {
|
|
50
|
+
const latestOperation = assertCommonTxProperties(previousAccount, currentAccount);
|
|
51
|
+
// Excluded UTXO must still be there
|
|
52
|
+
assertUtxoExcluded(currentAccount, secondUtxoHash, secondUtxoOutputIndex);
|
|
53
|
+
// First UTXO must be spent
|
|
54
|
+
assertUtxoSpent(previousAccount, currentAccount, firstUtxoHash, firstUtxoOutputIndex);
|
|
55
|
+
// No change expected when using all amount
|
|
56
|
+
const changeUtxos = getNewChangeUtxos(previousAccount, currentAccount);
|
|
57
|
+
expect(changeUtxos.length).toBe(0);
|
|
58
|
+
const spentUtxos = previousAccount.bitcoinResources.utxos.filter(utxo => !(utxo.hash === secondUtxoHash && utxo.outputIndex === secondUtxoOutputIndex));
|
|
59
|
+
const totalSpent = spentUtxos.reduce((sum, utxo) => sum.plus(utxo.value), new BigNumber(0));
|
|
60
|
+
const totalChange = changeUtxos.reduce((sum, utxo) => sum.plus(utxo.value), new BigNumber(0));
|
|
61
|
+
const expectedChange = totalSpent.minus(latestOperation.value);
|
|
62
|
+
expect(totalChange.toFixed()).toBe(expectedChange.toFixed());
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
const scenarioSendBtcTransaction = {
|
|
66
|
+
name: "Send 1 BTC",
|
|
67
|
+
rbf: false,
|
|
68
|
+
amount: new BigNumber(1e8),
|
|
69
|
+
recipient: "bcrt1qajglhjtctn88f5l6rajzz52fy78fhxspjajjwz",
|
|
70
|
+
expect: (previousAccount, currentAccount) => {
|
|
71
|
+
const [latestOperation] = currentAccount.operations;
|
|
72
|
+
expect(currentAccount.operations.length - previousAccount.operations.length).toBe(1);
|
|
73
|
+
expect(latestOperation.type).toBe("OUT");
|
|
74
|
+
expect(latestOperation.value.toFixed()).toBe(latestOperation.fee.plus(1e8).toFixed());
|
|
75
|
+
expect(currentAccount.balance.toFixed()).toBe(previousAccount.balance.minus(latestOperation.value).toFixed());
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
const scenarioSendFastFeesStrategyBtcTransaction = {
|
|
79
|
+
name: "Send Fast Fees Strategy BTC",
|
|
80
|
+
rbf: false,
|
|
81
|
+
feesStrategy: "fast",
|
|
82
|
+
amount: new BigNumber(1e6),
|
|
83
|
+
recipient: "bcrt1qajglhjtctn88f5l6rajzz52fy78fhxspjajjwz",
|
|
84
|
+
expect: (previousAccount, currentAccount) => {
|
|
85
|
+
const [latestOperation] = currentAccount.operations;
|
|
86
|
+
expect(currentAccount.operations.length - previousAccount.operations.length).toBe(1);
|
|
87
|
+
expect(latestOperation.type).toBe("OUT");
|
|
88
|
+
expect(currentAccount.balance.toFixed()).toBe(previousAccount.balance.minus(latestOperation.value).toFixed());
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
const scenarioSendSlowFeesStrategyBtcTransaction = {
|
|
92
|
+
name: "Send Slow Fees Strategy BTC",
|
|
93
|
+
rbf: false,
|
|
94
|
+
feesStrategy: "slow",
|
|
95
|
+
amount: new BigNumber(1e6),
|
|
96
|
+
recipient: "bcrt1qajglhjtctn88f5l6rajzz52fy78fhxspjajjwz",
|
|
97
|
+
expect: (previousAccount, currentAccount) => {
|
|
98
|
+
const [latestOperation] = currentAccount.operations;
|
|
99
|
+
expect(currentAccount.operations.length - previousAccount.operations.length).toBe(1);
|
|
100
|
+
expect(latestOperation.type).toBe("OUT");
|
|
101
|
+
expect(currentAccount.balance.toFixed()).toBe(previousAccount.balance.minus(latestOperation.value).toFixed());
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
const scenarioSendFIFOBtcTransaction = {
|
|
105
|
+
name: "Send FIFO BTC",
|
|
106
|
+
rbf: true,
|
|
107
|
+
utxoStrategy: { strategy: 0, excludeUTXOs: [] },
|
|
108
|
+
amount: new BigNumber(1e6),
|
|
109
|
+
recipient: "bcrt1qajglhjtctn88f5l6rajzz52fy78fhxspjajjwz",
|
|
110
|
+
expect: (previousAccount, currentAccount) => {
|
|
111
|
+
const [latestOperation] = currentAccount.operations;
|
|
112
|
+
expect(currentAccount.operations.length - previousAccount.operations.length).toBe(1);
|
|
113
|
+
expect(latestOperation.type).toBe("OUT");
|
|
114
|
+
expect(currentAccount.balance.toFixed()).toBe(previousAccount.balance.minus(latestOperation.value).toFixed());
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
const scenarioSendOptimizeSizeBtcTransaction = {
|
|
118
|
+
name: "Send Optimize Size BTC",
|
|
119
|
+
rbf: true,
|
|
120
|
+
utxoStrategy: {
|
|
121
|
+
strategy: 1,
|
|
122
|
+
excludeUTXOs: [],
|
|
123
|
+
},
|
|
124
|
+
amount: new BigNumber(1e6),
|
|
125
|
+
recipient: "bcrt1qajglhjtctn88f5l6rajzz52fy78fhxspjajjwz",
|
|
126
|
+
expect: (previousAccount, currentAccount) => {
|
|
127
|
+
const [latestOperation] = currentAccount.operations;
|
|
128
|
+
expect(currentAccount.operations.length - previousAccount.operations.length).toBe(1);
|
|
129
|
+
expect(latestOperation.type).toBe("OUT");
|
|
130
|
+
expect(currentAccount.balance.toFixed()).toBe(previousAccount.balance.minus(latestOperation.value).toFixed());
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
const scenarioSendMergeCoinsBtcTransaction = {
|
|
134
|
+
name: "Send Merge Coins BTC",
|
|
135
|
+
rbf: true,
|
|
136
|
+
utxoStrategy: { strategy: 2, excludeUTXOs: [] },
|
|
137
|
+
amount: new BigNumber(1e6),
|
|
138
|
+
recipient: "bcrt1qajglhjtctn88f5l6rajzz52fy78fhxspjajjwz",
|
|
139
|
+
expect: (previousAccount, currentAccount) => {
|
|
140
|
+
const [latestOperation] = currentAccount.operations;
|
|
141
|
+
expect(currentAccount.operations.length - previousAccount.operations.length).toBe(1);
|
|
142
|
+
expect(latestOperation.type).toBe("OUT");
|
|
143
|
+
expect(currentAccount.balance.toFixed()).toBe(previousAccount.balance.minus(latestOperation.value).toFixed());
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
const scenarioSendMaxBtcTransaction = {
|
|
147
|
+
name: "Send Max BTC",
|
|
148
|
+
rbf: false,
|
|
149
|
+
useAllAmount: true,
|
|
150
|
+
recipient: "bcrt1qajglhjtctn88f5l6rajzz52fy78fhxspjajjwz",
|
|
151
|
+
expect: (previousAccount, currentAccount) => {
|
|
152
|
+
const [latestOperation] = currentAccount.operations;
|
|
153
|
+
expect(currentAccount.operations.length - previousAccount.operations.length).toBe(1);
|
|
154
|
+
expect(latestOperation.type).toBe("OUT");
|
|
155
|
+
expect(currentAccount.balance.toFixed()).toBe(previousAccount.balance.minus(latestOperation.value).toFixed());
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
return [
|
|
159
|
+
scenarioExcludeTwoUtxos,
|
|
160
|
+
scenarioExcludeOneUtxo,
|
|
161
|
+
scenarioSendBtcTransaction,
|
|
162
|
+
scenarioSendFIFOBtcTransaction,
|
|
163
|
+
scenarioSendOptimizeSizeBtcTransaction,
|
|
164
|
+
scenarioSendMergeCoinsBtcTransaction,
|
|
165
|
+
scenarioSendFastFeesStrategyBtcTransaction,
|
|
166
|
+
scenarioSendSlowFeesStrategyBtcTransaction,
|
|
167
|
+
scenarioSendMaxBtcTransaction,
|
|
168
|
+
];
|
|
169
|
+
};
|
|
170
|
+
export const scenarioBitcoin = {
|
|
171
|
+
name: "Ledger Live Basic Bitcoin Transactions",
|
|
172
|
+
setup: async () => {
|
|
173
|
+
const [{ getOnSpeculosConfirmation, transport }] = await Promise.all([
|
|
174
|
+
spawnSpeculos(`/${defaultNanoApp.firmware}/BitcoinTest/app_${defaultNanoApp.version}.elf`),
|
|
175
|
+
spawnAtlas(),
|
|
176
|
+
]);
|
|
177
|
+
const signerContext = (_, crypto, fn) => fn(new Btc({ transport, currency: BITCOIN.id }));
|
|
178
|
+
const coinConfig = {
|
|
179
|
+
info: {
|
|
180
|
+
status: {
|
|
181
|
+
type: "active",
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
setCoinConfig(() => ({ ...coinConfig }));
|
|
186
|
+
LiveConfig.setConfig({
|
|
187
|
+
config_currency_bitcoin_regtest: {
|
|
188
|
+
type: "object",
|
|
189
|
+
default: {
|
|
190
|
+
status: {
|
|
191
|
+
type: "active",
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
const onSignerConfirmation = getOnSpeculosConfirmation("Sign transaction");
|
|
197
|
+
const { accountBridge, currencyBridge } = createBridges(signerContext, () => coinConfig);
|
|
198
|
+
await currencyBridge.preload();
|
|
199
|
+
const BITCOIN = getCryptoCurrencyById("bitcoin_regtest");
|
|
200
|
+
const getAddress = resolver(signerContext);
|
|
201
|
+
// Can also test LEGACY here
|
|
202
|
+
const { address, publicKey } = await getAddress("", {
|
|
203
|
+
path: "49'/1'/0'/0/0",
|
|
204
|
+
currency: BITCOIN,
|
|
205
|
+
derivationMode: "segwit",
|
|
206
|
+
});
|
|
207
|
+
const { bitcoinLikeInfo } = BITCOIN;
|
|
208
|
+
const { XPUBVersion: xpubVersion } = bitcoinLikeInfo;
|
|
209
|
+
const xpub = await signerContext("", BITCOIN, signer => signer.getWalletXpub({
|
|
210
|
+
path: "49'/1'/0'",
|
|
211
|
+
xpubVersion,
|
|
212
|
+
}));
|
|
213
|
+
const scenarioAccount = makeAccount(xpub, publicKey, address, BITCOIN, "segwit");
|
|
214
|
+
await loadWallet("coinTester");
|
|
215
|
+
// Need to wait 100 blocks to be able to spend coinbase UTXOs
|
|
216
|
+
await mineToWalletAddress("101");
|
|
217
|
+
// Fund it with 7 BTC in three send to have 3 UTXOs
|
|
218
|
+
await sendTo(address, 2);
|
|
219
|
+
await sendTo(address, 3);
|
|
220
|
+
await sendTo(address, 2);
|
|
221
|
+
return {
|
|
222
|
+
accountBridge,
|
|
223
|
+
currencyBridge,
|
|
224
|
+
account: scenarioAccount,
|
|
225
|
+
onSignerConfirmation,
|
|
226
|
+
retryLimit: 0,
|
|
227
|
+
};
|
|
228
|
+
},
|
|
229
|
+
getTransactions: () => makeScenarioTransactions(),
|
|
230
|
+
beforeAll: async (account) => {
|
|
231
|
+
firstUtxoHash = account.bitcoinResources.utxos[0].hash;
|
|
232
|
+
firstUtxoOutputIndex = account.bitcoinResources.utxos[0].outputIndex;
|
|
233
|
+
secondUtxoHash = account.bitcoinResources.utxos[1].hash;
|
|
234
|
+
secondUtxoOutputIndex = account.bitcoinResources.utxos[1].outputIndex;
|
|
235
|
+
},
|
|
236
|
+
afterEach: async () => {
|
|
237
|
+
// Mine 2 blocks after each transaction to confirm it
|
|
238
|
+
await mineToWalletAddress("2");
|
|
239
|
+
},
|
|
240
|
+
beforeEach: async () => {
|
|
241
|
+
// Make sure explorer is in sync before each transaction
|
|
242
|
+
await waitForExplorerSync();
|
|
243
|
+
},
|
|
244
|
+
beforeSync: async () => {
|
|
245
|
+
// Make sure explorer is in sync before sync
|
|
246
|
+
await waitForExplorerSync();
|
|
247
|
+
},
|
|
248
|
+
teardown: async () => {
|
|
249
|
+
await Promise.all([killSpeculos(), killAtlas()]);
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
//# sourceMappingURL=bitcoin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitcoin.js","sourceRoot":"","sources":["../../../src/scenarii/bitcoin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,aAAa,EA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,EAAE;QACpB,qDAAqD;QACrD,MAAM,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IACD,UAAU,EAAE,KAAK,IAAI,EAAE;QACrB,wDAAwD;QACxD,MAAM,mBAAmB,EAAE,CAAC;IAC9B,CAAC;IACD,UAAU,EAAE,KAAK,IAAI,EAAE;QACrB,4CAA4C;QAC5C,MAAM,mBAAmB,EAAE,CAAC;IAC9B,CAAC;IACD,QAAQ,EAAE,KAAK,IAAI,EAAE;QACnB,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACnD,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BitcoinAccount } from "@ledgerhq/coin-bitcoin/lib/types";
|
|
2
|
+
export declare function waitForExplorerSync(url?: string, pollInterval?: number): Promise<void>;
|
|
3
|
+
export declare function findUtxo(account: BitcoinAccount, hash: string, index: number): import("@ledgerhq/coin-bitcoin/lib/types").BitcoinOutput | undefined;
|
|
4
|
+
export declare function findNewUtxo(previous: BitcoinAccount, current: BitcoinAccount): import("@ledgerhq/coin-bitcoin/lib/types").BitcoinOutput | undefined;
|
|
5
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAQlE,wBAAsB,mBAAmB,CACvC,GAAG,GAAE,MAAwE,EAC7E,YAAY,GAAE,MAAa,GAC1B,OAAO,CAAC,IAAI,CAAC,CA4Bf;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,wEAI5E;AAGD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,wEAG5E"}
|