Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bolt07

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bolt07 - npm Package Compare versions

Comparing version 1.5.2 to 1.6.0

routing/as_tokens.js

5

CHANGELOG.md
# Versions
## 1.6.0
- `routeFromChannels`: Add support for `messages` in routes
- `routeFromHops`: Add method to calculate a route from a set of hops
## 1.5.2
- Add `routeFromChannels` method to calculate a route from channels

2

index.js

@@ -7,2 +7,3 @@ const {chanFormat} = require('./ids');

const {routeFromChannels} = require('./routing');
const {routeFromHops} = require('./routing');

@@ -16,2 +17,3 @@ module.exports = {

routeFromChannels,
routeFromHops,
};

6

package.json

@@ -10,7 +10,7 @@ {

"dependencies": {
"bn.js": "5.1.2"
"bn.js": "5.1.3"
},
"description": "Utilities for working with bolt07 data formats",
"devDependencies": {
"@alexbosworth/tap": "14.10.9"
"tap": "14.10.8"
},

@@ -35,3 +35,3 @@ "keywords": [

},
"version": "1.5.2"
"version": "1.6.0"
}

@@ -262,4 +262,5 @@ # BOLT07

cltv_delta: <Locktime Delta Number>
fee_rate: <Fees Charged Per Million Tokens Number>
fee_rate: <Fees Charged in Millitokens Per Million Number>
is_disabled: <Channel Is Disabled Bool>
max_htlc_mtokens: <Maximum HTLC Millitokens Value String>
min_htlc_mtokens: <Minimum HTLC Millitokens Value String>

@@ -272,2 +273,6 @@ public_key: <Node Public Key String>

height: <Current Block Height Number>
[messages]: [{
type: <Message Type Number String>
value: <Message Raw Value Hex Encoded String>
}]
mtokens: <Millitokens To Send String>

@@ -296,2 +301,6 @@ [payment]: <Payment Identification Value Hex String>

}]
[messages]: [{
type: <Message Type Number String>
value: <Message Raw Value Hex Encoded String>
}]
mtokens: <Total Fee-Inclusive Millitokens String>

@@ -304,1 +313,54 @@ [payment]: <Payment Identification Value Hex String>

}
### routeFromHops
Given hops to a destination, construct a payable route
{
[cltv_delta]: <Final Cltv Delta Number>
height: <Current Block Height Number>
hops: [{
base_fee_mtokens: <Base Fee Millitokens String>
channel: <Standard Format Channel Id String>
[channel_capacity]: <Channel Capacity Tokens Number>
cltv_delta: <CLTV Delta Number>
fee_rate: <Fee Rate In Millitokens Per Million Number>
public_key: <Next Hop Public Key Hex String>
}]
initial_cltv: <Initial CLTV Delta Number>
[messages]: [{
type: <Message Type Number String>
value: <Message Raw Value Hex Encoded String>
}]
mtokens: <Millitokens To Send String>
[payment]: <Payment Identification Value Hex String>
[total_mtokens]: <Total Millitokens For Sharded Payments String>
}
@throws
<Error>
@returns
{
fee: <Route Fee Tokens Number>
fee_mtokens: <Route Fee Millitokens String>
hops: [{
channel: <Standard Format Channel Id String>
channel_capacity: <Channel Capacity Tokens Number>
fee: <Fee Number>
fee_mtokens: <Fee Millitokens String>
forward: <Forward Tokens Number>
forward_mtokens: <Forward Millitokens String>
[public_key]: <Public Key Hex String>
timeout: <Timeout Block Height Number>
}]
[messages]: [{
type: <Message Type Number String>
value: <Message Raw Value Hex Encoded String>
}]
mtokens: <Total Fee-Inclusive Millitokens String>
[payment]: <Payment Identification Value Hex String>
timeout: <Timeout Block Height Number>
tokens: <Total Fee-Inclusive Tokens Number>
[total_mtokens]: <Sharded Payments Total Millitokens String>
}
const routeFromChannels = require('./route_from_channels');
const routeFromHops = require('./route_from_hops');
module.exports = {routeFromChannels};
module.exports = {routeFromChannels, routeFromHops};

