code: def namedb_account_debit(cur, account_addr, token_type, amount, block_id, vtxindex, txid):
      
      account = namedb_get_account(cur, account_addr, token_type)
      if account is None:
          traceback.print_stack()
          log.fatal('Account {} does not exist'.format(account_addr))
          os.abort()
  
      new_credit_value = account['credit_value']
      new_debit_value = account['debit_value'] + amount
  
      # sanity check
      if new_debit_value > new_credit_value:
          traceback.print_stack()
          log.fatal('Account {} for "{}" tokens overdrew (debits = {}, credits = {})'.format(account_addr, token_type, new_debit_value, new_credit_value))
          os.abort()
  
      new_balance = new_credit_value - new_debit_value
      log.debug("Account balance of units of '{}' for {} is now {}".format(token_type, account_addr, new_balance))
  
      res = namedb_account_transaction_save(cur, account_addr, token_type, new_credit_value, new_debit_value, block_id, vtxindex, txid, account)
      if not res:
          traceback.print_stack()
          log.fatal('Failed to save new account state for {}'.format(account_addr))
          os.abort()
  
      return True
docs: Debit an account at a particular point in time by the given amount.
      Insert a new history entry for the account into the accounts table.
  
      The account must exist
  
      Abort the program if the account balance goes negative, or the count does not exist