DogeJS / All tools / Light node

Check Dogecoin block headers yourself

A light node downloads headers from peers and verifies the proof of work on your own computer, so a server cannot simply tell you what is on the chain.

Syncing needs Node 20 or later. The header checks also run in a browser or a worker.

A run example verifying real mainnet block headers, with the output.

What it does

A run example showing the chain parameters, with the output.

Chain parameters for each network

Ports, genesis blocks and checkpoints for mainnet, testnet and regtest, and which difficulty rule applies at a given height.

  • Mainnet, testnet and regtest
  • Genesis block and last checkpoint for each
  • DigiShield or the older retarget, by height
A terminal session: the node syncing headers from a fake regtest peer, its status, and a transaction proof checked.

Sync from the command line

Start the node, let it download and verify headers, then ask for its status or verify a transaction proof.

  • Shows height, tip and chain work
  • verify-proof checks a transaction against your verified chain
  • Try it with no network using the bundled fake peer
Code that verifies a real mainnet block header and its proof of work.

Use the checks in your own code

The pure checks need no sockets: verify a header chain or a Merkle proof in a script, a browser or a worker.

  • verifyHeaderChain and verifyMerkleBlockProof
  • AuxPoW (merged mining) proofs are checked too
  • Plain functions, nothing stored

Check Dogecoin block headers yourself

Open source, MIT licensed, on GitHub.

For developers

Documentation

Modules, run examples, complete reference and FAQ.

Quick start

Build the package, then sync headers. Syncing needs Node.js 20 or later, because browsers cannot open the raw TCP connections that Dogecoin peers use.

Shell
npm run build
node dist/cli.mjs sync                 # testnet, DNS seeds, until Ctrl-C
node dist/cli.mjs status
node dist/cli.mjs verify-proof HEX     # a gettxoutproof result

To try it with no network, start the bundled fake regtest peer and sync from it. This is the real output of that run.

Shell
node examples/fake-peer.mjs 28444 300 &
node dist/cli.mjs sync --network regtest --peer 127.0.0.1:28444 --exit-when-synced

peer 127.0.0.1:28444 connected (/FAKE-regtest-peer:0.1/, height 300)
height 300 verified 300 1714 headers/s peers 1
synced: 1 peer(s) agree on the tip
peer 127.0.0.1:28444 closed: sync stopped

The pure checks also run in a browser or a worker, with no sockets and no storage:

JavaScript
import { verifyHeaderChain, verifyMerkleBlockProof } from '@dogejs/node/verify';

const inclusion = verifyMerkleBlockProof(proofHex, txid); // is the transaction under this header?
const result = verifyHeaderChain([headerHex, nextHex], {  // lowest first
  network: 'mainnet',
  firstHeight: 5_100_000,
});
if (!result.ok) console.log(result.code, result.reason);

@dogejs/node/verify is about 40 KB minified and imports nothing.

How it works

  1. Connect

    The node talks to Dogecoin peers over the peer-to-peer protocol, from DNS seeds or the peers you name.

  2. Download headers

    Headers are 80 bytes each, so the stored chain is about 470 MB, not the full blocks.

  3. Check each one

    Proof of work, difficulty, merged-mining proof, checkpoints and timestamps, in the order Dogecoin Core checks them.

  4. Follow the most work

    The node keeps the chain with the most work, and checks proofs against headers it verified itself.

The node reports synced only when enough peers have nothing more to offer. By default, at least two must agree. It follows the most-work header chain and cannot see invalid transactions inside a block, which is the usual light-client assumption.

What gets checked

CheckWhat it means
Proof of workThe scrypt hash (N=1024, r=1, p=1) of the 80 header bytes is at or below the target in its bits field.
Merged miningFor merged-mined blocks, the parent block meets the target and the merged-mining proof links it to this header, in 10 steps.
Chain IDBlocks carry Dogecoin's chain ID, 0x62. Legacy version 1 and 2 blocks are only allowed before merged mining starts.
LinkageThe previous header must be known.
Difficultybits must equal the value the era's rule computes from earlier headers.
TimestampsAfter the median of the last 11 blocks, and at most 2 hours ahead of your clock.
VersionsAt least version 3 after the BIP66 height and version 4 after the BIP65 height.
CheckpointsA header at a checkpoint height must have the checkpoint hash.
Merkle proofsA transaction proof must lead to the merkle root of a verified header.

A proof is accepted only at or below the verified height. The checks do not prove that a stated difficulty is the network's unless the headers come from a synced chain.

Examples

Three difficulty eras on mainnet

Each era uses a different rule. Verify a real block from each with the run example below.

  1. 0 to 144,999

    Early rules

    The difficulty retargets every 240 blocks.

  2. 145,000 to 371,336

    DigiShield

    The difficulty adjusts every block.

  3. 371,337 and later

    Merged mining

    Blocks must carry a merged-mining proof.

Reference

Command line

CommandWhat it does
syncDownload and verify block headers.
statusShow the stored chain: height, tip, verified height and chain work.
verify-proof HEXCheck a gettxoutproof result against the stored headers. Add --tx RAWTX to match a raw transaction.
OptionWhat it does
--networktestnet (default), mainnet or regtest.
--datadir DIRWhere headers are stored. Default ~/.dogejs-node.
--peer host:portUse only this peer. Repeat for more. No DNS seeds are used.
--max-peers NConnections to keep. Default 4.
--min-agreeing NPeers that must agree on the tip. Default 2, or 1 with one --peer.
--trust-checkpointsFaster: skip the scrypt checks up to the last checkpoint.
--exit-when-syncedStop after the peers agree on the tip.
--timeout SECONDSGive up after this long.
--jsonMachine-readable output.

API

JavaScript
import { HeaderChain, HeaderSync, getChainParams, verifyTxOutProof } from '@dogejs/node';

const chain = HeaderChain.open(getChainParams('testnet'), '/path/to/datadir');
const sync = new HeaderSync({ chain, maxPeers: 4 });
sync.on('progress', (p) => console.log(p.height, p.verifiedHeight));
await sync.start();
await sync.waitForSync();
const r = verifyTxOutProof(proofHex, chain, { rawTx, minConfirmations: 6 });
sync.stop();
chain.close();
NameWhat it does
HeaderChainThe stored header chain. HeaderChain.open(params, datadir).
HeaderSyncPeers, download and verification. Emits progress.
verifyTxOutProofCheck a transaction proof against a chain.
verifyHeaderChainCheck a list of headers, with no storage. In @dogejs/node/verify.
verifyMerkleBlockProofCheck that a transaction is under a header. In @dogejs/node/verify.
parseBlockHeader, headerHash, checkAuxPowProofOfWorkThe header checks, one at a time.

Every failure is a NodeError with a code. Header failures also carry Dogecoin Core's reject reason in reason.

Network parameters

NetworkHeightsRule
mainnet0 to 144,999Retarget every 240 blocks, with step limits.
mainnet145,000 to 371,336DigiShield every block, 60 second timespan.
mainnet371,337 and laterDigiShield, merged mining required.
testnet0 to 144,999As mainnet, plus minimum-difficulty blocks after a 2-minute gap.
testnet145,000 to 157,499DigiShield, no minimum-difficulty blocks.
testnet157,500 to 158,099DigiShield with minimum-difficulty blocks after a 2-minute gap.
testnet158,100 and laterAs above, merged mining required. Chain ID not strict.
regtest0 to 9, 10 to 19, 20 and laterBefore DigiShield, DigiShield, merged mining. Proof-of-work limit 2^255-1.

Headers are stored in <datadir>/<network>/headers.dat, 88 bytes per block. The last hard-coded checkpoints are at mainnet height 5,050,000 and testnet height 5,900,000.

Run examples

The first example uses real mainnet headers captured from Dogecoin Core (the three blocks around 371,336, where merged mining began). The transcript syncs against the fake regtest peer that ships in the repository, so no real network is involved.

Run: Verify real mainnet headers

JavaScript
// Real mainnet headers (captured from Dogecoin Core). Runs in Node; the same file works in a browser through @dogejs/node/verify.
import { verifyHeaderChain, parseHeaderLoose } from '@dogejs/node/verify';
import { readFileSync } from 'node:fs';

const blocks = JSON.parse(readFileSync('./test/fixtures/mainnet-blocks.json', 'utf8'));
const byHeight = new Map((Array.isArray(blocks) ? blocks : blocks.blocks).map((b) => [b.height, b]));

