From b5b775e90c8015f2bb6a5af9671a4d682c1f337d Mon Sep 17 00:00:00 2001 From: moneromooo Date: Mon, 2 Feb 2015 20:43:41 +0000 Subject: [PATCH] withdraw: add support for payment id --- tipbot/modules/withdraw.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/tipbot/modules/withdraw.py b/tipbot/modules/withdraw.py index e3bb0be..1825a58 100644 --- a/tipbot/modules/withdraw.py +++ b/tipbot/modules/withdraw.py @@ -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': '
[]', + 'parms': '
[] [paymentid]', 'function': Withdraw, 'registered': True, 'help': "withdraw part or all of your balance"