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.4.0 to 1.4.1

4

package.json

@@ -11,3 +11,3 @@ {

"devDependencies": {
"tap": "12.1.1"
"tap": "14.2.3"
},

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

},
"version": "1.4.0"
"version": "1.4.1"
}

@@ -17,24 +17,48 @@ # BOLT07

### Chan Format
```node
const {chanFormat} = require('bolt07');
const id = '15fbe70000260000';
const number = '1584113681139367936';
try {
const fromNumber = chanFormat({number}).channel;
// fromNumber === '1440743x38x0'
} catch (err) {
// valid channel, no error
}
try {
const fromId = chanFormat({id}).channel;
// fromId === '1440743x38x0'
} catch (err) {
// valid id, no error
}
```
### Chan Number
const {chanNumber} = require('bolt07');
const channel = '1440743x38x0';
const id = '15fbe70000260000';
try {
const fromChannel = chanNumber({channel}).number;
// fromChannel === '1584113681139367936'
} catch (err) {
// valid channel, no error
}
try {
const fromId = chanNumber({id}).number;
// fromId === '1584113681139367936'
} catch (err) {
// valid id, no error
}
```node
const {chanNumber} = require('bolt07');
const channel = '1440743x38x0';
const id = '15fbe70000260000';
try {
const fromChannel = chanNumber({channel}).number;
// fromChannel === '1584113681139367936'
} catch (err) {
// valid channel, no error
}
try {
const fromId = chanNumber({id}).number;
// fromId === '1584113681139367936'
} catch (err) {
// valid id, no error
}
```
### Decode Chan Id

@@ -44,35 +68,37 @@

const {decodeChanId} = require('bolt07');
const channel = '1440743x38x0';
const id = '15fbe70000260000';
const number = '1584113681139367936';
try {
const fromChannel = decodeChanId({channel});
// fromChannel.block_height === 1440743
// fromChannel.block_index === 38
// fromChannel.output_index === 0
} catch (err) {
// valid channel, no error
}
try {
const fromId = decodeChanId({id});
// fromId.block_height === 1440743
// fromId.block_index === 38
// fromId.output_index === 0
} catch (err) {
// valid id, no error
}
try {
const fromNumber = decodeChanId({channel});
// fromNumber.block_height === 1440743
// fromNumber.block_index === 38
// fromNumber.output_index === 0
} catch (err) {
// valid number, no error
}
```node
const {decodeChanId} = require('bolt07');
const channel = '1440743x38x0';
const id = '15fbe70000260000';
const number = '1584113681139367936';
try {
const fromChannel = decodeChanId({channel});
// fromChannel.block_height === 1440743
// fromChannel.block_index === 38
// fromChannel.output_index === 0
} catch (err) {
// valid channel, no error
}
try {
const fromId = decodeChanId({id});
// fromId.block_height === 1440743
// fromId.block_index === 38
// fromId.output_index === 0
} catch (err) {
// valid id, no error
}
try {
const fromNumber = decodeChanId({channel});
// fromNumber.block_height === 1440743
// fromNumber.block_index === 38
// fromNumber.output_index === 0
} catch (err) {
// valid number, no error
}
```
### Encode Chan Id

@@ -82,18 +108,20 @@

const {encodeChanId} = require('bolt07');
try {
const encoded = encodeChanId({
block_height: 1440743,
block_index: 38,
output_index: 0,
});
// encoded.channel === '1440743x38x0'
// encoded.id === '15fbe70000260000'
// encoded.number === '1584113681139367936'
} catch (err) {
// valid components, no error
}
```node
const {encodeChanId} = require('bolt07');
try {
const encoded = encodeChanId({
block_height: 1440743,
block_index: 38,
output_index: 0,
});
// encoded.channel === '1440743x38x0'
// encoded.id === '15fbe70000260000'
// encoded.number === '1584113681139367936'
} catch (err) {
// valid components, no error
}
```
### Raw Chan Id

@@ -103,20 +131,22 @@

const {rawChanId} = require('bolt07');
const channel = '1440743x38x0';
const number = '1584113681139367936';
try {
const idFromNumber = rawChanId({number}).id;
// idFromNumber === '15fbe70000260000'
} catch (err) {
// valid number, no error
}
try {
const idFromChannel = rawChanId({channel}).id;
// idFromChannel === '15fbe70000260000'
} catch (err) {
// valid channel, no error
}
```node
const {rawChanId} = require('bolt07');
const channel = '1440743x38x0';
const number = '1584113681139367936';
try {
const idFromNumber = rawChanId({number}).id;
// idFromNumber === '15fbe70000260000'
} catch (err) {
// valid number, no error
}
try {
const idFromChannel = rawChanId({channel}).id;
// idFromChannel === '15fbe70000260000'
} catch (err) {
// valid channel, no error
}
```
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