added code for adding flo keys to db
This commit is contained in:
parent
d7ff21f1e4
commit
6ec3cb33d8
@ -7587,9 +7587,9 @@
|
|||||||
wallets.prototype = {
|
wallets.prototype = {
|
||||||
ecparams: EllipticCurve.getSECCurveByName("secp256k1"),
|
ecparams: EllipticCurve.getSECCurveByName("secp256k1"),
|
||||||
|
|
||||||
generateFloKeys: function () {
|
generateFloKeys: function (pk) {
|
||||||
|
|
||||||
var privateKey = Bitcoin.ECDSA.getBigRandom(EllipticCurve.getSECCurveByName("secp256k1")
|
var privateKey = pk || Bitcoin.ECDSA.getBigRandom(EllipticCurve.getSECCurveByName("secp256k1")
|
||||||
.getN());
|
.getN());
|
||||||
//console.log(privateKey);
|
//console.log(privateKey);
|
||||||
|
|
||||||
@ -7613,6 +7613,12 @@
|
|||||||
console.log("pubKeyHash: ", pubKeyHash);
|
console.log("pubKeyHash: ", pubKeyHash);
|
||||||
console.log("pubKeyHex: ", pubKeyHex);
|
console.log("pubKeyHex: ", pubKeyHex);
|
||||||
console.log("address: ", address);
|
console.log("address: ", address);
|
||||||
|
|
||||||
|
return {
|
||||||
|
privateKeyWIF,
|
||||||
|
pubKeyHex,
|
||||||
|
address
|
||||||
|
};
|
||||||
},
|
},
|
||||||
sign: function (msg, privateKeyHex) {
|
sign: function (msg, privateKeyHex) {
|
||||||
|
|
||||||
@ -8175,7 +8181,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function readDB() {
|
function readDB(callback) {
|
||||||
var transaction = db.transaction(["localbitcoinUser"]);
|
var transaction = db.transaction(["localbitcoinUser"]);
|
||||||
var objectStore = transaction.objectStore("localbitcoinUser");
|
var objectStore = transaction.objectStore("localbitcoinUser");
|
||||||
var request = objectStore.get("00-01");
|
var request = objectStore.get("00-01");
|
||||||
@ -8187,7 +8193,7 @@
|
|||||||
request.onsuccess = function (event) {
|
request.onsuccess = function (event) {
|
||||||
// Do something with the request.result!
|
// Do something with the request.result!
|
||||||
if (request.result) {
|
if (request.result) {
|
||||||
console.log(request);
|
callback(request.result);
|
||||||
} else {
|
} else {
|
||||||
alert("Data couldn't be found in your database!");
|
alert("Data couldn't be found in your database!");
|
||||||
}
|
}
|
||||||
@ -8237,10 +8243,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeinDB() {
|
function removeinDB(id) {
|
||||||
var request = db.transaction(["localbitcoinUser"], "readwrite")
|
var request = db.transaction(["localbitcoinUser"], "readwrite")
|
||||||
.objectStore("localbitcoinUser")
|
.objectStore("localbitcoinUser")
|
||||||
.delete("00-01");
|
.delete(id);
|
||||||
|
|
||||||
request.onsuccess = function (event) {
|
request.onsuccess = function (event) {
|
||||||
alert("Data entry has been removed from your database.");
|
alert("Data entry has been removed from your database.");
|
||||||
@ -8249,30 +8255,6 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
let ask_flo_addr_btn = document.getElementById('ask_flo_addr_btn');
|
|
||||||
ask_flo_addr_btn.addEventListener('click', function () {
|
|
||||||
let ask_flo_addr = document.getElementById('ask_flo_addr');
|
|
||||||
let ask_flo_addr_val = ask_flo_addr.value.trim();
|
|
||||||
|
|
||||||
if (ask_flo_addr_val == null || typeof ask_flo_addr_val == undefined) {
|
|
||||||
throw new Error('Empty or invalid FLO address.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (localbitcoinplusplusObj.myLocalFLOPrivateKey.trim() == "") {
|
|
||||||
let user_pvt_key = prompt("Please Enter your private key");
|
|
||||||
if (user_pvt_key.trim() != null) {
|
|
||||||
localbitcoinplusplusObj.myLocalFLOPrivateKey = user_pvt_key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
localbitcoinplusplusObj.myLocalFLOAddress = ask_flo_addr_val;
|
|
||||||
updateinDB(localbitcoinplusplusObj, "00-01");
|
|
||||||
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
(function () {
|
|
||||||
|
|
||||||
var RM_WALLET = new localbitcoinplusplus.wallets;
|
var RM_WALLET = new localbitcoinplusplus.wallets;
|
||||||
var RM_TRADE = new localbitcoinplusplus.trade;
|
var RM_TRADE = new localbitcoinplusplus.trade;
|
||||||
var RM_RPC = new localbitcoinplusplus.rpc;
|
var RM_RPC = new localbitcoinplusplus.rpc;
|
||||||
@ -8291,7 +8273,51 @@
|
|||||||
doSend(buytrade);
|
doSend(buytrade);
|
||||||
}
|
}
|
||||||
document.getElementById("output_div").appendChild(trade_btn);
|
document.getElementById("output_div").appendChild(trade_btn);
|
||||||
})()
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.onload = function() {
|
||||||
|
let ask_flo_addr_btn = document.getElementById('ask_flo_addr_btn');
|
||||||
|
ask_flo_addr_btn.addEventListener('click', function () {
|
||||||
|
let ask_flo_addr = document.getElementById('ask_flo_addr');
|
||||||
|
let ask_flo_addr_val = ask_flo_addr.value.trim();
|
||||||
|
|
||||||
|
if (ask_flo_addr_val == null || typeof ask_flo_addr_val == undefined) {
|
||||||
|
throw new Error('Empty or invalid FLO address.');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
readDB(function(idbData) {
|
||||||
|
//console.log(idbData);
|
||||||
|
if (typeof idbData.myLocalFLOPrivateKey == undefined || idbData.myLocalFLOPrivateKey.trim() == '') {
|
||||||
|
let user_pvt_key = prompt("Please Enter your private key");
|
||||||
|
if (user_pvt_key.trim() != null) {
|
||||||
|
|
||||||
|
let newKeys = RM_WALLET.generateFloKeys(user_pvt_key);
|
||||||
|
|
||||||
|
if (typeof newKeys == 'object' && typeof newKeys.address !== undefined) {
|
||||||
|
localbitcoinplusplusObj.myLocalFLOAddress = newKeys.address;
|
||||||
|
localbitcoinplusplusObj.myLocalFLOPublicKey = newKeys.pubKeyHex;
|
||||||
|
localbitcoinplusplusObj.myLocalFLOPrivateKey = newKeys.privateKeyWIF;
|
||||||
|
localbitcoinplusplusObj.mySelfDeclaredBalance = 0;
|
||||||
|
localbitcoinplusplusObj.mySelfDeclaredBalanceFLO = 0;
|
||||||
|
localbitcoinplusplusObj.mySelfdeclaredBalanceBitcoin = 0;
|
||||||
|
localbitcoinplusplusObj.mySelfDeclaredBalanceINR = 0;
|
||||||
|
|
||||||
|
updateinDB(localbitcoinplusplusObj, "00-01");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
throw new Error(
|
||||||
|
"ERROR: Failed to initialise the database. You are unable to trade at the moment.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Further operation here
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user