adding dumb simple way to transfer funds

graphs-n-shit
lza_menace 4 years ago
parent 2b6f856059
commit c05eda5253

@ -7,6 +7,7 @@ from suchwow import config
from suchwow.models import Post, Profile, Comment, Notification, db from suchwow.models import Post, Profile, Comment, Notification, db
from suchwow.routes import auth, comment, post, profile from suchwow.routes import auth, comment, post, profile
from suchwow.utils.decorators import login_required from suchwow.utils.decorators import login_required
from suchwow import wownero
app = Flask(__name__) app = Flask(__name__)
@ -50,5 +51,16 @@ def init():
# init db # init db
db.create_tables([Post, Profile, Comment, Notification]) 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__": if __name__ == "__main__":
app.run() app.run()

@ -112,6 +112,15 @@ class Wallet(object):
transfer = self.make_wallet_rpc('transfer', data) transfer = self.make_wallet_rpc('transfer', data)
return transfer 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): def to_atomic(amount):
if not isinstance(amount, (Decimal, float) + six.integer_types): if not isinstance(amount, (Decimal, float) + six.integer_types):