@@ -19,4 +19,5 @@ const hopsFromChannels = require('./hops_from_channels');

cltv_delta: <Locktime Delta Number>
fee_rate: <Fees Charged Per Million Tokens Number>
fee_rate: <Fees Charged in Millitokens Per Million Number>
is_disabled: <Channel Is Disabled Bool>
max_htlc_mtokens: <Maximum HTLC Millitokens Value String>
min_htlc_mtokens: <Minimum HTLC Millitokens Value String>

@@ -29,2 +30,6 @@ public_key: <Node Public Key String>

height: <Current Block Height Number>
[messages]: [{
type: <Message Type Number String>
value: <Message Raw Value Hex Encoded String>
}]
mtokens: <Millitokens To Send String>

@@ -53,2 +58,6 @@ [payment]: <Payment Identification Value Hex String>

}]
[messages]: [{
type: <Message Type Number String>
value: <Message Raw Value Hex Encoded String>
}]
mtokens: <Total Fee-Inclusive Millitokens String>

@@ -89,2 +98,3 @@ [payment]: <Payment Identification Value Hex String>

initial_cltv: path.initial_cltv || defaultInitialCltvDelta,
messages: args.messages,
mtokens: args.mtokens,

@@ -91,0 +101,0 @@ payment: args.payment,

@@ -0,4 +1,4 @@

const asTokens = require('./as_tokens');
const policyFee = require('./policy_fee');
const asTokens = mtokens => Number(mtokens / BigInt(1e3));
const defaultCltvBuffer = 40;

@@ -23,2 +23,6 @@ const {isArray} = Array;

initial_cltv: <Initial CLTV Delta Number>
[messages]: [{
type: <Message Type Number String>
value: <Message Raw Value Hex Encoded String>
}]
mtokens: <Millitokens To Send String>

@@ -46,2 +50,6 @@ [payment]: <Payment Identification Value Hex String>

}]
[messages]: [{
type: <Message Type Number String>
value: <Message Raw Value Hex Encoded String>
}]
mtokens: <Total Fee-Inclusive Millitokens String>

@@ -117,5 +125,5 @@ [payment]: <Payment Identification Value Hex String>

channel_capacity: hop.channel_capacity,
fee: asTokens(feeMtokens),
fee: asTokens({mtokens: feeMtokens}).tokens,
fee_mtokens: feeMtokens.toString(),
forward: asTokens(forwardMtokens),
forward: asTokens({mtokens: forwardMtokens}).tokens,
forward_mtokens: forwardMtokens.toString(),

@@ -143,11 +151,12 @@ public_key: hop.public_key,

return {
fee: asTokens(totalFeeMtokens),
fee: asTokens({mtokens: totalFeeMtokens}).tokens,
fee_mtokens: totalFeeMtokens.toString(),
hops: backwardsPath.slice().reverse(),
messages: args.messages,
mtokens: totalMtokens.toString(),
payment: args.payment,
timeout: timeoutHeight + args.initial_cltv,
tokens: asTokens(totalMtokens),
tokens: asTokens({mtokens: totalMtokens}).tokens,
total_mtokens: args.total_mtokens,
};
};

@@ -1,2 +0,2 @@

const {test} = require('@alexbosworth/tap');
const {test} = require('tap');

@@ -3,0 +3,0 @@ const {chanFormat} = require('./../../');

@@ -1,2 +0,2 @@

const {test} = require('@alexbosworth/tap');
const {test} = require('tap');

@@ -3,0 +3,0 @@ const {chanNumber} = require('./../../');

@@ -1,2 +0,2 @@

const {test} = require('@alexbosworth/tap');
const {test} = require('tap');

@@ -3,0 +3,0 @@ const componentsFromBuffer = require('./../../ids/components_from_buffer');

@@ -1,2 +0,2 @@

const {test} = require('@alexbosworth/tap');
const {test} = require('tap');

@@ -3,0 +3,0 @@ const {decodeChanId} = require('./../../');

@@ -1,2 +0,2 @@

const {test} = require('@alexbosworth/tap');
const {test} = require('tap');

@@ -3,0 +3,0 @@ const {encodeChanId} = require('./../../');

