+ added get_transactions

This commit is contained in:
Lex Berezhny 2018-09-21 09:47:31 -04:00
parent 543f533a68
commit 0b75bb4052
2 changed files with 23 additions and 0 deletions

View file

@ -345,6 +345,9 @@ class BaseAccount:
def get_inputs_outputs(self, **constraints): def get_inputs_outputs(self, **constraints):
return self.ledger.db.get_txios_for_account(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 @defer.inlineCallbacks
def fund(self, to_account, amount=None, everything=False, def fund(self, to_account, amount=None, everything=False,
outputs=1, broadcast=False, **constraints): outputs=1, broadcast=False, **constraints):

View file

@ -266,6 +266,26 @@ class BaseDatabase(SQLiteMixin):
else: else:
return None, None, False 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): def get_balance_for_account(self, account, include_reserved=False, **constraints):
if not include_reserved: if not include_reserved:
constraints['is_reserved'] = 0 constraints['is_reserved'] = 0