mirror of
https://git.wownero.com/wownero/tippero.git
synced 2024-08-15 00:33:14 +00:00
withdraw: add support for payment id
This commit is contained in:
parent
c8b6ade388
commit
b5b775e90c
1 changed files with 19 additions and 4 deletions
|
@ -52,13 +52,24 @@ def Withdraw(link,cmd):
|
|||
try:
|
||||
address=cmd[1]
|
||||
except Exception,e:
|
||||
link.send("Usage: withdraw address [amount]")
|
||||
link.send("Usage: withdraw address [amount] [paymentid]")
|
||||
return
|
||||
|
||||
if not IsValidAddress(address):
|
||||
link.send("Invalid address")
|
||||
return
|
||||
amount = GetParam(cmd,2)
|
||||
|
||||
if GetParam(cmd,3):
|
||||
amount = GetParam(cmd,2)
|
||||
paymentid = GetParam(cmd,3)
|
||||
else:
|
||||
if IsValidPaymentID(GetParam(cmd,2)):
|
||||
amount = None
|
||||
paymentid = GetParam(cmd,2)
|
||||
else:
|
||||
amount = GetParam(cmd,2)
|
||||
paymentid = None
|
||||
|
||||
if amount:
|
||||
try:
|
||||
amount = StringToUnits(amount)
|
||||
|
@ -68,6 +79,10 @@ def Withdraw(link,cmd):
|
|||
except Exception,e:
|
||||
link.send("Invalid amount")
|
||||
return
|
||||
if paymentid != None:
|
||||
if not IsValidPaymentID(paymentid):
|
||||
link.send("Invalid payment ID")
|
||||
return
|
||||
|
||||
log_info("Withdraw: %s wants to withdraw %s to %s" % (identity, AmountToString(amount) if amount else "all", address))
|
||||
|
||||
|
@ -106,7 +121,7 @@ def Withdraw(link,cmd):
|
|||
log_info('Withdraw: fee: %s, to pay: %s' % (AmountToString(fee), AmountToString(topay)))
|
||||
params = {
|
||||
'destinations': [{'address': address, 'amount': topay}],
|
||||
'payment_id': GetPaymentID(link),
|
||||
'payment_id': paymentid,
|
||||
'fee': coinspecs.min_withdrawal_fee,
|
||||
'mixin': config.withdrawal_mixin,
|
||||
'unlock_time': 0,
|
||||
|
@ -153,7 +168,7 @@ RegisterModule({
|
|||
RegisterCommand({
|
||||
'module': __name__,
|
||||
'name': 'withdraw',
|
||||
'parms': '<address> [<amount>]',
|
||||
'parms': '<address> [<amount>] [paymentid]',
|
||||
'function': Withdraw,
|
||||
'registered': True,
|
||||
'help': "withdraw part or all of your balance"
|
||||
|
|
Loading…
Reference in a new issue