diff --git a/suchwow/routes/post.py b/suchwow/routes/post.py index 6c8ddd5..e1321fc 100644 --- a/suchwow/routes/post.py +++ b/suchwow/routes/post.py @@ -16,10 +16,16 @@ def top(): posts = Post.select() for post in posts: balance = float(wownero.Wallet().balances(post.account_index)[1]) - if balance > 0: + transfers = [] + incoming = wownero.Wallet().incoming_transfers(post.account_index) + if "transfers" in incoming: + for xfer in incoming["transfers"]: + transfers.append(wownero.from_atomic(xfer["amount"])) + total = sum(transfers) + if total > 0: top_posts[post.id] = { "post": post, - "balance": balance + "balance": total } return render_template("post/top.html", posts=top_posts) diff --git a/suchwow/wownero.py b/suchwow/wownero.py index bd94ca5..23bf657 100644 --- a/suchwow/wownero.py +++ b/suchwow/wownero.py @@ -120,6 +120,15 @@ class Wallet(object): sweep = self.make_wallet_rpc('sweep_all', data) return sweep + def incoming_transfers(self, account, transfer_type='all', verbose=True): + data = { + 'transfer_type': transfer_type, + 'account_index': account, + 'verbose': verbose + } + transfers = self.make_wallet_rpc('incoming_transfers', data) + return transfers + def to_atomic(amount):