mirror of
https://git.wownero.com/wownero/tippero.git
synced 2024-08-15 00:33:14 +00:00
New randompid command, to allow avoiding payment id reuse
This commit is contained in:
parent
e387fa67ab
commit
921212d217
2 changed files with 20 additions and 2 deletions
|
@ -161,6 +161,9 @@ def UpdateCoin(data):
|
|||
def Deposit(link,cmd):
|
||||
Help(link)
|
||||
|
||||
def RandomPaymentID(link,cmd):
|
||||
link.send_private(" New payment ID: %s" % GetRandomPaymentID(link))
|
||||
|
||||
def Help(link):
|
||||
GetAccount(link.identity())
|
||||
link.send_private("You can send %s to your account:" % coinspecs.name);
|
||||
|
@ -168,7 +171,8 @@ def Help(link):
|
|||
link.send_private(" Address: %s" % address)
|
||||
if config.openalias_address != None:
|
||||
link.send_private(" (or %s when using OpenAlias)" % config.openalias_address)
|
||||
link.send_private(" Payment ID: %s" % GetPaymentID(link))
|
||||
link.send_private(" Main payment ID: %s" % GetPaymentID(link))
|
||||
link.send_private(" OR generate random payment ids at will with: !randompid")
|
||||
link.send_private("Incoming transactions are credited after %d confirmations" % config.payment_confirmations)
|
||||
|
||||
RegisterModule({
|
||||
|
@ -182,4 +186,11 @@ RegisterCommand({
|
|||
'function': Deposit,
|
||||
'help': "Show instructions about depositing %s" % coinspecs.name
|
||||
})
|
||||
RegisterCommand({
|
||||
'module': __name__,
|
||||
'name': 'randompid',
|
||||
'function': RandomPaymentID,
|
||||
'registered': True,
|
||||
'help': "Generate a new random payment ID"
|
||||
})
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@ import time
|
|||
import threading
|
||||
import math
|
||||
import string
|
||||
import random
|
||||
from Crypto.Random.random import getrandbits
|
||||
from decimal import *
|
||||
import tipbot.config as config
|
||||
import tipbot.coinspecs as coinspecs
|
||||
|
@ -55,8 +57,10 @@ def GetParam(parms,idx):
|
|||
return parms[idx]
|
||||
return None
|
||||
|
||||
def GetPaymentID(link):
|
||||
def GetPaymentID(link,random=False):
|
||||
salt="2u3g55bkwrui32fi3g4bGR$j5g4ugnujb-"+coinspecs.name+"-";
|
||||
if random:
|
||||
salt = salt + "-" + str(time.time()) + "-" + str(getrandbits(128))
|
||||
p = hashlib.sha256(salt+link.identity()).hexdigest();
|
||||
try:
|
||||
redis_hset("paymentid",p,link.identity())
|
||||
|
@ -64,6 +68,9 @@ def GetPaymentID(link):
|
|||
log_error('GetPaymentID: failed to set payment ID for %s to redis: %s' % (link.identity(),str(e)))
|
||||
return p
|
||||
|
||||
def GetRandomPaymentID(link):
|
||||
return GetPaymentID(link, True)
|
||||
|
||||
def GetIdentityFromPaymentID(p):
|
||||
if not redis_hexists("paymentid",p):
|
||||
log_log('PaymentID %s not found' % p)
|
||||
|
|
Loading…
Reference in a new issue