paid-services 3.20.1 → 3.20.2

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
+ ## Version 3.20.2
4
+
5
+ - `manageGroupJoin`: Allow opening a pair channel when funds are below capacity
6
+
3
7
  ## Version 3.20.1
4
8
 
5
9
  - `manageTrades`: Fix seller connection when not peered
@@ -105,7 +105,7 @@ module.exports = ({ask, lnd}, cbk) => {
105
105
  ({getAlias, getBalance, getDetails}, cbk) =>
106
106
  {
107
107
  // Check to make sure that there are on chain funds for this group
108
- if (getBalance.chain_balance < getDetails.capacity) {
108
+ if (getBalance.chain_balance < getDetails.funding) {
109
109
  return cbk([
110
110
  400,
111
111
  'InsufficientChainFundsAvailableToJoinGroup',
@@ -1,11 +1,13 @@
1
1
  const {decodeBigSize} = require('bolt01');
2
2
 
3
3
  const findRecord = (records, type) => records.find(n => n.type === type);
4
+ const funding = (capacity, count) => count === 2 ? capacity / 2 : capacity;
4
5
  const {isArray} = Array;
5
6
  const isOdd = n => !!(n % 2);
6
7
  const maxCapacityTokens = BigInt(7e14);
7
8
  const maxMembersCount = BigInt(650);
8
9
  const maxFeeRate = BigInt(1e5);
10
+ const minMembersCount = BigInt(2);
9
11
  const typeCapacity = '1';
10
12
  const typeCount = '2';
11
13
  const typeRate = '3';
@@ -28,6 +30,7 @@ const version = '1';
28
30
  {
29
31
  capacity: <Channel Capacity Tokens Number>
30
32
  count: <Target Members Count Number>
33
+ funding: <Amount Of Funding Required Tokens Number>
31
34
  rate: <Chain Fee Rate Number>
32
35
  }
33
36
  */
@@ -88,6 +91,10 @@ module.exports = ({records}) => {
88
91
  throw new Error('UnexpectedValueForCountInGroupRecords');
89
92
  }
90
93
 
94
+ if (BigInt(count) < minMembersCount) {
95
+ throw new Error('ExpectedHigherMembersCountInGroupDetails');
96
+ }
97
+
91
98
  const rateRecord = findRecord(records, typeRate);
92
99
 
93
100
  try {
@@ -105,6 +112,7 @@ module.exports = ({records}) => {
105
112
  return {
106
113
  capacity: Number(capacity),
107
114
  count: Number(count),
115
+ funding: funding(Number(capacity), Number(count)),
108
116
  rate: Number(rate),
109
117
  };
110
118
  };
@@ -24,6 +24,7 @@ const typeGroupChannelId = '1';
24
24
  {
25
25
  capacity: <Channel Capacity Tokens Number>
26
26
  count: <Target Members Count Number>
27
+ funding: <Amount Of Funding Required Tokens Number>
27
28
  rate: <Chain Fee Rate Number>
28
29
  }
29
30
  */
package/package.json CHANGED
@@ -47,5 +47,5 @@
47
47
  "integration-tests": "tap -j 2 --branches=1 --functions=1 --lines=1 --statements=1 -t 180 test/integration/*.js",
48
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"
49
49
  },
50
- "version": "3.20.1"
50
+ "version": "3.20.2"
51
51
  }