Skip to content

Commit

Permalink
Force lowercase for bech32 addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
Kexkey committed Feb 3, 2021
1 parent f378280 commit de79c2c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/lib/HttpServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ class HttpServer {
const reqBatchRequest: IReqBatchRequest = params as IReqBatchRequest;
logger.debug("reqBatchRequest: %s", reqBatchRequest);

// Convert address to lowercase only if bech32
const lowercased = reqBatchRequest.address.toLowerCase();
if (
lowercased.startsWith("bc") ||
lowercased.startsWith("tb") ||
lowercased.startsWith("bcrt")
) {
reqBatchRequest.address = lowercased;
}

return await this._batcher.queueForNextBatch(reqBatchRequest);
}

Expand All @@ -79,6 +89,18 @@ class HttpServer {
const reqDequeueAndPay: IReqDequeueAndPay = params as IReqDequeueAndPay;
logger.debug("reqDequeueAndPay: %s", reqDequeueAndPay);

// Convert address to lowercase only if bech32
if (reqDequeueAndPay.address) {
const lowercased = reqDequeueAndPay.address.toLowerCase();
if (
lowercased.startsWith("bc") ||
lowercased.startsWith("tb") ||
lowercased.startsWith("bcrt")
) {
reqDequeueAndPay.address = lowercased;
}
}

return await this._batcher.dequeueAndPay(reqDequeueAndPay);
}

Expand Down

0 comments on commit de79c2c

Please sign in to comment.