BIT-77 adding sync back - end logic for db and the bitcoind api

Signed-off-by: Yasen Yankov <iasen.iankov@gmail.com>