Skip to Content
IntegrationsRPC Integration Patterns

RPC Integration Patterns

Tidecoin exposes the Bitcoin Core JSON-RPC model plus Tidecoin-specific PQHD and AuxPoW RPCs. This page covers integration idioms and workflows. For command schemas and return fields, use RPC Reference. For binding, authentication, and access control, use RPC Security.

Ownership boundary

NeedPage
Exact RPC arguments and result fieldsRPC Reference
Error codes and retry guidanceRPC Error Codes
Secure deployment of RPCRPC Security
Application workflowsThis page

Node health gate

Every long-running integration should gate work on node health:

tidecoin-cli getblockchaininfo tidecoin-cli getnetworkinfo

Before enabling deposits or withdrawals, check:

Field or conditionExpected handling
initialblockdownloadDeposits and withdrawals should wait until false.
Current block heightMust be close to your independent monitor or trusted peer set.
Best block hashStore it and compare on the next poll.
Peer countAlert if below your operational threshold.
Chain selectionConfirm mainnet/testnet/regtest matches the environment.

Block tailing

Prefer waitfornewblock for low-latency block tailing, with a polling fallback for process restarts.

tidecoin-cli waitfornewblock 60

Store both height and hash. Heights can be reused during a reorg; hashes identify the actual block.

Recommended loop:

  1. Read current tip from getblockchaininfo.
  2. If this is startup, backfill from the last finalized height you have processed.
  3. Call waitfornewblock <timeout>.
  4. Fetch the block by hash with getblock <hash> 2.
  5. Process transactions idempotently.
  6. Store the processed block hash, height, and previous block hash.

Reorg handling

Never treat height alone as a primary key.

For every processed block, store:

FieldWhy
heightOrdering and confirmation calculation.
hashCanonical identity of the block you processed.
previousblockhashFast continuity check.
Processed transaction IDsIdempotent credit/debit handling.

On a new tip:

  1. Compare the new block’s previousblockhash to your stored tip hash.
  2. If it matches, append normally.
  3. If it does not match, walk backward with getblockheader or getblock until you find a common ancestor.
  4. Mark transactions from disconnected blocks as unconfirmed or reversed.
  5. Replay blocks from the common ancestor to the new tip.

Wallet deposit monitoring

For wallet-backed deposits, listsinceblock is the simplest cursor API. Use a confirmation target so transactions are re-reported until they are deep enough.

tidecoin-cli -rpcwallet="deposits" listsinceblock "<lastblock>" 6 true true

Typical handling:

Result fieldHandling
transactions[]Process credits/debits idempotently by txid, vout, address/account metadata, and category.
removed[]Reverse or unconfirm records that were in disconnected blocks.
lastblockStore as the next cursor after successful processing.

If you do not use the wallet, scan blocks directly with getblock and decode outputs with your own address index.

Raw transaction lookup

Use getrawtransaction carefully:

tidecoin-cli getrawtransaction "<txid>" 2 "<blockhash>"

Passing a blockhash avoids ambiguity and avoids depending on mempool or global transaction index availability. For wallet transactions, use gettransaction on the wallet endpoint.

Mempool observation

Mempool data is policy-local. It is useful for withdrawal monitoring and broadcast feedback, but it is not consensus state.

Useful checks:

tidecoin-cli testmempoolaccept '["<rawtxhex>"]' tidecoin-cli sendrawtransaction "<rawtxhex>" "<maxfeerate>"

Handle RPC_VERIFY_REJECTED (-26) as a rejection and store the message for operator review. Common rejection reasons include low fee, dust, non-standardness, pre-activation witness/script use, and invalid signatures.

Batching and rate limits

JSON-RPC supports batching at the HTTP layer. Use it for independent lookups such as getblockhash or getrawtransaction, but do not batch state-changing wallet operations unless your application can tolerate partial success and retry ambiguity.

Rules:

PatternGuidance
Read-only block/tx lookupGood batch candidate.
Wallet sendsAvoid batching; handle one withdrawal at a time or with explicit internal locking.
Import/rescan operationsDo not mix with normal hot-path calls.
Long waitsKeep waitfornewblock on a separate worker connection.

Retry policy

ErrorHandling
RPC_IN_WARMUP (-28)Retry after startup delay.
RPC_CLIENT_IN_INITIAL_DOWNLOAD (-10)Wait for sync before deposit/withdrawal operations.
RPC_CLIENT_NOT_CONNECTED (-9)Retry after peer recovery; alert if persistent.
RPC_INVALID_ADDRESS_OR_KEY (-5)Treat as input or configuration error.
RPC_INVALID_PARAMETER (-8)Treat as caller bug unless input is user-provided.
RPC_VERIFY_REJECTED (-26)Do not blindly retry; inspect rejection reason.

Source of truth

TopicSource
RPC command registration and named args../tidecoin/src/rpc/client.cpp
Blockchain RPCs../tidecoin/src/rpc/blockchain.cpp
Raw transaction and mempool RPCs../tidecoin/src/rpc/rawtransaction.cpp, ../tidecoin/src/rpc/mempool.cpp
Wallet transaction RPCs../tidecoin/src/wallet/rpc/transactions.cpp, ../tidecoin/src/wallet/rpc/spend.cpp
Tidecoin-specific PQHD and AuxPoW RPCs../tidecoin/doc/pq-rpc.md, RPC Reference

See also: Reference / RPC Reference, Reference / RPC Error Codes, Exchange Integration.

Last updated on