@ -110,6 +110,13 @@ def status():
def send ( ) :
def send ( ) :
send_form = Send ( )
send_form = Send ( )
redirect_url = url_for ( ' wallet.dashboard ' ) + ' #send '
redirect_url = url_for ( ' wallet.dashboard ' ) + ' #send '
wallet = Wallet (
proto = ' http ' ,
host = ' 127.0.0.1 ' ,
port = current_user . wallet_port ,
username = current_user . id ,
password = current_user . wallet_password
)
if send_form . validate_on_submit ( ) :
if send_form . validate_on_submit ( ) :
address = str ( send_form . address . data )
address = str ( send_form . address . data )
user = User . query . get ( current_user . id )
user = User . query . get ( current_user . id )
@ -119,43 +126,32 @@ def send():
flash ( ' Wallet RPC interface is unavailable at this time. Try again later. ' )
flash ( ' Wallet RPC interface is unavailable at this time. Try again later. ' )
return redirect ( redirect_url )
return redirect ( redirect_url )
# Check if user funds flag is locked
if current_user . funds_locked :
flash ( ' You currently have transactions pending and transfers are locked. Try again later. ' )
return redirect ( redirect_url )
# Quick n dirty check to see if address is WOW
# Quick n dirty check to see if address is WOW
if len ( address ) not in [ 97 , 108 ] :
if len ( address ) not in [ 97 , 108 ] :
flash ( ' Invalid Wownero address provided. ' )
flash ( ' Invalid Wownero address provided. ' )
return redirect ( redirect_url )
return redirect ( redirect_url )
# Make sure the amount provided is a number
# Check if we're sweeping or not
try :
if send_form . amount . data == ' all ' :
amount = to_atomic ( Decimal ( send_form . amount . data ) )
tx = wallet . transfer ( address , None , ' sweep_all ' )
except :
else :
flash ( ' Invalid Wownero amount specified. ' )
# Make sure the amount provided is a number
return redirect ( redirect_url )
try :
amount = to_atomic ( Decimal ( send_form . amount . data ) )
# Make sure the amount does not exceed the balance
except :
if amount > = user . balance :
flash ( ' Invalid Wownero amount specified. ' )
flash ( ' Not enough funds to transfer that much. ' )
return redirect ( redirect_url )
return redirect ( redirect_url )
# Send transfer
# Lock user funds
tx = wallet . transfer ( address , amount )
user . funds_locked = True
db . session . commit ( )
# Inform user of result and redirect
if ' message ' in tx :
# Queue the transaction
msg = tx [ ' message ' ] . capitalize ( )
tx = TransferQueue (
flash ( f ' There was a problem sending the transaction: { msg } ' )
user = user . id ,
else :
address = address ,
flash ( ' Successfully sent transfer. ' )
amount = amount
)
db . session . add ( tx )
db . session . commit ( )
# Redirect back
flash ( ' Successfully queued transfer. ' )
return redirect ( redirect_url )
return redirect ( redirect_url )
else :
else :
for field , errors in send_form . errors . items ( ) :
for field , errors in send_form . errors . items ( ) :