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,49 +8255,69 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
let ask_flo_addr_btn = document.getElementById('ask_flo_addr_btn');
|
var RM_WALLET = new localbitcoinplusplus.wallets;
|
||||||
ask_flo_addr_btn.addEventListener('click', function () {
|
var RM_TRADE = new localbitcoinplusplus.trade;
|
||||||
let ask_flo_addr = document.getElementById('ask_flo_addr');
|
var RM_RPC = new localbitcoinplusplus.rpc;
|
||||||
let ask_flo_addr_val = ask_flo_addr.value.trim();
|
|
||||||
|
|
||||||
if (ask_flo_addr_val == null || typeof ask_flo_addr_val == undefined) {
|
//Test: fetch flo comment
|
||||||
throw new Error('Empty or invalid FLO address.');
|
// var rm_configs = RM_TRADE.fetch_configs(function(data) {
|
||||||
}
|
// console.log(data);
|
||||||
|
// });
|
||||||
|
|
||||||
if (localbitcoinplusplusObj.myLocalFLOPrivateKey.trim() == "") {
|
// // Test: Trade functionality
|
||||||
let user_pvt_key = prompt("Please Enter your private key");
|
var trade_btn = document.createElement("button");
|
||||||
if (user_pvt_key.trim() != null) {
|
trade_btn.innerText = "Trade";
|
||||||
localbitcoinplusplusObj.myLocalFLOPrivateKey = user_pvt_key;
|
trade_btn.onclick = function () {
|
||||||
}
|
var buytrade = RM_TRADE.place_order("buy", "BTC", "INR", 10000.00, "buyer_public_key",
|
||||||
}
|
"buyer_key_signature", "order_validator_public_key");
|
||||||
localbitcoinplusplusObj.myLocalFLOAddress = ask_flo_addr_val;
|
doSend(buytrade);
|
||||||
updateinDB(localbitcoinplusplusObj, "00-01");
|
}
|
||||||
|
document.getElementById("output_div").appendChild(trade_btn);
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
(function () {
|
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();
|
||||||
|
|
||||||
var RM_WALLET = new localbitcoinplusplus.wallets;
|
if (ask_flo_addr_val == null || typeof ask_flo_addr_val == undefined) {
|
||||||
var RM_TRADE = new localbitcoinplusplus.trade;
|
throw new Error('Empty or invalid FLO address.');
|
||||||
var RM_RPC = new localbitcoinplusplus.rpc;
|
}
|
||||||
|
|
||||||
//Test: fetch flo comment
|
try {
|
||||||
// var rm_configs = RM_TRADE.fetch_configs(function(data) {
|
readDB(function(idbData) {
|
||||||
// console.log(data);
|
//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) {
|
||||||
|
|
||||||
// // Test: Trade functionality
|
let newKeys = RM_WALLET.generateFloKeys(user_pvt_key);
|
||||||
var trade_btn = document.createElement("button");
|
|
||||||
trade_btn.innerText = "Trade";
|
if (typeof newKeys == 'object' && typeof newKeys.address !== undefined) {
|
||||||
trade_btn.onclick = function () {
|
localbitcoinplusplusObj.myLocalFLOAddress = newKeys.address;
|
||||||
var buytrade = RM_TRADE.place_order("buy", "BTC", "INR", 10000.00, "buyer_public_key",
|
localbitcoinplusplusObj.myLocalFLOPublicKey = newKeys.pubKeyHex;
|
||||||
"buyer_key_signature", "order_validator_public_key");
|
localbitcoinplusplusObj.myLocalFLOPrivateKey = newKeys.privateKeyWIF;
|
||||||
doSend(buytrade);
|
localbitcoinplusplusObj.mySelfDeclaredBalance = 0;
|
||||||
}
|
localbitcoinplusplusObj.mySelfDeclaredBalanceFLO = 0;
|
||||||
document.getElementById("output_div").appendChild(trade_btn);
|
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