fixed electrum chain generation infinite loop, refactored