From 9e76b34d052cd01c6bc1e61830f23ae5d003e52b Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Tue, 30 Dec 2025 13:34:02 -0700 Subject: [PATCH] fix(x402): Changing x402 default payment to 25,000 sats, so tx fee is 1% --- src/bch-js.js | 5 ++++- test/unit/x402.js | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/bch-js.js b/src/bch-js.js index da3f467..155afdc 100644 --- a/src/bch-js.js +++ b/src/bch-js.js @@ -86,7 +86,10 @@ class BCHJS { } else if (process.env.BCHJSWIF && process.env.BCHJSWIF !== '') { this.wif = process.env.BCHJSWIF } - this.paymentAmountSats = (config && config.paymentAmountSats) || 2000 * 5 + + // Most TXs cost about 250 sats. So we'll set the default to 25000 sats, + // so the mining fee is 1% of the transaction. + this.paymentAmountSats = (config && config.paymentAmountSats) || 25000 // BCH server URL for x402 payments (separate from REST API server) // This is used when broadcasting payment transactions to the blockchain diff --git a/test/unit/x402.js b/test/unit/x402.js index dbb2fcf..bf77d11 100644 --- a/test/unit/x402.js +++ b/test/unit/x402.js @@ -20,7 +20,9 @@ describe('#X402 Integration', () => { }) assert.strictEqual(bchjs.wif, '') - assert.strictEqual(bchjs.paymentAmountSats, 10000) + // assert.strictEqual(bchjs.paymentAmountSats, 10000) + assert.strictEqual(typeof bchjs.paymentAmountSats, 'number') + assert.ok(Number.isInteger(bchjs.paymentAmountSats) && bchjs.paymentAmountSats > 0) assert.strictEqual(bchjs.bchServerURL, 'https://bch.fullstack.cash/v6') }) @@ -59,7 +61,9 @@ describe('#X402 Integration', () => { }) assert.strictEqual(bchjs.wif, '') - assert.strictEqual(bchjs.paymentAmountSats, 10000) + // assert.strictEqual(bchjs.paymentAmountSats, 10000) + assert.strictEqual(typeof bchjs.paymentAmountSats, 'number') + assert.ok(Number.isInteger(bchjs.paymentAmountSats) && bchjs.paymentAmountSats > 0) assert.strictEqual(bchjs.bchServerURL, 'https://bch.fullstack.cash/v6') })