Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

btcrelay-bitcoind

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

btcrelay-bitcoind - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

25

dist/synchronizer/BitcoindRelaySynchronizer.js

@@ -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);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc