Add Bitcoin wallet withdraw and seed reveal UI in CMS.

Wire admin actions to the backend API with client-side address validation and configurable max fee rate.
This commit is contained in:
2026-09-07 02:08:17 +02:00
parent 626f2ea4f0
commit de52534271
7 changed files with 316 additions and 5 deletions
+28
View File
@@ -0,0 +1,28 @@
import type { BitcoinNetwork } from '@/types/bitcoinWallet/BitcoinNetwork';
// Soft validation only: prefix/length checks to reject obvious garbage and wrong-network
// addresses early. Checksums and spendability are validated by Electrum on payto.
const BASE58 = '[1-9A-HJ-NP-Za-km-z]';
const NETWORK_ADDRESS_PATTERNS: Record<BitcoinNetwork, RegExp[]> = {
mainnet: [
new RegExp(`^1${BASE58}{25,34}$`),
new RegExp(`^3${BASE58}{25,34}$`),
/^bc1[a-z0-9]{25,87}$/
],
testnet4: [
new RegExp(`^[mn]${BASE58}{25,34}$`),
new RegExp(`^2${BASE58}{25,34}$`),
/^(?:tb1|bcrt1)[a-z0-9]{25,87}$/
]
};
export const isBitcoinAddress = (value: unknown, network: BitcoinNetwork): boolean => {
if (typeof value !== 'string') {
return false;
}
const trimmed = value.trim();
return NETWORK_ADDRESS_PATTERNS[network].some(pattern => pattern.test(trimmed));
};