mirror of
https://git.wownero.com/lza_menace/suchwow.git
synced 2024-08-15 01:03:19 +00:00
adding dumb simple way to transfer funds
This commit is contained in:
parent
2b6f856059
commit
c05eda5253
2 changed files with 21 additions and 0 deletions
|
@ -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()
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue