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