resolved code to used in prod or dev
This commit is contained in:
parent
d6de1052d3
commit
a9346d79c6
22
.gitignore
vendored
22
.gitignore
vendored
@ -1,22 +1,2 @@
|
||||
json-rpc/
|
||||
supernode/playground/
|
||||
playground
|
||||
supernode/test/in
|
||||
supernode/test/in/index1.html
|
||||
supernode/test/in/index2.html
|
||||
supernode/test/in/index3.html
|
||||
supernode/test/in/index4.html
|
||||
supernode/flosend.html
|
||||
supernode/index1 (copy).html
|
||||
supernode/websocket_chat
|
||||
supernode/cash_payments_handler2.html
|
||||
.vscode/
|
||||
supernode/test/
|
||||
supernode/
|
||||
|
||||
|
||||
supernode/server/web/supernode2.html
|
||||
supernode/server/web/supernode3.html
|
||||
supernode/server/web/supernode4.html
|
||||
supernode/server/web/supernode5.html
|
||||
supernode/server/web/supernode6.html
|
||||
supernode/server/web/playground
|
||||
@ -8965,8 +8965,7 @@
|
||||
bitjs.priv = 0xef;
|
||||
bitjs.pub = 0x73;
|
||||
} else {
|
||||
bitjs.priv = 0xef;
|
||||
bitjs.pub = 0x6f;
|
||||
throw new Error("Unknown Asset");
|
||||
}
|
||||
|
||||
/* public vars */
|
||||
@ -11378,21 +11377,68 @@
|
||||
};
|
||||
|
||||
Object.defineProperty(localbitcoinplusplus, "server", {
|
||||
value: {
|
||||
//btc_mainnet: "https://blockexplorer.com",
|
||||
btc_mainnet: "https://insight.bitpay.com",
|
||||
//btc_testnet: "https://testnet.blockexplorer.com",
|
||||
btc_testnet: "https://test-insight.bitpay.com",
|
||||
flo_mainnet: "https://flosight.duckdns.org",
|
||||
flo_testnet: "https://testnet-flosight.duckdns.org",
|
||||
//flo_testnet: "https://testnet.flocha.in",
|
||||
flo_api_mainnet: "https://ranchimallflo.duckdns.org",
|
||||
flo_api_testnet: "https://ranchimallflo-testnet.duckdns.org",
|
||||
//flo_api_testnet: "ranchimall1.duckdns.org:5109"
|
||||
},
|
||||
writable: false,
|
||||
configurable: false,
|
||||
enumerable: false
|
||||
});
|
||||
|
||||
const ENVR = 'TEST'; // LIVE, TEST
|
||||
const WS = 'ws';
|
||||
|
||||
if(ENVR === 'LIVE') {
|
||||
|
||||
Object.defineProperty(localbitcoinplusplus, "RM_FLO_SENDING_ADDR", {
|
||||
value: "FGcDVp9f3eqDcXXqXwxhpEoCReihzGFQCo",
|
||||
writable: false,
|
||||
configurable: false,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(localbitcoinplusplus, "BASE_BLOCKCHAIN", {
|
||||
value: "FLO",
|
||||
writable: false,
|
||||
configurable: false,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(localbitcoinplusplus, "assets", {
|
||||
value: {
|
||||
//btc_mainnet: "https://blockexplorer.com",
|
||||
btc_mainnet: "https://insight.bitpay.com",
|
||||
//btc_testnet: "https://testnet.blockexplorer.com",
|
||||
btc_testnet: "https://test-insight.bitpay.com",
|
||||
flo_mainnet: "http://flosight.duckdns.org",
|
||||
//flo_testnet: "http://testnet-flosight.duckdns.org"
|
||||
flo_testnet: "https://testnet.flocha.in",
|
||||
flo_api_testnet: "https://ranchimallflo-testnet.duckdns.org",
|
||||
BTC: "BTC",
|
||||
FLO: "FLO"
|
||||
},
|
||||
writable: false,
|
||||
configurable: false,
|
||||
enumerable: false
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
Object.defineProperty(localbitcoinplusplus, "RM_FLO_SENDING_ADDR", {
|
||||
value: "ocKKEivXC3TA8yf3ZEyh2kRMDgSh99y1a7",
|
||||
writable: false,
|
||||
configurable: false,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(localbitcoinplusplus, "BASE_BLOCKCHAIN", {
|
||||
value: "FLO_TEST",
|
||||
writable: false,
|
||||
configurable: false,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(localbitcoinplusplus, "assets", {
|
||||
value: {
|
||||
BTC: "BTC_TEST",
|
||||
@ -11403,12 +11449,7 @@
|
||||
enumerable: false
|
||||
});
|
||||
|
||||
Object.defineProperty(localbitcoinplusplus, "RM_FLO_SENDING_ADDR", {
|
||||
value: "ocKKEivXC3TA8yf3ZEyh2kRMDgSh99y1a7",
|
||||
writable: false,
|
||||
configurable: false,
|
||||
enumerable: true
|
||||
});
|
||||
}
|
||||
|
||||
localbitcoinplusplus.privateKey = {
|
||||
isPrivateKey: function(key) {
|
||||
@ -11963,44 +12004,50 @@
|
||||
};
|
||||
|
||||
localbitcoinplusplus.actions = {
|
||||
parse_flo_comments: async function(callback) {
|
||||
text = `masterFLOPubKey=03EA5E2CAB18DA585400D6EC569438D415FAF200528E05D0E2B9BEAA2B5C3DCA90
|
||||
#!#tradableAsset1=BTC,FLO,BTC_TEST,FLO_TEST#!#tradableAsset2=INR,USD,
|
||||
#!#validTradingAmount=10,50,100,#!#btcTradeMargin=5000
|
||||
#!#MaxBackups=1
|
||||
#!#miners_fee={"btc":0.0003, "flo":0.0003}
|
||||
#!#supernodesPubKeys=0315C3A20FE7096CC2E0F81A80D5F1A687B8F9EFA65242A0B0881E1BA3EE7D7D53,
|
||||
03F7493F11B8E44B9798CD434D20FBE7FA34B9779D144984889D11A17C56A18742,039B4AA00DBFC0A6631DE6DA83526611A0E6B857D3579DF840BBDEAE8B6898E3B6,
|
||||
03C8E3836C9A77E2AF03D4265D034BA85732738919708EAF6A16382195AE796EDF,0349B08AA1ABDCFFB6D78CD7C949665AD2FF065EA02B3C6C47A5E9592C9A1C6BCB,
|
||||
026FCC6CFF6EB3A39E54BEB6E13FC2F02C3A93F4767AA80E49E7E876443F95AE5F,
|
||||
#!#assets={"BTC":"BTC_TEST","FLO":"FLO_TEST"}
|
||||
#!#externalFiles={"d3js":"58f54395efa8346e8e94d12609770f66b916897e7f4e05f6c98780cffa5c70a3"}
|
||||
#!#cashiers={"032871A74D2DDA9D0DE7135F58B5BD2D7F679D2CCA20EA7909466D1A6912DF4022":"johnDoe@upi",
|
||||
"03DB4A12EB543B293DDBB0CE314C46C36D6761294AFBB7264A6D78F710FFD97CF0":"janeDoe@upi"}
|
||||
#!#ShamirsMaxShares=8#!#supernodeSeeds={"ranchimall1":{"ip":"127.0.0.1","port":"9111","kbucketId":"oZxHcbSf1JC8t5GjutopWYXs7C6Fe9p7ps"},
|
||||
"ranchimall2":{"ip":"127.0.0.1","port":"9112","kbucketId":"oTWjPupy3Z7uMdPcu5uXd521HBkcsLuSuM"},
|
||||
"ranchimall3":{"ip":"127.0.0.1","port":"9113","kbucketId":"odYA6KagmbokSh9GY7yAfeTUZRtZLwecY1"},
|
||||
"ranchimall4":{"ip":"127.0.0.1","port":"9114","kbucketId":"oJosrve9dBv2Hj2bfncxv2oEpTysg3Wejv"},
|
||||
"ranchimall5":{"ip":"127.0.0.1","port":"9115","kbucketId":"oMhv5sAzqg77sYHxmUGZWKRrVo4P4JQduS"},
|
||||
"ranchimall6":{"ip":"127.0.0.1","port":"9116","kbucketId":"oV1wCeWca3VawbBTfUGKA7Vd368PATnKAx"}}`;
|
||||
return callback(text);
|
||||
const master_data = await helper_functions
|
||||
.ajaxGet(`${localbitcoinplusplus.server.flo_testnet}/api/txs/?address=${localbitcoinplusplus.RM_FLO_SENDING_ADDR}`);
|
||||
if(typeof master_data==="object" && typeof master_data.txs==="object") {
|
||||
let text = '';
|
||||
let tx_cmnt_arr = [];
|
||||
parse_flo_comments: async function(callback) {
|
||||
text = `masterFLOPubKey=03EA5E2CAB18DA585400D6EC569438D415FAF200528E05D0E2B9BEAA2B5C3DCA90
|
||||
#!#tradableAsset1=BTC,FLO,BTC_TEST,FLO_TEST#!#tradableAsset2=INR,USD,
|
||||
#!#validTradingAmount=10,50,100,#!#btcTradeMargin=5000
|
||||
#!#MaxBackups=1
|
||||
#!#miners_fee={"btc":0.0003, "flo":0.0003}
|
||||
#!#supernodesPubKeys=0315C3A20FE7096CC2E0F81A80D5F1A687B8F9EFA65242A0B0881E1BA3EE7D7D53,
|
||||
03F7493F11B8E44B9798CD434D20FBE7FA34B9779D144984889D11A17C56A18742,039B4AA00DBFC0A6631DE6DA83526611A0E6B857D3579DF840BBDEAE8B6898E3B6,
|
||||
03C8E3836C9A77E2AF03D4265D034BA85732738919708EAF6A16382195AE796EDF,0349B08AA1ABDCFFB6D78CD7C949665AD2FF065EA02B3C6C47A5E9592C9A1C6BCB,
|
||||
026FCC6CFF6EB3A39E54BEB6E13FC2F02C3A93F4767AA80E49E7E876443F95AE5F,
|
||||
#!#externalFiles={"d3js":"58f54395efa8346e8e94d12609770f66b916897e7f4e05f6c98780cffa5c70a3"}
|
||||
#!#cashiers={"032871A74D2DDA9D0DE7135F58B5BD2D7F679D2CCA20EA7909466D1A6912DF4022":"johnDoe@upi",
|
||||
"03DB4A12EB543B293DDBB0CE314C46C36D6761294AFBB7264A6D78F710FFD97CF0":"janeDoe@upi"}
|
||||
#!#ShamirsMaxShares=8#!#supernodeSeeds={"ranchimall1":{"ip":"127.0.0.1:9111","kbucketId":"oZxHcbSf1JC8t5GjutopWYXs7C6Fe9p7ps"},
|
||||
"ranchimall2":{"ip":"127.0.0.1:9112","kbucketId":"oTWjPupy3Z7uMdPcu5uXd521HBkcsLuSuM"},
|
||||
"ranchimall3":{"ip":"127.0.0.1:9113","kbucketId":"odYA6KagmbokSh9GY7yAfeTUZRtZLwecY1"},
|
||||
"ranchimall4":{"ip":"127.0.0.1:9114","kbucketId":"oJosrve9dBv2Hj2bfncxv2oEpTysg3Wejv"},
|
||||
"ranchimall5":{"ip":"127.0.0.1:9115","kbucketId":"oMhv5sAzqg77sYHxmUGZWKRrVo4P4JQduS"},
|
||||
"ranchimall6":{"ip":"127.0.0.1:9116","kbucketId":"oV1wCeWca3VawbBTfUGKA7Vd368PATnKAx"}}`;
|
||||
return callback(text);
|
||||
|
||||
for(txt of master_data.txs) {
|
||||
if(txt.vin[0].addr === localbitcoinplusplus.RM_FLO_SENDING_ADDR) {
|
||||
if(txt.floData.length===0) break;
|
||||
tx_cmnt_arr.push(txt.floData);
|
||||
}
|
||||
}
|
||||
|
||||
tx_cmnt_arr.reverse().map(m=>text += m.replace('text:', ''));
|
||||
callback(text);
|
||||
if(ENVR==='LIVE') {
|
||||
master_data = await helper_functions
|
||||
.ajaxGet(`${localbitcoinplusplus.server.flo_mainnet}/api/txs/?address=${localbitcoinplusplus.RM_FLO_SENDING_ADDR}`);
|
||||
} else {
|
||||
master_data = await helper_functions
|
||||
.ajaxGet(`${localbitcoinplusplus.server.flo_testnet}/api/txs/?address=${localbitcoinplusplus.RM_FLO_SENDING_ADDR}`);
|
||||
}
|
||||
},
|
||||
|
||||
if(typeof master_data==="object" && typeof master_data.txs==="object") {
|
||||
let text = '';
|
||||
let tx_cmnt_arr = [];
|
||||
|
||||
for(txt of master_data.txs) {
|
||||
if(txt.vin[0].addr === localbitcoinplusplus.RM_FLO_SENDING_ADDR) {
|
||||
if(txt.floData.length===0) break;
|
||||
tx_cmnt_arr.push(txt.floData);
|
||||
}
|
||||
}
|
||||
|
||||
tx_cmnt_arr.reverse().map(m=>text += m.replace('text:', ''));
|
||||
callback(text);
|
||||
}
|
||||
},
|
||||
|
||||
fetch_configs: function(callback) {
|
||||
this.parse_flo_comments(function(floData) {
|
||||
@ -12062,7 +12109,7 @@
|
||||
|
||||
wallets.prototype = {
|
||||
ecparams: EllipticCurve.getSECCurveByName("secp256k1"),
|
||||
generateFloKeys: function(pk, crypto = "FLO_TEST") {
|
||||
generateFloKeys: function(pk, crypto = localbitcoinplusplus.BASE_BLOCKCHAIN) {
|
||||
if (crypto == "BTC") {
|
||||
privKeyPrefix = 0x80; //mainnet 0x80, testnet: 0xEF
|
||||
networkVersion = 0x00; //mainnet 0x23, testnet: 0x6F
|
||||
@ -12110,7 +12157,7 @@
|
||||
address
|
||||
};
|
||||
},
|
||||
sign: function(msg, privateKeyHex, crypto = "FLO_TEST") {
|
||||
sign: function(msg, privateKeyHex, crypto = localbitcoinplusplus.BASE_BLOCKCHAIN) {
|
||||
if (crypto == "BTC") {
|
||||
privKeyPrefix = 0x80; //mainnet 0x80, testnet: 0xEF
|
||||
networkVersion = 0x00; //mainnet 0x23, testnet: 0x6F
|
||||
@ -12124,8 +12171,7 @@
|
||||
privKeyPrefix = 0xef;
|
||||
networkVersion = 0x73;
|
||||
} else {
|
||||
privKeyPrefix = 0xef;
|
||||
networkVersion = 0x73;
|
||||
throw new Error('Unknown Crypto asset');
|
||||
}
|
||||
|
||||
Bitcoin.ECKey.privateKeyPrefix = privKeyPrefix;
|
||||
@ -12565,13 +12611,13 @@
|
||||
try {
|
||||
const master_flo_pubKey =
|
||||
localbitcoinplusplus.master_configurations.masterFLOPubKey;
|
||||
const master_flo_addr = bitjs.FLO_TEST.pubkey2address(
|
||||
const master_flo_addr = bitjs[localbitcoinplusplus.BASE_BLOCKCHAIN].pubkey2address(
|
||||
master_flo_pubKey
|
||||
);
|
||||
if (typeof master_flo_addr !== "string") return reject(false);
|
||||
const SuKBucketId = localbitcoinplusplus.kademlia.floIdToKbucketId(
|
||||
"FLO_TEST",
|
||||
master_flo_addr
|
||||
localbitcoinplusplus.BASE_BLOCKCHAIN,
|
||||
master_flo_addr
|
||||
);
|
||||
const SukbOptions = { localNodeId: SuKBucketId };
|
||||
window.supernodeKBucket = new BuildKBucket(SukbOptions);
|
||||
@ -12638,7 +12684,7 @@
|
||||
|
||||
Object.entries(supernodeSeedsObj).map(seedObj => {
|
||||
let kbuck = this.addNewUserNodeInKbucket(
|
||||
"FLO_TEST",
|
||||
localbitcoinplusplus.BASE_BLOCKCHAIN,
|
||||
seedObj[1].kbucketId,
|
||||
{ id: seedObj[1].kbucketId },
|
||||
supernodeKBucket
|
||||
@ -12714,7 +12760,7 @@
|
||||
let isFloIdUint8 = flo_addr instanceof Uint8Array;
|
||||
if (!isFloIdUint8) {
|
||||
flo_addr = localbitcoinplusplus.kademlia.floIdToKbucketId(
|
||||
"FLO_TEST",
|
||||
localbitcoinplusplus.BASE_BLOCKCHAIN,
|
||||
flo_addr
|
||||
);
|
||||
}
|
||||
@ -12930,7 +12976,7 @@
|
||||
}
|
||||
|
||||
let db;
|
||||
const DBName = "paymentsHandlerDB";
|
||||
const DBName = "paymentsHandlerDBRemote";
|
||||
const request = window.indexedDB.open(DBName, 1);
|
||||
|
||||
request.onerror = function(event) {
|
||||
@ -13540,8 +13586,7 @@
|
||||
//if (request_array.includes(msgObj.method)) return resolve(true);
|
||||
if (onMessageAcceptTest("beforePrivateKeyEntry", {"methodList":request_array,"method":msgObj.method})) return resolve(true);
|
||||
|
||||
//const getFloId = bitjs.FLO_TEST.pubkey2address(msgObj.nodePubKey);
|
||||
const getFloId = bitjs[localbitcoinplusplus.assets.FLO].pubkey2address(msgObj.nodePubKey);
|
||||
const getFloId = bitjs[localbitcoinplusplus.BASE_BLOCKCHAIN].pubkey2address(msgObj.nodePubKey);
|
||||
|
||||
if (!onMessageAcceptTest("senderAddressMatchesSignerAddress", {"senderFloId":msgObj.globalParams.senderFloId,"calculatedFloId":getFloId})) {
|
||||
showMessage(
|
||||
@ -13679,7 +13724,7 @@
|
||||
localbitcoinplusplus.master_configurations.supernodeSeeds;
|
||||
let supernodeSeedsArray = Object.values(supernodeSeedsObj);
|
||||
supernodeSeedsArray.map(async wsUri => {
|
||||
localbitcoinplusplus.supernode_conns[wsUri.kbucketId] = await initializeWebSocket (`ws://${wsUri.ip}:${wsUri.port}`);
|
||||
localbitcoinplusplus.supernode_conns[wsUri.kbucketId] = await initializeWebSocket (`${WS}://${wsUri.ip}`);
|
||||
startWebSocket(localbitcoinplusplus.supernode_conns[wsUri.kbucketId]);
|
||||
});
|
||||
}
|
||||
@ -13760,7 +13805,7 @@
|
||||
const RM_WALLET = new localbitcoinplusplus.wallets;
|
||||
Array.from(recv_deposit_btn).forEach(function(element) {
|
||||
element.addEventListener("click", async function(evt) {
|
||||
//evt.preventDefault();
|
||||
evt.preventDefault();
|
||||
const deposit_id = this.value;
|
||||
const req_info = document.getElementById(`depositSpan${deposit_id}`);
|
||||
const req_info_arr = req_info.value.split("_");
|
||||
@ -13810,12 +13855,21 @@
|
||||
parent_supernode: websocket_name,
|
||||
}
|
||||
|
||||
const txidUrlDeposit = `${localbitcoinplusplus.server
|
||||
let txidUrlDeposit = '';
|
||||
|
||||
if(ENVR==="LIVE") {
|
||||
txidUrlDeposit = `${localbitcoinplusplus.server
|
||||
.flo_api_mainnet}/api/v1.0/getTransactionDetails/${flo_txid}`;
|
||||
|
||||
} else {
|
||||
txidUrlDeposit = `${localbitcoinplusplus.server
|
||||
.flo_api_testnet}/api/v1.0/getTransactionDetails/${flo_txid}`;
|
||||
}
|
||||
|
||||
let n=1;
|
||||
(async function validateTxidInBlockchain() {
|
||||
// Validate Flo txid
|
||||
await delay(120000);
|
||||
await delay(60000);
|
||||
const validate_flo_txid = await helper_functions.ajaxGet(txidUrlDeposit);
|
||||
console.log(validate_flo_txid);
|
||||
if(typeof validate_flo_txid == "object"
|
||||
@ -13885,7 +13939,12 @@
|
||||
const token_name_radio = document.querySelector('input[name="transfer_token_name"]:checked').value;
|
||||
|
||||
const flo_comment = `transfer ${token_amount} ${token_name_radio}# to ${token_receiver}`;
|
||||
const token_balance_url = `${localbitcoinplusplus.server.flo_api_testnet}/api/v1.0/getFloAddressBalance?token=${token_name_radio}&floAddress=${token_sender}`;
|
||||
let token_balance_url = '';
|
||||
if(ENVR==='LIVE') {
|
||||
token_balance_url = `${localbitcoinplusplus.server.flo_api_mainnet}/api/v1.0/getFloAddressBalance?token=${token_name_radio}&floAddress=${token_sender}`;
|
||||
} else {
|
||||
token_balance_url = `${localbitcoinplusplus.server.flo_api_testnet}/api/v1.0/getFloAddressBalance?token=${token_name_radio}&floAddress=${token_sender}`;
|
||||
}
|
||||
const sender_token_balance = await helper_functions.ajaxGet(token_balance_url);
|
||||
let err_msg = '';
|
||||
|
||||
@ -551,7 +551,7 @@
|
||||
</pre>
|
||||
</div>
|
||||
<div class="w3-button w3-teal w3-xlarge" onclick="displayMessages()">
|
||||
☰
|
||||
0
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -11518,6 +11518,7 @@
|
||||
----------------------------------------------------------------------------------->
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var localbitcoinplusplus = {
|
||||
wallets: {},
|
||||
trade: {},
|
||||
@ -11527,34 +11528,58 @@
|
||||
|
||||
Object.defineProperty(localbitcoinplusplus, "server", {
|
||||
value: {
|
||||
//btc_mainnet: "https://blockexplorer.com",
|
||||
btc_mainnet: "https://insight.bitpay.com",
|
||||
//btc_testnet: "https://testnet.blockexplorer.com",
|
||||
btc_testnet: "https://test-insight.bitpay.com",
|
||||
flo_mainnet: "http://flosight.duckdns.org",
|
||||
//flo_testnet: "http://testnet-flosight.duckdns.org"
|
||||
flo_testnet: "https://testnet.flocha.in",
|
||||
flo_api_testnet: "https://ranchimallflo-testnet.duckdns.org",
|
||||
//flo_api_testnet: "ranchimall1.duckdns.org:5109"
|
||||
//btc_mainnet: "https://blockexplorer.com",
|
||||
btc_mainnet: "https://insight.bitpay.com",
|
||||
//btc_testnet: "https://testnet.blockexplorer.com",
|
||||
btc_testnet: "https://test-insight.bitpay.com",
|
||||
flo_mainnet: "https://flosight.duckdns.org",
|
||||
flo_testnet: "https://testnet-flosight.duckdns.org",
|
||||
//flo_testnet: "https://testnet.flocha.in",
|
||||
flo_api_mainnet: "https://ranchimallflo.duckdns.org",
|
||||
flo_api_testnet: "https://ranchimallflo-testnet.duckdns.org",
|
||||
//flo_api_testnet: "ranchimall1.duckdns.org:5109"
|
||||
},
|
||||
writable: false,
|
||||
configurable: false,
|
||||
enumerable: false
|
||||
});
|
||||
|
||||
Object.defineProperty(localbitcoinplusplus, "RM_FLO_SENDING_ADDR", {
|
||||
value: "ocKKEivXC3TA8yf3ZEyh2kRMDgSh99y1a7",
|
||||
writable: false,
|
||||
configurable: false,
|
||||
enumerable: true
|
||||
});
|
||||
const ENVR = 'TEST'; // LIVE, TEST
|
||||
const WS = 'ws';
|
||||
|
||||
Object.defineProperty(localbitcoinplusplus, "BASE_BLOCKCHAIN", {
|
||||
value: "FLO",
|
||||
writable: false,
|
||||
configurable: false,
|
||||
enumerable: true
|
||||
});
|
||||
if(ENVR === 'LIVE') {
|
||||
|
||||
Object.defineProperty(localbitcoinplusplus, "RM_FLO_SENDING_ADDR", {
|
||||
value: "FGcDVp9f3eqDcXXqXwxhpEoCReihzGFQCo",
|
||||
writable: false,
|
||||
configurable: false,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(localbitcoinplusplus, "BASE_BLOCKCHAIN", {
|
||||
value: "FLO",
|
||||
writable: false,
|
||||
configurable: false,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
Object.defineProperty(localbitcoinplusplus, "RM_FLO_SENDING_ADDR", {
|
||||
value: "ocKKEivXC3TA8yf3ZEyh2kRMDgSh99y1a7",
|
||||
writable: false,
|
||||
configurable: false,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
Object.defineProperty(localbitcoinplusplus, "BASE_BLOCKCHAIN", {
|
||||
value: "FLO_TEST",
|
||||
writable: false,
|
||||
configurable: false,
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
localbitcoinplusplus.privateKey = {
|
||||
isPrivateKey: function(key) {
|
||||
@ -12106,15 +12131,24 @@
|
||||
#!#externalFiles={"d3js":"58f54395efa8346e8e94d12609770f66b916897e7f4e05f6c98780cffa5c70a3"}
|
||||
#!#cashiers={"032871A74D2DDA9D0DE7135F58B5BD2D7F679D2CCA20EA7909466D1A6912DF4022":"johnDoe@upi",
|
||||
"03DB4A12EB543B293DDBB0CE314C46C36D6761294AFBB7264A6D78F710FFD97CF0":"janeDoe@upi"}
|
||||
#!#ShamirsMaxShares=8#!#supernodeSeeds={"ranchimall1":{"ip":"127.0.0.1","port":"9111","kbucketId":"oZxHcbSf1JC8t5GjutopWYXs7C6Fe9p7ps"},
|
||||
"ranchimall2":{"ip":"127.0.0.1","port":"9112","kbucketId":"oTWjPupy3Z7uMdPcu5uXd521HBkcsLuSuM"},
|
||||
"ranchimall3":{"ip":"127.0.0.1","port":"9113","kbucketId":"odYA6KagmbokSh9GY7yAfeTUZRtZLwecY1"},
|
||||
"ranchimall4":{"ip":"127.0.0.1","port":"9114","kbucketId":"oJosrve9dBv2Hj2bfncxv2oEpTysg3Wejv"},
|
||||
"ranchimall5":{"ip":"127.0.0.1","port":"9115","kbucketId":"oMhv5sAzqg77sYHxmUGZWKRrVo4P4JQduS"},
|
||||
"ranchimall6":{"ip":"127.0.0.1","port":"9116","kbucketId":"oV1wCeWca3VawbBTfUGKA7Vd368PATnKAx"}}`;
|
||||
#!#ShamirsMaxShares=8#!#supernodeSeeds={"ranchimall1":{"ip":"127.0.0.1:9111","kbucketId":"oZxHcbSf1JC8t5GjutopWYXs7C6Fe9p7ps"},
|
||||
"ranchimall2":{"ip":"127.0.0.1:9112","kbucketId":"oTWjPupy3Z7uMdPcu5uXd521HBkcsLuSuM"},
|
||||
"ranchimall3":{"ip":"127.0.0.1:9113","kbucketId":"odYA6KagmbokSh9GY7yAfeTUZRtZLwecY1"},
|
||||
"ranchimall4":{"ip":"127.0.0.1:9114","kbucketId":"oJosrve9dBv2Hj2bfncxv2oEpTysg3Wejv"},
|
||||
"ranchimall5":{"ip":"127.0.0.1:9115","kbucketId":"oMhv5sAzqg77sYHxmUGZWKRrVo4P4JQduS"},
|
||||
"ranchimall6":{"ip":"127.0.0.1:9116","kbucketId":"oV1wCeWca3VawbBTfUGKA7Vd368PATnKAx"}}`;
|
||||
return callback(text);
|
||||
const master_data = await helper_functions
|
||||
.ajaxGet(`${localbitcoinplusplus.server.flo_testnet}/api/txs/?address=${localbitcoinplusplus.RM_FLO_SENDING_ADDR}`);
|
||||
|
||||
let master_data = '';
|
||||
|
||||
if(ENVR==='LIVE') {
|
||||
master_data = await helper_functions
|
||||
.ajaxGet(`${localbitcoinplusplus.server.flo_mainnet}/api/txs/?address=${localbitcoinplusplus.RM_FLO_SENDING_ADDR}`);
|
||||
} else {
|
||||
master_data = await helper_functions
|
||||
.ajaxGet(`${localbitcoinplusplus.server.flo_testnet}/api/txs/?address=${localbitcoinplusplus.RM_FLO_SENDING_ADDR}`);
|
||||
}
|
||||
|
||||
if(typeof master_data==="object" && typeof master_data.txs==="object") {
|
||||
let text = '';
|
||||
let tx_cmnt_arr = [];
|
||||
@ -12881,7 +12915,7 @@
|
||||
updateinDB("myClosestSupernodes", {
|
||||
id: index + 1,
|
||||
ip: nearestSupernodeAddress.ip,
|
||||
port: nearestSupernodeAddress.port,
|
||||
//port: nearestSupernodeAddress.port,
|
||||
trader_flo_address: nearestSupernodeAddress.kbucketId,
|
||||
is_live: null
|
||||
}).then(updatedClosestSupernodes => {
|
||||
@ -13028,7 +13062,9 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- Encryption -->
|
||||
<!-- E
|
||||
|
||||
const WS = 'wss';ncryption -->
|
||||
<script>
|
||||
localbitcoinplusplus.encrypt = {
|
||||
p: BigInteger(
|
||||
@ -13778,7 +13814,8 @@
|
||||
const getFLOId = wsSupsObj.trader_flo_address;
|
||||
if (getFLOId === localbitcoinplusplus.wallets.my_local_flo_address
|
||||
|| typeof getFLOId !== "string") return;
|
||||
const back_ws_url = `ws://${wsSupsObj.ip}:${wsSupsObj.port}`;
|
||||
//const back_ws_url = `ws://${wsSupsObj.ip}:${wsSupsObj.port}`;
|
||||
const back_ws_url = `${WS}://${wsSupsObj.ip}`;
|
||||
|
||||
let currenctBackupWsList = Object.keys(
|
||||
localbitcoinplusplus.backupWS
|
||||
@ -13803,8 +13840,6 @@
|
||||
if(reqFloIdIndex>=highestIndexOfConnectedSupernode) return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (
|
||||
typeof localbitcoinplusplus.backupWS[getFLOId] === "object" &&
|
||||
localbitcoinplusplus.backupWS[getFLOId].ws_connection.readyState == 1
|
||||
@ -14201,7 +14236,8 @@
|
||||
|| sn!==msg_obj.subject_flo_id)
|
||||
&& websocket.readyState===1) {
|
||||
|
||||
const url = `ws://${localbitcoinplusplus.myClosestSupernodes[sn].ip}:${localbitcoinplusplus.myClosestSupernodes[sn].port}`;
|
||||
//const url = `ws://${localbitcoinplusplus.myClosestSupernodes[sn].ip}:${localbitcoinplusplus.myClosestSupernodes[sn].port}`;
|
||||
const url = `${WS}://${localbitcoinplusplus.myClosestSupernodes[sn].ip}`;
|
||||
|
||||
tempWS[sn] = new WebSocket(url);
|
||||
tempWS[sn].onopen = async function(evt) {
|
||||
@ -14301,7 +14337,8 @@
|
||||
}
|
||||
|
||||
// If a ws conn does not exist with sn, start a temporary conn
|
||||
const url = `ws://${localbitcoinplusplus.myClosestSupernodes[sn].ip}:${localbitcoinplusplus.myClosestSupernodes[sn].port}`;
|
||||
//const url = `ws://${localbitcoinplusplus.myClosestSupernodes[sn].ip}:${localbitcoinplusplus.myClosestSupernodes[sn].port}`;
|
||||
const url = `${WS}://${localbitcoinplusplus.myClosestSupernodes[sn].ip}`;
|
||||
|
||||
tempWS[sn] = new WebSocket(url);
|
||||
tempWS[sn].onopen = async function(evt) {
|
||||
@ -14364,7 +14401,8 @@
|
||||
&& sn!==msg_obj.data.subject_flo_id
|
||||
&& websocket.readyState===1) {
|
||||
const switchMyWS = new backupSupernodesWebSocketObject();
|
||||
const url = `ws://${localbitcoinplusplus.myClosestSupernodes[sn].ip}:${localbitcoinplusplus.myClosestSupernodes[sn].port}`;
|
||||
//const url = `ws://${localbitcoinplusplus.myClosestSupernodes[sn].ip}:${localbitcoinplusplus.myClosestSupernodes[sn].port}`;
|
||||
const url = `${WS}://${localbitcoinplusplus.myClosestSupernodes[sn].ip}`;
|
||||
|
||||
tempWSL[sn] = new WebSocket(url);
|
||||
tempWSL[sn].onopen = async function(evt) {
|
||||
@ -18482,8 +18520,14 @@
|
||||
if (typeof user_deposit_req!=="object"
|
||||
|| user_deposit_req===null) return;
|
||||
|
||||
const txidUrlDeposit = `${localbitcoinplusplus.server
|
||||
let txidUrlDeposit = '';
|
||||
if(ENVR==="LIVE") {
|
||||
txidUrlDeposit = `${localbitcoinplusplus.server
|
||||
.flo_api_mainnet}/api/v1.0/getTransactionDetails/${params.flo_txid}`;
|
||||
} else {
|
||||
txidUrlDeposit = `${localbitcoinplusplus.server
|
||||
.flo_api_testnet}/api/v1.0/getTransactionDetails/${params.flo_txid}`;
|
||||
}
|
||||
|
||||
// Validate Flo txid
|
||||
const validate_flo_txid = await helper_functions.ajaxGet(txidUrlDeposit);
|
||||
@ -20578,7 +20622,8 @@
|
||||
);
|
||||
});
|
||||
|
||||
await startWebSocket(`ws://${wsUri[0].ip}:${wsUri[0].port}`);
|
||||
//await startWebSocket(`ws://${wsUri[0].ip}:${wsUri[0].port}`);
|
||||
await startWebSocket(`${WS}://${wsUri[0].ip}`);
|
||||
|
||||
RM_WALLET.distributeShamirsSecretShares(newKeys.privateKeyWIF)
|
||||
.then(() => privateKeyBuilder())
|
||||
@ -20700,7 +20745,8 @@
|
||||
});
|
||||
|
||||
// Connect with primary supernodes
|
||||
await startWebSocket(`ws://${wsUri[0].ip}:${wsUri[0].port}`);
|
||||
//await startWebSocket(`ws://${wsUri[0].ip}:${wsUri[0].port}`);
|
||||
await startWebSocket(`${WS}://${wsUri[0].ip}`);
|
||||
|
||||
// rebuild private key
|
||||
await privateKeyBuilder();
|
||||
@ -20869,7 +20915,8 @@
|
||||
const my_closest_su_list = await readAllDB("myClosestSupernodes");
|
||||
const disconnected_su = my_closest_su_list.filter(
|
||||
(my_closest_su_url_list, index) => {
|
||||
let my_closest_su_url = `ws://${my_closest_su_url_list.ip}:${my_closest_su_url_list.port}`;
|
||||
//let my_closest_su_url = `ws://${my_closest_su_url_list.ip}:${my_closest_su_url_list.port}`;
|
||||
let my_closest_su_url = `${WS}://${my_closest_su_url_list.ip}`;
|
||||
return my_closest_su_url == ws_url;
|
||||
}
|
||||
);
|
||||
@ -20939,7 +20986,8 @@
|
||||
|
||||
let nextClosestSupernodeElem = myClosestSupernodesArray.filter(
|
||||
(wew, index) => {
|
||||
let ww = `ws://${wew.ip}:${wew.port}`;
|
||||
// let ww = `ws://${wew.ip}:${wew.port}`;
|
||||
let ww = `${WS}://${wew.ip}`;
|
||||
if (typeof z == "boolean" && z) {
|
||||
z = false;
|
||||
if (
|
||||
@ -20962,7 +21010,8 @@
|
||||
return Promise.reject(ms);
|
||||
}
|
||||
|
||||
ideal_supernode = `ws://${nextClosestSupernodeElem[0].ip}:${nextClosestSupernodeElem[0].port}`;
|
||||
//ideal_supernode = `ws://${nextClosestSupernodeElem[0].ip}:${nextClosestSupernodeElem[0].port}`;
|
||||
ideal_supernode = `${WS}://${nextClosestSupernodeElem[0].ip}`;
|
||||
|
||||
await startWebSocket(ideal_supernode);
|
||||
|
||||
@ -22953,9 +23002,8 @@
|
||||
typeof newSu == "object" &&
|
||||
typeof newSu[0].trader_flo_address == "string"
|
||||
) {
|
||||
await startWebSocket(
|
||||
`ws://${newSu[0].ip}:${newSu[0].port}`
|
||||
);
|
||||
//await startWebSocket(`ws://${newSu[0].ip}:${newSu[0].port}`);
|
||||
await startWebSocket(`${WS}://${newSu[0].ip}`);
|
||||
showMssage(`INFO: ${su_db_data.server_msg}`);
|
||||
} else {
|
||||
alert(`INFO: Please reload the page.`);
|
||||
@ -25006,9 +25054,8 @@
|
||||
typeof newSu == "object" &&
|
||||
typeof newSu[0].trader_flo_address == "string"
|
||||
) {
|
||||
await startWebSocket(
|
||||
`ws://${newSu[0].ip}:${newSu[0].port}`
|
||||
);
|
||||
//await startWebSocket(`ws://${newSu[0].ip}:${newSu[0].port}`);
|
||||
await startWebSocket(`${WS}://${newSu[0].ip}`);
|
||||
showMessage(`INFO: ${su_db_data.server_msg}`);
|
||||
} else {
|
||||
alert(`INFO: Please reload the page.`);
|
||||
Binary file not shown.
@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Cesanta Software Limited
|
||||
* All rights reserved
|
||||
*/
|
||||
|
||||
#include "mongoose.h"
|
||||
|
||||
static sig_atomic_t s_signal_received = 0;
|
||||
static const char *s_http_port = "9116";
|
||||
static struct mg_serve_http_opts s_http_server_opts;
|
||||
|
||||
static void signal_handler(int sig_num) {
|
||||
signal(sig_num, signal_handler); // Reinstantiate signal handler
|
||||
s_signal_received = sig_num;
|
||||
}
|
||||
|
||||
static int is_websocket(const struct mg_connection *nc) {
|
||||
return nc->flags & MG_F_IS_WEBSOCKET;
|
||||
}
|
||||
|
||||
static void broadcast(struct mg_connection *nc, const struct mg_str msg) {
|
||||
struct mg_connection *c;
|
||||
printf("(Broadcast) \t[%d]\n", (int)msg.len);
|
||||
for (c = mg_next(nc->mgr, NULL); c != NULL; c = mg_next(nc->mgr, c)) {
|
||||
if (c == nc) continue; /* Don't send to the sender. */
|
||||
mg_send_websocket_frame(c, WEBSOCKET_OP_TEXT, msg.p, (int)msg.len);
|
||||
}
|
||||
}
|
||||
|
||||
void unicast(struct mg_connection *nc, const struct mg_str msg) {
|
||||
struct mg_connection *c;
|
||||
char recipient_floID[35];
|
||||
snprintf(recipient_floID, sizeof(recipient_floID), "%.*s", 34, &msg.p[1]);
|
||||
printf("%s \t[%d]\n",recipient_floID, (int)msg.len - 36); /* Local echo. */
|
||||
for (c = mg_next(nc->mgr, NULL); c != NULL; c = mg_next(nc->mgr, c)) {
|
||||
if (!strcmp(c->floID,recipient_floID)) /* Send to receiver */
|
||||
mg_send_websocket_frame(c, WEBSOCKET_OP_TEXT, &msg.p[36], (int)msg.len - 36);
|
||||
}
|
||||
}
|
||||
|
||||
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
|
||||
switch (ev) {
|
||||
case MG_EV_WEBSOCKET_HANDSHAKE_DONE: {
|
||||
/* New websocket connection. Tell everybody. */
|
||||
break;
|
||||
}
|
||||
case MG_EV_WEBSOCKET_FRAME: {
|
||||
struct websocket_message *wm = (struct websocket_message *) ev_data;
|
||||
/* New websocket message. Tell everybody. */
|
||||
struct mg_str d = {(char *) wm->data, wm->size};
|
||||
if (d.p[0] == '$')
|
||||
snprintf(nc->floID, sizeof(nc->floID), "%.*s", 34, &d.p[1]);
|
||||
else if ((d.p[0] == '>'))
|
||||
unicast(nc, d);
|
||||
else
|
||||
broadcast(nc, d);
|
||||
break;
|
||||
}
|
||||
case MG_EV_HTTP_REQUEST: {
|
||||
mg_serve_http(nc, (struct http_message *) ev_data, s_http_server_opts);
|
||||
break;
|
||||
}
|
||||
case MG_EV_CLOSE: {
|
||||
/* Disconnect. Tell everybody. */
|
||||
if (is_websocket(nc)) {
|
||||
//broadcast(nc, mg_mk_str("-- left"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
struct mg_mgr mgr;
|
||||
struct mg_connection *nc;
|
||||
|
||||
signal(SIGTERM, signal_handler);
|
||||
signal(SIGINT, signal_handler);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
setvbuf(stderr, NULL, _IOLBF, 0);
|
||||
|
||||
mg_mgr_init(&mgr, NULL);
|
||||
|
||||
nc = mg_bind(&mgr, s_http_port, ev_handler);
|
||||
mg_set_protocol_http_websocket(nc);
|
||||
s_http_server_opts.document_root = "web"; // Serve current directory
|
||||
s_http_server_opts.enable_directory_listing = "no";
|
||||
|
||||
printf("Started on port %s\n", s_http_port);
|
||||
while (s_signal_received == 0) {
|
||||
mg_mgr_poll(&mgr, 200);
|
||||
}
|
||||
mg_mgr_free(&mgr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
SOURCES = $(PROG).c ../mongoose.c
|
||||
CFLAGS = -g -W -Wall -Werror -I../ -Wno-unused-function $(CFLAGS_EXTRA) $(MODULE_CFLAGS)
|
||||
|
||||
all: $(PROG)
|
||||
|
||||
ifeq ($(OS), Windows_NT)
|
||||
# TODO(alashkin): enable SSL in Windows
|
||||
CFLAGS += -lws2_32
|
||||
CC = gcc
|
||||
else
|
||||
CFLAGS += -pthread
|
||||
endif
|
||||
|
||||
ifeq ($(SSL_LIB),openssl)
|
||||
CFLAGS += -DMG_ENABLE_SSL -lssl -lcrypto
|
||||
endif
|
||||
ifeq ($(SSL_LIB), krypton)
|
||||
CFLAGS += -DMG_ENABLE_SSL ../../../krypton/krypton.c -I../../../krypton
|
||||
endif
|
||||
ifeq ($(SSL_LIB),mbedtls)
|
||||
CFLAGS += -DMG_ENABLE_SSL -DMG_SSL_IF=MG_SSL_IF_MBEDTLS -DMG_SSL_MBED_DUMMY_RANDOM -lmbedcrypto -lmbedtls -lmbedx509
|
||||
endif
|
||||
|
||||
ifdef ASAN
|
||||
CC = clang
|
||||
CFLAGS += -fsanitize=address
|
||||
endif
|
||||
|
||||
$(PROG): $(SOURCES)
|
||||
$(CC) $(SOURCES) -o $@ $(CFLAGS)
|
||||
|
||||
$(PROG).exe: $(SOURCES)
|
||||
cl $(SOURCES) /I../.. /MD /Fe$@
|
||||
|
||||
clean:
|
||||
rm -rf *.gc* *.dSYM *.exe *.obj *.o a.out $(PROG)
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user