Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
@xchainjs/xchain-bitcoin
Advanced tools
@xchainjs/xchain-client
Implements the following:
interface BitcoinClient {
generatePhrase(): string
setPhrase(phrase?: string): void
validatePhrase(phrase: string): boolean
purgeClient(): void
setNetwork(net: Network): void
getNetwork(net: Network): Bitcoin.networks.Network
setBaseUrl(endpoint: string): void
getAddress(): string
validateAddress(address: string): boolean
scanUTXOs(): Promise<void>
getBalance(): number
getBalanceForAddress(address?: string): Promise<number>
getTransactions(address: string): Promise<Txs>
calcFees(memo?: string): Promise<object>
vaultTx(addressVault: string, valueOut: number, memo: string, feeRate: number): Promise<string>
normalTx(addressTo: string, valueOut: number, feeRate: number): Promise<string>
}
client
- Custom client for communicating with Bitcoin using BIP39 bitcoinjs-lib and WIFyarn add @xchainjs/xchain-client
Following dependencies will be installed into your project:
Uses a dotenv file to hold a USER_PHRASE
and a VAULT_PHRASE
Initialize client and use class methods:
import { Client, Network } from '../src/client'
const btcClient = new Client(Network.TEST)
const newPhrase = btcClient.generatePhrase()
Generate a 12 word BIP-39 seed phrase.
Return: string
phrase
)Loads a 12 word BIP-39 seed phrase to use as a BTC send/receive address.
phrase: 12 word BIP-39 seed phrase as string
Return: void
phrase
)Validates if provided phrase
is BIP-39.
phrase: 12 word BIP-39 seed phrase as string
Return: boolean
Clears UTXOs and seed phrase from client class properties.
Return: void
net
)Set testnet or mainnet network using the Network
interface.
net: Network.TEST
or Network.MAIN
Return: void
endpoint
)Set an electrs REST API endpoint to use for chain data.
endpoint: endpoint as string
Return: void
Gets a P2WPKH address using the seed phrase set in .setPhrase()
or initialization. If no phrase is set will error.
Return: string
address
)Validates if provided address
is p2wpkh and same network as the client.
address: string
Return: boolean
Async
Scans the UTXOs on the set seed phrase in .setPhrase()
and stores them in class properties.
Return: void
Get the balance of UTXOs from .scanUTXOs()
Return: number
in sats
address
)Async
Get the balance of UTXOs for an external address
address: string
Return: number
in sats
address
)Async
Get transactions for an address
address: string
Return: Array
of objects
memo
)Async
Calculates the fee rate and the fee total estimate for fast, regular, and slow transactions. Add a memo
for a vault TX
memo: string
optional
Return: object
of objects
addressVault
, valueOut
, memo
, feeRate
)Async
Generates a valid Vault TX hex to be broadcast
addressVault: string
valueOut: number
in sats
memo: string
feeRate: number
addressTo
, valueOut
, feeRate
)Async
Generates a valid Vault TX hex to be broadcast
addressTo: string
valueOut: number
in sats
feeRate: number
FAQs
Custom Bitcoin client and utilities used by XChainJS clients
The npm package @xchainjs/xchain-bitcoin receives a total of 165 weekly downloads. As such, @xchainjs/xchain-bitcoin popularity was classified as not popular.
We found that @xchainjs/xchain-bitcoin demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 11 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.