ln-service
Advanced tools
Comparing version 57.14.2 to 57.14.3
# Versions | ||
## 57.14.2 | ||
## 57.14.3 | ||
@@ -5,0 +5,0 @@ - `getChannel`: Add support for specifying `transaction_id` and |
@@ -10,3 +10,3 @@ { | ||
"dependencies": { | ||
"bolt07": "1.9.3", | ||
"bolt07": "1.9.4", | ||
"invoices": "3.0.0", | ||
@@ -76,3 +76,3 @@ "lightning": "10.14.1", | ||
}, | ||
"version": "57.14.2" | ||
"version": "57.14.3" | ||
} |
@@ -27,126 +27,128 @@ const {deepStrictEqual} = require('node:assert').strict; | ||
test(`Get a route to a destination`, async () => { | ||
const {kill, nodes} = await spawnLightningCluster({size}); | ||
await asyncRetry({}, async () => { | ||
const {kill, nodes} = await spawnLightningCluster({size}); | ||
const [control, target, remote] = nodes; | ||
const [control, target, remote] = nodes; | ||
await control.generate({count: 500}); | ||
await control.generate({count: 200}); | ||
await setupChannel({ | ||
generate: control.generate, | ||
lnd: control.lnd, | ||
to: target, | ||
}); | ||
await setupChannel({ | ||
generate: control.generate, | ||
lnd: control.lnd, | ||
to: target, | ||
}); | ||
await setupChannel({ | ||
generate: target.generate, | ||
give_tokens: 1e5, | ||
is_private: true, | ||
lnd: target.lnd, | ||
to: remote, | ||
}); | ||
await setupChannel({ | ||
generate: target.generate, | ||
give_tokens: 1e5, | ||
is_private: true, | ||
lnd: target.lnd, | ||
to: remote, | ||
}); | ||
const invoice = await asyncRetry({interval, times}, async () => { | ||
const invoice = await createInvoice({ | ||
tokens, | ||
is_including_private_channels: true, | ||
lnd: remote.lnd, | ||
const invoice = await asyncRetry({interval, times}, async () => { | ||
const invoice = await createInvoice({ | ||
tokens, | ||
is_including_private_channels: true, | ||
lnd: remote.lnd, | ||
}); | ||
const {routes} = parsePaymentRequest({request: invoice.request}); | ||
// Wait for private routes to get picked up | ||
if (!routes) { | ||
await cancelHodlInvoice({id: invoice.id, lnd: remote.lnd}); | ||
throw new Error('ExpectedRouteForInvoice'); | ||
} | ||
return invoice; | ||
}); | ||
const {routes} = parsePaymentRequest({request: invoice.request}); | ||
const parsed = parsePaymentRequest({request: invoice.request}); | ||
// Wait for private routes to get picked up | ||
if (!routes) { | ||
await cancelHodlInvoice({id: invoice.id, lnd: remote.lnd}); | ||
await asyncRetry({interval, times}, async () => { | ||
const {route} = await getRouteToDestination({ | ||
destination: parsed.destination, | ||
features: parsed.features, | ||
lnd: control.lnd, | ||
payment: parsed.payment, | ||
routes: parsed.routes, | ||
mtokens: parsed.mtokens, | ||
total_mtokens: parsed.mtokens, | ||
}); | ||
throw new Error('ExpectedRouteForInvoice'); | ||
} | ||
const paid = await payViaRoutes({ | ||
id: parsed.id, | ||
lnd: control.lnd, | ||
routes: [route], | ||
}); | ||
return invoice; | ||
}); | ||
strictEqual(invoice.secret, paid.secret, 'Paid multi-hop private route'); | ||
}); | ||
const parsed = parsePaymentRequest({request: invoice.request}); | ||
const inv = await createInvoice({tokens, lnd: target.lnd}); | ||
await asyncRetry({interval, times}, async () => { | ||
const {route} = await getRouteToDestination({ | ||
destination: parsed.destination, | ||
features: parsed.features, | ||
const invDetails = await decodePaymentRequest({ | ||
lnd: control.lnd, | ||
payment: parsed.payment, | ||
routes: parsed.routes, | ||
mtokens: parsed.mtokens, | ||
total_mtokens: parsed.mtokens, | ||
request: inv.request, | ||
}); | ||
const paid = await payViaRoutes({ | ||
id: parsed.id, | ||
const controlToTarget = await getRouteToDestination({ | ||
destination: target.id, | ||
features: invDetails.features, | ||
lnd: control.lnd, | ||
routes: [route], | ||
messages: [message], | ||
payment: invDetails.payment, | ||
tokens: invDetails.tokens / [control, remote].length, | ||
total_mtokens: invDetails.mtokens, | ||
}); | ||
strictEqual(invoice.secret, paid.secret, 'Paid multi-hop private route'); | ||
}); | ||
const remoteToTarget = await getRouteToDestination({ | ||
destination: target.id, | ||
features: invDetails.features, | ||
lnd: remote.lnd, | ||
messages: [message], | ||
payment: invDetails.payment, | ||
tokens: invDetails.tokens / [control, remote].length, | ||
total_mtokens: invDetails.mtokens, | ||
}); | ||
const inv = await createInvoice({tokens, lnd: target.lnd}); | ||
try { | ||
const [controlPay, remotePay] = await all([ | ||
payViaRoutes({ | ||
id: invDetails.id, | ||
lnd: control.lnd, | ||
routes: [controlToTarget.route], | ||
}), | ||
payViaRoutes({ | ||
id: invDetails.id, | ||
lnd: remote.lnd, | ||
routes: [remoteToTarget.route], | ||
}), | ||
]); | ||
const invDetails = await decodePaymentRequest({ | ||
lnd: control.lnd, | ||
request: inv.request, | ||
}); | ||
strictEqual(controlPay.secret, inv.secret, 'Control paid for secret'); | ||
strictEqual(remotePay.secret, inv.secret, 'Remote paid for secret'); | ||
const controlToTarget = await getRouteToDestination({ | ||
destination: target.id, | ||
features: invDetails.features, | ||
lnd: control.lnd, | ||
messages: [message], | ||
payment: invDetails.payment, | ||
tokens: invDetails.tokens / [control, remote].length, | ||
total_mtokens: invDetails.mtokens, | ||
}); | ||
const remoteToTarget = await getRouteToDestination({ | ||
destination: target.id, | ||
features: invDetails.features, | ||
lnd: remote.lnd, | ||
messages: [message], | ||
payment: invDetails.payment, | ||
tokens: invDetails.tokens / [control, remote].length, | ||
total_mtokens: invDetails.mtokens, | ||
}); | ||
try { | ||
const [controlPay, remotePay] = await all([ | ||
payViaRoutes({ | ||
const {payments} = await getInvoice({ | ||
id: invDetails.id, | ||
lnd: control.lnd, | ||
routes: [controlToTarget.route], | ||
}), | ||
payViaRoutes({ | ||
id: invDetails.id, | ||
lnd: remote.lnd, | ||
routes: [remoteToTarget.route], | ||
}), | ||
]); | ||
lnd: target.lnd, | ||
}); | ||
strictEqual(controlPay.secret, inv.secret, 'Control paid for secret'); | ||
strictEqual(remotePay.secret, inv.secret, 'Remote paid for secret'); | ||
const [payment1, payment2] = payments; | ||
const {payments} = await getInvoice({ | ||
id: invDetails.id, | ||
lnd: target.lnd, | ||
}); | ||
const [message1] = payment1.messages; | ||
const [message2] = payment2.messages; | ||
const [payment1, payment2] = payments; | ||
deepStrictEqual(message1, message, 'Target received message'); | ||
deepStrictEqual(message2, message, 'Target received both messages'); | ||
} catch (err) { | ||
strictEqual(err, null, 'Unexpected error paying invoice'); | ||
} | ||
const [message1] = payment1.messages; | ||
const [message2] = payment2.messages; | ||
await kill({}); | ||
}); | ||
deepStrictEqual(message1, message, 'Target received message'); | ||
deepStrictEqual(message2, message, 'Target received both messages'); | ||
} catch (err) { | ||
strictEqual(err, null, 'Unexpected error paying invoice'); | ||
} | ||
await kill({}); | ||
return; | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
AI-detected potential security risk
Supply chain riskAI has determined that this package may contain potential security issues or vulnerabilities.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
846950
179
14642
4
7
+ Addedbolt07@1.9.4(transitive)
Updatedbolt07@1.9.4