code: def get_tx_fee_per_byte(bitcoind_opts=None, config_path=None, bitcoind_client=None):
      
      if bitcoind_client is None:
          bitcoind_client = get_bitcoind_client(bitcoind_opts=bitcoind_opts, config_path=config_path)
  
      try:
          # try to confirm in 2-3 blocks
          try:
              fee_info = bitcoind_client.estimatesmartfee(2)
              if 'errors' in fee_info and len(fee_info['errors']) > 0:
                  fee = -1
              else:
                  fee = fee_info['feerate']
  
          except JSONRPCException as je:
              fee = bitcoind_client.estimatefee(2)
  
          if fee < 0:
              # if we're testing, then use our own fee
              if os.environ.get("BLOCKSTACK_TEST") == '1' or os.environ.get("BLOCKSTACK_TESTNET", None) == "1":
                  fee = 5500.0 / 10**8
  
              else:
                  log.error("Failed to estimate tx fee")
                  return None
          else:
              log.debug("Bitcoin estimatefee(2) is {}".format(fee))
  
          fee = float(fee)
  
          # fee is BTC/kb.  Return satoshis/byte
          ret = int(round(fee * 10**8 / 1024.0))
          log.debug("Bitcoin estimatefee(2) is {} ({} satoshi/byte)".format(fee, ret))
          return ret
  
      except Exception as e:
          if os.environ.get("BLOCKSTACK_DEBUG") == '1':
              log.exception(e)
  
          log.error("Failed to estimate tx fee per byte")
          return None
docs: Get the tx fee per byte from the underlying blockchain
      Return the fee on success
      Return None on error