Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"coininfo": "git+https://github.com/cryptocoinjs/coininfo.git#dc3e6cc59e593ee7dbeb7c993485706e72d32743",
"crypto-browserify": "^3.12.1",
"framer-motion": "^12.40.0",
"lodash": "^4.17.15",
"lucide-react": "^1.17.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
Expand Down
6 changes: 3 additions & 3 deletions src/lib/bolt11.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import secp256k1 from 'secp256k1'
import { Buffer } from 'buffer'
import BN from 'bn.js'
import * as bitcoinjsAddress from 'bitcoinjs-lib/src/address'
import cloneDeep from 'lodash/cloneDeep'

import coininfo from 'coininfo'

function createBitcoinJSNetwork (network, invoiceBech32, addressBech32) {
Expand Down Expand Up @@ -383,7 +383,7 @@ function hrpToMillisat (hrpString, outputString) {
}

function sign (inputPayReqObj, inputPrivateKey) {
let payReqObj = cloneDeep(inputPayReqObj)
let payReqObj = structuredClone(inputPayReqObj)
let privateKey = hexToBuffer(inputPrivateKey)
if (payReqObj.complete && payReqObj.paymentRequest) return payReqObj

Expand Down Expand Up @@ -458,7 +458,7 @@ function sign (inputPayReqObj, inputPrivateKey) {
*/
function encode (inputData, addDefaults) {
// we don't want to affect the data being passed in, so we copy the object
let data = cloneDeep(inputData)
let data = structuredClone(inputData)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve Buffer instances when cloning encode input

When callers pass Buffer-valued fields to encode(), structuredClone() converts them into plain Uint8Arrays instead of preserving Buffer instances. That regresses inputs the existing code accepts: for example routing_info.short_channel_id as a Buffer now reaches the later shortId instanceof Buffer validation and is rejected, and a Buffer payeeNodeKey is serialized with Uint8Array#toString('hex') as comma-separated bytes rather than hex. cloneDeep preserved Buffers, so these valid encode inputs now fail or produce malformed output.

Useful? React with 👍 / 👎.


// by default we will add default values to description, expire time, and min cltv
if (addDefaults === undefined) addDefaults = true
Expand Down
Loading