Overview
Replace the ElectrumX network layer with direct bitmarkd RPC calls to enable the wallet to:
- Query address balances
- Fetch transaction history
- Broadcast signed transactions
This is a temporary backend for Stage 1 PoC. Stage 2 will migrate to proper ElectrumX protocol.
Architecture
Current (broken):
┌─────────────┐ ┌─────────────┐
│ Electrum │ ───? │ ElectrumX │ (no server exists)
│ Wallet │ │ Server │
└─────────────┘ └─────────────┘
Stage 1 Target:
┌─────────────┐ ┌─────────────┐
│ Electrum │ RPC │ bitmarkd │
│ Wallet │ ───► │ (local) │
└─────────────┘ └─────────────┘
bitmarkd RPC Methods Required
| Wallet Function |
bitmarkd RPC Call |
| Get balance |
getreceivedbyaddress or listunspent |
| Get UTXOs |
listunspent |
| Get tx history |
listtransactions / gettransaction |
| Broadcast tx |
sendrawtransaction |
| Get fee estimate |
estimatefee |
| Verify address |
validateaddress |
| Get block height |
getblockcount |
Implementation Plan
1. Create RPC Client Module
New file: electrum/bitmarkd_rpc.py
class BitmarkdRPC:
def __init__(self, host='127.0.0.1', port=9266, user=None, password=None):
self.url = f'http://{host}:{port}'
self.auth = (user, password) if user else None
async def call(self, method, *params):
"""Make RPC call to bitmarkd"""
pass
async def get_balance(self, address):
"""Get confirmed balance for address"""
pass
async def list_unspent(self, addresses):
"""Get UTXOs for addresses"""
pass
async def broadcast_transaction(self, raw_tx):
"""Broadcast signed transaction"""
pass
2. Create Network Adapter
New file: electrum/network_rpc.py
Implement the same interface as network.py but using bitmarkd RPC:
class BitmarkdNetwork:
"""Drop-in replacement for Network class using bitmarkd RPC"""
async def get_address_history(self, address):
pass
async def get_address_balance(self, address):
pass
async def broadcast_transaction(self, tx):
pass
3. Modify Wallet Initialization
In electrum/daemon.py or startup code:
- Add config option:
--rpc-host, --rpc-port, --rpc-user, --rpc-password
- Or read from
~/.bitmark/bitmark.conf
4. Configuration
Read bitmarkd credentials from ~/.bitmark/bitmark.conf:
rpcuser=bitmarkrpc
rpcpassword=yourpassword
rpcport=9266
Or allow command-line override:
./run_electrum gui --rpc-host=127.0.0.1 --rpc-port=9266
Files to Modify
| File |
Changes |
electrum/bitmarkd_rpc.py |
NEW - RPC client |
electrum/network_rpc.py |
NEW - Network adapter |
electrum/daemon.py |
Add RPC config options |
electrum/network.py |
May need interface changes |
electrum/synchronizer.py |
May need to use new adapter |
Testing
- Unit tests for RPC client
- Integration test with running bitmarkd:
# Start bitmarkd
bitmarkd -daemon
# Test wallet
./run_electrum getbalance -w test_wallet
Limitations (Stage 1)
- Requires local bitmarkd node (not lightweight)
- No SPV verification (trusts the node)
- Single server (no redundancy)
These limitations are addressed in Stage 2 with ElectrumX.
References
Acceptance Criteria
Overview
Replace the ElectrumX network layer with direct bitmarkd RPC calls to enable the wallet to:
This is a temporary backend for Stage 1 PoC. Stage 2 will migrate to proper ElectrumX protocol.
Architecture
bitmarkd RPC Methods Required
getreceivedbyaddressorlistunspentlistunspentlisttransactions/gettransactionsendrawtransactionestimatefeevalidateaddressgetblockcountImplementation Plan
1. Create RPC Client Module
New file:
electrum/bitmarkd_rpc.py2. Create Network Adapter
New file:
electrum/network_rpc.pyImplement the same interface as
network.pybut using bitmarkd RPC:3. Modify Wallet Initialization
In
electrum/daemon.pyor startup code:--rpc-host,--rpc-port,--rpc-user,--rpc-password~/.bitmark/bitmark.conf4. Configuration
Read bitmarkd credentials from
~/.bitmark/bitmark.conf:Or allow command-line override:
Files to Modify
electrum/bitmarkd_rpc.pyelectrum/network_rpc.pyelectrum/daemon.pyelectrum/network.pyelectrum/synchronizer.pyTesting
Limitations (Stage 1)
These limitations are addressed in Stage 2 with ElectrumX.
References
Acceptance Criteria