From 0b75bb405204768d6bfc50d1387b3199979679de Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Fri, 21 Sep 2018 09:47:31 -0400 Subject: [PATCH] + added get_transactions --- torba/baseaccount.py | 3 +++ torba/basedatabase.py | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/torba/baseaccount.py b/torba/baseaccount.py index e7f020b2f..f22b5ad24 100644 --- a/torba/baseaccount.py +++ b/torba/baseaccount.py @@ -345,6 +345,9 @@ class BaseAccount: def get_inputs_outputs(self, **constraints): return self.ledger.db.get_txios_for_account(self, **constraints) + def get_transactions(self): + return self.ledger.db.get_transactions(self) + @defer.inlineCallbacks def fund(self, to_account, amount=None, everything=False, outputs=1, broadcast=False, **constraints): diff --git a/torba/basedatabase.py b/torba/basedatabase.py index 8e4463631..d7b7c62ea 100644 --- a/torba/basedatabase.py +++ b/torba/basedatabase.py @@ -266,6 +266,26 @@ class BaseDatabase(SQLiteMixin): else: return None, None, False + @defer.inlineCallbacks + def get_transactions(self, account): + txs = self.run_query( + """ + SELECT raw FROM tx where txid in ( + SELECT txo.txid + FROM txo + JOIN pubkey_address USING (address) + WHERE pubkey_address.account = :account + UNION + SELECT txo.txid + FROM txi + JOIN txo USING (txoid) + JOIN pubkey_address USING (address) + WHERE pubkey_address.account = :account + ) + """, {'account': account.public_key.address} + ) + return [account.ledger.transaction_class(values[0]) for values in txs] + def get_balance_for_account(self, account, include_reserved=False, **constraints): if not include_reserved: constraints['is_reserved'] = 0