dotwallet
Version:
A DotWallet helper library
41 lines (40 loc) • 1.15 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const md5 = require("md5");
const crypto = require("crypto");
var SupportCoinType;
(function (SupportCoinType) {
SupportCoinType["BTC"] = "BTC";
SupportCoinType["BSV"] = "BSV";
SupportCoinType["ETH"] = "ETH";
})(SupportCoinType = exports.SupportCoinType || (exports.SupportCoinType = {}));
class DWError extends Error {
constructor(code, msg) {
super(msg);
this.name = 'DotWalletError';
}
}
exports.DWError = DWError;
;
function CreateSignature(queryData, app_secret) {
let str = "";
const secret = md5(app_secret);
for (let key in queryData) {
if (key != "sign" && key != "opreturn") {
if (str) {
str += "&" + key + "=" + queryData[key];
}
else {
str = key + "=" + queryData[key];
}
}
}
str += "&secret=" + secret;
str = str.toUpperCase();
const sign = crypto
.createHmac("sha256", secret)
.update(str, "utf8")
.digest("hex");
return sign;
}
exports.CreateSignature = CreateSignature;
;