Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@synonymdev/blocktank-lsp-btc-client
Advanced tools
Client to interact with the blocktank-lsp-btc service.
Watched Addresses are onchain addresses that you get notified about in case of a incoming transaction.
Create WatchedAddress
import { LspBtcClient, IWatchedAddress } from '@synonymdev/blocktank-lsp-btc-client';
const daysToWatch = 1 // How long in time this address is watched for. Default: 1
const maxWatchedBlockConfirmations = 6 // How many blockConfirmations you want to receive events for. Default: 6.
const client = new LspBtcClient()
const watched: IWatchedAddress = await client.createAddress(daysToWatch, maxWatchedBlockConfirmations)
console.log('Newly created address', watched.address)
Listen for updates
Update events are sent when a tx gets added/removed to the watched address or the tx confirmation state changes.
maxWatchedBlockConfirmations
.Important: Due to reorgs, the number of block confirmations can go backward!
import {LspBtcClient, IWatchedAddress, LspBtcEventListener, IAddressUpdateEvent, SuspiciousZeroConfReason } from "@synonymdev/blocktank-lsp-btc-client";
const listener = new LspBtcEventListener()
await listener.init()
const client = new LspBtcClient()
await listener.listenToAddressUpdates(async message => {
const event: IAddressUpdateEvent = message.content
// Pull the latest invoice
const watched = await client.getAddress(event.id)
if (watched.isBlacklisted) {
// DO NOT TOUCH! Address received a tx from a blacklisted address.
return;
}
const _1ConfirmationTxs = watched.transactions.filter(tx => {
// Do your own risk analysis here.
// Block confirmations are great.
// 0conf is always risky.
// Do NOT use 0conf for high value txs or high value products.
return tx.blockConfirmationCount >= 1 || tx.suspicious0ConfReason === SuspiciousZeroConfReason.NONE;
})
const amountSat = _1ConfirmationTxs.reduce((acc, tx) => acc + tx.amountSat, 0)
console.log(`Received ${amountSat} satoshis on address ${watched.address}`)
})
Important
blockConfirmationCount
may be higher thanmaxWatchedBlockConfirmations
.blockConfirmationCount
may also jump suddendly from 0 to 6. So always checkblockConfirmationCount
with>=
.
Info Always close your event listener with
await listener.close()
when you are done listening to events.
For regtest, the client exposes some methods:
regtestMineBlocks
regtestSendPayment
Checkout the types to see how to use them. They are very simple.
package.json
.CHANGELOG.md
.git tag v0.1.0
.git push origin v0.1.0
.npm run build
.npm publish
.FAQs
Blocktank BTC client
The npm package @synonymdev/blocktank-lsp-btc-client receives a total of 11 weekly downloads. As such, @synonymdev/blocktank-lsp-btc-client popularity was classified as not popular.
We found that @synonymdev/blocktank-lsp-btc-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.