From ca99ef0d83a46d4be9173714c807b7de4a7eaaaf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 11 Jan 2026 20:35:19 +0000 Subject: [PATCH 1/3] Initial plan From 8006862b8fc0eff1af110e897b5b6c0a2dffbd4b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 11 Jan 2026 20:40:14 +0000 Subject: [PATCH 2/3] Apply security and code quality fixes to metro.config.js and rbf-service.ts Co-authored-by: jamespepper81 <84083764+jamespepper81@users.noreply.github.com> --- metro.config.js | 8 +++++--- services/rbf-service.ts | 19 +++++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/metro.config.js b/metro.config.js index c3b0e12..45de989 100644 --- a/metro.config.js +++ b/metro.config.js @@ -2,7 +2,7 @@ const { getDefaultConfig } = require('expo/metro-config'); const config = getDefaultConfig(__dirname); -// Enable debug logging and better error reporting +// Configure supported platforms for module resolution config.resolver.platforms = ['ios', 'android', 'native', 'web']; // Polyfill Node.js modules for React Native @@ -24,13 +24,15 @@ config.transformer.minifierConfig = { config.server = { enhanceMiddleware: (middleware) => { return (req, res, next) => { - console.log(`[Metro] ${req.method} ${req.url}`); + if (process.env.NODE_ENV !== 'production') { + console.log(`[Metro] ${req.method} ${req.url}`); + } return middleware(req, res, next); }; }, }; -// Enable better error handling +// Configure Metro transformer options for imports and inline requires config.transformer.getTransformOptions = async () => ({ transform: { experimentalImportSupport: false, diff --git a/services/rbf-service.ts b/services/rbf-service.ts index 077d4e8..9c3017b 100644 --- a/services/rbf-service.ts +++ b/services/rbf-service.ts @@ -18,6 +18,13 @@ let bip32Module: unknown = null; */ const NON_RBF_SEQUENCE = 0xFFFFFFFF; +/** + * Minimum required fee increase (as a fraction of the original fee) + * to consider a replacement transaction for RBF. + * For example, 0.1 means a 10% minimum fee increase. + */ +const MIN_RBF_FEE_INCREASE_RATE = 0.1; + /** * Validates the given ECC library by checking basic functionality. * Throws an error if validation fails. @@ -36,8 +43,6 @@ function validateECCLibrary(ecc: any): void { if (!publicKey || publicKey.length !== 33) { throw new Error('ECC point generation failed'); } - - console.log('✅ ECC library validation passed'); } export interface RBFTransaction { @@ -54,7 +59,7 @@ export interface RBFValidationResult { isValid: boolean; canReplace: boolean; reason?: string; - originalTx?: any; + originalTx?: Transaction; utxos?: UTXO[]; } @@ -409,8 +414,10 @@ export async function createReplacementTransaction( } const bip32Instance = bip32.BIP32Factory(ecc); - // Create transaction builder (replace TransactionBuilder with PSBT for modern bitcoinjs-lib) - let txb = new bitcoin.TransactionBuilder(bitcoin.networks.bitcoin); + // Create transaction using PSBT for modern bitcoinjs-lib + const psbt = new bitcoin.Psbt({ network: bitcoin.networks.bitcoin }); + // Keep existing variable name for compatibility with downstream code + const txb = psbt as unknown as any; // Get our inputs from the original transaction const walletAddressesSet = new Set(walletAddresses); @@ -519,7 +526,7 @@ export async function createReplacementTransaction( // Ensure the new fee meets RBF requirements (must be higher than original) // Only apply minimum increase if user's requested fee is too low - const minFeeIncrease = Math.ceil(originalFee * 0.1); // 10% increase minimum for RBF + const minFeeIncrease = Math.ceil(originalFee * MIN_RBF_FEE_INCREASE_RATE); // minimum increase for RBF const actualTargetFee = Math.max(targetFee, originalFee + minFeeIncrease); const feeIncrease = actualTargetFee - originalFee; From c2be976c66ebea613ae11d6d11246bacde0c4736 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 11 Jan 2026 20:42:56 +0000 Subject: [PATCH 3/3] Revert PSBT migration fix as it breaks TransactionBuilder API compatibility Co-authored-by: jamespepper81 <84083764+jamespepper81@users.noreply.github.com> --- services/rbf-service.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/services/rbf-service.ts b/services/rbf-service.ts index 9c3017b..cf114f6 100644 --- a/services/rbf-service.ts +++ b/services/rbf-service.ts @@ -414,10 +414,8 @@ export async function createReplacementTransaction( } const bip32Instance = bip32.BIP32Factory(ecc); - // Create transaction using PSBT for modern bitcoinjs-lib - const psbt = new bitcoin.Psbt({ network: bitcoin.networks.bitcoin }); - // Keep existing variable name for compatibility with downstream code - const txb = psbt as unknown as any; + // Create transaction builder (replace TransactionBuilder with PSBT for modern bitcoinjs-lib) + let txb = new bitcoin.TransactionBuilder(bitcoin.networks.bitcoin); // Get our inputs from the original transaction const walletAddressesSet = new Set(walletAddresses);