btcrelay-bitcoind
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -27,24 +27,11 @@ "use strict"; | ||
}; | ||
let btcRelayTipBlockHash; | ||
let spvTipBlockHeader; | ||
try { | ||
console.log("[BtcRelaySynchronizer]: Stored tip hash: ", tipData.blockhash); | ||
const btcBlockHeader = yield this.bitcoinRpc.getBlockHeader(tipData.blockhash); | ||
if (btcBlockHeader.confirmations <= 0) | ||
throw new Error("Block not in main chain"); | ||
cacheData.lastStoredHeader = yield this.btcRelay.retrieveLogByCommitHash(tipData.commitHash, tipData.blockhash); | ||
spvTipBlockHeader = btcBlockHeader; | ||
btcRelayTipBlockHash = btcBlockHeader.hash; | ||
} | ||
catch (e) { | ||
console.error(e); | ||
//Block not found, therefore relay tip is probably in a fork | ||
const { resultStoredHeader, resultBitcoinHeader } = yield this.btcRelay.retrieveLatestKnownBlockLog(); | ||
cacheData.lastStoredHeader = resultStoredHeader; | ||
const { resultStoredHeader, resultBitcoinHeader } = yield this.btcRelay.retrieveLatestKnownBlockLog(); | ||
cacheData.lastStoredHeader = resultStoredHeader; | ||
if (resultStoredHeader.getBlockheight() < tipData.blockheight) { | ||
cacheData.forkId = -1; //Indicate that we will be submitting blocks to fork | ||
spvTipBlockHeader = resultBitcoinHeader; | ||
btcRelayTipBlockHash = resultBitcoinHeader.hash; | ||
} | ||
let spvTipBlockHeader = resultBitcoinHeader; | ||
const btcRelayTipBlockHash = resultBitcoinHeader.hash; | ||
console.log("[BtcRelaySynchronizer]: Retrieved stored header with commitment: ", cacheData.lastStoredHeader); | ||
console.log("[BtcRelaySynchronizer]: SPV tip hash: ", tipData.blockhash); | ||
console.log("[BtcRelaySynchronizer]: SPV tip commit hash: ", tipData.commitHash); | ||
console.log("[BtcRelaySynchronizer]: SPV tip header: ", spvTipBlockHeader); | ||
@@ -51,0 +38,0 @@ const txsList = []; |
{ | ||
"name": "btcrelay-bitcoind", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Connector and synchronizer using bitcoind for bitcoin relay", | ||
@@ -29,5 +29,5 @@ "main": "./dist/index.js", | ||
"bn.js": "^5.2.1", | ||
"crosslightning-base": "^1.0.0", | ||
"crosslightning-base": "^1.0.1", | ||
"typescript": "^4.9.5" | ||
} | ||
} |
@@ -39,25 +39,13 @@ | ||
let btcRelayTipBlockHash: string; | ||
let spvTipBlockHeader: BitcoindBlock; | ||
try { | ||
console.log("[BtcRelaySynchronizer]: Stored tip hash: ", tipData.blockhash); | ||
const btcBlockHeader = await this.bitcoinRpc.getBlockHeader(tipData.blockhash); | ||
if(btcBlockHeader.confirmations<=0) throw new Error("Block not in main chain"); | ||
cacheData.lastStoredHeader = await this.btcRelay.retrieveLogByCommitHash(tipData.commitHash, tipData.blockhash); | ||
spvTipBlockHeader = btcBlockHeader; | ||
btcRelayTipBlockHash = btcBlockHeader.hash; | ||
} catch (e) { | ||
console.error(e); | ||
//Block not found, therefore relay tip is probably in a fork | ||
const {resultStoredHeader, resultBitcoinHeader} = await this.btcRelay.retrieveLatestKnownBlockLog(); | ||
cacheData.lastStoredHeader = resultStoredHeader; | ||
const {resultStoredHeader, resultBitcoinHeader} = await this.btcRelay.retrieveLatestKnownBlockLog(); | ||
cacheData.lastStoredHeader = resultStoredHeader; | ||
if(resultStoredHeader.getBlockheight()<tipData.blockheight) { | ||
cacheData.forkId = -1; //Indicate that we will be submitting blocks to fork | ||
spvTipBlockHeader = resultBitcoinHeader; | ||
btcRelayTipBlockHash = resultBitcoinHeader.hash; | ||
} | ||
let spvTipBlockHeader: BitcoindBlock = resultBitcoinHeader; | ||
const btcRelayTipBlockHash: string = resultBitcoinHeader.hash; | ||
console.log("[BtcRelaySynchronizer]: Retrieved stored header with commitment: ", cacheData.lastStoredHeader); | ||
console.log("[BtcRelaySynchronizer]: SPV tip hash: ", tipData.blockhash); | ||
console.log("[BtcRelaySynchronizer]: SPV tip commit hash: ", tipData.commitHash); | ||
@@ -64,0 +52,0 @@ console.log("[BtcRelaySynchronizer]: SPV tip header: ", spvTipBlockHeader); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48177
941
Updatedcrosslightning-base@^1.0.1