Avoid duplicating blocks and txs on privkey imports.
Avoid duplicating blocks and txs on privkey imports.

When detaching the tail end of a slice of blocks or transactions and
appending the newly inserted middle block, and the previous tail, the
capacity of the slice head must be limited to prevent overwriting the
newly inserted block/tx in the same memory as the tail slice.

Bug discovered by @mably while working on the peercoin port of
btcwallet and reported on IRC.

jrick/btcwallet,synrg-labs/btcwallet,btcsuite/btcwallet,Roasbeef/btcwallet,jrick/dcrwallet,synrg-labs/btcwallet,jrick/dcrwallet,Stash-Crypto/btcwallet,jrick/btcwallet,btcsuite/btcwallet,decred/dcrwallet,Stash-Crypto/btcwallet,decred/dcrwallet,Roasbeef/btcwallet