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.1.0 to 1.2.0

lib/components_from_buffer.js

20

lib/decode_chan_id.js

@@ -1,7 +0,5 @@

const BN = require('bn.js');
const {blockIndexByteLen} = require('./constants');
const {blockIndexOffset} = require('./constants');
const componentsFromBuffer = require('./components_from_buffer');
const {decBase} = require('./constants');
const decodeFromBuffer = require('./decode_from_buffer');
const {endian} = require('./constants');

@@ -11,2 +9,3 @@ const {heightByteLen} = require('./constants');

const {outputIndexByteLen} = require('./constants');
const rawChanId = require('./raw_chan_id');

@@ -19,3 +18,4 @@ const heightBytesUsed = heightByteLen - heightByteOffset;

{
number: <Channel Id Number Format String>
[id]: <Channel Id Hex String>
[number]: <Channel Id Number Format String>
}

@@ -33,4 +33,4 @@

*/
module.exports = ({number}) => {
if (!number) {
module.exports = ({id, number}) => {
if (!id && !number) {
throw new Error('ExpectedShortChannelIdToDecode');

@@ -41,6 +41,10 @@ }

if (!!id && Buffer.from(id, 'hex').length !== idLen) {
throw new Error('UnexpectedLengthOfShortChannelId');
}
try {
const rawId = new BN(number, decBase).toArrayLike(Buffer, endian, idLen);
const channelId = !id ? rawChanId({number}).id : id;
const channel = decodeFromBuffer({id: rawId});
const channel = componentsFromBuffer({id: Buffer.from(channelId, 'hex')});

@@ -47,0 +51,0 @@ return {

2

package.json

@@ -31,3 +31,3 @@ {

},
"version": "1.1.0"
"version": "1.2.0"
}

@@ -16,2 +16,11 @@ const {test} = require('tap');

{
args: {id: '15fbe70000260000'},
description: 'Standard testnet channel id',
expected: {
block_height: 1440743,
block_index: 38,
output_index: 0,
},
},
{
args: {number: '590587277833404417'},

@@ -25,2 +34,11 @@ description: 'Standard bitcoin channel id',

},
{
args: {id: '0832300008200001'},
description: 'Standard bitcoin channel id',
expected: {
block_height: 537136,
block_index: 2080,
output_index: 1,
},
},
];

@@ -27,0 +45,0 @@

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