mirror of
https://git.wownero.com/wownero/tippero.git
synced 2024-08-15 00:33:14 +00:00
Wait for some number of confirmations before acting on a deposit
This commit is contained in:
parent
1ad4474315
commit
55ec6907d3
2 changed files with 54 additions and 22 deletions
|
@ -34,6 +34,7 @@ withdrawal_fee=None # None defaults to the network default fee
|
||||||
min_withdraw_amount = None # None defaults to the withdrawal fee
|
min_withdraw_amount = None # None defaults to the withdrawal fee
|
||||||
withdrawal_mixin=0
|
withdrawal_mixin=0
|
||||||
disable_withdraw_on_error = True
|
disable_withdraw_on_error = True
|
||||||
|
payment_confirmations = 6
|
||||||
|
|
||||||
admins = ["freenode:moneromooo", "freenode:moneromoo"]
|
admins = ["freenode:moneromooo", "freenode:moneromoo"]
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,20 @@ def UpdateCoin(data):
|
||||||
last_wallet_update_time = time.time()
|
last_wallet_update_time = time.time()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
j = SendDaemonHTMLCommand("getheight")
|
||||||
|
except Exception,e:
|
||||||
|
log_error('UpdateCoin: error getting height: %s' % str(e))
|
||||||
|
return
|
||||||
|
if not "height" in j:
|
||||||
|
log_error('UpdateCoin: error getting height: height not found in %s' % str(j))
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
height=long(j["height"])
|
||||||
|
except Exception,e:
|
||||||
|
log_error('UpdateCoin: error getting height: %s' % str(e))
|
||||||
|
return
|
||||||
|
|
||||||
full_payment_ids = redis_hgetall("paymentid")
|
full_payment_ids = redis_hgetall("paymentid")
|
||||||
#print 'Got full payment ids: %s' % str(full_payment_ids)
|
#print 'Got full payment ids: %s' % str(full_payment_ids)
|
||||||
payment_ids = []
|
payment_ids = []
|
||||||
|
@ -69,12 +83,25 @@ def UpdateCoin(data):
|
||||||
if "payments" in result:
|
if "payments" in result:
|
||||||
payments = result["payments"]
|
payments = result["payments"]
|
||||||
log_info('UpdateCoin: Got %d payments' % len(payments))
|
log_info('UpdateCoin: Got %d payments' % len(payments))
|
||||||
|
new_payments = []
|
||||||
|
n_confirming = 0
|
||||||
for p in payments:
|
for p in payments:
|
||||||
log_log('UpdateCoin: Looking at payment %s' % str(p))
|
log_log('UpdateCoin: Looking at payment %s' % str(p))
|
||||||
bh = p["block_height"]
|
bh = p["block_height"]
|
||||||
|
confirmations = height-1-bh
|
||||||
|
if confirmations >= config.payment_confirmations:
|
||||||
|
log_info('Payment %s is now confirmed' % str(p))
|
||||||
|
new_payments.append(p)
|
||||||
|
else:
|
||||||
|
log_info('Payment %s has %d/%d confirmations' % (str(p),confirmations,config.payment_confirmations))
|
||||||
|
n_confirming += 1
|
||||||
|
payments=new_payments
|
||||||
|
if len(payments) > 0:
|
||||||
|
for p in payments:
|
||||||
if bh > scan_block_height:
|
if bh > scan_block_height:
|
||||||
scan_block_height = bh
|
scan_block_height = bh
|
||||||
log_log('UpdateCoin: seen payments up to block %d' % scan_block_height)
|
log_info('UpdateCoin: Got %d mature payments and %d confirming payments' % (len(payments),n_confirming))
|
||||||
|
log_log('UpdateCoin: updated payments up to block %d' % scan_block_height)
|
||||||
try:
|
try:
|
||||||
pipe = redis_pipeline()
|
pipe = redis_pipeline()
|
||||||
pipe.set("scan_block_height", scan_block_height)
|
pipe.set("scan_block_height", scan_block_height)
|
||||||
|
@ -83,12 +110,16 @@ def UpdateCoin(data):
|
||||||
payment_id=p["payment_id"]
|
payment_id=p["payment_id"]
|
||||||
tx_hash=p["tx_hash"]
|
tx_hash=p["tx_hash"]
|
||||||
amount=p["amount"]
|
amount=p["amount"]
|
||||||
|
bh = p["block_height"]
|
||||||
try:
|
try:
|
||||||
recipient = GetIdentityFromPaymentID(payment_id)
|
recipient = GetIdentityFromPaymentID(payment_id)
|
||||||
if not recipient:
|
if not recipient:
|
||||||
raise RuntimeError('Payment ID %s not found' % payment_id)
|
raise RuntimeError('Payment ID %s not found' % payment_id)
|
||||||
log_info('UpdateCoin: Found payment %s to %s for %s' % (tx_hash,recipient, AmountToString(amount)))
|
log_info('UpdateCoin: Found payment %s to %s for %s' % (tx_hash,recipient, AmountToString(amount)))
|
||||||
pipe.hincrby("balances",recipient,amount);
|
if bh < height-config.payment_confirmations:
|
||||||
|
pipe.hincrby("balances",recipient,amount)
|
||||||
|
else:
|
||||||
|
log_log('%d/%d confirmations' % (height-1-bh,config.payment_confirmations))
|
||||||
except Exception,e:
|
except Exception,e:
|
||||||
log_error('UpdateCoin: No identity found for payment id %s, tx hash %s, amount %s: %s' % (payment_id, tx_hash, amount, str(e)))
|
log_error('UpdateCoin: No identity found for payment id %s, tx hash %s, amount %s: %s' % (payment_id, tx_hash, amount, str(e)))
|
||||||
log_log('UpdateCoin: Executing received payments pipeline')
|
log_log('UpdateCoin: Executing received payments pipeline')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue