From c05eda52533f6c6c316f9b19da095d41ad1fa55e Mon Sep 17 00:00:00 2001 From: lza_menace Date: Thu, 13 Aug 2020 23:42:43 -0700 Subject: [PATCH] adding dumb simple way to transfer funds --- suchwow/app.py | 12 ++++++++++++ suchwow/wownero.py | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/suchwow/app.py b/suchwow/app.py index eda0d7c..92ec23e 100644 --- a/suchwow/app.py +++ b/suchwow/app.py @@ -7,6 +7,7 @@ from suchwow import config from suchwow.models import Post, Profile, Comment, Notification, db from suchwow.routes import auth, comment, post, profile from suchwow.utils.decorators import login_required +from suchwow import wownero app = Flask(__name__) @@ -50,5 +51,16 @@ def init(): # init db db.create_tables([Post, Profile, Comment, Notification]) +@app.cli.command("payout_users") +def payout_users(): + wallet = wownero.Wallet() + for post in Post.select(): + submitter = Profile.get(username=post.submitter) + balances = wallet.balances(post.account_index) + if balances[1] > 0: + print(f"Post #{post.id} has {balances[1]} funds unlocked and ready to send. Sweeping all funds to user's address ({submitter.address}).") + sweep = wallet.sweep_all(account=post.account_index, dest_address=submitter.address) + print(sweep) + if __name__ == "__main__": app.run() diff --git a/suchwow/wownero.py b/suchwow/wownero.py index 6d036e2..bd94ca5 100644 --- a/suchwow/wownero.py +++ b/suchwow/wownero.py @@ -112,6 +112,15 @@ class Wallet(object): transfer = self.make_wallet_rpc('transfer', data) return transfer + def sweep_all(self, account, dest_address): + data = { + 'address': dest_address, + 'account_index': account, + } + sweep = self.make_wallet_rpc('sweep_all', data) + return sweep + + def to_atomic(amount): if not isinstance(amount, (Decimal, float) + six.integer_types):