From 5c0cfdaa90571ef0b987816d424a989b72fb281c Mon Sep 17 00:00:00 2001 From: lza_menace Date: Sun, 16 Aug 2020 02:02:02 -0700 Subject: [PATCH] fix top post logic by checking incoming transfers --- suchwow/routes/post.py | 10 ++++++++-- suchwow/wownero.py | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) 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):