// 1. Three consecutive blocks around the first merged-mined (AuxPoW) block, 371335 to 371337.
const run = [371335, 371336, 371337].map((h) => byHeight.get(h).rawHeader);
const r = verifyHeaderChain(run, { network: 'mainnet', firstHeight: 371335 });
console.log('ok:', r.ok);
for (const h of r.headers) console.log(h.height, h.hash.slice(0, 16) + '...', 'pow:', h.pow, 'auxpow:', h.auxpow, 'difficulty rule:', h.difficultyRule);

// 2. Change one byte of the second header: the link to the first no longer matches, and the check says so.
const bad = [...run]; bad[1] = bad[1].slice(0, 20) + (bad[1][20] === 'a' ? 'b' : 'a') + bad[1].slice(21);
const rb = verifyHeaderChain(bad, { network: 'mainnet', firstHeight: 371335 });
console.log('tampered:', rb.ok, rb.ok ? '' : rb.code);

// 3. Only the 80 bytes of an AuxPoW block: its proof of work lives in the parent block, so it is reported as unchecked, never as passed.
const only80 = byHeight.get(371337).rawHeader.slice(0, 160);
const one = verifyHeaderChain([only80], { network: 'mainnet', firstHeight: 371337 });
console.log('80 bytes only:', parseHeaderLoose(only80).auxpow, '| pow:', one.headers[0].pow);
console.log('strict:', verifyHeaderChain([only80], { network: 'mainnet', firstHeight: 371337, allowMissingAuxPow: false }).code);
Output
ok: true
371335 8ad58fc406423207... pow: ok auxpow: absent difficulty rule: not-checked
371336 46a8b109fb016fa4... pow: ok auxpow: absent difficulty rule: not-checked
371337 60323982f9c5ff1b... pow: ok auxpow: present difficulty rule: ok
tampered: false linkage
80 bytes only: missing | pow: unchecked
strict: auxpow-missing

Run: Chain parameters

