Lightning Nodes

Bitcoin Node Developer Guide

Bitcoin Node Developer Guide

Build applications on Bitcoin using Comet's Bitcoin Core integration.

Overview

Comet provides full Bitcoin Core RPC access for:

  • Wallet operations

  • Transaction management

  • Blockchain queries

  • Network monitoring

Supported Versions: Bitcoin Core 24.0+

Quick Start

Deploy Bitcoin Core

comet bitcoin deploy fastsync

RPC Access

Credentials:

comet bitcoin credentials --node_id <node_id><

Output:

jsonCopy{
  "rpc_host": "bitcoin.comet.dev",
  "rpc_port": 80,
  "rpc_user": "user_abc123",
  "rpc_password": "pass_xyz789"
}

Test Connection

bitcoin-cli -rpcconnect=bitcoin.comet.dev \
  -rpcport=80 \
  -rpcuser=user_abc123 \
  -rpcpassword=pass_xyz789 \
  getblockchaininfo

Wallet Management

Create Wallet

bitcoin-cli createwallet "my_wallet"

With Descriptors:

bitcoin-cli createwallet "my_wallet" false false "" false true

Parameters:

  • wallet_name: Wallet identifier

  • disable_private_keys: false (default)

  • blank: false (default)

  • passphrase: "" (optional)

  • avoid_reuse: false (default)

  • descriptors: true (recommended)

Load Wallet

bitcoin-cli loadwallet "my_wallet"

List Wallets

bitcoin-cli listwallets

Wallet Info

bitcoin-cli -rpcwallet=my_wallet getwalletinfo

Response:

jsonCopy{
  "walletname": "my_wallet",
  "walletversion": 169900,
  "balance": 0.05000000,
  "unconfirmed_balance": 0.00000000,
  "immature_balance": 0.00000000,
  "txcount": 15,
  "keypoolsize": 1000
}

Address Management

Generate Address

Legacy:

bitcoin-cli -rpcwallet=my_wallet getnewaddress "" "legacy"

SegWit:

bitcoin-cli -rpcwallet=my_wallet getnewaddress "" "p2sh-segwit"

Native SegWit (Bech32):

bitcoin-cli -rpcwallet=my_wallet getnewaddress "" "bech32"

Taproot (Bech32m):

bitcoin-cli -rpcwallet=my_wallet getnewaddress "" "bech32m"

Address Types

Type

Format

Example

Use Case

Legacy

P2PKH

1A1zP1...

Legacy compatibility

P2SH-SegWit

P2SH

3J98t1...

Wide compatibility

Native SegWit

Bech32

bc1qw5...

Lower fees

Taproot

Bech32m

bc1p5d...

Privacy, efficiency

Recommendation: Use Taproot (bech32m) for new applications.

Validate Address

bitcoin-cli validateaddress "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4"

Get Address Info

bitcoin-cli -rpcwallet=my_wallet getaddressinfo "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4"

Transaction Management

Send Bitcoin

Simple Send:

bitcoin-cli -rpcwallet=my_wallet sendtoaddress "bc1q..." 0.001

With Fee Control:

bitcoin-cli -rpcwallet=my_wallet sendtoaddress "bc1q..." 0.001 "" "" false true 10

Parameters:

  • address: Recipient address

  • amount: BTC amount

  • comment: "" (optional)

  • comment_to: "" (optional)

  • subtractfeefromamount: false (default)

  • replaceable: true (enable RBF)

  • conf_target: 10 (blocks)

Batch Transactions

bitcoin-cli -rpcwallet=my_wallet sendmany "" '{
  "bc1q...": 0.001,
  "bc1p...": 0.002,
  "3J98t...": 0.0015
}'

Create Raw Transaction

Step 1: List Unspent Outputs

bitcoin-cli -rpcwallet=my_wallet listunspent

Step 2: Create Transaction

bitcoin-cli createrawtransaction '[
  {"txid": "abc123...", "vout": 0}
]' '{
  "bc1q...": 0.001,
  "bc1p...": 0.0489
}'

Step 3: Sign Transaction

bitcoin-cli -rpcwallet=my_wallet signrawtransactionwithwallet "02000000..."

Step 4: Broadcast

bitcoin-cli sendrawtransaction "02000000..."

Transaction Details

