Skip to content

Instantly share code, notes, and snippets.

@kcalvinalvin
Created May 19, 2025 05:13
Show Gist options
  • Save kcalvinalvin/e85085f3ca2a08564c51758d8cb35897 to your computer and use it in GitHub Desktop.
Save kcalvinalvin/e85085f3ca2a08564c51758d8cb35897 to your computer and use it in GitHub Desktop.
Verifying a block as an utreexo compact state node for v0.4.1

Verifying a bitcoin block as an utreexo compact state node

A utreexo compact state node doesn't have all the data required for verifying a bitcoin block just with the block. It also requires a utreexo proof.

The method described here is only valid for utreexod v0.4.1. The next version will have a different P2P messaging flow.

For v0.4.1, to get the necessary utreexo data, one must ask for a MSG_UTREEXO_BLOCK when constructing the getdata. Since we also want segwit blocks as well, we use the MSG_WITNESS_UTREEXO_BLOCk. Constructing the inv is done like so:

iv := wire.NewInvVect(wire.InvTypeWitnessUtreexoBlock, hashOfTheBlock)

This will send a request to the utreexo node that a utreexo proof should be attached to the block.

Calling blockchain.ProcessBlock with the import being from github.com/utreexo/utreexod/blockchain will automatically handle the utreexo proof.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment