Lowercasing bech32 addresses

This commit is contained in:
kexkey
2021-02-11 14:06:50 -05:00
parent bc4e4fa26e
commit 738051859e
5 changed files with 64 additions and 30 deletions

View File

@@ -2,6 +2,7 @@
. ./trace.sh
. ./sendtobitcoinnode.sh
. ./bitcoin.sh
createbatcher() {
trace "Entering createbatcher()..."
@@ -159,6 +160,9 @@ addtobatch() {
local webhook_url=$(echo "${request}" | jq ".webhookUrl")
trace "[addtobatch] webhook_url=${webhook_url}"
# Let's lowercase bech32 addresses
address=$(lowercase_if_bech32 "${address}")
local isvalid
isvalid=$(validateaddress "${address}" | jq ".result.isvalid")
if [ "${isvalid}" != "true" ]; then
@@ -191,7 +195,7 @@ addtobatch() {
response='{"result":null,"error":{"code":-32700,"message":"batcher not found","data":'${request}'}}'
else
# Check if address already pending for this batcher...
inserted_id=$(sql "SELECT id FROM recipient WHERE address=\"${address}\" AND tx_id IS NULL AND batcher_id=${batcher_id}")
inserted_id=$(sql "SELECT id FROM recipient WHERE LOWER(address)=LOWER(\"${address}\") AND tx_id IS NULL AND batcher_id=${batcher_id}")
if [ -n "${inserted_id}" ]; then
response='{"result":null,"error":{"code":-32700,"message":"Duplicated address","data":'${request}'}}'