update
refactor and backport from v0.5-bitcoinj-0.7