From 9389e043e4cc47fe2aa3c5b7083f1e468728d13e Mon Sep 17 00:00:00 2001 From: moneromooo Date: Fri, 26 Dec 2014 12:16:08 +0000 Subject: [PATCH] Handle multi-character prefixes in address sanity checking --- tipbot.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tipbot.py b/tipbot.py index f3e4f51..eca22dd 100644 --- a/tipbot.py +++ b/tipbot.py @@ -388,13 +388,18 @@ def CheckDisableWithdraw(): if disable_withdraw_on_error: DisableWithdraw(None,None) +def IsValidAddress(address): + if len(address) < address_length[0] or len(address) > address_length[1]: + return False + for prefix in address_prefix: + if address.startswith(prefix): + return True + return False + def Withdraw(nick,data): address=data[0] amount=data[1] - if len(address) < address_length[0] or len(address) > address_length[1]: - SendTo(nick, "Invalid address") - return - if not address[0] in address_prefix: + if not IsValidAddress(address): SendTo(nick, "Invalid address") return if amount: