paid-services 3.15.0 → 3.15.1
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
package/package.json
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"@alexbosworth/fiat": "1.0.2",
|
|
11
11
|
"async": "3.2.3",
|
|
12
12
|
"asyncjs-util": "1.2.9",
|
|
13
|
+
"bech32": "2.0.0",
|
|
13
14
|
"bolt01": "1.2.4",
|
|
14
15
|
"bolt07": "1.8.1",
|
|
15
16
|
"ecpair": "2.0.1",
|
|
@@ -46,5 +47,5 @@
|
|
|
46
47
|
"integration-tests": "tap -j 2 --branches=1 --functions=1 --lines=1 --statements=1 -t 180 test/integration/*.js",
|
|
47
48
|
"test": "tap --branches=1 --functions=1 --lines=1 --statements=1 -t 60 test/actions/*.js test/balanced/*.js test/capacity/*.js test/client/*.js test/config/*.js test/p2p/*.js test/records/*.js test/respond/*.js test/server/*.js test/server/*.js test/services/*.js test/trades/*.js"
|
|
48
49
|
},
|
|
49
|
-
"version": "3.15.
|
|
50
|
+
"version": "3.15.1"
|
|
50
51
|
}
|
|
@@ -5,6 +5,7 @@ const asyncAuto = require('async/auto');
|
|
|
5
5
|
const asyncMap = require('async/map');
|
|
6
6
|
const asyncRace = require('async/race');
|
|
7
7
|
const asyncReflect = require('async/reflect');
|
|
8
|
+
const {bech32m} = require('bech32');
|
|
8
9
|
const {broadcastChainTransaction} = require('ln-service');
|
|
9
10
|
const {confirmationFee} = require('goldengate');
|
|
10
11
|
const {controlBlock} = require('p2tr');
|
|
@@ -19,12 +20,14 @@ const {getNetwork} = require('ln-sync');
|
|
|
19
20
|
const {getPayment} = require('ln-service');
|
|
20
21
|
const {getPublicKey} = require('ln-service');
|
|
21
22
|
const {hashForTree} = require('p2tr');
|
|
23
|
+
const {networks} = require('bitcoinjs-lib');
|
|
22
24
|
const {parsePaymentRequest} = require('ln-service');
|
|
23
25
|
const {pay} = require('ln-service');
|
|
24
26
|
const {payViaPaymentDetails} = require('ln-service');
|
|
25
27
|
const {pointAdd} = require('tiny-secp256k1');
|
|
26
28
|
const {privateAdd} = require('tiny-secp256k1');
|
|
27
29
|
const {returnResult} = require('asyncjs-util');
|
|
30
|
+
const {script} = require('bitcoinjs-lib');
|
|
28
31
|
const {signTransaction} = require('ln-service');
|
|
29
32
|
const {subscribeToBlocks} = require('ln-service');
|
|
30
33
|
const {subscribeToPastPayment} = require('ln-service');
|
|
@@ -42,12 +45,14 @@ const {typePayMetadata} = require('./swap_field_types');
|
|
|
42
45
|
|
|
43
46
|
const bufferAsHex = buffer => buffer.toString('hex');
|
|
44
47
|
const {ceil} = Math;
|
|
48
|
+
const decompileOutputScript = hex => script.decompile(Buffer.from(hex, 'hex'));
|
|
45
49
|
const defaultConfsCount = 1;
|
|
46
50
|
const defaultDepositSettleTimeoutMs = 1000 * 60 * 10;
|
|
47
51
|
const defaultMaxFeeMultiplier = 1000;
|
|
48
52
|
const defaultMaxPreimagePushFee = 10;
|
|
49
53
|
const defaultMinSweepBlocks = 20;
|
|
50
54
|
const defaultWaitForChainFundingMs = 1000 * 60 * 60 * 3;
|
|
55
|
+
const encodeAddress = (prefix, data) => bech32m.encode(prefix, data);
|
|
51
56
|
const family = 805;
|
|
52
57
|
const {floor} = Math;
|
|
53
58
|
const {from} = Buffer;
|
|
@@ -69,6 +74,7 @@ const sweepInputIndex = 0;
|
|
|
69
74
|
const times = n => Array(n).fill(null).map((_, i) => i);
|
|
70
75
|
const tokensForPushPreimage = 1;
|
|
71
76
|
const uniqBy = (a,b) => a.filter((e,i) => a.findIndex(n => n[b] == e[b]) == i);
|
|
77
|
+
const v1AddressWords = key => [].concat(1).concat(bech32m.toWords(key));
|
|
72
78
|
|
|
73
79
|
/** Complete the off to on swap
|
|
74
80
|
|
|
@@ -393,9 +399,13 @@ module.exports = (args, cbk) => {
|
|
|
393
399
|
'swap',
|
|
394
400
|
({deadline, getNetwork, requestDetails, startHeight, swap}, cbk) =>
|
|
395
401
|
{
|
|
402
|
+
const [, key] = decompileOutputScript(swap.output_script);
|
|
396
403
|
const outputScript = swap.output_script;
|
|
404
|
+
const prefix = networks[getNetwork.bitcoinjs].bech32;
|
|
397
405
|
|
|
398
|
-
|
|
406
|
+
const address = encodeAddress(prefix, v1AddressWords(key));
|
|
407
|
+
|
|
408
|
+
args.emitter.emit('update', {waiting_for_chain_funding: address});
|
|
399
409
|
|
|
400
410
|
if (!!args.request) {
|
|
401
411
|
return findDeposit({
|
|
@@ -718,7 +718,7 @@ module.exports = (args, cbk) => {
|
|
|
718
718
|
return cbk();
|
|
719
719
|
}
|
|
720
720
|
|
|
721
|
-
args.emitter.emit('update', {receiving_funds:
|
|
721
|
+
args.emitter.emit('update', {receiving_funds: getSettlement.tokens});
|
|
722
722
|
|
|
723
723
|
return settleHodlInvoice({
|
|
724
724
|
lnd: args.lnd,
|