bitcoin-cli -rpcwallet=my_wallet gettransaction "txid"

Response:

jsonCopy{
  "amount": 0.001,
  "confirmations": 6,
  "blockhash": "00000000...",
  "blockheight": 820450,
  "txid": "abc123...",
  "time": 1704537600,
  "details": [...]
}

List Transactions

bitcoin-cli -rpcwallet=my_wallet listtransactions "*" 10

UTXO Management

List Unspent

bitcoin-cli -rpcwallet=my_wallet listunspent 1 9999999

Filter by Amount:

bitcoin-cli -rpcwallet=my_wallet listunspent 1 9999999 '[]' true '{
  "minimumAmount": 0.001,
  "maximumAmount": 0.01
}'

Lock UTXO

bitcoin-cli -rpcwallet=my_wallet lockunspent false '[
  {"txid": "abc123...", "vout": 0}
]'

Unlock UTXO

bitcoin-cli -rpcwallet=my_wallet lockunspent true '[
  {"txid": "abc123...", "vout": 0}
]'

List Locked

bitcoin-cli -rpcwallet=my_wallet listlockunspent

Fee Management

Estimate Fee

bitcoin-cli estimatesmartfee 6

Response:

jsonCopy{
  "feerate": 0.00010000,
  "blocks": 6
}

Confirmation Targets:

  • 1 block: ~10 minutes (high priority)

  • 6 blocks: ~1 hour (standard)

  • 144 blocks: ~24 hours (low priority)

Set Transaction Fee

bitcoin-cli -rpcwallet=my_wallet settxfee 0.0001

Replace-By-Fee (RBF)

Bump Fee:

bitcoin-cli -rpcwallet=my_wallet bumpfee "txid" '{"fee_rate": 25}'

Blockchain Queries

Block Info

Latest Block:

bitcoin-cli getblockcount

Block Hash:

bitcoin-cli getblockhash 820450

Block Details:

bitcoin-cli getblock "00000000000000000001..."

Block with Transactions:

bitcoin-cli getblock "00000000000000000001..." 2

Blockchain Info

bitcoin-cli getblockchaininfo

Key Fields:

  • chain: "main" or "test"

  • blocks: Current height

  • headers: Header count

  • verificationprogress: Sync progress (0-1)

  • pruned: Pruning status

Transaction Lookup

Get Raw Transaction:

bitcoin-cli getrawtransaction "txid" true

Decode Transaction:

bitcoin-cli decoderawtransaction "02000000..."

Mempool Operations

Mempool Info

bitcoin-cli getmempoolinfo

Response:

jsonCopy{
  "size": 5432,
  "bytes": 2456789,
  "usage": 8901234,
  "maxmempool": 300000000,
  "mempoolminfee": 0.00001000
}

Mempool Contents

bitcoin-cli getrawmempool

Verbose:

bitcoin-cli getrawmempool true

Mempool Entry

bitcoin-cli getmempoolentry "txid"

Network Information

Peer Info

bitcoin-cli getpeerinfo

Network Info

bitcoin-cli getnetworkinfo

Connection Count

bitcoin-cli getconnectioncount

Descriptors

Output Descriptors

Modern wallet standard for deterministic key derivation.

Generate Descriptor:

bitcoin-cli -rpcwallet=my_wallet getdescriptorinfo "wpkh([fingerprint/84'/0'/0']xpub.../0/*)"

Import Descriptor:

bitcoin-cli -rpcwallet=my_wallet importdescriptors '[{
  "desc": "wpkh([fingerprint/84h/0h/0h]xpub.../0/*)#checksum",
  "timestamp": "now",
  "active": true
}]'

List Descriptors:

bitcoin-cli -rpcwallet=my_wallet listdescriptors

PSBTs (Partially Signed Bitcoin Transactions)

Create PSBT

bitcoin-cli -rpcwallet=my_wallet walletcreatefundedpsbt '[]' '[{
  "bc1q...": 0.001
}]'

Process PSBT

bitcoin-cli -rpcwallet=my_wallet walletprocesspsbt "cHNidP8BAH..."

Finalize PSBT

bitcoin-cli finalizepsbt "cHNidP8BAH..."

Decode PSBT

bitcoin-cli decodepsbt "cHNidP8BAH..."

