From e449fed8cc98f9eb0946f12bf70dff5263b89c7b Mon Sep 17 00:00:00 2001 From: koalaKoolaid Date: Fri, 10 Apr 2020 17:08:10 -0400 Subject: [PATCH] Switched to integrated addresses --- tipbot/modules/payment.py | 25 ++++++++++++++----------- tipbot/utils.py | 7 +++++++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/tipbot/modules/payment.py b/tipbot/modules/payment.py index 3e4c208..2383405 100644 --- a/tipbot/modules/payment.py +++ b/tipbot/modules/payment.py @@ -22,19 +22,22 @@ from tipbot.command_manager import * last_wallet_update_time = None -def GetTipbotAddress(): +def GetTipbotIntAddress(): try: - j = SendWalletJSONRPCCommand("getaddress",None) + j = SendWalletJSONRPCCommand("make_integrated_address",None) if not "result" in j: - log_error('GetTipbotAddress: No result found in getaddress reply') + log_error('GetTipbotIntAddress: No result found in make_integrated_address reply') return None result = j["result"] - if not "address" in result: - log_error('GetTipbotAddress: No address found in getaddress reply') + if not "integrated_address" in result: + log_error('GetTipbotIntAddress: No integrated_address found in make_integrated_address reply') return None - return result["address"] + if not "payment_id" in result: + log_error('GetTipbotIntAddress: No payment_id found in make_integrated_address reply') + return None + return result except Exception,e: - log_error("GetTipbotAddress: Error retrieving %s's address: %s" % (config.tipbot_name, str(e))) + log_error("GetTipbotIntAddress: Error retrieving %s's int_address: %s" % (config.tipbot_name, str(e))) return None def UpdateCoin(data): @@ -167,12 +170,12 @@ def RandomPaymentID(link,cmd): def Help(link): GetAccount(link.identity()) link.send_private("You can send %s to your account using this address AND payment ID:" % coinspecs.name); - address=GetTipbotAddress() or 'ERROR' - link.send_private(" Address: %s" % address) + result=GetTipbotIntAddress() or 'ERROR' + link.send_private(" Address: %s" % result["integrated_address"]) if config.openalias_address != None: link.send_private(" (or %s when using OpenAlias)" % config.openalias_address) - link.send_private(" Use your primary payment ID: %s" % GetPaymentID(link)) - link.send_private(" OR generate random payment ids at will with: !randompid") + SetPaymentID(link,result["payment_id"]) + link.send_private(" Use your primary payment ID: %s" % result["payment_id"]) link.send_private("Incoming transactions are credited after %d confirmations" % config.payment_confirmations) RegisterModule({ diff --git a/tipbot/utils.py b/tipbot/utils.py index 30300a2..d006c76 100644 --- a/tipbot/utils.py +++ b/tipbot/utils.py @@ -57,6 +57,13 @@ def GetParam(parms,idx): return parms[idx] return None +def SetPaymentID(link,pid): + try: + redis_hset("paymentid",pid,link.identity()) + except Exception,e: + log_error('GetPaymentID: failed to set payment ID for %s to redis: %s' % (link.identity(),str(e))) + return + def GetPaymentID(link,random=False): salt="2u3g55bkwrui32fi3g4bGR$j5g4ugnujb-"+coinspecs.name+"-"; if random: