paid-services 9.0.0 → 9.1.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 +7 -1
- package/groups/assemble/coordinate_group.js +3 -9
- package/groups/assemble_channel_group.js +6 -8
- package/groups/coordinate_channel_group.js +1 -7
- package/groups/create_group_channel.js +4 -8
- package/groups/fanout/assemble_fanout_group.js +3 -6
- package/groups/fanout/coordinate_fanout.js +4 -9
- package/groups/fanout/create_group_fanout.js +1 -7
- package/groups/fanout/get_fanout_funding.js +2 -6
- package/groups/fanout/join_fanout.js +2 -7
- package/groups/funding/sign_and_fund_group_channel.js +2 -6
- package/groups/join_channel_group.js +3 -11
- package/groups/messages/decode_signed_funding.js +3 -5
- package/groups/p2p/register_fanout_proposal.js +3 -9
- package/groups/p2p/register_pending_open.js +3 -8
- package/index.js +4 -0
- package/network/create_network_path.js +122 -0
- package/network/encode_network_response.js +37 -0
- package/network/get_message_hops.js +130 -0
- package/network/get_path_id.js +61 -0
- package/network/get_path_outbound.js +82 -0
- package/network/get_relaying_route.js +100 -0
- package/network/index.js +15 -0
- package/network/make_network_request.js +152 -0
- package/network/parse_network_request.js +34 -0
- package/network/path_introduction.js +65 -0
- package/network/regular_reply_bytes.js +66 -0
- package/network/relays_as_hops.js +37 -0
- package/network/reply_introduction.js +44 -0
- package/network/request_network_reply.js +239 -0
- package/network/resolve_path_introductions.js +100 -0
- package/network/return_network_response.js +115 -0
- package/network/route_relays.js +44 -0
- package/network/service_network_messages.js +278 -0
- package/network/service_network_requests.js +180 -0
- package/offers/check_offer_invoice_reply.js +82 -0
- package/offers/constants.json +5 -0
- package/offers/get_offer_invoice.js +194 -0
- package/offers/index.js +5 -0
- package/offers/invoice_request_for_offer.js +147 -0
- package/offers/offer_invoice_failure.js +32 -0
- package/offers/pay_offer.js +101 -0
- package/offers/pay_offer_invoice.js +135 -0
- package/offers/random_secret.js +24 -0
- package/p2p/service_peer_requests.js +0 -3
- package/package.json +15 -10
- package/service_records/add_service_label.js +55 -0
- package/service_records/constants.json +21 -0
- package/service_records/decode_records.js +49 -0
- package/service_records/decode_service_label.js +79 -0
- package/service_records/decode_service_record.js +106 -0
- package/service_records/encode_service_label.js +71 -0
- package/service_records/encode_service_record.js +116 -0
- package/service_records/get_record_key.js +84 -0
- package/service_records/hex_as_list.js +60 -0
- package/service_records/hex_as_version.js +27 -0
- package/service_records/index.js +37 -0
- package/service_records/known_types.js +27 -0
- package/service_records/list_as_hex.js +34 -0
- package/service_records/number_as_truncated.js +39 -0
- package/service_records/open_sealed_data.js +50 -0
- package/service_records/read_record_key_index.js +95 -0
- package/service_records/read_service_label.js +62 -0
- package/service_records/record_key_for_secret.js +33 -0
- package/service_records/record_point.js +24 -0
- package/service_records/seal_key_for_salt.js +41 -0
- package/service_records/truncated_as_number.js +33 -0
- package/service_records/version_as_hex.js +28 -0
- package/service_records/without_record.js +43 -0
- package/support/add_offer_records.js +49 -0
- package/support/amounts_as_hex.js +35 -0
- package/support/bip353_name_as_hex.js +36 -0
- package/support/bitcoin_chains.json +7 -0
- package/support/call_or_throw.js +23 -0
- package/support/constants.json +72 -0
- package/support/create_menu_request.js +91 -0
- package/support/create_support_offer.js +365 -0
- package/support/decode_menu_entry.js +129 -0
- package/support/decode_safe_number.js +28 -0
- package/support/decode_suggested_amounts.js +63 -0
- package/support/decode_support_menu.js +168 -0
- package/support/decode_support_record.js +123 -0
- package/support/encode_menu_entry.js +128 -0
- package/support/encode_payer_offer.js +104 -0
- package/support/encode_suggested_amounts.js +56 -0
- package/support/encode_support_menu.js +132 -0
- package/support/encode_support_record.js +104 -0
- package/support/erroneous_request_field.js +27 -0
- package/support/erroneous_request_fields.json +48 -0
- package/support/get_support_menu.js +357 -0
- package/support/has_unknown_even_record.js +23 -0
- package/support/hex_as_amounts.js +34 -0
- package/support/hex_as_bip353_name.js +55 -0
- package/support/index.js +15 -0
- package/support/invoice_for_request.js +116 -0
- package/support/invoice_paths_to_fit.js +80 -0
- package/support/is_reply_too_large.js +24 -0
- package/support/is_support_offer.js +64 -0
- package/support/known_record_types.js +37 -0
- package/support/length_without_record.js +25 -0
- package/support/menu_id_for_pages.js +49 -0
- package/support/menu_offers.js +173 -0
- package/support/menu_pages.js +81 -0
- package/support/menu_signature_preimage.js +74 -0
- package/support/offer_bitcoin_network.js +45 -0
- package/support/offer_for_request.js +124 -0
- package/support/offer_records_for_payer.js +103 -0
- package/support/offer_suggested_amounts.js +75 -0
- package/support/offer_with_paths.js +53 -0
- package/support/open_support_note.js +81 -0
- package/support/payer_offer_args.js +39 -0
- package/support/payer_offer_for_request.js +171 -0
- package/support/payer_offer_signature_preimage.js +59 -0
- package/support/payer_offer_signer.js +95 -0
- package/support/payer_offer_types.js +21 -0
- package/support/read_menu_request.js +53 -0
- package/support/related_menu_levels.js +39 -0
- package/support/related_menus.js +171 -0
- package/support/reply_invoice_error.js +41 -0
- package/support/request_key.js +31 -0
- package/support/seal_support_note.js +63 -0
- package/support/service_support_offer.js +1032 -0
- package/support/shared_result.js +30 -0
- package/support/sign_invoice_for_request.js +125 -0
- package/support/sign_payer_offer.js +203 -0
- package/support/sign_support_menus.js +140 -0
- package/support/support_note_for_invoice.js +63 -0
- package/support/support_note_key.js +47 -0
- package/support/tlv_stream_records.js +26 -0
- package/support/unpaid_invoices.js +47 -0
- package/support/verify_menu_signature.js +44 -0
- package/support/verify_offer_reference.js +90 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
-
## Version 9.
|
|
3
|
+
## Version 9.1.0
|
|
4
|
+
|
|
5
|
+
- `createGroupFanout`: Fix error response for an invalid key spend signature
|
|
6
|
+
- `createSupportOffer`: Add method to create a support offer
|
|
7
|
+
- `serviceSupportOffer`: Add method to receive payments to a support offer
|
|
8
|
+
|
|
9
|
+
## Version 9.0.1
|
|
4
10
|
|
|
5
11
|
### Breaking Changes
|
|
6
12
|
|
|
@@ -3,7 +3,6 @@ const {randomBytes} = require('crypto');
|
|
|
3
3
|
|
|
4
4
|
const {assembleUnsignedPsbt} = require('ln-sync');
|
|
5
5
|
|
|
6
|
-
const {decodeGroupDetails} = require('./../messages');
|
|
7
6
|
const {decodePendingProposal} = require('./../messages');
|
|
8
7
|
const {decodeSignedFunding} = require('./../messages');
|
|
9
8
|
const {encodeConnectedRecords} = require('./../messages');
|
|
@@ -33,7 +32,6 @@ const uniq = arr => Array.from(new Set(arr));
|
|
|
33
32
|
{
|
|
34
33
|
capacity: <Channel Capacity Tokens Number>
|
|
35
34
|
count: <Group Members Count Number>
|
|
36
|
-
ecp: <ECPair Library Object>
|
|
37
35
|
identity: <Coordinator Identity Public Key Hex String>
|
|
38
36
|
lnd: <Authenticated LND API Object>
|
|
39
37
|
[members]: [<Member Node Id Public Key Hex String>]
|
|
@@ -97,15 +95,11 @@ const uniq = arr => Array.from(new Set(arr));
|
|
|
97
95
|
// All members have submitted their partial signatures
|
|
98
96
|
@event 'signed'
|
|
99
97
|
*/
|
|
100
|
-
module.exports = ({capacity, count,
|
|
98
|
+
module.exports = ({capacity, count, identity, lnd, members, rate}) => {
|
|
101
99
|
if (count < minGroupCount) {
|
|
102
100
|
throw new Error('ExpectedHigherGroupMembersCountToCoordinateGroup');
|
|
103
101
|
}
|
|
104
102
|
|
|
105
|
-
if (!ecp) {
|
|
106
|
-
throw new Error('ExpectedEcpLibraryToCoordinateChannelGroup');
|
|
107
|
-
}
|
|
108
|
-
|
|
109
103
|
if (!identity) {
|
|
110
104
|
throw new Error('ExpectedSelfIdentityPublicKeyToCoordinateGroup');
|
|
111
105
|
}
|
|
@@ -377,12 +371,12 @@ module.exports = ({capacity, count, ecp, identity, lnd, members, rate}) => {
|
|
|
377
371
|
}
|
|
378
372
|
|
|
379
373
|
try {
|
|
380
|
-
decodeSignedFunding({
|
|
374
|
+
decodeSignedFunding({records: req.records});
|
|
381
375
|
} catch (err) {
|
|
382
376
|
return res.failure([400, err.message]);
|
|
383
377
|
}
|
|
384
378
|
|
|
385
|
-
const signed = decodeSignedFunding({
|
|
379
|
+
const signed = decodeSignedFunding({records: req.records});
|
|
386
380
|
|
|
387
381
|
// Register the signed funding
|
|
388
382
|
if (!group.signed.find(n => n.id === req.from)) {
|
|
@@ -25,7 +25,6 @@ const times = 2 * 60 * 10;
|
|
|
25
25
|
{
|
|
26
26
|
capacity: <Channel Capacity Tokens Number>
|
|
27
27
|
count: <Channel Members Count Number>
|
|
28
|
-
ecp: <ECPair Library Object>
|
|
29
28
|
identity: <Coordinator Identity Public Key Hex String>
|
|
30
29
|
lnd: <Authenticated LND API Object>
|
|
31
30
|
[members]: [<Member Identity Public Key Hex String>]
|
|
@@ -75,7 +74,7 @@ const times = 2 * 60 * 10;
|
|
|
75
74
|
@event 'signed'
|
|
76
75
|
{}
|
|
77
76
|
*/
|
|
78
|
-
module.exports = ({capacity, count,
|
|
77
|
+
module.exports = ({capacity, count, identity, lnd, members, rate}) => {
|
|
79
78
|
if (count < minGroupCount) {
|
|
80
79
|
throw new Error('ExpectedHigherGroupCountToAssembleChannelGroup');
|
|
81
80
|
}
|
|
@@ -83,7 +82,6 @@ module.exports = ({capacity, count, ecp, identity, lnd, members, rate}) => {
|
|
|
83
82
|
const coordinator = coordinateGroup({
|
|
84
83
|
capacity,
|
|
85
84
|
count,
|
|
86
|
-
ecp,
|
|
87
85
|
identity,
|
|
88
86
|
lnd,
|
|
89
87
|
members,
|
|
@@ -162,7 +160,7 @@ module.exports = ({capacity, count, ecp, identity, lnd, members, rate}) => {
|
|
|
162
160
|
emitter.emit('proposed', {unsigned: coordinator.unsigned()});
|
|
163
161
|
|
|
164
162
|
try {
|
|
165
|
-
const basePsbt = decodePsbt({
|
|
163
|
+
const basePsbt = decodePsbt({psbt: coordinator.unsigned()});
|
|
166
164
|
|
|
167
165
|
// Sign the unsigned funding transaction
|
|
168
166
|
const signed = await signAndFundGroupChannel({
|
|
@@ -202,15 +200,15 @@ module.exports = ({capacity, count, ecp, identity, lnd, members, rate}) => {
|
|
|
202
200
|
|
|
203
201
|
try {
|
|
204
202
|
// Merge partial PSBTs into a single PSBT
|
|
205
|
-
const combined = combinePsbts({
|
|
203
|
+
const combined = combinePsbts({psbts});
|
|
206
204
|
|
|
207
205
|
// Finalize the PSBT to convert partial signatures to final signatures
|
|
208
|
-
const finalized = finalizePsbt({
|
|
206
|
+
const finalized = finalizePsbt({psbt: combined.psbt});
|
|
209
207
|
|
|
210
208
|
// Pull out the raw transaction from the PSBT
|
|
211
|
-
const {transaction} = extractTransaction({
|
|
209
|
+
const {transaction} = extractTransaction({psbt: finalized.psbt});
|
|
212
210
|
|
|
213
|
-
const {inputs} = decodePsbt({
|
|
211
|
+
const {inputs} = decodePsbt({psbt: combined.psbt});
|
|
214
212
|
|
|
215
213
|
// Make sure the final transaction fee rate is not too low
|
|
216
214
|
if (transactionFeeRate({inputs, transaction}).rate < rate) {
|
|
@@ -4,7 +4,6 @@ const {broadcastTransaction} = require('ln-sync');
|
|
|
4
4
|
const {getIdentity} = require('ln-service');
|
|
5
5
|
const {getNodeAlias} = require('ln-sync');
|
|
6
6
|
const {returnResult} = require('asyncjs-util');
|
|
7
|
-
const tinysecp = require('tiny-secp256k1');
|
|
8
7
|
|
|
9
8
|
const askForGroupDetails = require('./ask_for_group_details');
|
|
10
9
|
const assembleChannelGroup = require('./assemble_channel_group');
|
|
@@ -26,9 +25,6 @@ const niceName = ({alias, id}) => `${alias} ${id}`.trim();
|
|
|
26
25
|
module.exports = ({ask, lnd, logger}, cbk) => {
|
|
27
26
|
return new Promise((resolve, reject) => {
|
|
28
27
|
return asyncAuto({
|
|
29
|
-
// Import ECPair library
|
|
30
|
-
ecp: async () => (await import('ecpair')).ECPairFactory(tinysecp),
|
|
31
|
-
|
|
32
28
|
// Check arguments
|
|
33
29
|
validate: cbk => {
|
|
34
30
|
if (!ask) {
|
|
@@ -56,13 +52,11 @@ module.exports = ({ask, lnd, logger}, cbk) => {
|
|
|
56
52
|
|
|
57
53
|
// Fund and assemble the group
|
|
58
54
|
assembleGroup: [
|
|
59
|
-
'ecp',
|
|
60
55
|
'askForDetails',
|
|
61
56
|
'getIdentity',
|
|
62
|
-
({
|
|
57
|
+
({askForDetails, getIdentity}, cbk) =>
|
|
63
58
|
{
|
|
64
59
|
const coordinate = assembleChannelGroup({
|
|
65
|
-
ecp,
|
|
66
60
|
lnd,
|
|
67
61
|
capacity: askForDetails.capacity,
|
|
68
62
|
count: askForDetails.count,
|
|
@@ -6,7 +6,6 @@ const {getIdentity} = require('ln-service');
|
|
|
6
6
|
const {getMethods} = require('ln-service');
|
|
7
7
|
const {getNodeAlias} = require('ln-sync');
|
|
8
8
|
const {returnResult} = require('asyncjs-util');
|
|
9
|
-
const tinysecp = require('tiny-secp256k1');
|
|
10
9
|
|
|
11
10
|
const assembleChannelGroup = require('./assemble_channel_group');
|
|
12
11
|
|
|
@@ -44,9 +43,6 @@ const staleMs = 1000 * 60 * 5;
|
|
|
44
43
|
module.exports = (args, cbk) => {
|
|
45
44
|
return new Promise((resolve, reject) => {
|
|
46
45
|
return asyncAuto({
|
|
47
|
-
// Import ECPair library
|
|
48
|
-
ecp: async () => (await import('ecpair')).ECPairFactory(tinysecp),
|
|
49
|
-
|
|
50
46
|
// Check arguments
|
|
51
47
|
validate: cbk => {
|
|
52
48
|
if (!args.capacity) {
|
|
@@ -102,7 +98,9 @@ module.exports = (args, cbk) => {
|
|
|
102
98
|
}],
|
|
103
99
|
|
|
104
100
|
// Get identity public key
|
|
105
|
-
getIdentity: ['validate', ({}, cbk) =>
|
|
101
|
+
getIdentity: ['validate', ({}, cbk) => {
|
|
102
|
+
return getIdentity({lnd: args.lnd}, cbk);
|
|
103
|
+
}],
|
|
106
104
|
|
|
107
105
|
// Get methods to confim partial signing is supported
|
|
108
106
|
getMethods: ['validate', ({}, cbk) => getMethods({lnd: args.lnd}, cbk)],
|
|
@@ -134,18 +132,16 @@ module.exports = (args, cbk) => {
|
|
|
134
132
|
|
|
135
133
|
// Fund and assemble the group
|
|
136
134
|
create: [
|
|
137
|
-
'ecp',
|
|
138
135
|
'confirmBalance',
|
|
139
136
|
'confirmSigner',
|
|
140
137
|
'getBalance',
|
|
141
138
|
'getIdentity',
|
|
142
|
-
({
|
|
139
|
+
({getIdentity}, cbk) =>
|
|
143
140
|
{
|
|
144
141
|
const announced = [];
|
|
145
142
|
const members = [getIdentity.public_key].concat(args.members);
|
|
146
143
|
|
|
147
144
|
const coordinate = assembleChannelGroup({
|
|
148
|
-
ecp,
|
|
149
145
|
capacity: args.capacity,
|
|
150
146
|
count: args.count,
|
|
151
147
|
identity: getIdentity.public_key,
|
|
@@ -18,7 +18,6 @@ const transactionFeeRate = require('./../transaction_fee_rate');
|
|
|
18
18
|
{
|
|
19
19
|
capacity: <Output Size Tokens Number>
|
|
20
20
|
count: <Fanout Members Count Number>
|
|
21
|
-
ecp: <ECPair Library Object>
|
|
22
21
|
identity: <Coordinator Identity Public Key Hex String>
|
|
23
22
|
inputs: [<Utxo Outpoint String>]
|
|
24
23
|
lnd: <Authenticated LND API Object>
|
|
@@ -74,7 +73,6 @@ module.exports = args => {
|
|
|
74
73
|
const coordinator = coordinateFanout({
|
|
75
74
|
capacity: args.capacity,
|
|
76
75
|
count: args.count,
|
|
77
|
-
ecp: args.ecp,
|
|
78
76
|
identity: args.identity,
|
|
79
77
|
lnd: args.lnd,
|
|
80
78
|
members: args.members,
|
|
@@ -150,18 +148,17 @@ module.exports = args => {
|
|
|
150
148
|
|
|
151
149
|
try {
|
|
152
150
|
// Merge all the partial signed PSBTs into a single PSBT with all sigs
|
|
153
|
-
const combined = combinePsbts({psbts
|
|
151
|
+
const combined = combinePsbts({psbts});
|
|
154
152
|
|
|
155
153
|
// Finalize the PSBT to convert partial signatures to final signatures
|
|
156
|
-
const finalized = finalizePsbt({
|
|
154
|
+
const finalized = finalizePsbt({psbt: combined.psbt});
|
|
157
155
|
|
|
158
156
|
// Pull out the raw transaction from the PSBT
|
|
159
157
|
const {transaction} = extractTransaction({
|
|
160
|
-
ecp: args.ecp,
|
|
161
158
|
psbt: finalized.psbt,
|
|
162
159
|
});
|
|
163
160
|
|
|
164
|
-
const {inputs} = decodePsbt({
|
|
161
|
+
const {inputs} = decodePsbt({psbt: combined.psbt});
|
|
165
162
|
|
|
166
163
|
// Make sure the final transaction fee rate is not too low
|
|
167
164
|
if (transactionFeeRate({inputs, transaction}).rate < args.rate) {
|
|
@@ -29,7 +29,6 @@ const uniq = arr => Array.from(new Set(arr));
|
|
|
29
29
|
{
|
|
30
30
|
capacity: <Fanout Output Capacity Tokens Number>
|
|
31
31
|
count: <Group Members Count Number>
|
|
32
|
-
ecp: <ECPair Library Object>
|
|
33
32
|
identity: <Coordinator Identity Public Key Hex String>
|
|
34
33
|
lnd: <Authenticated LND API Object>
|
|
35
34
|
[members]: [<Member Node Id Public Key Hex String>]
|
|
@@ -79,7 +78,7 @@ const uniq = arr => Array.from(new Set(arr));
|
|
|
79
78
|
// All members have submitted their partial signatures
|
|
80
79
|
@event 'signed'
|
|
81
80
|
*/
|
|
82
|
-
module.exports = ({capacity, count,
|
|
81
|
+
module.exports = ({capacity, count, identity, lnd, members, rate}) => {
|
|
83
82
|
if (!capacity) {
|
|
84
83
|
throw new Error('ExpectedOutputSizeCapacityToCoordinateFanoutGroup');
|
|
85
84
|
}
|
|
@@ -88,10 +87,6 @@ module.exports = ({capacity, count, ecp, identity, lnd, members, rate}) => {
|
|
|
88
87
|
throw new Error('ExpectedHigherGroupMembersCountToCoordinateFanoutGroup');
|
|
89
88
|
}
|
|
90
89
|
|
|
91
|
-
if (!ecp) {
|
|
92
|
-
throw new Error('ExpectedEcLibraryToCoordinateFanoutGroup');
|
|
93
|
-
}
|
|
94
|
-
|
|
95
90
|
if (!identity) {
|
|
96
91
|
throw new Error('ExpectedSelfIdentityPublicKeyToCoordinateFanoutGroup');
|
|
97
92
|
}
|
|
@@ -308,15 +303,15 @@ module.exports = ({capacity, count, ecp, identity, lnd, members, rate}) => {
|
|
|
308
303
|
}
|
|
309
304
|
|
|
310
305
|
try {
|
|
311
|
-
decodeSignedFunding({
|
|
306
|
+
decodeSignedFunding({records: req.records});
|
|
312
307
|
} catch (err) {
|
|
313
308
|
return res.failure([400, err.message]);
|
|
314
309
|
}
|
|
315
310
|
|
|
316
|
-
const signed = decodeSignedFunding({
|
|
311
|
+
const signed = decodeSignedFunding({records: req.records});
|
|
317
312
|
|
|
318
313
|
if (signed.p2tr.find(n => n.length !== keySpendSignatureHexLength)) {
|
|
319
|
-
return failure([400, 'InvalidSignatureLengthForKeySpend']);
|
|
314
|
+
return res.failure([400, 'InvalidSignatureLengthForKeySpend']);
|
|
320
315
|
}
|
|
321
316
|
|
|
322
317
|
// Register the signed funding
|
|
@@ -7,7 +7,6 @@ const {getMethods} = require('ln-service');
|
|
|
7
7
|
const {getUtxos} = require('ln-service');
|
|
8
8
|
const {getNodeAlias} = require('ln-sync');
|
|
9
9
|
const {returnResult} = require('asyncjs-util');
|
|
10
|
-
const tinysecp = require('tiny-secp256k1');
|
|
11
10
|
|
|
12
11
|
const assembleFanoutGroup = require('./assemble_fanout_group');
|
|
13
12
|
|
|
@@ -52,9 +51,6 @@ const sumOf = arr => arr.reduce((sum, n) => sum + n, Number());
|
|
|
52
51
|
module.exports = (args, cbk) => {
|
|
53
52
|
return new Promise((resolve, reject) => {
|
|
54
53
|
return asyncAuto({
|
|
55
|
-
// Import ECPair library
|
|
56
|
-
ecp: async () => (await import('ecpair')).ECPairFactory(tinysecp),
|
|
57
|
-
|
|
58
54
|
// Check arguments
|
|
59
55
|
validate: cbk => {
|
|
60
56
|
if (!args.ask) {
|
|
@@ -209,19 +205,17 @@ module.exports = (args, cbk) => {
|
|
|
209
205
|
|
|
210
206
|
// Fund and assemble the group
|
|
211
207
|
create: [
|
|
212
|
-
'ecp',
|
|
213
208
|
'confirmBalance',
|
|
214
209
|
'confirmSigner',
|
|
215
210
|
'getBalance',
|
|
216
211
|
'getIdentity',
|
|
217
212
|
'utxos',
|
|
218
|
-
({
|
|
213
|
+
({getIdentity, utxos}, cbk) =>
|
|
219
214
|
{
|
|
220
215
|
const announced = [];
|
|
221
216
|
const members = [getIdentity.public_key].concat(args.members);
|
|
222
217
|
|
|
223
218
|
const coordinate = assembleFanoutGroup({
|
|
224
|
-
ecp,
|
|
225
219
|
capacity: args.capacity,
|
|
226
220
|
count: args.count,
|
|
227
221
|
identity: getIdentity.public_key,
|
|
@@ -6,7 +6,6 @@ const {fundPsbt} = require('ln-service');
|
|
|
6
6
|
const {decodePsbt} = require('psbt');
|
|
7
7
|
const {getUtxos} = require('ln-service');
|
|
8
8
|
const {returnResult} = require('asyncjs-util');
|
|
9
|
-
const tinysecp = require('tiny-secp256k1');
|
|
10
9
|
const {unlockUtxo} = require('ln-service');
|
|
11
10
|
|
|
12
11
|
const allowedAddressFormats = ['p2tr', 'p2wpkh'];
|
|
@@ -52,9 +51,6 @@ const sumOf = arr => arr.reduce((sum, n) => sum + n, 0);
|
|
|
52
51
|
module.exports = ({capacity, inputs, lnd, outputs, rate}, cbk) => {
|
|
53
52
|
return new Promise((resolve, reject) => {
|
|
54
53
|
return asyncAuto({
|
|
55
|
-
// Import ECPair library
|
|
56
|
-
ecp: async () => (await import('ecpair')).ECPairFactory(tinysecp),
|
|
57
|
-
|
|
58
54
|
// Check arguments
|
|
59
55
|
validate: cbk => {
|
|
60
56
|
if (!capacity) {
|
|
@@ -157,10 +153,10 @@ module.exports = ({capacity, inputs, lnd, outputs, rate}, cbk) => {
|
|
|
157
153
|
}],
|
|
158
154
|
|
|
159
155
|
// Put together final funding elements to use for PSBT construction
|
|
160
|
-
funding: ['
|
|
156
|
+
funding: ['fund', ({fund}, cbk) => {
|
|
161
157
|
const change = fund.outputs.find(n => n.is_change) || {};
|
|
162
158
|
const funding = fund.outputs.filter(n => !n.is_change);
|
|
163
|
-
const {inputs} = decodePsbt({
|
|
159
|
+
const {inputs} = decodePsbt({psbt: fund.psbt});
|
|
164
160
|
|
|
165
161
|
// UTXOs have been selected
|
|
166
162
|
return cbk(null, {
|
|
@@ -2,14 +2,12 @@ const EventEmitter = require('events');
|
|
|
2
2
|
|
|
3
3
|
const asyncAuto = require('async/auto');
|
|
4
4
|
const {decodePsbt} = require('psbt');
|
|
5
|
-
const tinysecp = require('tiny-secp256k1');
|
|
6
5
|
const {Transaction} = require('bitcoinjs-lib');
|
|
7
6
|
|
|
8
7
|
const getFanoutFunding = require('./get_fanout_funding');
|
|
9
8
|
const {registerGroupConnected} = require('./../p2p');
|
|
10
9
|
const {registerFanoutProposal} = require('./../p2p');
|
|
11
10
|
const {registerFanoutSigned} = require('./../p2p');
|
|
12
|
-
const {serviceTypeRegisterPendingFanout} = require('./../../service_types')
|
|
13
11
|
|
|
14
12
|
const {fromHex} = Transaction;
|
|
15
13
|
const {isArray} = Array;
|
|
@@ -44,9 +42,6 @@ module.exports = (args, cbk) => {
|
|
|
44
42
|
const emitter = new EventEmitter();
|
|
45
43
|
|
|
46
44
|
asyncAuto({
|
|
47
|
-
// Import ECPair library
|
|
48
|
-
ecp: async () => (await import('ecpair')).ECPairFactory(tinysecp),
|
|
49
|
-
|
|
50
45
|
// Check arguments
|
|
51
46
|
validate: cbk => {
|
|
52
47
|
if (!isArray(args.inputs)) {
|
|
@@ -130,8 +125,8 @@ module.exports = (args, cbk) => {
|
|
|
130
125
|
}],
|
|
131
126
|
|
|
132
127
|
// Decode the unsigned PSBT given back by registration
|
|
133
|
-
transaction: ['
|
|
134
|
-
const psbt = decodePsbt({
|
|
128
|
+
transaction: ['register', ({register}, cbk) => {
|
|
129
|
+
const psbt = decodePsbt({psbt: register.psbt});
|
|
135
130
|
|
|
136
131
|
const tx = fromHex(psbt.unsigned_transaction);
|
|
137
132
|
|
|
@@ -5,7 +5,6 @@ const {fundPendingChannels} = require('ln-service');
|
|
|
5
5
|
const {getPendingChannels} = require('ln-service');
|
|
6
6
|
const {returnResult} = require('asyncjs-util');
|
|
7
7
|
const {signAndFundPsbt} = require('ln-sync');
|
|
8
|
-
const tinysecp = require('tiny-secp256k1');
|
|
9
8
|
const {Transaction} = require('bitcoinjs-lib');
|
|
10
9
|
|
|
11
10
|
const {fromHex} = Transaction;
|
|
@@ -45,9 +44,6 @@ const times = 500;
|
|
|
45
44
|
module.exports = ({id, lnd, psbt, utxos}, cbk) => {
|
|
46
45
|
return new Promise((resolve, reject) => {
|
|
47
46
|
return asyncAuto({
|
|
48
|
-
// Import ECPair library
|
|
49
|
-
ecp: async () => (await import('ecpair')).ECPairFactory(tinysecp),
|
|
50
|
-
|
|
51
47
|
// Check arguments
|
|
52
48
|
validate: cbk => {
|
|
53
49
|
if (!lnd) {
|
|
@@ -86,13 +82,13 @@ module.exports = ({id, lnd, psbt, utxos}, cbk) => {
|
|
|
86
82
|
}],
|
|
87
83
|
|
|
88
84
|
// Confirm that the outgoing pending channel is present
|
|
89
|
-
confirmOutPending: ['
|
|
85
|
+
confirmOutPending: ['fundChannel', ({}, cbk) => {
|
|
90
86
|
// Exit early when this is a pair channel and there is no proposal
|
|
91
87
|
if (!id) {
|
|
92
88
|
return cbk();
|
|
93
89
|
}
|
|
94
90
|
|
|
95
|
-
const tx = fromHex(decodePsbt({
|
|
91
|
+
const tx = fromHex(decodePsbt({psbt}).unsigned_transaction);
|
|
96
92
|
|
|
97
93
|
// Wait for the outgoing pending channel to be present
|
|
98
94
|
return asyncRetry({interval, times}, cbk => {
|
|
@@ -3,11 +3,8 @@ const EventEmitter = require('events');
|
|
|
3
3
|
const asyncAuto = require('async/auto');
|
|
4
4
|
const asyncReflect = require('async/reflect');
|
|
5
5
|
const asyncRetry = require('async/retry');
|
|
6
|
-
const {cancelPendingChannel} = require('ln-service');
|
|
7
6
|
const {decodePsbt} = require('psbt');
|
|
8
7
|
const {deletePendingChannel} = require('ln-service');
|
|
9
|
-
const {returnResult} = require('asyncjs-util');
|
|
10
|
-
const tinysecp = require('tiny-secp256k1');
|
|
11
8
|
const {Transaction} = require('bitcoinjs-lib');
|
|
12
9
|
|
|
13
10
|
const {confirmIncomingChannel} = require('./funding');
|
|
@@ -56,9 +53,6 @@ module.exports = ({capacity, coordinator, count, id, lnd, rate}, cbk) => {
|
|
|
56
53
|
const emitter = new EventEmitter();
|
|
57
54
|
|
|
58
55
|
asyncAuto({
|
|
59
|
-
// Import ECPair library
|
|
60
|
-
ecp: async () => (await import('ecpair')).ECPairFactory(tinysecp),
|
|
61
|
-
|
|
62
56
|
// Check arguments
|
|
63
57
|
validate: cbk => {
|
|
64
58
|
if (!capacity) {
|
|
@@ -150,13 +144,12 @@ module.exports = ({capacity, coordinator, count, id, lnd, rate}, cbk) => {
|
|
|
150
144
|
|
|
151
145
|
// Decode the unsigned PSBT
|
|
152
146
|
transaction: [
|
|
153
|
-
'ecp',
|
|
154
147
|
'propose',
|
|
155
148
|
'register',
|
|
156
|
-
({
|
|
149
|
+
({propose, register}, cbk) =>
|
|
157
150
|
{
|
|
158
151
|
const funding = hexAsBuffer(propose.funding);
|
|
159
|
-
const psbt = decodePsbt({
|
|
152
|
+
const psbt = decodePsbt({psbt: register.psbt});
|
|
160
153
|
|
|
161
154
|
const tx = fromHex(psbt.unsigned_transaction);
|
|
162
155
|
|
|
@@ -169,11 +162,10 @@ module.exports = ({capacity, coordinator, count, id, lnd, rate}, cbk) => {
|
|
|
169
162
|
|
|
170
163
|
// Confirm the incoming channel
|
|
171
164
|
incoming: [
|
|
172
|
-
'ecp',
|
|
173
165
|
'partners',
|
|
174
166
|
'register',
|
|
175
167
|
'transaction',
|
|
176
|
-
asyncReflect(({
|
|
168
|
+
asyncReflect(({partners, register, transaction}, cbk) =>
|
|
177
169
|
{
|
|
178
170
|
// Exit early when there is no inbound partner
|
|
179
171
|
if (!partners.inbound) {
|
|
@@ -3,14 +3,12 @@ const {decodePsbt} = require('psbt');
|
|
|
3
3
|
const findRecord = (records, type) => records.find(n => n.type === type);
|
|
4
4
|
const {isArray} = Array;
|
|
5
5
|
const nonEmpty = arr => arr.filter(n => !!n);
|
|
6
|
-
const typeGroupChannelId = '1';
|
|
7
6
|
const typeSignedFunding = '2';
|
|
8
7
|
const typeVersion = '0';
|
|
9
8
|
|
|
10
9
|
/** Decode signed funding records
|
|
11
10
|
|
|
12
11
|
{
|
|
13
|
-
ecp: <ECPair Library Object>
|
|
14
12
|
records: [{
|
|
15
13
|
type: <Type Number String>
|
|
16
14
|
value: <Value Hex String>
|
|
@@ -26,7 +24,7 @@ const typeVersion = '0';
|
|
|
26
24
|
psbt: <Signed PSBT Hex String>
|
|
27
25
|
}
|
|
28
26
|
*/
|
|
29
|
-
module.exports = ({
|
|
27
|
+
module.exports = ({records}) => {
|
|
30
28
|
if (!isArray(records)) {
|
|
31
29
|
throw new Error('ExpectedArrayOfRecordsToDecodeSignedFunding');
|
|
32
30
|
}
|
|
@@ -44,12 +42,12 @@ module.exports = ({ecp, records}) => {
|
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
try {
|
|
47
|
-
decodePsbt({
|
|
45
|
+
decodePsbt({psbt: signedFundingRecord.value});
|
|
48
46
|
} catch (err) {
|
|
49
47
|
throw new Error('ExpectedValidPsbtRecordInSignedFunding');
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
const {inputs} = decodePsbt({
|
|
50
|
+
const {inputs} = decodePsbt({psbt: signedFundingRecord.value});
|
|
53
51
|
|
|
54
52
|
return {
|
|
55
53
|
p2tr: nonEmpty(inputs.map(input => input.taproot_key_spend_sig)),
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
const asyncAuto = require('async/auto');
|
|
2
2
|
const asyncReflect = require('async/reflect');
|
|
3
3
|
const asyncRetry = require('async/retry');
|
|
4
|
-
const {cancelPendingChannel} = require('ln-service');
|
|
5
4
|
const {connectPeer} = require('ln-sync');
|
|
6
5
|
const {decodePsbt} = require('psbt');
|
|
7
6
|
const {returnResult} = require('asyncjs-util');
|
|
8
7
|
const {signAndFundPsbt} = require('ln-sync');
|
|
9
|
-
const tinysecp = require('tiny-secp256k1');
|
|
10
8
|
const {Transaction} = require('bitcoinjs-lib');
|
|
11
9
|
|
|
12
10
|
const {decodeUnsignedFunding} = require('./../messages');
|
|
@@ -23,7 +21,6 @@ const {fromHex} = Transaction;
|
|
|
23
21
|
const hexAsBuffer = hex => Buffer.from(hex, 'hex');
|
|
24
22
|
const {isArray} = Array;
|
|
25
23
|
const missingGroupPartners = 'NoGroupPartnersFound';
|
|
26
|
-
const typeGroupChannelId = '1';
|
|
27
24
|
|
|
28
25
|
/** Register fanout proposal with the coordinator
|
|
29
26
|
|
|
@@ -56,9 +53,6 @@ const typeGroupChannelId = '1';
|
|
|
56
53
|
module.exports = (args, cbk) => {
|
|
57
54
|
return new Promise((resolve, reject) => {
|
|
58
55
|
return asyncAuto({
|
|
59
|
-
// Import ECPair library to use for funding checks
|
|
60
|
-
ecp: async () => (await import('ecpair')).ECPairFactory(tinysecp),
|
|
61
|
-
|
|
62
56
|
// Check arguments
|
|
63
57
|
validate: cbk => {
|
|
64
58
|
if (!args.capacity) {
|
|
@@ -152,14 +146,14 @@ module.exports = (args, cbk) => {
|
|
|
152
146
|
})],
|
|
153
147
|
|
|
154
148
|
// Check the unsigned funding transaction represents the funding
|
|
155
|
-
check: ['
|
|
149
|
+
check: ['request', ({request}, cbk) => {
|
|
156
150
|
try {
|
|
157
|
-
decodePsbt({
|
|
151
|
+
decodePsbt({psbt: request.value});
|
|
158
152
|
} catch (err) {
|
|
159
153
|
return cbk([503, 'ExpectedValidUnsignedResponsePsbt', {err}]);
|
|
160
154
|
}
|
|
161
155
|
|
|
162
|
-
const psbt = decodePsbt({
|
|
156
|
+
const psbt = decodePsbt({psbt: request.value});
|
|
163
157
|
|
|
164
158
|
if (!!psbt.inputs.find(n => !n.witness_utxo)) {
|
|
165
159
|
return cbk([503, 'ExpectedAllFanoutInputsSpendingWitnessUtxos']);
|
|
@@ -5,7 +5,6 @@ const {cancelPendingChannel} = require('ln-service');
|
|
|
5
5
|
const {connectPeer} = require('ln-sync');
|
|
6
6
|
const {decodePsbt} = require('psbt');
|
|
7
7
|
const {returnResult} = require('asyncjs-util');
|
|
8
|
-
const tinysecp = require('tiny-secp256k1');
|
|
9
8
|
const {Transaction} = require('bitcoinjs-lib');
|
|
10
9
|
|
|
11
10
|
const {decodeUnsignedFunding} = require('./../messages');
|
|
@@ -23,7 +22,6 @@ const {fromHex} = Transaction;
|
|
|
23
22
|
const hexAsBuffer = hex => Buffer.from(hex, 'hex');
|
|
24
23
|
const {isArray} = Array;
|
|
25
24
|
const missingGroupPartners = 'NoGroupPartnersFound';
|
|
26
|
-
const typeGroupChannelId = '1';
|
|
27
25
|
|
|
28
26
|
/** Register pending open with the coordinator
|
|
29
27
|
|
|
@@ -56,9 +54,6 @@ const typeGroupChannelId = '1';
|
|
|
56
54
|
module.exports = (args, cbk) => {
|
|
57
55
|
return new Promise((resolve, reject) => {
|
|
58
56
|
return asyncAuto({
|
|
59
|
-
// Import ECPair library
|
|
60
|
-
ecp: async () => (await import('ecpair')).ECPairFactory(tinysecp),
|
|
61
|
-
|
|
62
57
|
// Check arguments
|
|
63
58
|
validate: cbk => {
|
|
64
59
|
if (!args.capacity) {
|
|
@@ -175,14 +170,14 @@ module.exports = (args, cbk) => {
|
|
|
175
170
|
}],
|
|
176
171
|
|
|
177
172
|
// Check the unsigned funding transaction represents the partial open
|
|
178
|
-
check: ['clean', '
|
|
173
|
+
check: ['clean', 'request', ({request}, cbk) => {
|
|
179
174
|
try {
|
|
180
|
-
decodePsbt({
|
|
175
|
+
decodePsbt({psbt: request.value});
|
|
181
176
|
} catch (err) {
|
|
182
177
|
return cbk([503, 'ExpectedValidUnsignedResponsePsbt', {err}]);
|
|
183
178
|
}
|
|
184
179
|
|
|
185
|
-
const psbt = decodePsbt({
|
|
180
|
+
const psbt = decodePsbt({psbt: request.value});
|
|
186
181
|
|
|
187
182
|
if (!!psbt.inputs.find(n => !n.witness_utxo)) {
|
|
188
183
|
return cbk([503, 'ExpectedAllGroupInputsSpendingWitnessUtxos']);
|
package/index.js
CHANGED
|
@@ -3,6 +3,7 @@ const {confirmServiceUse} = require('./client');
|
|
|
3
3
|
const {createAnchoredTrade} = require('./trades');
|
|
4
4
|
const {createGroupChannel} = require('./groups');
|
|
5
5
|
const {createGroupFanout} = require('./groups');
|
|
6
|
+
const {createSupportOffer} = require('./support');
|
|
6
7
|
const {decodeTrade} = require('./trades');
|
|
7
8
|
const {encodeTrade} = require('./trades');
|
|
8
9
|
const {getAnchoredTrade} = require('./trades');
|
|
@@ -19,6 +20,7 @@ const {schema} = require('./services');
|
|
|
19
20
|
const {serviceAnchoredTrades} = require('./trades');
|
|
20
21
|
const {servicePaidRequests} = require('./server');
|
|
21
22
|
const {servicePeerRequests} = require('./p2p');
|
|
23
|
+
const {serviceSupportOffer} = require('./support');
|
|
22
24
|
|
|
23
25
|
const serviceIds = schema.types;
|
|
24
26
|
|
|
@@ -28,6 +30,7 @@ module.exports = {
|
|
|
28
30
|
createAnchoredTrade,
|
|
29
31
|
createGroupChannel,
|
|
30
32
|
createGroupFanout,
|
|
33
|
+
createSupportOffer,
|
|
31
34
|
decodeTrade,
|
|
32
35
|
encodeTrade,
|
|
33
36
|
getAnchoredTrade,
|
|
@@ -44,4 +47,5 @@ module.exports = {
|
|
|
44
47
|
serviceIds,
|
|
45
48
|
servicePaidRequests,
|
|
46
49
|
servicePeerRequests,
|
|
50
|
+
serviceSupportOffer,
|
|
47
51
|
};
|