BitcoinCashClient makes it trivially easy to integrate native (non-custodial) Bitcoin Cash transactions into any C# .NET application with internet access.
This library provides a simple interface enabling on-chain sending and receiving of Bitcoin Cash by abstracting away as much complexity as possible. Wallet (private key and public address) creation, fetching wallet info from a block explorer, fetching up-to-date price data, managing utxos (hashes and indexes), inputs and outputs, network fee calculation, transaction signing, and broadcasting to the network are ALL handled by this library behind the scenes.
Private keys are never exposed. Don't trust. Verify.
using BitcoinCash;
var client = new BitcoinCashClient();
Generate a new Bitcoin Cash private key and its associated public address.
var wallet = client.GetWallet();
Use a private key to get a live wallet. This operation retrieves all utxos, calculates the wallet balance (and fiat value), and enables sending funds.
var privateKey = "<your-private-key>";
var wallet = await client.GetWallet(privateKey);
Note: Again, the private key is never exposed. The key is used to compute the public address, which is then used to fetch the wallet info from a block explorer.
Send the specified amount of Bitcoin Cash to the specified address.
// send one dollar's worth of BCH to the destination address
await wallet.Send("<destination-address>", 1m, Currency.USDollar);
Send the entire wallet balance to the specified address.
await wallet.SendAll("<destination-address>");
Use a public address to get a read-only wallet.
var publicAddress = "<any-valid-bch-address>";
var wallet = await client.GetWalletByAddress(publicAddress);
Please view the sample project for simple live examples.
For a detailed explanation of the code, please see this tutorial.
- Async/Await refactor
- .NET 8 and C# 12
- Send to many
- Unambiguous error states
- Convert address to CashAddr format
- Check if address is valid
- Mass wallet balance check
- Support for many fiat currencies
- Support for legacy addresses
- Get fiat value
- Create wallet
- Get live wallet by private key
- Get read-only wallet by public address
- Get list of live wallets by list of private keys
- Get list of read-only wallets by list of public addresses
- All wallets include balance in satoshis and current value in USD
- Send specified amount of USD or BCH to specified address
- Send entire wallet balance to specified address
BitcoinCashClient is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.