<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def setup_recovery(working_dir):
 """ Set up the recovery metadata so we can fully recover secondary state, like subdomains. """

    db = get_db_state(working_dir)
    bitcoind_session = get_bitcoind(new=True)
    assert bitcoind_session is not None

    _, current_block = virtualchain.get_index_range('bitcoin', bitcoind_session, virtualchain_hooks, working_dir)
    assert current_block, 'Failed to connect to bitcoind'

    set_recovery_range(working_dir, db.lastblock, current_block - NUM_CONFIRMATIONS)
    return True