mirror of
https://github.com/luxfi/bridge.git
synced 2026-09-24 00:26:46 +00:00
Extend the MPC keygen client to surface the compressed secp256k1 public key alongside the chain-appropriate address, and derive a bech32 P2WPKH locally for BITCOIN_* networks instead of relying on mpcd's legacy P2PKH "1..." output. Why: bridge release on BTC needs P2WPKH (witness-discount fees, direct btcsuite/txscript compatibility, broader wallet support). mpcd's pubKeyToBtcAddress emits Base58Check P2PKH; rather than round-tripping a fix through mpcd, the bridge re-derives locally from the same ECDSAPubKey the keygen already returns. Changes: - Wallet gains ECDSAPubKey []byte; 33-byte compressed form preferred, uncompressed (65/64) and x-only (32) inputs all compress canonically - keygenResult parses both eth_address and evm_address (mpcd renamed) - pickAddress() takes the network internal_name so BITCOIN_MAINNET vs BITCOIN_TESTNET selects the right bech32 hrp (bc / tb) - new btc_address.go: deriveBTCBech32Address + compressSecp256k1Pubkey + bitcoinChainParams; uses btcd/btcutil for canonical HASH160 + segwit-v0 encoding - 11 new tests covering mainnet/testnet hrp selection, 32/33/64/65 byte pubkey shapes, empty/malformed input, keygen integration