Bitcoin
هل أنت مستعد لاستدعاء هذا في الإنتاج؟
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
Bitcoin
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
https://bitcoin.therpc.io/YOUR_API_KEY or send it as a Bearer header.subscribe method and no push channel, so TheRPC doesn't offer one either.getblockcount (or getbestblockhash) on a sensible interval and react when the value changes. Since blocks arrive roughly every 10 minutes, polling every few seconds wastes quota — a short interval only while actively watching is enough.getblockcount return fast, but heavier ones — getblock at verbosity 2 or 3, or a verbose getrawmempool — return much larger payloads and take longer. Set a generous timeout (several seconds or more) for those calls rather than a tight one tuned to the cheap reads.Bitcoin Core returns errors in the error object with a numeric code. The standard JSON-RPC codes flag envelope problems — -32700 parse error, -32600 invalid request, -32601 method not found, -32602 invalid params — while Bitcoin's own codes flag domain failures: -5 invalid address/key or not found, -8 invalid parameter, -22 deserialization (bad transaction hex), -25 verify error, -26 transaction rejected by the mempool, and -27 transaction already in the chain. The full table is below. Four habits keep integrations robust: always check the error field before reading result; retry transient failures (timeouts, rate limits) with exponential backoff, but never blindly retry deterministic rejections like -26; log the code and message so failures are diagnosable; and set sensible HTTP timeouts so a slow heavy read fails cleanly instead of hanging.
| Code | Meaning |
|---|---|
-32700 | Parse error |
-32600 | Invalid request |
-32601 | Method not found |
-32602 | Invalid params |
-5 | Invalid address/key or not found |
-8 | Invalid parameter |
-22 | Deserialization (bad hex) |
-25 | Verify error |
-26 | Transaction rejected by mempool |
-27 | Transaction already in chain |
getrawtransaction with verbose true and read its confirmations field — 0 or absent means it's still pending. While it's unconfirmed you can inspect it in the mempool with getmempoolentry to see its fee and how long it's been waiting. Once confirmations climbs, it's in a block.getrawtransaction find an old transaction? Without -txindex, a node only resolves transactions still in the mempool or in blocks it specifically knows to look in, so a historical txid lookup fails unless you also pass the blockhash. TheRPC runs Bitcoin with transaction indexing on; you can confirm txindex is active and synced via getindexinfo.getbestblockhash for an unexpected tip change, and use getchaintips to detect competing branches. A transaction that was confirmed can return to the mempool after a reorg, so re-check confirmations rather than caching "confirmed" permanently.X-RateLimit-* response headers to back off before you're throttled, and avoid pulling full verbose mempool dumps (getrawmempool true) on a loop — they're large and change constantly.getblockchaininfo and read the chain field: main for mainnet, test for testnet, plus signet and regtest for the test networks. This is the reliable way to be sure you're not broadcasting a real BTC transaction against testnet or vice versa.value from gettxout and the feerate from estimatesmartfee), so multiply by 1e8 when you need satoshis. Remember there are no accounts and no nonce — the UTXO model tracks unspent outputs, not address balances.fetch/axios in JavaScript, requests in Python, net/http in Go. Bitcoin has no dominant high-level SDK, so a plain POST of the 1.0 envelope works everywhere; thin clients like python-bitcoinrpc are optional conveniences, not requirements.getblockchaininfo call (confirm the chain field matches the network you expect), and monitor latency and rate-limit headers as you scale. Move to mainnet only once the testnet path is solid.