From 9edc0d2e313f46d63090dc492be87f76cc868c77 Mon Sep 17 00:00:00 2001 From: matograine <tom.ngr@zaclys.net> Date: Sat, 14 Nov 2020 12:52:13 +0100 Subject: [PATCH] [mod] tx.py : use MAX_COMMENT_LENGTH as a constant for comment check --- silkaj/tx.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/silkaj/tx.py b/silkaj/tx.py index fdbf60d9..edbe3b16 100644 --- a/silkaj/tx.py +++ b/silkaj/tx.py @@ -41,6 +41,8 @@ from duniterpy.api.bma.tx import process from duniterpy.documents import BlockUID, Transaction from duniterpy.documents.transaction import OutputSource, Unlock, SIGParameter +MAX_COMMENT_LENGTH = 255 + @command("tx", help="Send transaction") @option( @@ -469,13 +471,13 @@ def generate_output(listoutput, unitbase, rest, recipient_address): unitbase = unitbase - 1 -def checkComment(Comment): - if len(Comment) > 255: +def checkComment(comment): + if len(comment) > MAX_COMMENT_LENGTH: tools.message_exit("Error: Comment is too long") regex = compile( "^[0-9a-zA-Z\\ \\-\\_\\:\\/\\;\\*\\[\\]\\(\\)\\?\\!\\^\\+\\=\\@\\&\\~\\#\\{\\}\\|\\\\<\\>\\%\\.]*$" ) - if not search(regex, Comment): + if not search(regex, comment): tools.message_exit("Error: the format of the comment is invalid") -- GitLab