From ccb286a1059f87e2a4297add4f5aa7b102135b41 Mon Sep 17 00:00:00 2001 From: sairajzero Date: Tue, 1 Aug 2023 04:10:25 +0530 Subject: [PATCH] bug fixes --- scripts/btcMortgage.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/scripts/btcMortgage.js b/scripts/btcMortgage.js index 56231b8..881de48 100644 --- a/scripts/btcMortgage.js +++ b/scripts/btcMortgage.js @@ -5,8 +5,8 @@ const APP_NAME = "BTCMortgage"; const APP_IDENTIFIER = "BTC Mortgage"; - const BANKER_ID = ""; - const BANKER_PUBKEY = ""; + const BANKER_ID = "FKAEdnPfjXLHSYwrXQu377ugN4tXU7VGdf"; + const BANKER_PUBKEY = '032FCA79F94AF6D6BC4A90B93A55B81501618E1B670665D161334C0041A41C54C3'; const CURRENCY = "USD"; 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 () { - initDB().then(result => { - console.log(result); - loadOwnedCollateralLocksFromIDB().then(_ => { - readPoliciesFromBlockchain().then(policies => { - console.log("Policies", policies); - readAllLoans().then(loans => { - console.log("Loans", loans); - resolve("App initiation successful") + return new Promise((resolve, reject) => { + initDB().then(result => { + console.log(result); + loadOwnedCollateralLocksFromIDB().then(_ => { + readPoliciesFromBlockchain().then(policies => { + console.log("Policies", policies); + readAllLoans().then(loans => { + 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)) + }) } function initDB() { @@ -208,7 +210,7 @@ return new Promise((resolve, reject) => { const LASTTX_IDB_KEY = "B#" + BANKER_ID 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) query_options.ignoreOld = lastTx; else if (typeof lastTx == 'string') //lastTx is txid of last tx