designing new template for website

This commit is contained in:
Abhishek Sinha 2019-02-15 19:38:03 +05:30
parent b0a722e590
commit 58f37465ed
2 changed files with 501 additions and 44 deletions

422
supernode/design.html Normal file
View File

@ -0,0 +1,422 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Local BTC ++</title>
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
<style>
html, body {
height: 100%;
margin: 0;
color: #ffffff;
font-family: 'Montserrat', sans-serif;
}
input[type=text] {
border: 1px solid #F4F4F4;
border-radius: 3px;
display: block;
width: 100%;
margin-top: 10px;
margin-bottom: 10px;
padding: 15px;
}
.box {
height: 100%;
width: 100%;
display: flex;
flex: 1;
align-items: center;
justify-content: center;
flex-wrap: wrap;
}
.center-div {
display: block;
align-items: center;
justify-content: center;
padding: 15px 15px;
text-align: center;
}
.custom-select {
width: 100%;
height: auto;
display: flex;
flex-wrap: wrap;
flex: 1;
}
select {
display: flex;
flex: 1;
margin: 20px 20px;
width: auto;
padding: 10px 10px 10px 10px;
font-size: 16px;
height: 47px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background-color: rgba(0, 0, 0, 0.1); /*#1f8ffc*/
color: #ffffff;
font-family: 'Montserrat';
border-radius: 2px;
border: none;
/* background: url(http://www.stackoverflow.com/favicon.ico) 96% / 15% no-repeat #eee; */
}
/* CAUTION: IE hackery ahead */
select::-ms-expand {
display: none; /* remove default arrow in IE 10 and 11 */
}
option {
color: #6b8e23;
padding: 8px 16px;
border: 1px solid transparent;
/* border-color: #1f8ffc transparent rgba(0, 0, 0, 0.1) transparent; */
cursor: pointer;
user-select: none;
white-space: pre;
background-color: transparent;
}
/* target Internet Explorer 9 to undo the custom arrow */
@media screen and (min-width:0\0) {
select {
background:none\9;
padding: 5px\9;
}
}
.button {
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
border-radius: 2px;
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.4s;
}
.button:hover {
background-color: #4CAF50; /* Green */
color: white;
}
.bg-green {background-color: #4CAF50;} /* Green */
.bg-blue {background-color: #008CBA;} /* Blue */
.bg-lightblue {background-color: #7acfd6}
.bg-lightblue2 {background-color: #93b7ec}
.bg-red {background-color: #f44336;} /* Red */
.bg-grey {background-color: #e7e7e7; color: black;} /* Gray */
.bg-black {background-color: #555555;}
.bg-white {background-color: #ffffff;}
.bg-purple {background-color: #9f93ec}
.bg-olive {background-color: olivedrab}
.bg-pink {background-color: #e0474c}
.bg-lightpink {background-color: #ec93d3}
.bg-gold {background-color: #DCAE1D}
.bg-darkred {background-color: #b11a21}
.bg-transparent {background-color: rgba(0, 0, 0, 0.1)}
.bg-yellow {background-color: #e2ec93}
.fs-10 {font-size: 10px;}
.fs-12 {font-size: 12px;}
.fs-16 {font-size: 16px;}
.fs-20 {font-size: 20px;}
.fs-24 {font-size: 24px;}
.pd1 {padding: 10px 24px;}
.pd2 {padding: 12px 28px;}
.pd3 {padding: 14px 40px;}
.pd4 {padding: 32px 16px;}
.pd5 {padding: 16px;}
.mg-top-5 {margin-top: 5rem;}
.mg-5 {margin: 5px 5px}
.ptext-div {
text-align:center;
margin-bottom: 3rem;
}
.ptext {
color: #ffffff;
font-weight: 600;
font-size: 4rem;
}
.h1text {
color: #ffffff; /*008CBA*/
font-weight: bolder;
font-size: 3rem;
}
.circles {
display: inline-flex;
}
.circle-with-text {
justify-content: center;
align-items: center;
border-radius: 100%;
text-align: center;
margin: 5px 20px;
font-size: 16px;
font-weight: 900;
padding: 15px;
display: flex;
height: 125px;
width: 125px;
color: #9f93ec;
}
.multi-line-text {
font-size: 20px;
}
.center {
text-align: center;
}
#talkbubble {
width: 75%;
height: 75%;
background: #ec9393;
position: relative;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
}
#talkbubble:before {
content: "";
position: absolute;
right: 100%;
top: 26px;
width: 0;
height: 0;
border-top: 13px solid transparent;
border-right: 26px solid #ec9393;
border-bottom: 13px solid transparent;
}
.push-left {
float: left;
}
.push-right {
float: right;
}
#talkbubble {
width: 80%;
height: 75%;
position: relative;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
}
#talkbubble:before {
content: "";
position: absolute;
right: 100%;
top: 26px;
width: 0;
height: 0;
border-top: 13px solid transparent;
border-right: 26px solid #ec9293;
border-bottom: 13px solid transparent;
}
.action-keys-left {
display: flex;
flex: 1;
flex-direction: column;
flex-wrap: wrap;
height: 100%;
}
.action-keys-right {
display: flex;
flex: 1;
flex-direction: column;
flex-wrap: wrap;
height: 100%;
}
.flo_gen_keys_div, .messages_div {
height: 75%;
width: auto;
background-color: rgb(199, 219, 226);
color: #e7e7e7;
margin: 25px 10px;
padding: 20px 20px;
border-radius: 5px;
}
</style>
</head>
<body>
<div class="box bg-purple">
<div class="center-div">
<em><h1 class="h1text">Local Bitcoin Plus Plus P2P EXCHANGE </h1></em>
<div class="circles">
<div class="circle-with-text bg-white">DEPOSIT WITHDRAW SECTION</div>
<div class="circle-with-text bg-white">TRADE ASSETS SECTION</div>
<div class="circle-with-text bg-white">MANAGE ACTIONS SECTION</div>
</div>
<h2 class="mg-top-5">FLO ID: oJK2grERGPMD6i2TDVTfTh6NXwH99gcMKm</h2>
<h4 class="center">
<span> BTC: 25.00020123 </span> &nbsp
<span> FLO: 1225.8478378 </span> &nbsp
<span> USD: 1125.00 </span> &nbsp
<span> INR: 25000.00 </span> &nbsp
</h4>
</div>
<div class="center-div">
<span> Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Aliquam, ipsum recusandae voluptatibus mollitia quidem.
</span>
</div>
</div>
<div class="box bg-olive">
<div class="center-div">
<div class="ptext-div">
<span class="ptext">DEPOSIT WITHDRAW ASSET</span>
</div>
<div class="custom-select">
<select>
<option value="0">Select Asset:</option>
<option value="1">Bitcoin</option>
<option value="2">FLO</option>
<option value="3">Bitcoin Testnet</option>
<option value="4">FLO Testnet</option>
<option value="4">INR</option>
<option value="4">USD</option>
</select>
<select>
<option value="0">Select Fiat:</option>
<option value="1">INR</option>
<option value="2">USD</option>
</select>
<select>
<option value="0">Select Amount (in Fiat):</option>
<option value="1">10000</option>
<option value="2">50000</option>
<option value="3">100000</option>
</select>
</div>
<div style="text-align:center">
<button class="button bg-transparent fs-16">Deposit</button>
<button class="button bg-transparent fs-16">Confirm Deposit</button>
<button class="button bg-transparent fs-16">Withdraw</button>
</div>
</div>
</div>
<div class="box bg-pink">
<div class="center-div">
<div style="text-align:center; margin-bottom: 3rem">
<span class="ptext">BUY SELL ASSET</span>
</div>
<div class="custom-select">
<select>
<option value="0">Select Crypto:</option>
<option value="1">Bitcoin</option>
<option value="2">FLO</option>
<option value="3">Bitcoin Testnet</option>
<option value="4">FLO Testnet</option>
</select>
<select>
<option value="0">Select Fiat:</option>
<option value="1">INR</option>
<option value="2">USD</option>
</select>
<select>
<option value="0">Select Amount:</option>
<option value="1">10000</option>
<option value="2">50000</option>
<option value="3">100000</option>
</select>
</div>
<div style="text-align:center">
<button class="button bg-transparent fs-16">BUY</button>
<button class="button bg-transparent fs-16">SELL</button>
</div>
</div>
</div>
<div class="box bg-lightblue">
<div class="center-div">
<div style="text-align:center; margin-bottom: 3rem">
<span class="ptext">SEND CRYPTO</span>
</div>
<div class="custom-select">
<select>
<option value="0">Select Crypto:</option>
<option value="1">Bitcoin</option>
<option value="2">FLO</option>
<option value="3">Bitcoin Testnet</option>
<option value="4">FLO Testnet</option>
</select>
<select>
<option value="0">Select Fiat:</option>
<option value="1">INR</option>
<option value="2">USD</option>
</select>
</div>
<input type="text" placeholder="UTXO Address of Crypto">
<input type="text" placeholder="Private Key of Crypto">
<input type="text" placeholder="Receiver Address">
<input type="text" placeholder="Amount To Send">
<input type="text" placeholder="Change Address">
<div style="text-align:center">
<button class="button bg-blue fs-16">SEND TRANSACTION</button>
</div>
</div>
</div>
<div class="box bg-yellow">
<div id="talkbubble">
<ul>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</li>
</ul>
</div>
</div>
<div class="box bg-lightblue2">
<div class="push-left action-keys-left">
<div class="flo_gen_keys_div"></div>
<input type="file" class="button bg-purple"></button>
<button class="button bg-purple">Upload D3 JS</button>
</div>
<div class="push-right action-keys-right">
<div class="messages_div"></div>
<button class="button bg-purple mg-5">Generate FLO Keys</button>
</div>
</div>
</body>
</html>

View File

@ -5,7 +5,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<title>P2P Exchange</title>
<style>
.tradebox {
@ -34685,7 +34685,7 @@ exports.createContext = Script.createContext = function (context) {
#!#MASTER_RECEIVING_ADDRESS=oVRq2nka1GtALQT8pbuLHAGjqAQ7PAo6uy#!#validTradingAmount=10000,50000,100000,#!#btcTradeMargin=5000
#!#supernodesPubKeys=02B2D2F40EC5BC9D336BAF14017D629B3A96892D5E86095923A50A734E2364FB34,
#!#externalFiles={"d3js":"58f54395efa8346e8e94d12609770f66b916897e7f4e05f6c98780cffa5c70a3"},
#!#ShamirsMaxShares=8#!#supernodeSeeds={"ranchimall1":{"ip":"167.99.5.116","port":"9002"}}`;
#!#ShamirsMaxShares=8#!#supernodeSeeds={"ranchimall1":{"ip":"167.99.5.116","port":"9002","kbucketId":"88031fd65ed787b235724f21eff03e8c1a729422"}}`;
let floAssetsArray = RMAssets.split('#!#');
if (floAssetsArray.length > 0 && typeof floAssetsArray[0] !== undefined &&
@ -34777,12 +34777,12 @@ exports.createContext = Script.createContext = function (context) {
if (typeof withdraw_data == "object" && withdraw_data.length>0) {
let action_req = ``;
let t = `<table>
<tr>
<th>Withdrawer Flo Id</th>
<th>Depositor Flo Id</th>
<th>Amount</th>
<th>Action required</th>
</tr>`;
<tr>
<th>Withdrawer Flo Id</th>
<th>Depositor Flo Id</th>
<th>Amount</th>
<th>Action required</th>
</tr>`;
withdraw_data.filter(wdf=>(wdf.status==2 || wdf.status==3)).map(wd=>{
if(typeof localbitcoinplusplus.wallets.my_local_flo_address=="string") {
let claim_id = `${wd.id}!!${localbitcoinplusplus.wallets.my_local_flo_address}`;
@ -34795,12 +34795,12 @@ exports.createContext = Script.createContext = function (context) {
action_req += `<button onclick="localbitcoinplusplus.actions.claim_deposit_withdraw('${claim_id}')" >I deposited the money.</button>`;
}
}
t += ` <tr>
<td>${wd.trader_flo_address}</td>
<td>${wd.depositor_flo_id}</td>
<td>${wd.withdraw_amount}</td>
<td>${action_req}</td>`;
t += ` </tr>`;
t += `<tr>
<td>${wd.trader_flo_address}</td>
<td>${wd.depositor_flo_id}</td>
<td>${wd.withdraw_amount}</td>
<td>${action_req}</td>`;
t += `</tr>`;
});
t += ` </table>`;
@ -34893,11 +34893,17 @@ exports.createContext = Script.createContext = function (context) {
},
};
// supernodeSeedsObj.filter(seed=>{
// seedbytes = Crypto.util.hexToBytes(seed.kbucketId);
// localbitcoinplusplus.kademlia.floIdToKbucketId("FLO_TEST", seedbytes);
// })
if (!localbitcoinplusplus.master_configurations
.supernodesPubKeys.includes(flo_pub_key)) {
seedContactArray.transport = {
host: supernodeSeedsObj.ranchimall1.ip,
port: supernodeSeedsObj.ranchimall1.port
port: supernodeSeedsObj.ranchimall1.port,
//id: supernodeSeedsObj.ranchimall1.kbucketId
}
}
@ -35032,14 +35038,14 @@ exports.createContext = Script.createContext = function (context) {
// This function is only useful when sender and receiver are both online.
// If receiver is not online he might never get the message
testMessageBroadcasting: function(message, flo_id) {
messageBroadcasting: function(message, flo_id) {
readDB('userPublicData', flo_id).then((res)=>{
pubKey = res.trader_flo_pubKey;
let foo = localbitcoinplusplus.encrypt.encryptMessage(message, pubKey);
const RM_RPC = new localbitcoinplusplus.rpc;
let bar = RM_RPC
.send_rpc
.call(this, "testMessageBroadcasting", foo);
.call(this, "messageBroadcasting", foo);
doSend(bar);
});
},
@ -37190,8 +37196,8 @@ exports.createContext = Script.createContext = function (context) {
}
}
wsUri = await localbitcoinplusplus.kademlia.getSupernodeSeed(localbitcoinplusplusObj.myLocalFLOAddress,
localbitcoinplusplusObj.myLocalFLOPublicKey);
wsUri = await localbitcoinplusplus.kademlia.getSupernodeSeed(idbData.myLocalFLOAddress,
idbData.myLocalFLOPublicKey);
resolve(startWebSocket(wsUri));
});
@ -37279,7 +37285,9 @@ exports.createContext = Script.createContext = function (context) {
buyOrders_data.supernodePubKey);
if (isDataSignedBySuperNode === true) {
// Add buy order
addDB("buyOrders", buyOrders_data);
addDB("buyOrders", buyOrders_data).then(()=>{
showMessage(`Your buy order is placed successfully.`);
});
}
}
}
@ -37300,7 +37308,9 @@ exports.createContext = Script.createContext = function (context) {
sellOrders_data.supernodePubKey);
if (isDataSignedBySuperNode === true) {
// Add buy order
addDB("sellOrders", sellOrders_data);
addDB("sellOrders", sellOrders_data).then(()=>{
showMessage(`Your sell order is placed successfully.`);
});;
}
}
}
@ -37392,7 +37402,9 @@ exports.createContext = Script.createContext = function (context) {
if (RM_WALLET
.verify(res_obj.params[0].withdrawDataHash, res_obj.params[0].order_validator_sign,
res_obj.params[0].order_validator_public_key)) {
addDB('withdraw_cash', res_obj.params[0]);
addDB('withdraw_cash', res_obj.params[0]).then(()=>{
showMessage(`Your cash withdrawal request is placed successfully.`);
});
}
}
break;
@ -37408,13 +37420,13 @@ exports.createContext = Script.createContext = function (context) {
if(RM_WALLET
.verify(cancel_request.trade_id, cancel_request.signed_trade_id, trader_data.trader_flo_pubKey)) {
removeinDB(tradeDB, cancel_request.trade_id)
.then((id)=>console.info(`Trade Id ${id} deleted.`));
.then((id)=>showMessage(`Trade Id ${id} deleted.`));
} else {
console.error(`Failed to verify trade for trade id ${cancel_request.trade_id}`);
showMessage(`Failed to verify trade for trade id ${cancel_request.trade_id}`);
}
})
} else {
console.error("Failed to cancel trade.");
showMessage("Failed to cancel trade.");
}
}
break;
@ -37639,25 +37651,25 @@ exports.createContext = Script.createContext = function (context) {
}
break;
case "update_all_deposit_withdraw_success":
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
let withdraw_success_response = res_obj.params[0];
let update_cash_balance_obj_res = {
depositor_cash_data:withdraw_success_response.depositor_cash_data
}
let update_cash_balance_obj_res_str = JSON.stringify(update_cash_balance_obj_res);
let update_cash_balance_obj_res_hash = Crypto.SHA256(update_cash_balance_obj_res_str);
let update_cash_balance_obj_res_verification = RM_WALLET
.verify(update_cash_balance_obj_res_hash, withdraw_success_response.sign, withdraw_success_response.publicKey);
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
let withdraw_success_response = res_obj.params[0];
let update_cash_balance_obj_res = {
depositor_cash_data:withdraw_success_response.depositor_cash_data
}
let update_cash_balance_obj_res_str = JSON.stringify(update_cash_balance_obj_res);
let update_cash_balance_obj_res_hash = Crypto.SHA256(update_cash_balance_obj_res_str);
let update_cash_balance_obj_res_verification = RM_WALLET
.verify(update_cash_balance_obj_res_hash, withdraw_success_response.sign, withdraw_success_response.publicKey);
if ((update_cash_balance_obj_res_hash==withdraw_success_response.hash) && update_cash_balance_obj_res_verification==true) {
updateinDB('cash_balances', withdraw_success_response.depositor_cash_data);
updateinDB('cash_balances', withdraw_success_response.withdrawer_cash_data);
removeByIndex('deposit', 'trader_flo_address', withdraw_success_response.depositor_cash_data.trader_flo_address);
removeinDB('withdraw_cash', withdraw_success_response.withdraw_id);
return true;
if ((update_cash_balance_obj_res_hash==withdraw_success_response.hash) && update_cash_balance_obj_res_verification==true) {
updateinDB('cash_balances', withdraw_success_response.depositor_cash_data);
updateinDB('cash_balances', withdraw_success_response.withdrawer_cash_data);
removeByIndex('deposit', 'trader_flo_address', withdraw_success_response.depositor_cash_data.trader_flo_address);
removeinDB('withdraw_cash', withdraw_success_response.withdraw_id);
return true;
}
return false;
}
return false;
}
break;
case "add_user_public_data":
@ -37835,7 +37847,7 @@ exports.createContext = Script.createContext = function (context) {
}
break;
case "testMessageBroadcasting":
case "messageBroadcasting":
console.log(res_obj);
try {
let data = res_obj.params[0];
@ -37992,9 +38004,17 @@ exports.createContext = Script.createContext = function (context) {
last_updated_on: null,
}
const messages_table = {
id: null,
trader_flo_address: null,
supernode_flo_address: null,
timestamp: null,
message: null
}
var db;
const DBName = "localbitcoinDB";
var request = window.indexedDB.open(DBName, 1);
var request = window.indexedDB.open(DBName, 2);
request.onerror = function (event) {
//https://stackoverflow.com/questions/13972385/invalidstateerror-while-opening-indexeddb-in-firefox
@ -38140,6 +38160,17 @@ exports.createContext = Script.createContext = function (context) {
keyPath: "id"
})
}
if (!db.objectStoreNames.contains('messages_table')) {
var objectStore = db.createObjectStore("messages_table", {
keyPath: 'id'
});
objectStore.createIndex('trader_flo_address', 'trader_flo_address', {
unique: true
});
objectStore.createIndex('supernode_flo_address', 'supernode_flo_address', {
unique: false
});
}
}
@ -38951,6 +38982,10 @@ exports.createContext = Script.createContext = function (context) {
}
function showMessage(message) {
console.log(message);
}
//Function to check current balance of a BTC address
function validateDepositedBTCBalance(trader_deposits) {
if (!localbitcoinplusplus.master_configurations.supernodesPubKeys