Multisig Wallets

Create Multisig Address

2-of-3 Multisig:

bitcoin-cli createmultisig 2 '[
  "pubkey1",
  "pubkey2",
  "pubkey3"
]' "bech32"

Response:

jsonCopy{
  "address": "bc1q...",
  "redeemScript": "5221...",
  "descriptor": "wsh(multi(2,...))"
}

Import Multisig

bitcoin-cli -rpcwallet=multisig_wallet importmulti '[{
  "desc": "wsh(multi(2,...))#checksum",
  "timestamp": "now",
  "watchonly": true
}]'

Backup & Recovery

Backup Wallet

bitcoin-cli -rpcwallet=my_wallet backupwallet "/path/to/backup.dat"

Dump Private Key

bitcoin-cli -rpcwallet=my_wallet dumpprivkey "address"

⚠️ Warning: Keep private keys secure. Never share.

Import Private Key

bitcoin-cli -rpcwallet=my_wallet importprivkey "private_key" "label" false

Dump Wallet

bitcoin-cli -rpcwallet=my_wallet dumpwallet "/path/to/wallet.txt"

Python Integration

Using python-bitcoinrpc

from bitcoinrpc.authproxy import AuthServiceProxy

rpc = AuthServiceProxy(
    "http://user:pass@bitcoin.comet.dev:8332"
)

# Get blockchain info
info = rpc.getblockchaininfo()
print(f"Block height: {info['blocks']}")

# Create address
address = rpc.getnewaddress("", "bech32m")
print(f"New address: {address}")

# Send transaction
txid = rpc.sendtoaddress(address, 0.001)
print(f"Transaction: {txid}")

Error Handling

from bitcoinrpc.authproxy import JSONRPCException

try:
    result = rpc.sendtoaddress("invalid_address", 0.001)
except JSONRPCException as e:
    print(f"RPC Error: {e.error['message']}")

JavaScript Integration

Using bitcoin-core

const Client = require('bitcoin-core');

const client = new Client({
  host: 'bitcoin.comet.dev',
  port: 8332,
  username: 'user_abc123',
  password: 'pass_xyz789'
});

// Get blockchain info
const info = await client.getBlockchainInfo();
console.log(`Block height: ${info.blocks}`);

// Create address
const address = await client.getNewAddress('', 'bech32m');
console.log(`New address: ${address}`);

// Send transaction
const txid = await client.sendToAddress(address, 0.001);
console.log(`Transaction: ${txid}`);

Best Practices

  1. Use Descriptors: Modern wallet standard

  2. Enable RBF: Allow fee bumping

  3. Taproot Addresses: Better privacy and efficiency

  4. Coin Control: Manage UTXOs explicitly

  5. Fee Estimation: Use estimatesmartfee

  6. Backup Regularly: Export wallet backups

  7. Test on Testnet: Validate before mainnet

  8. Handle Errors: Implement robust error handling

Security

RPC Security

  • Never expose RPC publicly: Use VPN or SSH tunnels

  • Strong passwords: Generate random credentials

  • IP whitelisting: Restrict access by IP

  • TLS encryption: Use HTTPS for RPC calls

Wallet Security

  • Encrypt wallets: Use encryptwallet

  • Backup seeds: Store recovery phrases securely

  • Cold storage: Keep large amounts offline

  • Multi-signature: Require multiple approvals

Troubleshooting

Common Issues

Connection Refused:

  • Verify RPC credentials

  • Check firewall settings

  • Confirm node is running

Insufficient Funds:

  • Check wallet balance

  • Verify UTXO availability

  • Account for transaction fees

Transaction Not Confirming:

  • Check fee rate

  • Use RBF to bump fee

  • Monitor mempool status

Debug Mode

bitcoin-cli -rpcwallet=my_wallet logging '["rpc"]'

Resources

Next Steps

  1. Enable Bitcoin Core on your node

  2. Create test wallet on testnet

  3. Practice transaction creation

  4. Implement error handling

  5. Build production application

Table of Contents

Copyright © 2025 Comet Cash

Czech Republic VASP License Registration Nº 22053751

info@cometcash.com

All rights reserved.

Copyright © 2025 Comet Cash

Czech Republic VASP License Registration Nº 22053751

info@cometcash.com

All rights reserved.