13 Commits
Author SHA1 Message Date
Chris Troutner 6e32723b29 fix(getTransactionsBulk()): Adding bearer token debugging 2026-02-04 14:47:12 -07:00
Chris Troutner 3b08fc3b62 Merge pull request #18 from Permissionless-Software-Foundation/ct-unstable
fix(auth token): Passing auth token to internal bch-js
2026-02-04 14:32:04 -07:00
Chris Troutner 2c1f02d6c7 fix(auth token): Passing auth token to internal bch-js 2026-02-04 14:31:06 -07:00
Chris Troutner 6cf03ca0fe Merge pull request #17 from Permissionless-Software-Foundation/ct-unstable
fix(Fulcrum): Handling different URL and auth tokens
2026-02-04 14:10:58 -07:00
Chris Troutner 5ea7bc9c29 fix(Fulcrum): Handling different URL and auth tokens 2026-02-04 14:09:12 -07:00
Chris Troutner 39021aba46 Merge pull request #16 from Permissionless-Software-Foundation/ct-unstable
fix(node v22): Updating dependencies & testing node.js v22
2026-01-16 11:10:38 -07:00
Chris Troutner de34547951 fix(node v22): Updating dependencies & testing node.js v22 2026-01-16 11:09:54 -07:00
Chris Troutner b8f34fb40e Merge pull request #15 from Permissionless-Software-Foundation/ct-unstable
fix(forward slashes): Fixing express specific issue
2025-12-29 18:16:13 -07:00
Chris Troutner 3778894ce2 Merge branch 'master' into ct-unstable 2025-12-29 18:15:16 -07:00
Chris Troutner 02eb8afd21 fix(forward slashes): Fixing express specific issue 2025-12-29 18:14:59 -07:00
Chris Troutner e708fc1228 Merge pull request #14 from Permissionless-Software-Foundation/ct-unstable
Adding middleware to detect multiple forward slashes in URL and automatically fix it.
2025-12-29 18:07:43 -07:00
Chris Troutner fed4b2da59 fix(forward slashes): Adding middleware to detect multiple forward slashes in the URL 2025-12-29 18:06:43 -07:00
Chris Troutner f30c2ede04 fix(deps): Updating dependencies 2025-12-29 18:01:30 -07:00
5 changed files with 205 additions and 86 deletions
+13
View File
@@ -74,6 +74,19 @@ class Server {
allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With']
}))
// URL normalization middleware - collapse multiple slashes
app.use((req, res, next) => {
if (req.url && req.url.includes('//')) {
// Split URL into path and query string
const [path, queryString] = req.url.split('?')
// Collapse multiple consecutive slashes into a single slash
const normalizedPath = path.replace(/\/+/g, '/')
// Reconstruct req.url with normalized path (req.path is read-only and will auto-update)
req.url = queryString ? `${normalizedPath}?${queryString}` : normalizedPath
}
next()
})
// Apply basic auth middleware if enabled
// This must run before x402 middleware to set req.locals.basicAuthValid
if (basicAuthSettings.enabled) {
+131 -76
View File
@@ -9,12 +9,12 @@
"version": "7.0.0",
"license": "MIT",
"dependencies": {
"@psf/bch-js": "7.1.4",
"@psf/bch-js": "7.1.11",
"axios": "1.7.7",
"cors": "2.8.5",
"dotenv": "16.3.1",
"express": "5.1.0",
"minimal-slp-wallet": "7.0.5",
"minimal-slp-wallet": "7.1.4",
"psffpp": "1.2.1",
"slp-token-media": "1.2.10",
"winston": "3.11.0",
@@ -513,9 +513,9 @@
}
},
"node_modules/@eslint-community/eslint-utils": {
"version": "4.9.0",
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.0.tgz",
"integrity": "sha512-ayVFHdtZ+hsq1t2Dy24wCmGXGe4q9Gu3smhLYALJrr473ZH27MsnSL+LKUlimp4BWJqMDMLmPpx/Q9R3OAlL4g==",
"version": "4.9.1",
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.1.tgz",
"integrity": "sha512-phrYmNiYppR7znFEdqgfWHXR6NCkZEK7hwWDHZUjit/2/U0r6XvkDl0SYnoM51Hq7FhCGdLDT6zxCCOY1hexsQ==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -858,9 +858,9 @@
}
},
"node_modules/@psf/bch-js": {
"version": "7.1.4",
"resolved": "https://registry.npmjs.org/@psf/bch-js/-/bch-js-7.1.4.tgz",
"integrity": "sha512-/+5mbg6RFybKPNtB/m0NEOJYVyT4Rosy/GHGjHknOEkBRF2Xd0/pZTtPAd+BtvzePDki4c2KyL13VkF5XghFyw==",
"version": "7.1.11",
"resolved": "https://registry.npmjs.org/@psf/bch-js/-/bch-js-7.1.11.tgz",
"integrity": "sha512-gDJCaY2aG8EtUWcR9D4tbiyM1BkHd7gkuO7NRaLpwdbSrnU51lyPr69mjQLKOcVlL+aXdJsOjL5pm15t4zq18w==",
"license": "MIT",
"dependencies": {
"@chris.troutner/bip32-utils": "1.0.5",
@@ -886,7 +886,7 @@
"slp-mdm": "0.0.7",
"slp-parser": "0.0.4",
"wif": "2.0.6",
"x402-bch-axios": "2.1.0"
"x402-bch-axios": "2.2.1"
}
},
"node_modules/@psf/bch-js/node_modules/axios": {
@@ -1064,9 +1064,9 @@
"license": "MIT"
},
"node_modules/@types/node": {
"version": "25.0.3",
"resolved": "https://registry.npmjs.org/@types/node/-/node-25.0.3.tgz",
"integrity": "sha512-W609buLVRVmeW693xKfzHeIV6nJGGz98uCPfeXI1ELMLXVeKYZ9m15fAMSaUPBHYLGFsVRcMmSCksQOrZV9BYA==",
"version": "25.0.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-25.0.9.tgz",
"integrity": "sha512-/rpCXHlCWeqClNBwUhDcusJxXYDjZTyE8v5oTO7WbL8eij2nKhUeU89/6xgjU7N4/Vh3He0BtyhJdQbDyhiXAw==",
"license": "MIT",
"dependencies": {
"undici-types": "~7.16.0"
@@ -1715,9 +1715,9 @@
}
},
"node_modules/baseline-browser-mapping": {
"version": "2.9.11",
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.11.tgz",
"integrity": "sha512-Sg0xJUNDU1sJNGdfGWhVHX0kkZ+HWcvmVymJbj6NSgZZmW/8S9Y2HQ5euytnIgakgxN6papOAWiwDo1ctFDcoQ==",
"version": "2.9.15",
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.15.tgz",
"integrity": "sha512-kX8h7K2srmDyYnXRIppo4AH/wYgzWVCs+eKr3RusRSQ5PvRYoEFmR/I0PbdTjKFAoKqp5+kbxnNTFO9jOfSVJg==",
"license": "Apache-2.0",
"bin": {
"baseline-browser-mapping": "dist/cli.js"
@@ -2578,9 +2578,9 @@
"license": "MIT"
},
"node_modules/body-parser": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.1.tgz",
"integrity": "sha512-nfDwkulwiZYQIGwxdy0RUmowMhKcFVcYXUU7m4QlKYim1rUtg83xm2yjZ40QjDuc291AJjjeSc9b++AWHSgSHw==",
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.2.tgz",
"integrity": "sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==",
"license": "MIT",
"dependencies": {
"bytes": "^3.1.2",
@@ -2589,7 +2589,7 @@
"http-errors": "^2.0.0",
"iconv-lite": "^0.7.0",
"on-finished": "^2.4.1",
"qs": "^6.14.0",
"qs": "^6.14.1",
"raw-body": "^3.0.1",
"type-is": "^2.0.1"
},
@@ -2602,9 +2602,9 @@
}
},
"node_modules/body-parser/node_modules/iconv-lite": {
"version": "0.7.1",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.1.tgz",
"integrity": "sha512-2Tth85cXwGFHfvRgZWszZSvdo+0Xsqmw8k8ZwxScfcBneNUraK+dxRxRm24nszx80Y0TVio8kKLt5sLE7ZCLlw==",
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz",
"integrity": "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3.0.0"
@@ -2879,9 +2879,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001761",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001761.tgz",
"integrity": "sha512-JF9ptu1vP2coz98+5051jZ4PwQgd2ni8A+gYSN7EA7dPKIMf0pDlSUxhdmVOaV3/fYK5uWBkgSXJaRLr4+3A6g==",
"version": "1.0.30001764",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001764.tgz",
"integrity": "sha512-9JGuzl2M+vPL+pz70gtMF9sHdMFbY9FJaQBi186cHKH3pSzDvzoUJUPV6fqiKIMyXbud9ZLg4F3Yza1vJ1+93g==",
"funding": [
{
"type": "opencollective",
@@ -4380,9 +4380,9 @@
}
},
"node_modules/esquery": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz",
"integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==",
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz",
"integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==",
"dev": true,
"license": "BSD-3-Clause",
"dependencies": {
@@ -4562,9 +4562,9 @@
}
},
"node_modules/fastq": {
"version": "1.19.1",
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.19.1.tgz",
"integrity": "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==",
"version": "1.20.1",
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.1.tgz",
"integrity": "sha512-GGToxJ/w1x32s/D2EKND7kTil4n8OVk/9mycTc4VDza13lOvpUZTGX3mFSCtV9ksdGBVzvsyAVLM6mHFThxXxw==",
"dev": true,
"license": "ISC",
"dependencies": {
@@ -6475,13 +6475,13 @@
}
},
"node_modules/minimal-slp-wallet": {
"version": "7.0.5",
"resolved": "https://registry.npmjs.org/minimal-slp-wallet/-/minimal-slp-wallet-7.0.5.tgz",
"integrity": "sha512-yrWQwXrtUZYvB6mWe3HTBzQGK1oEjgHuXkanx94tejPR3N8nJLmRRMQu27oWIYD/m3wm0wU8UreYXPIA0iN/iw==",
"version": "7.1.4",
"resolved": "https://registry.npmjs.org/minimal-slp-wallet/-/minimal-slp-wallet-7.1.4.tgz",
"integrity": "sha512-oHPDu+dUyAT8YOyKvb6JGZYIoalXAEHvcAUby7OgL3D/5R+cR21FTjpqpp7BJp+NFcGRANohnLAqpP2vt6tgFA==",
"license": "MIT",
"dependencies": {
"@chris.troutner/retry-queue": "1.0.11",
"@psf/bch-js": "7.1.4",
"@psf/bch-js": "7.1.11",
"bch-consumer": "1.6.2",
"bch-donation": "1.1.2",
"crypto-js": "4.0.0"
@@ -7775,9 +7775,9 @@
}
},
"node_modules/qs": {
"version": "6.14.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz",
"integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==",
"version": "6.14.1",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.1.tgz",
"integrity": "sha512-4EK3+xJl8Ts67nLYNwqw/dsFVnCf+qR7RgXSK9jEEm9unao3njwMDdmsdvoKBKHzxd7tCYz5e5M+SnMjdtXGQQ==",
"license": "BSD-3-Clause",
"dependencies": {
"side-channel": "^1.1.0"
@@ -7859,9 +7859,9 @@
}
},
"node_modules/raw-body/node_modules/iconv-lite": {
"version": "0.7.1",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.1.tgz",
"integrity": "sha512-2Tth85cXwGFHfvRgZWszZSvdo+0Xsqmw8k8ZwxScfcBneNUraK+dxRxRm24nszx80Y0TVio8kKLt5sLE7ZCLlw==",
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz",
"integrity": "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3.0.0"
@@ -9089,9 +9089,9 @@
}
},
"node_modules/terser": {
"version": "5.44.1",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.44.1.tgz",
"integrity": "sha512-t/R3R/n0MSwnnazuPpPNVO60LX0SKL45pyl9YlvxIdkH0Of7D5qM2EVe+yASRIlY5pZ73nclYJfNANGWPwFDZw==",
"version": "5.46.0",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.46.0.tgz",
"integrity": "sha512-jTwoImyr/QbOWFFso3YoU3ik0jBBDJ6JTOQiy/J2YxVJdZCc+5u7skhNwiOR3FQIygFqVUPHl7qbbxtjW2K3Qg==",
"license": "BSD-2-Clause",
"dependencies": {
"@jridgewell/source-map": "^0.3.3",
@@ -9597,9 +9597,9 @@
}
},
"node_modules/watchpack": {
"version": "2.4.4",
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.4.tgz",
"integrity": "sha512-c5EGNOiyxxV5qmTtAB7rbiXxi1ooX1pQKMLX/MIabJjRA0SJBQOjKF+KSVfHkr9U1cADPon0mRiVe/riyaiDUA==",
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.5.1.tgz",
"integrity": "sha512-Zn5uXdcFNIA1+1Ei5McRd+iRzfhENPCe7LeABkJtNulSxjma+l7ltNx55BWZkRlwRnpOgHqxnjyaDgJnNXnqzg==",
"license": "MIT",
"dependencies": {
"glob-to-regexp": "^0.4.1",
@@ -9869,9 +9869,9 @@
}
},
"node_modules/which-typed-array": {
"version": "1.1.19",
"resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.19.tgz",
"integrity": "sha512-rEvr90Bck4WZt9HHFC4DJMsjvu7x+r6bImz0/BrbWb7A2djJ8hnZMrWnHo9F8ssv0OMErasDhftrfROTyqSDrw==",
"version": "1.1.20",
"resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.20.tgz",
"integrity": "sha512-LYfpUkmqwl0h9A2HL09Mms427Q1RZWuOHsukfVcKRq9q95iQxdw0ix1JQrqbcDR9PH1QDwf5Qo8OZb5lksZ8Xg==",
"license": "MIT",
"dependencies": {
"available-typed-arrays": "^1.0.7",
@@ -10025,19 +10025,19 @@
"license": "ISC"
},
"node_modules/x402-bch-axios": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/x402-bch-axios/-/x402-bch-axios-2.1.0.tgz",
"integrity": "sha512-6IE6tUmg/+W4Poi6JBs5z0xjSOhvouzea9IH6BUnuBIdXDm0wv5cwT0cN5qAA4k7BE7hiB98LPiG6QIIkoGjVA==",
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/x402-bch-axios/-/x402-bch-axios-2.2.1.tgz",
"integrity": "sha512-N23DpQRA746bqGDTCJYVQ8QL55PoxE6LTSNMFzx5sySsvnBem6H0hQLSf2N9e45O8xPVw3ulSvXncgTcVM8ikw==",
"license": "MIT",
"dependencies": {
"@chris.troutner/retry-queue": "1.0.11",
"minimal-slp-wallet": "7.0.2"
"minimal-slp-wallet": "7.0.5"
}
},
"node_modules/x402-bch-axios/node_modules/@psf/bch-js": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/@psf/bch-js/-/bch-js-7.1.1.tgz",
"integrity": "sha512-Wknq+q418Zb2Hmb6aDmxt/6VLrU81N+Iq9KP0KHGo1lFHeupJJonBkVt74R1ulry61F7MNRr39iDCTQsMM0ctg==",
"version": "7.1.4",
"resolved": "https://registry.npmjs.org/@psf/bch-js/-/bch-js-7.1.4.tgz",
"integrity": "sha512-/+5mbg6RFybKPNtB/m0NEOJYVyT4Rosy/GHGjHknOEkBRF2Xd0/pZTtPAd+BtvzePDki4c2KyL13VkF5XghFyw==",
"license": "MIT",
"dependencies": {
"@chris.troutner/bip32-utils": "1.0.5",
@@ -10063,7 +10063,7 @@
"slp-mdm": "0.0.7",
"slp-parser": "0.0.4",
"wif": "2.0.6",
"x402-bch-axios": "1.1.1"
"x402-bch-axios": "2.1.0"
}
},
"node_modules/x402-bch-axios/node_modules/@types/node": {
@@ -10229,13 +10229,13 @@
}
},
"node_modules/x402-bch-axios/node_modules/minimal-slp-wallet": {
"version": "7.0.2",
"resolved": "https://registry.npmjs.org/minimal-slp-wallet/-/minimal-slp-wallet-7.0.2.tgz",
"integrity": "sha512-H3H46VXXhvHF/1EKIaAVpBXevX5Bmt1SYqpfQFIcb7JSajXwwncQv7gmhf5Q9H3jtwdY43YWq2TFoeLUkI7E4g==",
"version": "7.0.5",
"resolved": "https://registry.npmjs.org/minimal-slp-wallet/-/minimal-slp-wallet-7.0.5.tgz",
"integrity": "sha512-yrWQwXrtUZYvB6mWe3HTBzQGK1oEjgHuXkanx94tejPR3N8nJLmRRMQu27oWIYD/m3wm0wU8UreYXPIA0iN/iw==",
"license": "MIT",
"dependencies": {
"@chris.troutner/retry-queue": "1.0.11",
"@psf/bch-js": "7.1.1",
"@psf/bch-js": "7.1.4",
"bch-consumer": "1.6.2",
"bch-donation": "1.1.2",
"crypto-js": "4.0.0"
@@ -10330,6 +10330,61 @@
}
},
"node_modules/x402-bch-axios/node_modules/x402-bch-axios": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/x402-bch-axios/-/x402-bch-axios-2.1.0.tgz",
"integrity": "sha512-6IE6tUmg/+W4Poi6JBs5z0xjSOhvouzea9IH6BUnuBIdXDm0wv5cwT0cN5qAA4k7BE7hiB98LPiG6QIIkoGjVA==",
"license": "MIT",
"dependencies": {
"@chris.troutner/retry-queue": "1.0.11",
"minimal-slp-wallet": "7.0.2"
}
},
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/@psf/bch-js": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/@psf/bch-js/-/bch-js-7.1.1.tgz",
"integrity": "sha512-Wknq+q418Zb2Hmb6aDmxt/6VLrU81N+Iq9KP0KHGo1lFHeupJJonBkVt74R1ulry61F7MNRr39iDCTQsMM0ctg==",
"license": "MIT",
"dependencies": {
"@chris.troutner/bip32-utils": "1.0.5",
"@psf/bip21": "2.0.1",
"@psf/bitcoincashjs-lib": "4.0.3",
"@psf/coininfo": "4.0.0",
"axios": "1.13.2",
"bc-bip68": "1.0.5",
"bchaddrjs-slp": "0.2.14",
"bigi": "1.4.2",
"bignumber.js": "9.3.1",
"bip-schnorr": "0.6.7",
"bip38": "3.1.1",
"bip39": "3.1.0",
"bip66": "1.1.5",
"bitcoinjs-message": "2.2.0",
"bs58": "4.0.1",
"ecashaddrjs": "1.0.7",
"ini": "6.0.0",
"randombytes": "2.1.0",
"safe-buffer": "5.2.1",
"satoshi-bitcoin": "1.0.5",
"slp-mdm": "0.0.7",
"slp-parser": "0.0.4",
"wif": "2.0.6",
"x402-bch-axios": "1.1.1"
}
},
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/minimal-slp-wallet": {
"version": "7.0.2",
"resolved": "https://registry.npmjs.org/minimal-slp-wallet/-/minimal-slp-wallet-7.0.2.tgz",
"integrity": "sha512-H3H46VXXhvHF/1EKIaAVpBXevX5Bmt1SYqpfQFIcb7JSajXwwncQv7gmhf5Q9H3jtwdY43YWq2TFoeLUkI7E4g==",
"license": "MIT",
"dependencies": {
"@chris.troutner/retry-queue": "1.0.11",
"@psf/bch-js": "7.1.1",
"bch-consumer": "1.6.2",
"bch-donation": "1.1.2",
"crypto-js": "4.0.0"
}
},
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/x402-bch-axios": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/x402-bch-axios/-/x402-bch-axios-1.1.1.tgz",
"integrity": "sha512-jQ0AyjAzvyTw7ejTTvUSIQiH8//wVn/SRwSgcJ3LeM38SJlJWpTMvvNpOpcjcZ+kFKOe4SsurOy/AcH7o+akjQ==",
@@ -10339,7 +10394,7 @@
"minimal-slp-wallet": "6.1.0"
}
},
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/@psf/bch-js": {
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/@psf/bch-js": {
"version": "6.8.1",
"resolved": "https://registry.npmjs.org/@psf/bch-js/-/bch-js-6.8.1.tgz",
"integrity": "sha512-xu5YT9L3OhdILwJUmkV7Pg/WZ3r2aA6jD7fr5WMvo0OJSzzBBbXGShIbQNZp9+Vv9BoeVLCMqpZoW1Fp7OLCbg==",
@@ -10371,7 +10426,7 @@
"wif": "2.0.6"
}
},
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/axios": {
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/axios": {
"version": "0.26.1",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz",
"integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==",
@@ -10380,7 +10435,7 @@
"follow-redirects": "^1.14.8"
}
},
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/bchaddrjs-slp": {
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/bchaddrjs-slp": {
"version": "0.2.5",
"resolved": "https://registry.npmjs.org/bchaddrjs-slp/-/bchaddrjs-slp-0.2.5.tgz",
"integrity": "sha512-33flmPcqMFswerKu7477DSUNMVMQR3tHDk3lvbmsdkEva+TxVGGWWE/p5Lqx9M/8t3vkbe7fzmVhj4QhChcCyA==",
@@ -10393,7 +10448,7 @@
"node": ">= 6.0.0"
}
},
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/bignumber.js": {
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/bignumber.js": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.0.tgz",
"integrity": "sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A==",
@@ -10402,7 +10457,7 @@
"node": "*"
}
},
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/bip-schnorr": {
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/bip-schnorr": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/bip-schnorr/-/bip-schnorr-0.3.0.tgz",
"integrity": "sha512-Sc1Hn2+1n+okPEW8G+JLjeaM12dsUOwr+oFlMDSKR9wYwNGMw0alskeBIHTmXxBxMZSWKhCW7PwKQVDyGmnaVg==",
@@ -10417,7 +10472,7 @@
"node": ">=8.0.0"
}
},
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/bip38": {
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/bip38": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/bip38/-/bip38-2.0.2.tgz",
"integrity": "sha512-22KDak0RDyghFbR0Si7wyq9IgY423YzGYzWLpGeofH3DaolOQqjD3mNN08eFoubKlbyclOQKFwtONMv2SD9V3A==",
@@ -10431,7 +10486,7 @@
"scryptsy": "^2.0.0"
}
},
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/bip39": {
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/bip39": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/bip39/-/bip39-3.0.2.tgz",
"integrity": "sha512-J4E1r2N0tUylTKt07ibXvhpT2c5pyAFgvuA5q1H9uDy6dEGpjV8jmymh3MTYJDLCNbIVClSB9FbND49I6N24MQ==",
@@ -10443,7 +10498,7 @@
"randombytes": "^2.0.1"
}
},
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/bitcoinjs-message": {
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/bitcoinjs-message": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/bitcoinjs-message/-/bitcoinjs-message-2.0.0.tgz",
"integrity": "sha512-H5pJC7/eSqVjREiEOZ4jifX+7zXYP3Y28GIOIqg9hrgE7Vj8Eva9+HnVqnxwA1rJPOwZKuw0vo6k0UxgVc6q1A==",
@@ -10459,13 +10514,13 @@
"node": ">=0.10"
}
},
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/ini": {
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/ini": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
"integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==",
"license": "ISC"
},
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/minimal-slp-wallet": {
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/minimal-slp-wallet": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/minimal-slp-wallet/-/minimal-slp-wallet-6.1.0.tgz",
"integrity": "sha512-P24WzJu2kHg5aQtKkIVJ42Gu1dsYXWAc0z5MCmlinjDq11Bgy4ICBu73YxpNTB3TQwrWIIi2LJgsuQa/dqH50Q==",
@@ -10479,7 +10534,7 @@
"crypto-js": "4.0.0"
}
},
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/randombytes": {
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/randombytes": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz",
"integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==",
@@ -10488,13 +10543,13 @@
"safe-buffer": "^5.1.0"
}
},
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/safe-buffer": {
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"license": "MIT"
},
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/satoshi-bitcoin": {
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/satoshi-bitcoin": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/satoshi-bitcoin/-/satoshi-bitcoin-1.0.4.tgz",
"integrity": "sha512-YuHOmw5wsz6wuHIQdsz5b2cgtuKtV/jEcZ4NGmWN5tM/gz5T9Q+DSuLlnuf5BP/jsQWgR0ofmY4f8Dm6JnqSug==",
@@ -10503,7 +10558,7 @@
"big.js": "^3.1.3"
}
},
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/slp-mdm": {
"node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/x402-bch-axios/node_modules/slp-mdm": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/slp-mdm/-/slp-mdm-0.0.6.tgz",
"integrity": "sha512-fbjlIg/o8OtzgK2JydC6POJp3Qup/rLgy4yB5hoLgxWRlERyJyE29ScwS3r9TTwPxe12qK55pyivAdNOZZXL0A==",
+2 -2
View File
@@ -15,12 +15,12 @@
"license": "MIT",
"description": "REST API proxy to Bitcoin Cash infrastructure",
"dependencies": {
"@psf/bch-js": "7.1.4",
"@psf/bch-js": "7.1.11",
"axios": "1.7.7",
"cors": "2.8.5",
"dotenv": "16.3.1",
"express": "5.1.0",
"minimal-slp-wallet": "7.0.5",
"minimal-slp-wallet": "7.1.4",
"psffpp": "1.2.1",
"slp-token-media": "1.2.10",
"winston": "3.11.0",
+25 -2
View File
@@ -424,7 +424,20 @@ class FulcrumRESTController {
const cashAddr = this._validateAndConvertAddress(address)
const result = await this.fulcrumUseCases.getTransactions({ address: cashAddr, allTxs })
// Extract bearer token from request header if present
let bearerToken = null
if (req.headers && req.headers.authorization) {
const parts = req.headers.authorization.split(' ')
if (parts.length === 2 && parts[0] === 'Bearer') {
bearerToken = parts[1]
}
}
const result = await this.fulcrumUseCases.getTransactions({
address: cashAddr,
allTxs,
bearerToken
})
return res.status(200).json(result)
} catch (err) {
return this.handleError(err, res)
@@ -470,9 +483,19 @@ class FulcrumRESTController {
}
}
// Extract bearer token from request header if present
let bearerToken = null
if (req.headers && req.headers.authorization) {
const parts = req.headers.authorization.split(' ')
if (parts.length === 2 && parts[0] === 'Bearer') {
bearerToken = parts[1]
}
}
const result = await this.fulcrumUseCases.getTransactionsBulk({
addresses: validatedAddresses,
allTxs
allTxs,
bearerToken
})
return res.status(200).json(result)
} catch (err) {
+34 -6
View File
@@ -6,9 +6,14 @@ import wlogger from '../adapters/wlogger.js'
import BCHJS from '@psf/bch-js'
import config from '../config/index.js'
// Use RESTURL (from test) or REST_URL (from psf-bch-api config) or fallback to config
const restURL = process.env.RESTURL || process.env.REST_URL || process.env.LOCAL_RESTURL || config.restURL
// Use BCHJSBEARERTOKEN (from test) or BASIC_AUTH_TOKEN (from psf-bch-api config) or fallback to config
const bearerToken = process.env.BCHJSBEARERTOKEN || process.env.BASIC_AUTH_TOKEN || config.basicAuth.token
const bchjs = new BCHJS({
restURL: config.restURL,
bearerToken: config.basicAuth.token
restURL,
bearerToken
})
class FulcrumUseCases {
@@ -101,13 +106,24 @@ class FulcrumUseCases {
}
}
async getTransactions ({ address, allTxs }) {
async getTransactions ({ address, allTxs, bearerToken = null }) {
try {
const response = await this.fulcrum.get(`electrumx/transactions/${address}`)
// Sort transactions in descending order, so that newest transactions are first.
if (response.transactions && Array.isArray(response.transactions)) {
response.transactions = await this.bchjs.Electrumx.sortAllTxs(response.transactions, 'DESCENDING')
// Use bearer token from request if provided, otherwise use the default bchjs instance
let bchjsInstance = this.bchjs
if (bearerToken) {
// Create a temporary bchjs instance with the bearer token from the request
const restURL = process.env.RESTURL || process.env.REST_URL || process.env.LOCAL_RESTURL || config.restURL
bchjsInstance = new BCHJS({
restURL,
bearerToken
})
}
response.transactions = await bchjsInstance.Electrumx.sortAllTxs(response.transactions, 'DESCENDING')
if (!allTxs) {
// Return only the first 100 transactions of the history.
@@ -122,16 +138,28 @@ class FulcrumUseCases {
}
}
async getTransactionsBulk ({ addresses, allTxs }) {
async getTransactionsBulk ({ addresses, allTxs, bearerToken = null }) {
try {
const response = await this.fulcrum.post('electrumx/transactions/', { addresses })
// Sort transactions in descending order for each address entry.
if (response.transactions && Array.isArray(response.transactions)) {
// Use bearer token from request if provided, otherwise use the default bchjs instance
let bchjsInstance = this.bchjs
console.log('getTransactionsBulk() bearerToken: ', bearerToken)
if (bearerToken) {
// Create a temporary bchjs instance with the bearer token from the request
const restURL = process.env.RESTURL || process.env.REST_URL || process.env.LOCAL_RESTURL || config.restURL
bchjsInstance = new BCHJS({
restURL,
bearerToken
})
}
for (let i = 0; i < response.transactions.length; i++) {
const thisEntry = response.transactions[i]
if (thisEntry.transactions && Array.isArray(thisEntry.transactions)) {
thisEntry.transactions = await this.bchjs.Electrumx.sortAllTxs(thisEntry.transactions, 'DESCENDING')
thisEntry.transactions = await bchjsInstance.Electrumx.sortAllTxs(thisEntry.transactions, 'DESCENDING')
if (!allTxs && thisEntry.transactions.length > 100) {
// Extract only the first 100 transactions.