@@ -1,2 +0,2 @@

const {test} = require('@alexbosworth/tap');
const {test} = require('tap');

@@ -3,0 +3,0 @@ const {rawChanId} = require('./../../');

@@ -1,2 +0,2 @@

const {test} = require('@alexbosworth/tap');
const {test} = require('tap');

@@ -3,0 +3,0 @@ const betaChannels = require('./../fixtures/graph_beta').channels;

@@ -1,2 +0,2 @@

const {test} = require('@alexbosworth/tap');
const {test} = require('tap');

@@ -3,0 +3,0 @@ const policyFee = require('./../../routing/policy_fee');

@@ -1,2 +0,2 @@

const {test} = require('@alexbosworth/tap');
const {test} = require('tap');

@@ -38,3 +38,3 @@ const {routeFromChannels} = require('./../../');

fee_rate: 1000,
cltv_delta: 1,
cltv_delta: undefined,
destination: 'b',

@@ -49,3 +49,3 @@ number: 1,

},
description: 'Single channel means no delays or fees',
description: 'An unknown CLTV is replaced',
expected: {

@@ -65,2 +65,3 @@ route: {

}],
messages: undefined,
mtokens: '100000',

@@ -78,2 +79,3 @@ timeout: 101,

fee_rate: 1000,
cltv_delta: 1,
destination: 'b',

@@ -88,3 +90,3 @@ number: 1,

},
description: 'Single channel with no cltv delta still returns route',
description: 'Single channel means no delays or fees',
expected: {

@@ -104,2 +106,3 @@ route: {

}],
messages: undefined,
mtokens: '100000',

@@ -161,2 +164,3 @@ timeout: 101,

],
messages: undefined,
mtokens: '100130',

@@ -213,27 +217,28 @@ timeout: 106,

timeout: 104,
},
{
channel: '2x2x2',
channel_capacity: 1000000,
fee: 0,
fee_mtokens: '1',
forward: 100,
forward_mtokens: '100000',
public_key: 'c',
timeout: 101,
},
{
channel: '3x3x3',
channel_capacity: 1000000,
fee: 0,
fee_mtokens: '0',
forward: 100,
forward_mtokens: '100000',
public_key: 'd',
timeout: 101,
},
],
mtokens: '100002',
timeout: 109,
tokens: 100,
},
{
channel: '2x2x2',
channel_capacity: 1000000,
fee: 0,
fee_mtokens: '1',
forward: 100,
forward_mtokens: '100000',
public_key: 'c',
timeout: 101,
},
{
channel: '3x3x3',
channel_capacity: 1000000,
fee: 0,
fee_mtokens: '0',
forward: 100,
forward_mtokens: '100000',
public_key: 'd',
timeout: 101,
},
],
messages: undefined,
mtokens: '100002',
timeout: 109,
tokens: 100,
},

@@ -309,2 +314,3 @@ },

],
messages: undefined,
mtokens: '102010',

@@ -383,2 +389,3 @@ timeout: 109,

],
messages: undefined,
mtokens: '101101',

@@ -505,2 +512,3 @@ timeout: 109,

],
messages: undefined,
mtokens: '1001003',

@@ -627,2 +635,3 @@ timeout: 1574992,

],
messages: undefined,
mtokens: '500001001',

@@ -782,2 +791,3 @@ timeout: 592381,

],
messages: undefined,
mtokens: '500002511',

@@ -904,2 +914,3 @@ timeout: 592506,

],
messages: undefined,
mtokens: '500001002',

@@ -906,0 +917,0 @@ timeout: 592354,

@@ -1,4 +0,4 @@

const {test} = require('@alexbosworth/tap');
const {test} = require('tap');
const routeFromHops = require('./../../routing/route_from_hops');
const {routeFromHops} = require('./../../');

@@ -92,2 +92,3 @@ const tests = [

],
messages: undefined,
mtokens: '1003602',

@@ -185,2 +186,3 @@ timeout: 590572,

],
messages: undefined,
mtokens: '300035300',

@@ -259,2 +261,3 @@ timeout: 551182,

],
messages: undefined,
mtokens: '2000015000',

@@ -261,0 +264,0 @@ timeout: 368,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc