bug fixes

This commit is contained in:
sairajzero 2023-08-01 04:10:25 +05:30
parent 01332905a0
commit ccb286a105

View File

@ -5,8 +5,8 @@
const APP_NAME = "BTCMortgage"; const APP_NAME = "BTCMortgage";
const APP_IDENTIFIER = "BTC Mortgage"; const APP_IDENTIFIER = "BTC Mortgage";
const BANKER_ID = ""; const BANKER_ID = "FKAEdnPfjXLHSYwrXQu377ugN4tXU7VGdf";
const BANKER_PUBKEY = ""; const BANKER_PUBKEY = '032FCA79F94AF6D6BC4A90B93A55B81501618E1B670665D161334C0041A41C54C3';
const CURRENCY = "USD"; const CURRENCY = "USD";
const ALLOWED_DEVIATION = 0.98, //ie, upto 2% of decrease in rate can be accepted in processing stage const ALLOWED_DEVIATION = 0.98, //ie, upto 2% of decrease in rate can be accepted in processing stage
@ -169,18 +169,20 @@
} }
btcMortgage.init = function () { btcMortgage.init = function () {
initDB().then(result => { return new Promise((resolve, reject) => {
console.log(result); initDB().then(result => {
loadOwnedCollateralLocksFromIDB().then(_ => { console.log(result);
readPoliciesFromBlockchain().then(policies => { loadOwnedCollateralLocksFromIDB().then(_ => {
console.log("Policies", policies); readPoliciesFromBlockchain().then(policies => {
readAllLoans().then(loans => { console.log("Policies", policies);
console.log("Loans", loans); readAllLoans().then(loans => {
resolve("App initiation successful") console.log("Loans", loans);
resolve("App initiation successful")
}).catch(error => reject(error))
}).catch(error => reject(error)) }).catch(error => reject(error))
}).catch(error => reject(error)) }).catch(error => reject(error))
}).catch(error => reject(error)) }).catch(error => reject(error))
}).catch(error => reject(error)) })
} }
function initDB() { function initDB() {
@ -208,7 +210,7 @@
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const LASTTX_IDB_KEY = "B#" + BANKER_ID const LASTTX_IDB_KEY = "B#" + BANKER_ID
compactIDB.readData("lastTx", LASTTX_IDB_KEY).then(lastTx => { compactIDB.readData("lastTx", LASTTX_IDB_KEY).then(lastTx => {
var query_options = { sentOnly: true, tx: true, filter: d => d.startsWith(APP_IDENTIFIER) }; var query_options = { sentOnly: true, tx: true, filter: d => typeof d == 'string' && d.startsWith(APP_IDENTIFIER) };
if (typeof lastTx == 'number') //lastTx is tx count (*backward support) if (typeof lastTx == 'number') //lastTx is tx count (*backward support)
query_options.ignoreOld = lastTx; query_options.ignoreOld = lastTx;
else if (typeof lastTx == 'string') //lastTx is txid of last tx else if (typeof lastTx == 'string') //lastTx is txid of last tx