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

invoices

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

invoices - npm Package Compare versions

Comparing version 2.1.0 to 2.1.2

5

bolt11/conf/tagged_fields.json

@@ -51,3 +51,8 @@ {

"type": "number"
},
"27": {
"label": "metadata",
"name": "m",
"type": "words"
}
}

@@ -154,2 +154,12 @@ const {createHash} = require('crypto');

case 'metadata':
if (!args.metadata) {
return {};
}
return {
field,
words: hexAsWords({hex: args.metadata}),
};
case 'min_final_cltv_expiry':

@@ -156,0 +166,0 @@ if (!args.cltv_delta) {

2

bolt11/description_as_words.js

@@ -18,3 +18,3 @@ const {bech32} = require('bech32');

module.exports = ({description}) => {
if (!description) {
if (description === undefined) {
return {};

@@ -21,0 +21,0 @@ }

@@ -9,2 +9,3 @@ const {featureFlagsFromWords} = require('bolt09');

const bufferAsHex = buffer => buffer.toString('hex');
const descriptionHashByteLength = 32;

@@ -101,2 +102,9 @@ const paymentHashByteLength = 32;

case feature.metadata:
try {
return {metadata: bufferAsHex(wordsAsBuffer({trim, words}))};
} catch (err) {
throw new Error('FailedToParsePaymentContextualMetadata');
}
case feature.min_final_cltv_expiry:

@@ -103,0 +111,0 @@ return {cltv_delta: wordsAsNumber({words})};

@@ -48,2 +48,3 @@ const {bech32} = require('bech32');

is_expired: <Invoice is Expired Bool>
[metadata]: <Payment Metadata Hex String>
mtokens: <Requested Milli-Tokens Value String> (can exceed Number limit)

@@ -50,0 +51,0 @@ network: <Network Name String>

const {safeTokens} = require('./../bolt00');
const asDateString = ms => new Date(ms).toISOString();
const defaultCltvDelta = 9;
const defaultCltvDelta = 18;
const defaultExpireSeconds = 3600;

@@ -54,2 +54,3 @@ const defaultMtokens = '0';

id: <Payment Request Hash String>
[metadata]: <Payment Metadata Hex String>
[mtokens]: <Requested Milli-Tokens Value String> (can exceed Number limit)

@@ -101,2 +102,6 @@ network: <Network Name String>

if (!!n.metadata) {
sum.metadata = n.metadata;
}
if (!!n.payment) {

@@ -103,0 +108,0 @@ sum.payment = n.payment;

# Versions
## 2.1.2
- `createUnsignedRequest`: Fix support for empty description requests
## 2.1.1
- `parsePaymentRequest`: Change default CLTV delta from 9 to 18
## 2.1.0

@@ -4,0 +12,0 @@

@@ -8,5 +8,5 @@ {

"bolt07": "1.8.2",
"bolt09": "0.2.3",
"bolt09": "0.2.4",
"bech32": "2.0.0",
"bitcoinjs-lib": "6.0.1",
"bitcoinjs-lib": "6.0.2",
"bn.js": "5.2.1",

@@ -39,3 +39,3 @@ "tiny-secp256k1": "2.2.1"

},
"version": "2.1.0"
"version": "2.1.2"
}

@@ -59,4 +59,4 @@ const {sign} = require('tiny-secp256k1');

expected: {
data: '0b25fe64410d00004080c1014181c20240004080c1014181c20240004080c1014181c202404080',
hash: 'f499669af812a4d642d09eb9e1d79e63f434a5e0c0eaf177ee95b5561b295d18',
data: '0b25fe64410d00004080c1014181c20240004080c1014181c20240004080c1014181c202404081a000',
hash: 'a7c24a7ac6369ea6b25ca3534cba0e5971d7b3ac93a2cb74e620b6eac52be9d9',
hrp: 'lnbc',

@@ -296,3 +296,3 @@ },

strictSame(parsed.chain_addresses, args.chain_addresses, 'Expected fallbacks');
equal(parsed.cltv_delta, args.cltv_delta || 9, 'Request cltv is expected');
equal(parsed.cltv_delta, args.cltv_delta || 18, 'Request cltv expected');
equal(parsed.created_at, args.created_at, 'Request create_at is expected');

@@ -299,0 +299,0 @@ equal(parsed.description, args.description, 'Req description expected');

@@ -45,3 +45,3 @@ const {test} = require('@alexbosworth/tap');

expected: {
cltv_delta: 9,
cltv_delta: 18,
created_at: new Date(1496314658 * msPerSec).toISOString(),

@@ -63,3 +63,3 @@ description: 'Please consider supporting this project',

expected: {
cltv_delta: 9,
cltv_delta: 18,
created_at: new Date(1496314658 * msPerSec).toISOString(),

@@ -81,3 +81,3 @@ description: '1 cup coffee',

expected: {
cltv_delta: 9,
cltv_delta: 18,
created_at: new Date(1496314658 * msPerSec).toISOString(),

@@ -99,3 +99,3 @@ description: 'ナンセンス 1杯',

expected: {
cltv_delta: 9,
cltv_delta: 18,
created_at: new Date(1496314658 * msPerSec).toISOString(),

@@ -118,3 +118,3 @@ description_hash: '3925b6f67e2c340036ed12093dd44e0368df1b6ea26c53dbe4811f58fd5db8c1',

chain_addresses: ['1RustyRX2oai4EYYDpQGWvEL62BBGqN9T'],
cltv_delta: 9,
cltv_delta: 18,
created_at: new Date(1496314658 * msPerSec).toISOString(),

@@ -158,3 +158,3 @@ description_hash: '3925b6f67e2c340036ed12093dd44e0368df1b6ea26c53dbe4811f58fd5db8c1',

chain_addresses: ['3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX'],
cltv_delta: 9,
cltv_delta: 18,
created_at: new Date(1496314658 * msPerSec).toISOString(),

@@ -177,3 +177,3 @@ description_hash: '3925b6f67e2c340036ed12093dd44e0368df1b6ea26c53dbe4811f58fd5db8c1',

chain_addresses: ['bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4'],
cltv_delta: 9,
cltv_delta: 18,
created_at: new Date(1496314658 * msPerSec).toISOString(),

@@ -196,3 +196,3 @@ description_hash: '3925b6f67e2c340036ed12093dd44e0368df1b6ea26c53dbe4811f58fd5db8c1',

chain_addresses: ['bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3'],
cltv_delta: 9,
cltv_delta: 18,
created_at: new Date(1496314658 * msPerSec).toISOString(),

@@ -232,3 +232,3 @@ description_hash: '3925b6f67e2c340036ed12093dd44e0368df1b6ea26c53dbe4811f58fd5db8c1',

chain_addresses: ['tb1qvzxxvnahw6gkj9aqpptktxpt6906cn2svvhayd'],
cltv_delta: 9,
cltv_delta: 18,
created_at: new Date(1533923529 * msPerSec).toISOString(),

@@ -262,3 +262,3 @@ description: '',

expected: {
cltv_delta: 9,
cltv_delta: 18,
created_at: new Date(1496314658 * 1e3).toISOString(),

@@ -301,2 +301,37 @@ description: 'coffee beans',

},
{
description: 'Metadata blob request',
expected: {
cltv_delta: 18,
created_at: '2017-06-01T10:57:38.000Z',
description: 'payment metadata inside',
destination: '03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad',
expires_at: '2017-06-01T11:57:38.000Z',
features: [
{
bit: 14,
is_required: true,
type: 'payment_identifier',
},
{
bit: 48,
is_required: true,
type: 'pay_includes_metadata',
},
{
bit: 8,
is_required: true,
type: 'tlv_onion',
},
],
id: '0001020304050607080900010203040506070809000102030405060708090102',
is_expired: true,
metadata: '01fafaf0',
mtokens: '1000000000',
network: 'bitcoin',
payment: '1111111111111111111111111111111111111111111111111111111111111111',
tokens: 1000000,
},
request: 'lnbc10m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdp9wpshjmt9de6zqmt9w3skgct5vysxjmnnd9jx2mq8q8a04uqsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q2gqqqqqqsgq7hf8he7ecf7n4ffphs6awl9t6676rrclv9ckg3d3ncn7fct63p6s365duk5wrk202cfy3aj5xnnp5gs3vrdvruverwwq7yzhkf5a3xqpd05wjc',
},
];

@@ -318,2 +353,3 @@

equal(details.is_expired, expected.is_expired, 'Check expiration status');
equal(details.metadata, expected.metadata, 'Parse metadata blob');
equal(details.mtokens, expected.mtokens, 'Parse millitokens amount');

@@ -320,0 +356,0 @@ equal(details.network, expected.network, 'Parse network');

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