JavaScript
import { getChainParams, HeaderChain, getConsensus } from '@dogejs/node';
import { mkdtempSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';

for (const name of ['mainnet', 'testnet', 'regtest']) {
  const p = getChainParams(name);
  console.log(name.padEnd(8), 'port', p.defaultPort, '| genesis', p.genesis.hash.slice(0, 12) + '...', '| last checkpoint', p.checkpoints.at(-1)?.height ?? 'none');
}
const dir = mkdtempSync(join(tmpdir(), 'dogejs-node-'));
const chain = HeaderChain.open(getChainParams('mainnet'), dir);
console.log('empty store -> height', chain.height, 'tip', chain.tip.hashHex.slice(0, 12) + '...');
chain.close(); rmSync(dir, { recursive: true });
const mainnet = getChainParams('mainnet');
for (const h of [100_000, 200_000, 400_000]) {
  const e = getConsensus(mainnet, h);
  console.log('height', String(h).padStart(7), '->', e.digishield ? 'DigiShield' : 'retarget every ' + e.powTargetTimespan / e.powTargetSpacing + ' blocks', '| legacy (non-AuxPoW) blocks allowed:', e.allowLegacyBlocks);
}
Output
mainnet  port 22556 | genesis 1a91e3dace36... | last checkpoint 5050000
testnet  port 44556 | genesis bb0a78264637... | last checkpoint 5900000
regtest  port 18444 | genesis 3d2160a3b5dc... | last checkpoint 0
empty store -> height 0 tip 1a91e3dace36...
height  100000 -> retarget every 240 blocks | legacy (non-AuxPoW) blocks allowed: true
height  200000 -> DigiShield | legacy (non-AuxPoW) blocks allowed: true
height  400000 -> DigiShield | legacy (non-AuxPoW) blocks allowed: false

Run: the command line against the fake peer

Terminal
$ node examples/fake-peer.mjs 28445 300 &
FAKE regtest peer on 127.0.0.1:28445, height 300, tip 01d4e5d4656fc9d001ad01b1dc2c05de2116c2c16178b8efeba0cec911bb3f2e
$ dogejs-node sync --network regtest --peer 127.0.0.1:28445 --datadir ./data --exit-when-synced
peer 127.0.0.1:28445 connected (/FAKE-regtest-peer:0.1/, height 300)
height 300 verified 300 2041 headers/s peers 1
synced: 1 peer(s) agree on the tip
peer 127.0.0.1:28445 closed: sync stopped
network:         regtest
height:          300
tip:             01d4e5d4656fc9d001ad01b1dc2c05de2116c2c16178b8efeba0cec911bb3f2e
tip time:        2011-02-03T04:16:42.000Z
verified height: 300
chain work:      0x25a
minimum work:    reached
[exit 0]
$ dogejs-node status --network regtest --datadir ./data
network:         regtest
height:          300
tip:             01d4e5d4656fc9d001ad01b1dc2c05de2116c2c16178b8efeba0cec911bb3f2e
tip time:        2011-02-03T04:16:42.000Z
verified height: 300
chain work:      0x25a
minimum work:    reached
[exit 0]
$ dogejs-node verify-proof <proof hex> --network regtest --datadir ./data
VALID: 1 transaction(s) in block 9265170c72918f8f0efc299994cfba700dea5179b3273e9283274e7737e296e2
height 150, 151 confirmation(s) on this node's verified chain
  txid 0202020202020202020202020202020202020202020202020202020202020202
[exit 0]
$ dogejs-node verify-proof <proof cut short> --network regtest --datadir ./data
INVALID: Malformed proof: Unexpected end of data.
[exit 1]

AuxPoW in plain words

Since block 371,337 Dogecoin is merge-mined with Litecoin. A miner solves a Litecoin block whose coinbase contains a commitment to the Dogecoin block; that solved parent block is the proof of work. So an AuxPoW header carries a proof next to its 80 bytes: the parent block header, the path linking the coinbase to the parent, and the path linking the Dogecoin hash to the coinbase. The node checks all three. If only the 80 bytes are available, the header is reported unchecked and never as passed (see the strict flag in the reference).

Limits

  • It follows the most-work header chain and cannot see invalid transactions inside a block: the usual SPV assumption.
  • It refuses forks that start more than 2,000 blocks below the tip (Core accepts any fork above its last checkpoint).
  • The local clock is used where Core uses network-adjusted time.
  • Any invalid data disconnects and bans that peer for the session.
  • Out of scope: relaying transactions, mempool, full block download and validation, script validation, bloom filters, inbound connections, proxies.
  • Syncing needs Node.js (raw TCP); the verification entry @dogejs/node/verify also runs in browsers.

Complete API

Generated from the built type declarations of @dogejs/node 0.2.1 (262 exports).

index (main entry)179 exports
NameKindSignatureWhat it does
AcceptResultinterface{ added, duplicates, tipChanged, reorg?, error?, errorIndex?, last?, sideAdded }Result of adding a batch of headers to a HeaderChain: how many were new, whether the tip or a reorg happened, and the first failure (later headers of the batch were not looked at).
AddrEntryinterface{ time }An address from an `addr` message: a network address plus the time the sender last saw it (Unix seconds).
allowDigishieldMinDifficultyForBlockfunctionallowDigishieldMinDifficultyForBlock(last: IndexView, newBlockTime: number, era: ConsensusEra, params: ChainParams): boolean;AllowDigishieldMinDifficultyForBlock (dogecoin.cpp:26-39).
AncestorFntypeAncestorFn = (height: number) => IndexView;Ancestor access on the same branch as `last` (CBlockIndex::GetAncestor / pprev).
AuxPowinterface{ coinbaseTx, parentHash, merkleBranch, index, chainMerkleBranch, chainIndex, parentBlock }Merged-mining proof (CAuxPow): the parent block's coinbase transaction and the two merkle branches that tie it to this block.
AUXPOW_CHAIN_IDconstAUXPOW_CHAIN_ID = 98chainparams.cpp:120, 276, 417: `consensus.nAuxpowChainId = 0x0062; // 98 - Josh Wise!`
AuxPowAvailabilitytypeAuxPowAvailability = 'absent' | 'present' | 'missing';Whether a header's merged-mining proof was available: `absent` (not needed), `present`, or `missing` (flagged but only 80 bytes given, so its proof of work cannot be checked).
AuxPowCheckParamsinterface{ strictChainId }Parameters of the AuxPoW check: whether the chain id in the version must match the network's (`strictChainId`).
bigIntToHashfunctionbigIntToHash(n: bigint): Uint8Array;Inverse of hashToBigInt: 32 bytes little-endian.
BlockHeaderinterface{ auxpow? }A Dogecoin block header as sent on the wire: 80 bytes plus AuxPoW when the version flag is set.
blockProoffunctionblockProof(bits: number): bigint;GetBlockProof (chain.cpp:150-163): ~target / (target + 1) + 1, or 0 for an invalid target.
buildPartialMerkleTreefunctionbuildPartialMerkleTree(txids: readonly Uint8Array[], match: readonly boolean[]): PartialMerkleTree;Builds a tree the way gettxoutproof does (CPartialMerkleTree ctor + TraverseAndBuild, merkleblock.cpp:78-146).
ByteReaderclassclass: position, remaining, data, bytes(), slice(), u8(), u16(), u16be(), u32(), i32(), u64(), i64(), compactSize(), varBytes(), hashes(), end()Strict little-endian reader: every read is bounds-checked and fails with PARSE_ERROR.
bytesToHexfunctionbytesToHex(bytes: Uint8Array): string;Lowercase hex of `bytes`.
bytesToIpfunctionbytesToIp(b: Uint8Array): string;Formats the 16-byte network form of an address as dotted IPv4 (for ::ffff:a.b.c.d) or colon- separated IPv6 groups.
ByteWriterclassclass: bytes(), u8(), u16(), u16be(), u32(), i32(), u64(), i64(), compactSize(), varBytes(), hashes(), length, finish()Little-endian serializer.
calculateDogecoinNextWorkRequiredfunctioncalculateDogecoinNextWorkRequired(last: IndexView, firstBlockTime: number, era: ConsensusEra, powLimit: bigint): number;CalculateDogecoinNextWorkRequired (dogecoin.cpp:41-85). Note it never reads fPowNoRetargeting, unlike Bitcoin's CalculateNextWorkRequired.
calculateNextWorkRequiredfunctioncalculateNextWorkRequired(last: IndexView, firstBlockTime: number, era: ConsensusEra, powLimit: bigint): number;Bitcoin's CalculateNextWorkRequired (pow.cpp:90-113). Dogecoin consensus never calls it (GetNextWorkRequired uses the Dogecoin function); it is ported only so Core's pow_tests.cpp vectors can be run.
CHAIN_PARAMSconstCHAIN_PARAMS: Readonly<Record<NetworkName, ChainParams>>The parameters of every built-in network, by name. Frozen.
ChainEntryinterface{ height, hash, hashHex, header, chainWork, powVerified }A header in a HeaderChain with its height, hash, accumulated work and whether this node checked its proof of work.
ChainOptionsinterface{ trustCheckpoints?, now?, forkWindow?, maxSideHeaders? }Options for HeaderChain.memory and HeaderChain.open: trust-checkpoints mode, clock, fork window and side-chain limit.
ChainParamsinterface{ name, coreName, magic, defaultPort, dnsSeeds, powLimit, auxpowChainId, strictChainId, minimumChainWork, genesis, checkpoints, consensusRoot, eras, newDifficultyProtocolHeight, digishieldMinDifficultyHeight }Consensus and network parameters of one Dogecoin network: magic bytes, ports, DNS seeds, genesis block, checkpoints and difficulty eras.
ChainStatusinterface{ network, height, tipHash, tipTime, chainWork, verifiedHeight, trustCheckpoints, minimumChainWorkReached, lastCheckpointHeight, sideHeaders }Summary of a HeaderChain: network, height, tip, total work, how far verification reaches and whether the minimum chain work was reached.
checkAuxPowfunctioncheckAuxPow(auxpow: AuxPow, hashAuxBlock: Uint8Array, chainId: number, params: AuxPowCheckParams): void;Checks a merged-mining proof (AuxPoW) against the block it belongs to, step by step as Core does. Throws NodeError INVALID_HEADER on failure.
checkAuxPowProofOfWorkfunctioncheckAuxPowProofOfWork(block: BlockHeader, params: ChainParams, pow?: Uint8Array): void;CheckAuxPowProofOfWork (dogecoin.cpp:87-123). Throws NodeError INVALID_HEADER with reason "high-hash" and DoS 50, which is what CheckBlockHeader turns any failure here into (validation.cpp:2932-2933).
checkMerkleBranchfunctioncheckMerkleBranch(hash: Uint8Array, branch: readonly Uint8Array[], index: number): Uint8Array;Folds a merkle branch from a leaf hash and its index up to the root (the AuxPoW merkle check).
Checkpointinterface{ height, hash }A block hash that Dogecoin Core hard-codes for a height.
checkpointAtfunctioncheckpointAt(params: ChainParams, height: number): Uint8Array | undefined;Checkpoint hash at exactly `height`, if one exists (internal byte order).
checkProofOfWorkfunctioncheckProofOfWork(hash: Uint8Array, bits: number, powLimit: bigint): boolean;CheckProofOfWork (pow.cpp:115-132). `hash` in internal byte order.
CoinbaseInputinterface{ prevHash, prevIndex, scriptSig, sequence, witness }The input of a parent block's coinbase transaction, as stored in an AuxPoW.
CoinbaseOutputinterface{ value, script }An output of a parent block's coinbase transaction: value in koinu and script.
CompactResultinterface{ target, negative, overflow }Result of decoding a compact difficulty value (nBits): the 256-bit target and the negative and overflow flags.
compactToTargetfunctioncompactToTarget(compact: number): CompactResult;arith_uint256::SetCompact (arith_uint256.cpp:204-222).
ConsensusErainterface{ heightEffective, powTargetTimespan, powTargetSpacing, digishield, allowMinDifficultyBlocks, allowDigishieldMinDifficultyBlocks, powNoRetargeting, allowLegacyBlocks, bip65Height, bip66Height }One set of consensus parameters, valid from `heightEffective`. Core copies the whole Consensus::Params struct per era (chainparams.cpp:126-136, 282-300, 425-432); so does this file, field for field, for the fields that matter to header validation.
ConsensusNodeinterface{ era, left?, right? }A node of the binary tree of consensus eras that selects the rules in force at a height.
ContextOptionsinterface{ ancestor, medianTimePast, now, highestCheckpointOnChain }What a contextual header check needs to look back at the chain: ancestors by height, median time past and the clock.
contextualCheckBlockHeaderfunctioncontextualCheckBlockHeader(h: PureHeader, hash: Uint8Array, prev: IndexView, params: ChainParams, ctx: ContextOptions): void;ContextualCheckBlockHeader (validation.cpp:3065-3118) for a header at `prev.height + 1`, followed by the DogeJS exact-checkpoint rule. Throws NodeError INVALID_HEADER with Core's reject reason.
crc32functioncrc32(data: Uint8Array, start?: number, end?: number): number;CRC-32 (IEEE 802.3, as zlib).
decodeAddrfunctiondecodeAddr(payload: Uint8Array): AddrEntry[];addr payload with nTime (protocol.h CAddress, version >= CADDR_TIME_VERSION).
decodeGetHeadersfunctiondecodeGetHeaders(payload: Uint8Array): { version: number; locator: Uint8Array[]; hashStop: Uint8Array; };Decodes a `getheaders` payload: protocol version, block locator hashes and stop hash. Throws NodeError PARSE_ERROR on truncated data.
decodeHeadersfunctiondecodeHeaders(payload: Uint8Array): HeadersEntry[];Decodes a headers payload (net_processing.cpp:2397-2408). More than MAX_HEADERS_RESULTS headers is a protocol violation (Core: Misbehaving 20).
decodeInvfunctiondecodeInv(payload: Uint8Array): InvItem[];Decodes an `inv` payload into items. Throws NodeError PROTOCOL_ERROR for more than the allowed number of items and PARSE_ERROR for truncated data.
decodeNoncefunctiondecodeNonce(payload: Uint8Array): bigint;Decodes the 8-byte nonce of a `ping` or `pong` payload.
decodeVersionfunctiondecodeVersion(payload: Uint8Array): VersionMessage;Parses a version payload the way net_processing.cpp:1399-1437 reads it (later fields optional).
DEFAULT_BANSCORE_THRESHOLDconstDEFAULT_BANSCORE_THRESHOLD = 100validation.h:146 `DEFAULT_BANSCORE_THRESHOLD = 100;`
DEFAULT_CONNECT_TIMEOUTconstDEFAULT_CONNECT_TIMEOUT = 5000netbase.h:25 `DEFAULT_CONNECT_TIMEOUT = 5000;` ms
difficultyfunctiondifficulty(bits: number): number;Difficulty as Core's GetDifficulty prints it (rpc/blockchain.cpp:53-80), for display only.
electrumMerkleRootfunctionelectrumMerkleRoot(txid: string, merkle: readonly string[], pos: number): string;Computes the merkle root from a txid and an Electrum-style merkle branch (displayed hex). Throws NodeError INVALID_PROOF on a malformed branch.
encodeAddrfunctionencodeAddr(list: readonly AddrEntry[]): Uint8Array;Encodes an `addr` payload (with times) from a list of entries.
encodeGetHeadersfunctionencodeGetHeaders(locator: readonly Uint8Array[], hashStop?: Uint8Array, version?: number): Uint8Array;getheaders payload: CBlockLocator (int32 version + vector<uint256>, block.h:142-146) then hashStop.
encodeHeadersfunctionencodeHeaders(entries: readonly (BlockHeader | HeadersEntry)[]): Uint8Array;headers payload: CompactSize n, then n x (CBlockHeader incl. AuxPoW, CompactSize tx count).
encodeInvfunctionencodeInv(items: readonly InvItem[]): Uint8Array;Encodes an `inv` payload from a list of items.
encodeMessagefunctionencodeMessage(magic: Uint8Array, command: string, payload?: Uint8Array): Uint8Array;Builds one framed message.
encodeNoncefunctionencodeNonce(nonce: bigint): Uint8Array;Encodes a `ping` or `pong` nonce as 8 little-endian bytes.
encodeVersionfunctionencodeVersion(v: VersionMessage): Uint8Array;The fields PushNodeVersion sends (net_processing.cpp:285-286).
extractMatchesfunctionextractMatches(tree: PartialMerkleTree): ExtractResult;Reads a partial merkle tree: returns its merkle root and the transaction hashes it proves, or a null root if malformed.
ExtractResultinterface{ root, matches, indexes }Result of reading a partial merkle tree: the merkle root (null if the tree is malformed) and the matched transaction hashes.
genesisHeaderfunctiongenesisHeader(params: ChainParams): PureHeader;The genesis header of `params` (chainparams.cpp CreateGenesisBlock fields).
GenesisHeaderinterface{ version, merkleRoot, time, bits, nonce, hash }The fields of a network's genesis block header, as Core's chainparams.cpp states them.
getBaseVersionfunctiongetBaseVersion(version: number): number;pureheader.h:92-95 `return ver % VERSION_AUXPOW;` (C++ remainder: sign follows the dividend, like JS %).
getChainIdfunctiongetChainId(version: number): number;pureheader.h:110-113 `return nVersion >> 16;` (arithmetic shift of an int32).
getChainParamsfunctiongetChainParams(name: NetworkName): ChainParams;Returns the parameters of a built-in network by name. Throws an Error for an unknown name.
getConsensusfunctiongetConsensus(params: ChainParams, height: number): ConsensusEra;Returns the consensus era (rules and parameters) in force at `height`.
getExpectedIndexfunctiongetExpectedIndex(nonce: number, chainId: number, h: number): number;Expected position of a merge-mined block in the chain merkle tree, from the nonce, chain id and tree height.
getNextWorkRequiredfunctiongetNextWorkRequired(last: IndexView | null, newBlockTime: number, era: ConsensusEra, params: ChainParams, ancestor: AncestorFn): number;GetNextWorkRequired (pow.cpp:32-88), ported line by line.
hashHexToBigIntfunctionhashHexToBigInt(hex: string): bigint;Integer value of a displayed hash (for comparisons with targets).
hashToBigIntfunctionhashToBigInt(hash: Uint8Array): bigint;Reads a 32-byte hash (little-endian, internal order) as a number.
hashToHexfunctionhashToHex(hash: Uint8Array): string;Displayed (RPC / explorer) hex of a 32-byte hash stored in internal (wire) order.
HEADER_SIZEconstHEADER_SIZE = 80Size in bytes of a block header without AuxPoW (80).
HeaderChainclassclass: params, lastOpen, memory(), open(), close(), tip, height, hashAt(), headerAt(), findMainHeight(), knows(), isInvalid(), verifiedHeight, minimumChainWorkReached, status(), locator(), locatorFrom(), medianTimePast(), acceptHeaders(), sideHeadersA verified chain of block headers, in memory (HeaderChain.memory) or persisted in a directory (HeaderChain.open). Accepts headers in batches, applies Dogecoin's consensus header rules for every era (proof of work, difficulty, timestamps, checkpoints, AuxPoW) and follows the chain with the most work.
headerHashfunctionheaderHash(h: PureHeader | Uint8Array): Uint8Array;Block hash: SHA256d of the 80 bytes (pureheader.cpp:20-23 SerializeHash). Internal byte order.
headerHashHexfunctionheaderHashHex(h: PureHeader | Uint8Array): string;Displayed (RPC) block hash.
HeadersEntryinterface{ header, txCount }One entry of a `headers` message: the header and the transaction count that follows it on the wire.
HeaderStoreclassclass: dir, count, open(), read(), readRange(), candidates(), append(), truncate(), writeState(), close()The on-disk file that persists a HeaderChain: fixed-size records, checksummed, recovered after a crash. Normally used through HeaderChain.open.
HeaderSyncclassclass: chain, banned, synced, start(), stop(), waitForSync(), progress(), headersReceivedDownloads headers from peers into a HeaderChain and cross-checks the tip with other peers. Emits `progress`, `synced`, `reorg`, `peer-connected`, `peer-closed` and `error`. Needs network access to Dogecoin peers.
hexToBytesfunctionhexToBytes(input: string, name?: string): Uint8Array;Strict hex: even length, hex digits only, no prefix or whitespace.
hexToHashfunctionhexToHash(hex: string, name?: string): Uint8Array;Internal (wire) order bytes of a displayed 64-hex-char hash.
IndexViewinterface{ height, time, bits }Minimal view of a CBlockIndex used by the difficulty rules.
InvIteminterface{ type, hash }An inventory item of an `inv` message: its type number and 32-byte hash.
ipToBytesfunctionipToBytes(ip: string): Uint8Array;IPv4 / IPv6 text to the 16-byte form.
isAuxpowVersionfunctionisAuxpowVersion(version: number): boolean;pureheader.h:129-132 `return nVersion & VERSION_AUXPOW;`
isLegacyVersionfunctionisLegacyVersion(version: number): boolean;pureheader.h:150-155: version 1, or version 2 with chain ID 0 ("Dogecoin: We have a random v2 block with no AuxPoW, treat as legacy"). Note `nVersion == 2` already implies chain ID 0; the extra test is kept as in Core.
lastCheckpointfunctionlastCheckpoint(params: ChainParams): Checkpoint;Highest checkpoint (Core: the last entry of mapCheckpoints).
LightFailureCodetypeLightFailureCode = /** Bytes could not be parsed. */ 'malformed' /** A header does not commit to the previous header's hash. */ | 'linkage' /** nBits is not a valid target, or it is easier than the network's powLimit. */ | 'bad-target' /** The scrypt hash (or the AuxPoW parent's) is above the target, or the AuxPoW proof is invalid. */ | 'pow' /** The header's target is easier than the caller's ...Why verifyHeaderChain rejected a list of headers: malformed, linkage, bad-target, pow, below-floor, checkpoint, anchor, difficulty-rule, auxpow-missing or bad-input.
LightHeaderReportinterface{ index, height?, hash, prevHash, merkleRoot, time, bits, version, auxpow, pow, work, difficultyRule, checkpoint? }What verifyHeaderChain found out about one header: its index and hash and whether its proof of work was verified.
LooseHeaderinterface{ header, pure, auxpow, hash }A header parsed on its own: the header, its 80 hashed bytes, its hash and whether its AuxPoW is present.
mainnetParamsconstmainnetParams: ChainParamsParameters of the Dogecoin main network. Frozen.
makeTransactionfunctionmakeTransaction(fields: Pick<ParsedTransaction, 'version' | 'inputs' | 'outputs' | 'locktime'>): ParsedTransaction;Builds a ParsedTransaction from fields (canonical bytes as `raw`). Used to construct test parent coinbases.
makeVersionfunctionmakeVersion(baseVersion: number, chainId: number, auxpow?: boolean): number;pureheader.cpp:13-18 SetBaseVersion (without the asserts it throws).
MAX_ADDR_TO_SENDconstMAX_ADDR_TO_SEND = 1000net.h:57 `MAX_ADDR_TO_SEND = 1000;` (also the addr receive limit, net_processing.cpp:1600)
MAX_BLOCKS_TO_ANNOUNCEconstMAX_BLOCKS_TO_ANNOUNCE = 8validation.h:154 `MAX_BLOCKS_TO_ANNOUNCE = 8;`
MAX_CHAIN_MERKLE_BRANCHconstMAX_CHAIN_MERKLE_BRANCH = 30auxpow.cpp:90 `if (vChainMerkleBranch.size() > 30)`
MAX_FUTURE_BLOCK_TIMEconstMAX_FUTURE_BLOCK_TIME: numbervalidation.cpp:3106 `nAdjustedTime + 2 * 60 * 60`
MAX_HEADERS_RESULTSconstMAX_HEADERS_RESULTS = 2000validation.h:100 `MAX_HEADERS_RESULTS = 2000;`
MAX_INV_SZconstMAX_INV_SZ = 50000net.h:53 `MAX_INV_SZ = 50000;`
MAX_LIGHT_HEADERSconstMAX_LIGHT_HEADERS = 2000Default cap on the number of headers verifyHeaderChain accepts in one call.
MAX_LOCATOR_SZconstMAX_LOCATOR_SZ = 101net.h:55 `MAX_LOCATOR_SZ = 101;`
MAX_PMT_TRANSACTIONSconstMAX_PMT_TRANSACTIONS: numberconsensus/consensus.h:17 `MAX_BLOCK_BASE_SIZE = 1000000`; merkleblock.cpp:156 divides by 60.
MAX_PROTOCOL_MESSAGE_LENGTHconstMAX_PROTOCOL_MESSAGE_LENGTH: numbernet.h:59 `MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1000 * 1000;`
MAX_SIZEconstMAX_SIZE = 33554432Largest size accepted for a CompactSize value or message payload, in bytes (0x02000000).
MAX_SUBVERSION_LENGTHconstMAX_SUBVERSION_LENGTH = 256net.h:61 `MAX_SUBVERSION_LENGTH = 256;`
MAX_UNCONNECTING_HEADERSconstMAX_UNCONNECTING_HEADERS = 10validation.h:157 `MAX_UNCONNECTING_HEADERS = 10;`
MEDIAN_TIME_SPANconstMEDIAN_TIME_SPAN = 11chain.h:284 `enum { nMedianTimeSpan=11 };`
MERGED_MINING_HEADERconstMERGED_MINING_HEADER: Uint8Array<ArrayBuffer>auxpow.h:24 `pchMergedMiningHeader[] = { 0xfa, 0xbe, 'm', 'm' };`
MerkleBlockinterface{ header, tree }A parsed `merkleblock` (the format of Core's `gettxoutproof`): a header and a partial merkle tree.
MerkleBlockProofResultinterface{ header, headerBytes, index, nTransactions }Result of verifyMerkleBlockProof: the header as it came in the proof, its bytes, and the position of the transaction.
merkleBranchfunctionmerkleBranch(leaves: readonly Uint8Array[], index: number): Uint8Array[];Merkle branch for leaf `index` (merkle_tests.cpp:42-54 BlockGetMerkleBranch).
merkleRootfunctionmerkleRoot(leaves: readonly Uint8Array[]): { root: Uint8Array; mutated: boolean; };Merkle root of `leaves` (internal byte order). Empty list gives 32 zero bytes, as Core.
MESSAGE_HEADER_SIZEconstMESSAGE_HEADER_SIZE = 24protocol.h:32-39
MessageDecoderclassclass: pending, push()Incremental frame decoder. `push` returns complete messages and throws NodeError('PROTOCOL_ERROR') on anything Core would reject or this node bans.
MIN_PEER_PROTO_VERSIONconstMIN_PEER_PROTO_VERSION = 70003version.h:23 `static const int MIN_PEER_PROTO_VERSION = 70003;`
MSG_BLOCKconstMSG_BLOCK = 2protocol.h:334
MSG_TXconstMSG_TX = 1protocol.h:333
NetAddressinterface{ services, ip, port }A peer network address: service bits, the 16-byte IP and the port.
NODE_BLOOMconstNODE_BLOOM: numberprotocol.h:269
NODE_NETWORKconstNODE_NETWORK = 1protocol.h:261
NodeErrorclassclass: code, reason, dosError thrown by every `@dogejs/node` function. Parsers never throw anything else on malformed input (this is checked by seeded fuzz tests).
NodeErrorCodetypeNodeErrorCode = /** Bytes could not be parsed (truncated, non-canonical, trailing data, out of range). */ 'PARSE_ERROR' /** A caller passed a bad argument. */ | 'INVALID_ARGUMENT' /** A block header broke a consensus rule. `reason` holds Dogecoin Core's reject reason. */ | 'INVALID_HEADER' /** A merkle / txout proof did not verify. */ | 'INVALID_PROOF' /** A peer broke the P2P protocol (framing...Machine-readable reason codes for NodeError.
OpenResultinterface{ store, recovery, dropped, state }Result of opening a HeaderStore: the store, how it was brought back to a consistent state, how many records were dropped and the cached state if valid.
parentBlockHashHexfunctionparentBlockHashHex(a: AuxPow): string;Convenience: displayed hash of the parent block (its sha256d, not its PoW hash).
parseBlockHeaderfunctionparseBlockHeader(bytes: Uint8Array): BlockHeader;Parses one full header (80 bytes + optional AuxPoW), no trailing bytes allowed.
ParsedTransactioninterface{ version, inputs, outputs, locktime, raw, txid }A parent coinbase transaction as parsed inside an AuxPoW, with its raw bytes.
parseHeaderLoosefunctionparseHeaderLoose(input: Uint8Array | string): LooseHeader;Parses a block header with or without its AuxPoW. Throws NodeError PARSE_ERROR on anything else.
parseMerkleBlockfunctionparseMerkleBlock(input: Uint8Array | string): MerkleBlock;Parses a `merkleblock` (bytes or hex). Throws NodeError on malformed data.
parsePureHeaderfunctionparsePureHeader(bytes: Uint8Array): PureHeader;Parses exactly 80 bytes.
parseTransactionfunctionparseTransaction(bytes: Uint8Array): ParsedTransaction;Parses exactly one transaction (no trailing bytes).
PartialMerkleTreeinterface{ nTransactions, hashes, flags, bitCount }A partial merkle tree (CPartialMerkleTree): the number of transactions, the hashes and the flag bits.
Peerclassclass: host, port, params, id, ready, remoteVersion, closed, connect(), send(), sendGetHeaders(), close()One outbound connection. Emits 'ready' after version/verack, then 'headers', 'inv', 'addr' and 'message'; 'close' exactly once with the reason and whether the peer should be banned for the session.
PeerAddressinterface{ host, port }Host and port of a peer to connect to.
PeerCloseReasontypePeerCloseReason = { readonly message: string; readonly ban: boolean; };Why a peer connection was closed and whether the peer should be banned.
PeerEventsinterface{ ready, headers, inv, addr, message, close }Events a Peer emits and their payloads: `ready`, `headers`, `inv`, `addr`, `message` and `close`.
PeerInfointerface{ id, ready, userAgent, startHeight, bestKnownHeight, agrees, score }What HeaderSync knows about a connected peer: user agent, start and best known height, agreement with our tip and misbehaviour score.
PeerOptionsinterface{ host, port, params, startHeight?, userAgent?, connectTimeoutMs?, handshakeTimeoutMs?, messageTimeoutMs?, idleTimeoutMs?, pingIntervalMs?, maxMessageSize?, socketFactory? }Options for a Peer: host, port, network parameters, our height and timeouts.
PING_INTERVALconstPING_INTERVAL: numbernet.h:47 `PING_INTERVAL = 2 * 60;` seconds
powHashfunctionpowHash(h: PureHeader | Uint8Array): Uint8Array;Proof-of-work hash: scrypt with N=1024, r=1, p=1, 32-byte output, the 80-byte header as both password and salt. Core: pureheader.cpp:25-30 calls scrypt_1024_1_1_256(BEGIN(nVersion), ...); crypto/scrypt.cpp:187-218 runs PBKDF2_SHA256(input, 80, input, 80, 1, B, 128), 1024 rounds of the Salsa20/8 ROMix, then PBKDF2_SHA256(input, 80, B, 128, 1, output, 32), which is standard scrypt(N=1024, r=1, p=1, dkLen=32). Computed with node:crypto (OpenSSL); the tests cross-check it against `@noble/hashes` scrypt and Core's vectors.
powHashAsyncfunctionpowHashAsync(bytes: Uint8Array): Promise<Uint8Array>;Same as powHash on the libuv thread pool, so many headers hash in parallel.
powPreimagefunctionpowPreimage(block: BlockHeader): Uint8Array;The 80 bytes whose scrypt hash must meet the target: the block itself, or its AuxPoW parent.
ProofResultinterface{ txids, indexes, blockHash, height, confirmations, merkleRoot }Result of verifyTxOutProof: the transaction ids proven to be in a block, their positions and the block hash.
PROTOCOL_VERSIONconstPROTOCOL_VERSION = 70015version.h:14 `static const int PROTOCOL_VERSION = 70015;`
PureHeaderinterface{ version, prevHash, merkleRoot, time, bits, nonce }The 80-byte part of a block header: version, previous hash, merkle root, time, bits and nonce.
RawMessageinterface{ command, payload }A framed peer-to-peer message: the command name and its payload.
readAuxPowfunctionreadAuxPow(r: ByteReader): AuxPow;Reads an AuxPoW from a ByteReader. Throws NodeError on malformed data.
readBlockHeaderfunctionreadBlockHeader(r: ByteReader): BlockHeader;Reads a block header (80 bytes, plus the AuxPoW when the version flags one) from a ByteReader.
readPartialMerkleTreefunctionreadPartialMerkleTree(r: ByteReader): PartialMerkleTree;Reads a partial merkle tree from a ByteReader.
readPureHeaderfunctionreadPureHeader(r: ByteReader): PureHeader;Reads the 80-byte header part from a ByteReader.
readTransactionfunctionreadTransaction(r: ByteReader): ParsedTransaction;Reads one transaction at the reader's position (witness allowed, as Core does on P2P streams).
RECORD_SIZEconstRECORD_SIZE = 88Size in bytes of one record in the header store file (88).
regtestParamsconstregtestParams: ChainParamsParameters of the Dogecoin regression-test network. Frozen.
SENDHEADERS_VERSIONconstSENDHEADERS_VERSION = 70012version.h:39 `static const int SENDHEADERS_VERSION = 70012;`
serializeAuxPowfunctionserializeAuxPow(a: AuxPow): Uint8Array;Serialises an AuxPoW.
serializeBlockHeaderfunctionserializeBlockHeader(h: BlockHeader): Uint8Array;Serialises a block header: 80 bytes, followed by the AuxPoW when the version flags one.
serializeMerkleBlockfunctionserializeMerkleBlock(mb: MerkleBlock): Uint8Array;Serialises a `merkleblock`.
serializePureHeaderfunctionserializePureHeader(h: PureHeader): Uint8Array;Serialises the 80-byte header part.
serializeTransactionfunctionserializeTransaction(tx: Pick<ParsedTransaction, 'version' | 'inputs' | 'outputs' | 'locktime'>, withWitness?: boolean): Uint8Array;Serialises a transaction canonically; the witness form is used only if asked and some input has a witness.
sha256dfunctionsha256d(data: Uint8Array): Uint8Array;Double SHA-256, Core's Hash() (src/hash.h).
StoredRecordinterface{ header, flags }One record of the header store: the 80-byte header and its flags.
StoreStateinterface{ count, firstUnverified?, tipHash, chainWork }Cached summary of a header store: record count, the lowest header whose proof of work was not checked (trust mode), tip hash and chain work.
SyncEventsinterface{ progress, synced, reorg, 'peer-connected', 'peer-closed', error }Events a HeaderSync emits and their payloads.
SyncOptionsinterface{ chain, peers?, maxPeers?, minAgreeing?, requestTimeoutMs?, maxSideHeadersPerPeer?, peerOptions?, resolve? }Options for HeaderSync: the chain to fill, explicit peers (no DNS), connection count, peers that must agree and timeouts.
SyncProgressinterface{ height, tipHash, verifiedHeight, headersPerSecond, peers, synced }Sync progress: height, tip, verified height, speed, connected peers and whether the chain is synced.
targetOffunctiontargetOf(bits: number): bigint | undefined;The target (as an integer) of a compact nBits, or undefined if invalid.
targetToCompactfunctiontargetToCompact(target: bigint, negative?: boolean): number;arith_uint256::GetCompact (arith_uint256.cpp:224-245).
testnetParamsconsttestnetParams: ChainParamsParameters of the Dogecoin test network. Frozen.
TIMEOUT_INTERVALconstTIMEOUT_INTERVAL: numbernet.h:49 `TIMEOUT_INTERVAL = 20 * 60;` seconds
USER_AGENTconstUSER_AGENT = "/dogejs-node:0.1.0/"The user agent string sent to peers in the `version` message.
verifyHeaderChainfunctionverifyHeaderChain(headers: readonly (Uint8Array | string)[], opts: VerifyHeaderChainOptions): VerifyHeaderChainResult;Verifies a short run of consecutive headers without the rest of the chain: linkage, proof of work, difficulty and checkpoints. Returns a result; does not throw for bad headers.
VerifyHeaderChainOptionsinterface{ network, firstHeight?, anchor?, maxTarget?, allowMissingAuxPow?, knownValid?, checkDifficulty?, maxHeaders?, powHash? }Options for verifyHeaderChain: the network, the claimed first height, an optional trusted anchor, a target floor and limits.
VerifyHeaderChainResulttypeVerifyHeaderChainResult = { readonly ok: true; readonly headers: readonly LightHeaderReport[]; /** Sum of GetBlockProof over the headers. */ readonly totalWork: bigint; /** Headers whose proof of work verified (now or `known`). */ readonly powVerified: number; /** Headers whose proof of work could not be checked (AuxPoW missing). */ readonly powUnchecked: number; readonly checkpoints: readonly ...Result of verifyHeaderChain: `ok: true` with per-header reports and totals, or `ok: false` with a failure code, a reason and the index of the offending header. It does not throw for invalid headers.
verifyMerkleBlockProoffunctionverifyMerkleBlockProof(proof: Uint8Array | string, txid: string): MerkleBlockProofResult;Checks that a `merkleblock` proof (Core's `gettxoutproof`) commits to a txid under its header. Throws NodeError INVALID_PROOF otherwise.
VerifyProofOptionsinterface{ rawTx?, requireVerified?, minConfirmations? }Options for verifyTxOutProof: optionally the raw transaction that must be among the proven ones.
verifyTxOutProoffunctionverifyTxOutProof(proof: Uint8Array | string, chain: HeaderChain, opts?: VerifyProofOptions): ProofResult;Checks a `gettxoutproof` result against the headers of a synced chain and reports the proven txids and confirmations.
VERSION_AUXPOWconstVERSION_AUXPOW: numberpureheader.h:23 `static const int32_t VERSION_AUXPOW = (1 << 8);`
VERSION_CHAIN_STARTconstVERSION_CHAIN_START: numberpureheader.h:26 `static const int32_t VERSION_CHAIN_START = (1 << 16);`
VersionMessageinterface{ version, services, time, addrRecv, addrFrom, nonce, userAgent, startHeight, relay }The `version` message of the peer handshake: protocol version, services, time, addresses, nonce, user agent and start height.
workForBitsfunctionworkForBits(bits: number): bigint;Expected scrypt hashes for one header at this nBits (GetBlockProof). Re-exported for clarity.
writeAuxPowfunctionwriteAuxPow(w: ByteWriter, a: AuxPow): ByteWriter;Writes an AuxPoW to a ByteWriter and returns it.
writeBlockHeaderfunctionwriteBlockHeader(w: ByteWriter, h: BlockHeader): ByteWriter;Writes a block header (with its AuxPoW when the version flags one) to a ByteWriter. Throws NodeError INVALID_ARGUMENT if the AuxPoW is missing.
writePartialMerkleTreefunctionwritePartialMerkleTree(w: ByteWriter, t: PartialMerkleTree): ByteWriter;Writes a partial merkle tree to a ByteWriter.
writePureHeaderfunctionwritePureHeader(w: ByteWriter, h: PureHeader): ByteWriter;Writes the 80-byte header part to a ByteWriter. Throws NodeError INVALID_ARGUMENT unless both hashes are 32 bytes.
verify (browser-safe entry)83 exports
NameKindSignatureWhat it does
allowDigishieldMinDifficultyForBlockfunctionallowDigishieldMinDifficultyForBlock(last: IndexView, newBlockTime: number, era: ConsensusEra, params: ChainParams): boolean;AllowDigishieldMinDifficultyForBlock (dogecoin.cpp:26-39).
AuxPowinterface{ coinbaseTx, parentHash, merkleBranch, index, chainMerkleBranch, chainIndex, parentBlock }Merged-mining proof (CAuxPow): the parent block's coinbase transaction and the two merkle branches that tie it to this block.
AUXPOW_CHAIN_IDconstAUXPOW_CHAIN_ID = 98chainparams.cpp:120, 276, 417: `consensus.nAuxpowChainId = 0x0062; // 98 - Josh Wise!`
AuxPowAvailabilitytypeAuxPowAvailability = 'absent' | 'present' | 'missing';Whether a header's merged-mining proof was available: `absent` (not needed), `present`, or `missing` (flagged but only 80 bytes given, so its proof of work cannot be checked).
bigIntToHashfunctionbigIntToHash(n: bigint): Uint8Array;Inverse of hashToBigInt: 32 bytes little-endian.
BlockHeaderinterface{ auxpow? }A Dogecoin block header as sent on the wire: 80 bytes plus AuxPoW when the version flag is set.
blockProoffunctionblockProof(bits: number): bigint;GetBlockProof (chain.cpp:150-163): ~target / (target + 1) + 1, or 0 for an invalid target.
buildPartialMerkleTreefunctionbuildPartialMerkleTree(txids: readonly Uint8Array[], match: readonly boolean[]): PartialMerkleTree;Builds a tree the way gettxoutproof does (CPartialMerkleTree ctor + TraverseAndBuild, merkleblock.cpp:78-146).
bytesToHexfunctionbytesToHex(bytes: Uint8Array): string;Lowercase hex of `bytes`.
calculateDogecoinNextWorkRequiredfunctioncalculateDogecoinNextWorkRequired(last: IndexView, firstBlockTime: number, era: ConsensusEra, powLimit: bigint): number;CalculateDogecoinNextWorkRequired (dogecoin.cpp:41-85). Note it never reads fPowNoRetargeting, unlike Bitcoin's CalculateNextWorkRequired.
CHAIN_PARAMSconstCHAIN_PARAMS: Readonly<Record<NetworkName, ChainParams>>The parameters of every built-in network, by name. Frozen.
ChainParamsinterface{ name, coreName, magic, defaultPort, dnsSeeds, powLimit, auxpowChainId, strictChainId, minimumChainWork, genesis, checkpoints, consensusRoot, eras, newDifficultyProtocolHeight, digishieldMinDifficultyHeight }Consensus and network parameters of one Dogecoin network: magic bytes, ports, DNS seeds, genesis block, checkpoints and difficulty eras.
checkAuxPowfunctioncheckAuxPow(auxpow: AuxPow, hashAuxBlock: Uint8Array, chainId: number, params: AuxPowCheckParams): void;Checks a merged-mining proof (AuxPoW) against the block it belongs to, step by step as Core does. Throws NodeError INVALID_HEADER on failure.
checkAuxPowProofOfWorkfunctioncheckAuxPowProofOfWork(block: BlockHeader, params: ChainParams, pow?: Uint8Array): void;CheckAuxPowProofOfWork (dogecoin.cpp:87-123). Throws NodeError INVALID_HEADER with reason "high-hash" and DoS 50, which is what CheckBlockHeader turns any failure here into (validation.cpp:2932-2933).
checkMerkleBranchfunctioncheckMerkleBranch(hash: Uint8Array, branch: readonly Uint8Array[], index: number): Uint8Array;Folds a merkle branch from a leaf hash and its index up to the root (the AuxPoW merkle check).
Checkpointinterface{ height, hash }A block hash that Dogecoin Core hard-codes for a height.
checkpointAtfunctioncheckpointAt(params: ChainParams, height: number): Uint8Array | undefined;Checkpoint hash at exactly `height`, if one exists (internal byte order).
checkProofOfWorkfunctioncheckProofOfWork(hash: Uint8Array, bits: number, powLimit: bigint): boolean;CheckProofOfWork (pow.cpp:115-132). `hash` in internal byte order.
CompactResultinterface{ target, negative, overflow }Result of decoding a compact difficulty value (nBits): the 256-bit target and the negative and overflow flags.
compactToTargetfunctioncompactToTarget(compact: number): CompactResult;arith_uint256::SetCompact (arith_uint256.cpp:204-222).
ConsensusErainterface{ heightEffective, powTargetTimespan, powTargetSpacing, digishield, allowMinDifficultyBlocks, allowDigishieldMinDifficultyBlocks, powNoRetargeting, allowLegacyBlocks, bip65Height, bip66Height }One set of consensus parameters, valid from `heightEffective`. Core copies the whole Consensus::Params struct per era (chainparams.cpp:126-136, 282-300, 425-432); so does this file, field for field, for the fields that matter to header validation.
difficultyfunctiondifficulty(bits: number): number;Difficulty as Core's GetDifficulty prints it (rpc/blockchain.cpp:53-80), for display only.
electrumMerkleRootfunctionelectrumMerkleRoot(txid: string, merkle: readonly string[], pos: number): string;Computes the merkle root from a txid and an Electrum-style merkle branch (displayed hex). Throws NodeError INVALID_PROOF on a malformed branch.
extractMatchesfunctionextractMatches(tree: PartialMerkleTree): ExtractResult;Reads a partial merkle tree: returns its merkle root and the transaction hashes it proves, or a null root if malformed.
ExtractResultinterface{ root, matches, indexes }Result of reading a partial merkle tree: the merkle root (null if the tree is malformed) and the matched transaction hashes.
getBaseVersionfunctiongetBaseVersion(version: number): number;pureheader.h:92-95 `return ver % VERSION_AUXPOW;` (C++ remainder: sign follows the dividend, like JS %).
getChainIdfunctiongetChainId(version: number): number;pureheader.h:110-113 `return nVersion >> 16;` (arithmetic shift of an int32).
getChainParamsfunctiongetChainParams(name: NetworkName): ChainParams;Returns the parameters of a built-in network by name. Throws an Error for an unknown name.
getConsensusfunctiongetConsensus(params: ChainParams, height: number): ConsensusEra;Returns the consensus era (rules and parameters) in force at `height`.
getExpectedIndexfunctiongetExpectedIndex(nonce: number, chainId: number, h: number): number;Expected position of a merge-mined block in the chain merkle tree, from the nonce, chain id and tree height.
getNextWorkRequiredfunctiongetNextWorkRequired(last: IndexView | null, newBlockTime: number, era: ConsensusEra, params: ChainParams, ancestor: AncestorFn): number;GetNextWorkRequired (pow.cpp:32-88), ported line by line.
hashHexToBigIntfunctionhashHexToBigInt(hex: string): bigint;Integer value of a displayed hash (for comparisons with targets).
hashPairfunctionhashPair(a: Uint8Array, b: Uint8Array): Uint8Array;sha256d(a || b) without an intermediate concat (merkle nodes).
hashToBigIntfunctionhashToBigInt(hash: Uint8Array): bigint;Reads a 32-byte hash (little-endian, internal order) as a number.
hashToHexfunctionhashToHex(hash: Uint8Array): string;Displayed (RPC / explorer) hex of a 32-byte hash stored in internal (wire) order.
HEADER_SIZEconstHEADER_SIZE = 80Size in bytes of a block header without AuxPoW (80).
headerHashfunctionheaderHash(h: PureHeader | Uint8Array): Uint8Array;Block hash: SHA256d of the 80 bytes (pureheader.cpp:20-23 SerializeHash). Internal byte order.
headerHashHexfunctionheaderHashHex(h: PureHeader | Uint8Array): string;Displayed (RPC) block hash.
hexToBytesfunctionhexToBytes(input: string, name?: string): Uint8Array;Strict hex: even length, hex digits only, no prefix or whitespace.
hexToHashfunctionhexToHash(hex: string, name?: string): Uint8Array;Internal (wire) order bytes of a displayed 64-hex-char hash.
IndexViewinterface{ height, time, bits }Minimal view of a CBlockIndex used by the difficulty rules.
isAuxpowVersionfunctionisAuxpowVersion(version: number): boolean;pureheader.h:129-132 `return nVersion & VERSION_AUXPOW;`
isLegacyVersionfunctionisLegacyVersion(version: number): boolean;pureheader.h:150-155: version 1, or version 2 with chain ID 0 ("Dogecoin: We have a random v2 block with no AuxPoW, treat as legacy"). Note `nVersion == 2` already implies chain ID 0; the extra test is kept as in Core.
lastCheckpointfunctionlastCheckpoint(params: ChainParams): Checkpoint;Highest checkpoint (Core: the last entry of mapCheckpoints).
LightFailureCodetypeLightFailureCode = /** Bytes could not be parsed. */ 'malformed' /** A header does not commit to the previous header's hash. */ | 'linkage' /** nBits is not a valid target, or it is easier than the network's powLimit. */ | 'bad-target' /** The scrypt hash (or the AuxPoW parent's) is above the target, or the AuxPoW proof is invalid. */ | 'pow' /** The header's target is easier than the caller's ...Why verifyHeaderChain rejected a list of headers: malformed, linkage, bad-target, pow, below-floor, checkpoint, anchor, difficulty-rule, auxpow-missing or bad-input.
LightHeaderReportinterface{ index, height?, hash, prevHash, merkleRoot, time, bits, version, auxpow, pow, work, difficultyRule, checkpoint? }What verifyHeaderChain found out about one header: its index and hash and whether its proof of work was verified.
LooseHeaderinterface{ header, pure, auxpow, hash }A header parsed on its own: the header, its 80 hashed bytes, its hash and whether its AuxPoW is present.
mainnetParamsconstmainnetParams: ChainParamsParameters of the Dogecoin main network. Frozen.
makeVersionfunctionmakeVersion(baseVersion: number, chainId: number, auxpow?: boolean): number;pureheader.cpp:13-18 SetBaseVersion (without the asserts it throws).
MAX_CHAIN_MERKLE_BRANCHconstMAX_CHAIN_MERKLE_BRANCH = 30auxpow.cpp:90 `if (vChainMerkleBranch.size() > 30)`
MAX_LIGHT_HEADERSconstMAX_LIGHT_HEADERS = 2000Default cap on the number of headers verifyHeaderChain accepts in one call.
MAX_PMT_TRANSACTIONSconstMAX_PMT_TRANSACTIONS: numberconsensus/consensus.h:17 `MAX_BLOCK_BASE_SIZE = 1000000`; merkleblock.cpp:156 divides by 60.
MERGED_MINING_HEADERconstMERGED_MINING_HEADER: Uint8Array<ArrayBuffer>auxpow.h:24 `pchMergedMiningHeader[] = { 0xfa, 0xbe, 'm', 'm' };`
MerkleBlockinterface{ header, tree }A parsed `merkleblock` (the format of Core's `gettxoutproof`): a header and a partial merkle tree.
MerkleBlockProofResultinterface{ header, headerBytes, index, nTransactions }Result of verifyMerkleBlockProof: the header as it came in the proof, its bytes, and the position of the transaction.
merkleBranchfunctionmerkleBranch(leaves: readonly Uint8Array[], index: number): Uint8Array[];Merkle branch for leaf `index` (merkle_tests.cpp:42-54 BlockGetMerkleBranch).
merkleRootfunctionmerkleRoot(leaves: readonly Uint8Array[]): { root: Uint8Array; mutated: boolean; };Merkle root of `leaves` (internal byte order). Empty list gives 32 zero bytes, as Core.
NodeErrorclassclass: code, reason, dosError thrown by every `@dogejs/node` function. Parsers never throw anything else on malformed input (this is checked by seeded fuzz tests).
NodeErrorCodetypeNodeErrorCode = /** Bytes could not be parsed (truncated, non-canonical, trailing data, out of range). */ 'PARSE_ERROR' /** A caller passed a bad argument. */ | 'INVALID_ARGUMENT' /** A block header broke a consensus rule. `reason` holds Dogecoin Core's reject reason. */ | 'INVALID_HEADER' /** A merkle / txout proof did not verify. */ | 'INVALID_PROOF' /** A peer broke the P2P protocol (framing...Machine-readable reason codes for NodeError.
parentBlockHashHexfunctionparentBlockHashHex(a: AuxPow): string;Convenience: displayed hash of the parent block (its sha256d, not its PoW hash).
parseBlockHeaderfunctionparseBlockHeader(bytes: Uint8Array): BlockHeader;Parses one full header (80 bytes + optional AuxPoW), no trailing bytes allowed.
parseHeaderLoosefunctionparseHeaderLoose(input: Uint8Array | string): LooseHeader;Parses a block header with or without its AuxPoW. Throws NodeError PARSE_ERROR on anything else.
parseMerkleBlockfunctionparseMerkleBlock(input: Uint8Array | string): MerkleBlock;Parses a `merkleblock` (bytes or hex). Throws NodeError on malformed data.
parsePureHeaderfunctionparsePureHeader(bytes: Uint8Array): PureHeader;Parses exactly 80 bytes.
PartialMerkleTreeinterface{ nTransactions, hashes, flags, bitCount }A partial merkle tree (CPartialMerkleTree): the number of transactions, the hashes and the flag bits.
powHashfunctionpowHash(h: PureHeader | Uint8Array): Uint8Array;Proof-of-work hash: scrypt with N=1024, r=1, p=1, 32-byte output, the 80-byte header as both password and salt. Core: pureheader.cpp:25-30 calls scrypt_1024_1_1_256(BEGIN(nVersion), ...); crypto/scrypt.cpp:187-218 runs PBKDF2_SHA256(input, 80, input, 80, 1, B, 128), 1024 rounds of the Salsa20/8 ROMix, then PBKDF2_SHA256(input, 80, B, 128, 1, output, 32), which is standard scrypt(N=1024, r=1, p=1, dkLen=32). Computed with node:crypto (OpenSSL); the tests cross-check it against `@noble/hashes` scrypt and Core's vectors.
powPreimagefunctionpowPreimage(block: BlockHeader): Uint8Array;The 80 bytes whose scrypt hash must meet the target: the block itself, or its AuxPoW parent.
PureHeaderinterface{ version, prevHash, merkleRoot, time, bits, nonce }The 80-byte part of a block header: version, previous hash, merkle root, time, bits and nonce.
regtestParamsconstregtestParams: ChainParamsParameters of the Dogecoin regression-test network. Frozen.
serializeBlockHeaderfunctionserializeBlockHeader(h: BlockHeader): Uint8Array;Serialises a block header: 80 bytes, followed by the AuxPoW when the version flags one.
serializeMerkleBlockfunctionserializeMerkleBlock(mb: MerkleBlock): Uint8Array;Serialises a `merkleblock`.
serializePureHeaderfunctionserializePureHeader(h: PureHeader): Uint8Array;Serialises the 80-byte header part.
sha256dfunctionsha256d(data: Uint8Array): Uint8Array;Double SHA-256, Core's Hash() (src/hash.h).
targetOffunctiontargetOf(bits: number): bigint | undefined;The target (as an integer) of a compact nBits, or undefined if invalid.
targetToCompactfunctiontargetToCompact(target: bigint, negative?: boolean): number;arith_uint256::GetCompact (arith_uint256.cpp:224-245).
testnetParamsconsttestnetParams: ChainParamsParameters of the Dogecoin test network. Frozen.
verifyHeaderChainfunctionverifyHeaderChain(headers: readonly (Uint8Array | string)[], opts: VerifyHeaderChainOptions): VerifyHeaderChainResult;Verifies a short run of consecutive headers without the rest of the chain: linkage, proof of work, difficulty and checkpoints. Returns a result; does not throw for bad headers.
VerifyHeaderChainOptionsinterface{ network, firstHeight?, anchor?, maxTarget?, allowMissingAuxPow?, knownValid?, checkDifficulty?, maxHeaders?, powHash? }Options for verifyHeaderChain: the network, the claimed first height, an optional trusted anchor, a target floor and limits.
VerifyHeaderChainResulttypeVerifyHeaderChainResult = { readonly ok: true; readonly headers: readonly LightHeaderReport[]; /** Sum of GetBlockProof over the headers. */ readonly totalWork: bigint; /** Headers whose proof of work verified (now or `known`). */ readonly powVerified: number; /** Headers whose proof of work could not be checked (AuxPoW missing). */ readonly powUnchecked: number; readonly checkpoints: readonly ...Result of verifyHeaderChain: `ok: true` with per-header reports and totals, or `ok: false` with a failure code, a reason and the index of the offending header. It does not throw for invalid headers.
verifyMerkleBlockProoffunctionverifyMerkleBlockProof(proof: Uint8Array | string, txid: string): MerkleBlockProofResult;Checks that a `merkleblock` proof (Core's `gettxoutproof`) commits to a txid under its header. Throws NodeError INVALID_PROOF otherwise.
VERSION_AUXPOWconstVERSION_AUXPOW: numberpureheader.h:23 `static const int32_t VERSION_AUXPOW = (1 << 8);`
VERSION_CHAIN_STARTconstVERSION_CHAIN_START: numberpureheader.h:26 `static const int32_t VERSION_CHAIN_START = (1 << 16);`
workForBitsfunctionworkForBits(bits: number): bigint;Expected scrypt hashes for one header at this nBits (GetBlockProof). Re-exported for clarity.

Self-hosting and source

Source: github.com/DogeJS-Dev/light-node (package @dogejs/node).

Shell
git clone https://github.com/DogeJS-Dev/light-node
cd light-node
npm install
npm run build
npm test

FAQ

Is this a full node?

No. It downloads and verifies block headers only (80 bytes each), plus merkle proofs for single transactions.

Why trust it over an indexer?

It checks proof of work and difficulty itself, so a lying peer cannot show you a chain with less work than the real one.

Can I run it in a browser?

Syncing cannot (no raw TCP). Verifying headers and proofs can, through the verify entry.