def test_tx(account): pprint.pprint( api.tx( account, api.get_account_address(account), "receive", api.get_transactions(account)[0] ) )
def main(): apiKey = raw_input('Please enter your API key: ') budgetID = raw_input('Please enter the budget ID: ') print('Fetching accounts') accounts = ynab.get_accounts(apiKey, budgetID) print('Found the following accounts:') for a in accounts['data']['accounts']: print(a['name']) transactions = ynab.get_transactions(apiKey, budgetID) pprint.pprint(output.asCSV(accounts, transactions))
def next_key(self): # return the first key that hasn't seen any transactions for key in self.keys: address = key.public_key.address(testnet=self.testnet) if len(get_transactions(address)) == 0: return key # if all keys have seen transactions, generate more keys # and return the first one index = len(self.keys) self.fill() return self.keys[index]
def monitor_transactions(db): while True: # it's quite inefficient to query the entire transaction list again and again. # would be better to change the api to allow a timestamp "since" parameter to only get new transactions transactions = api.get_transactions() # check the db mapping table for any matching transactions deposit_addresses = db.get_deposit_addresses() matching_transactions = [t for t in transactions if t["toAddress"] in deposit_addresses] processed_transactions_set = db.get_processed_transactions() for t in matching_transactions: # check to make sure we haven't processed this transaction already if (t["timestamp"], t["toAddress"]) in processed_transactions_set: continue # process the transaction on a background thread so we don't stop monitoring transactions thread = threading.Thread(target=_handle_transaction, args=[t, db]) thread.start() print(f"Deposit to {t['toAddress']} detected!") # simulated long polling time.sleep(5)
def transactions(self): '''retrieves all transactions''' transactions = [] for address in self.addresses(): transactions.extend(get_transactions(address)) return transactions
def listtransactions(account, limit=0): return [ api.account_tx(account, api.get_account_address(account), "receive", data) for data in api.get_transactions(account) ]
def test_get_transactions(account): # pprint.pprint(list(api.get_transactions(account))) for tx in api.get_transactions(account): print(tx["tx_hash"])
def run(self): result = get_transactions(config.creds['key_id'], config.creds['access_code']) outfile = self.output().open('w') outfile.write(result) outfile.close()
def transactions(self): return get_transactions(self.address())