balanceofsatoshis 23.2.0 → 23.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Versions
2
2
 
3
+ ## 23.3.0
4
+
5
+ - `call`: Add `subscribeToMessages` to listen for received onion messages
6
+
3
7
  ## 23.2.0
4
8
 
5
9
  - `invoice`: Add `--encrypted-hints` to hide the node behind blinded paths in
@@ -1,6 +1,7 @@
1
1
  const asyncAuto = require('async/auto');
2
2
  const asyncEach = require('async/each');
3
3
  const {broadcastTransaction} = require('ln-sync');
4
+ const {componentsOfTransaction} = require('@alexbosworth/blockchain');
4
5
  const {formatTokens} = require('ln-sync');
5
6
  const {fundPsbt} = require('ln-service');
6
7
  const {getChainFeeRate} = require('ln-service');
@@ -10,7 +11,7 @@ const {getUtxos} = require('ln-service');
10
11
  const {parseAmount} = require('ln-accounting');
11
12
  const {returnResult} = require('asyncjs-util');
12
13
  const {signPsbt} = require('ln-service');
13
- const {Transaction} = require('bitcoinjs-lib');
14
+ const {sizeOfTransaction} = require('@alexbosworth/blockchain');
14
15
  const {unlockUtxo} = require('ln-service');
15
16
 
16
17
  const allowUnconfirmed = 0;
@@ -18,19 +19,14 @@ const asBigUnit = n => (n / 1e8).toFixed(8);
18
19
  const asOutpoint = utxo => `${utxo.transaction_id}:${utxo.transaction_vout}`;
19
20
  const asInput = n => ({transaction_id: n.id, transaction_vout: n.vout});
20
21
  const asUtxo = n => ({id: n.slice(0, 64), vout: Number(n.slice(65))});
21
- const bufferAsHex = buffer => buffer.toString('hex');
22
22
  const dustValue = 293;
23
23
  const formattedFeeRate = n => n.toFixed(2);
24
- const {fromHex} = Transaction;
25
24
  const hasMaxAmount = amounts => !!amounts.find(n => !!n && !!/max/gim.test(n));
26
25
  const {isArray} = Array;
27
26
  const isOutpoint = n => !!n && /^[0-9A-F]{64}:[0-9]{1,6}$/i.test(n);
28
27
  const isPublicKey = n => !!n && /^0[2-3][0-9A-F]{64}$/i.test(n);
29
28
  const isValidFeeRate = n => !n || Number.isInteger(Number(n));
30
- const minConfs = 1;
31
29
  const sumOf = arr => arr.reduce((sum, n) => sum + n, Number());
32
- const taprootAddressVersion = 1;
33
- const txHashAsTxId = hash => hash.reverse().toString('hex');
34
30
 
35
31
  /** Fund and sign a transaction
36
32
 
@@ -332,13 +328,13 @@ module.exports = (args, cbk) => {
332
328
  // Final funded transaction
333
329
  funded: ['getUtxos', 'sign', ({getUtxos, sign}, cbk) => {
334
330
  // Match the inputs of the tx up to the wallet outputs
335
- const tx = fromHex(sign.transaction);
331
+ const tx = componentsOfTransaction({transaction: sign.transaction});
336
332
 
337
333
  // Find the UTXOs that are being spent in the final transaction
338
- const spending = tx.ins.map(input => {
334
+ const spending = tx.inputs.map(input => {
339
335
  const outpoint = asOutpoint({
340
- transaction_id: txHashAsTxId(input.hash),
341
- transaction_vout: input.index,
336
+ transaction_id: input.id,
337
+ transaction_vout: input.vout,
342
338
  });
343
339
 
344
340
  return getUtxos.utxos.find(n => asOutpoint(n) === outpoint);
@@ -350,12 +346,14 @@ module.exports = (args, cbk) => {
350
346
  }
351
347
 
352
348
  const inputsValue = sumOf(spending.map(n => n.tokens));
353
- const outputsValue = sumOf(tx.outs.map(n => n.value));
349
+ const outputsValue = sumOf(tx.outputs.map(n => n.tokens));
354
350
 
355
351
  const feeTotal = inputsValue - outputsValue;
356
352
 
353
+ const {vsize} = sizeOfTransaction({transaction: sign.transaction});
354
+
357
355
  return cbk(null, {
358
- fee_tokens_per_vbyte: formattedFeeRate(feeTotal / tx.virtualSize()),
356
+ fee_tokens_per_vbyte: formattedFeeRate(feeTotal / vsize),
359
357
  signed_transaction: sign.transaction,
360
358
  });
361
359
  }],
package/commands/api.json CHANGED
@@ -971,6 +971,10 @@
971
971
  "events": ["invoice_updated"],
972
972
  "method": "subscribeToInvoices"
973
973
  },
974
+ {
975
+ "events": ["message_received"],
976
+ "method": "subscribeToMessages"
977
+ },
974
978
  {
975
979
  "arguments": [{
976
980
  "description": "Payment hash id hex-encoded",
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "author": {
8
8
  "name": "Alex Bosworth",
9
- "url": "https://twitter.com/alexbosworth"
9
+ "url": "https://x.com/alexbosworth"
10
10
  },
11
11
  "bin": {
12
12
  "bos": "bos"
@@ -30,7 +30,7 @@
30
30
  "bitcoinjs-lib": "6.1.7",
31
31
  "bolt01": "4.0.0",
32
32
  "bolt03": "2.0.0",
33
- "bolt04": "1.2.0",
33
+ "bolt04": "1.3.0",
34
34
  "bolt07": "2.0.0",
35
35
  "cbor": "10.0.12",
36
36
  "colorette": "2.0.20",
@@ -41,7 +41,7 @@
41
41
  "ini": "7.0.0",
42
42
  "inquirer": "14.2.2",
43
43
  "ln-accounting": "10.0.7",
44
- "ln-service": "59.6.0",
44
+ "ln-service": "59.7.0",
45
45
  "ln-sync": "8.0.6",
46
46
  "ln-telegram": "8.0.6",
47
47
  "moment": "2.31.0",
@@ -109,5 +109,5 @@
109
109
  "postpublish": "docker buildx build --platform linux/amd64,linux/arm64 -t alexbosworth/balanceofsatoshis -t alexbosworth/balanceofsatoshis:$npm_package_version --push .",
110
110
  "test": "node --experimental-test-coverage --test test/arrays/*.js test/balances/*.js test/chain/*.js test/display/*.js test/encryption/*.js test/lnd/*.js test/network/*.js test/nodes/*.js test/offchain/*.js test/peers/*.js test/responses/*.js test/routing/*.js test/services/*.js test/swaps/*.js test/tags/*.js test/telegram/*.js test/wallets/*.js"
111
111
  },
112
- "version": "23.2.0"
112
+ "version": "23.3.0"
113
113
  }