Comparing version 1.4.0 to 1.4.1
@@ -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" | ||
} |
198
README.md
@@ -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 | ||
} | ||
``` | ||
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
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
19360
149