mirror of
https://github.com/Permissionless-Software-Foundation/psf-bch-api-base.git
synced 2026-09-21 16:52:00 -07:00
Merge branch 'master' into ct-unstable
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
# START INFRASTRUCTURE SETUP
|
||||
|
||||
# Full Node Connection
|
||||
export RPC_BASEURL=http://172.17.0.1:8332
|
||||
export RPC_USERNAME=bitcoin
|
||||
export RPC_PASSWORD=password
|
||||
|
||||
# Fulcrum Indexer
|
||||
export FULCRUM_API=http://172.17.0.1:3001/v1
|
||||
|
||||
# SLP Indexer
|
||||
export SLP_INDEXER_API=http://localhost:5010
|
||||
|
||||
# REST API URL for wallet operations
|
||||
export LOCAL_RESTURL=http://localhost:5942/v6
|
||||
|
||||
# END INFRASTRUCTURE SETUP
|
||||
|
||||
|
||||
# START ACCESS CONTROL
|
||||
|
||||
export PORT=5942
|
||||
|
||||
# x402 payments required to access this API?
|
||||
export X402_ENABLED=true
|
||||
export SERVER_BASE_ADDRESS=0xd32585CE60815654C50CAf350e18de8096061e63
|
||||
export X402_PRICE_USDC=0.1
|
||||
export x402_NETWORK=base
|
||||
|
||||
# Coinbase CDP Facilitator (for Bazaar registration)
|
||||
export x402_FACILITATOR_URL=https://api.cdp.coinbase.com/platform/v2/x402
|
||||
export FACILITATOR_KEY_ID=your_key_id_here
|
||||
export FACILITATOR_SECRET_KEY=your_secret_key_here
|
||||
|
||||
# Basic Authentication required to access this API?
|
||||
export USE_BASIC_AUTH=true
|
||||
export BASIC_AUTH_TOKEN=some-random-token
|
||||
|
||||
# END ACCESS CONTROL
|
||||
+14
-4
@@ -25,14 +25,24 @@ export PORT=5942
|
||||
export X402_ENABLED=true
|
||||
export SERVER_BASE_ADDRESS=0xd32585CE60815654C50CAf350e18de8096061e63
|
||||
export X402_PRICE_USDC=0.1
|
||||
export x402_NETWORK=base
|
||||
export x402_FACILITATOR_URL=http://localhost:4022
|
||||
|
||||
# Network configuration (CAIP-2 format required by CDP)
|
||||
# Use 'eip155:8453' for Base mainnet
|
||||
# Use 'eip155:84532' for Base Sepolia (testnet)
|
||||
export x402_NETWORK=eip155:8453
|
||||
|
||||
# Facilitator URL
|
||||
# For Coinbase CDP (recommended): https://api.cdp.coinbase.com/platform/v2/x402
|
||||
# For custom/local facilitator: http://localhost:4022
|
||||
export x402_FACILITATOR_URL=https://api.cdp.coinbase.com/platform/v2/x402
|
||||
|
||||
# CDP API Credentials (required when using CDP facilitator)
|
||||
# Get these from https://cdp.coinbase.com - API Keys section
|
||||
export FACILITATOR_KEY_ID=your_key_id_here
|
||||
export FACILITATOR_SECRET_KEY=your_secret_key_here
|
||||
|
||||
# Basic Authentication required to access this API?
|
||||
export USE_BASIC_AUTH=true
|
||||
export BASIC_AUTH_TOKEN=some-random-token
|
||||
|
||||
# END ACCESS CONTROL
|
||||
|
||||
npm start
|
||||
Vendored
+9
-2
@@ -31,13 +31,20 @@ const normalizeBoolean = (value, defaultValue) => {
|
||||
const parsedPrice = Number(process.env.X402_PRICE_USDC)
|
||||
const priceUSDC = Number.isFinite(parsedPrice) && parsedPrice > 0 ? parsedPrice : 200
|
||||
|
||||
// Network configuration: CDP requires CAIP-2 format (eip155:chainId)
|
||||
// base-sepolia = eip155:84532, base-mainnet = eip155:8453
|
||||
const x402Network = process.env.x402_NETWORK || 'eip155:8453'
|
||||
|
||||
const x402Defaults = {
|
||||
enabled: normalizeBoolean(process.env.X402_ENABLED, true),
|
||||
facilitatorUrl: process.env.x402_FACILITATOR_URL || 'http://localhost:4022',
|
||||
// CDP Facilitator: https://api.cdp.coinbase.com/platform/v2/x402
|
||||
// Custom/Local Facilitator: http://localhost:4022
|
||||
facilitatorUrl: process.env.x402_FACILITATOR_URL || 'https://api.cdp.coinbase.com/platform/v2/x402',
|
||||
serverAddress: process.env.SERVER_BASE_ADDRESS || 'bitcoincash:qqsrke9lh257tqen99dkyy2emh4uty0vky9y0z0lsr',
|
||||
facilitatorKeyId: process.env.FACILITATOR_KEY_ID || '',
|
||||
facilitatorSecretKey: process.env.FACILITATOR_SECRET_KEY || '',
|
||||
network: process.env.x402_NETWORK || 'base-sepolia',
|
||||
// CDP requires CAIP-2 network format: eip155:8453 (base) or eip155:84532 (base-sepolia)
|
||||
network: x402Network,
|
||||
priceUSDC
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -3,8 +3,6 @@ import { generateJwt } from '@coinbase/cdp-sdk/auth'
|
||||
|
||||
const DEFAULT_DESCRIPTION = 'Access to protected psf-bch-api resources'
|
||||
const DEFAULT_TIMEOUT_SECONDS = 120
|
||||
const NETWORK = config.x402.network
|
||||
if (!NETWORK) throw new Error('x402_NETWORK env required!')
|
||||
|
||||
/**
|
||||
* Builds a route configuration map for x402-bch middleware.
|
||||
@@ -22,6 +20,10 @@ export function buildX402Routes (apiPrefix = '/v6') {
|
||||
|
||||
const routeKey = `${prefixWithSlash}/*`
|
||||
|
||||
// Get network from config (now supports CAIP-2 format: eip155:8453)
|
||||
const NETWORK = config.x402.network
|
||||
if (!NETWORK) throw new Error('x402_NETWORK env required!')
|
||||
|
||||
return {
|
||||
network: NETWORK,
|
||||
[routeKey]: {
|
||||
|
||||
Reference in New Issue
Block a user