Skip to content

Conversation

@n8mgr
Copy link
Member

@n8mgr n8mgr commented Feb 2, 2026

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds explicit origin tracking for siacoin UTXOs and exposes that information via a new decorated consensus block API.

Changes:

  • Introduces SiacoinOrigin/CreatedSiacoinElement in the wallet layer and extends applyChainUpdate to infer and attach origins for all siacoin UTXO sources (transactions, siafund claims, miner/foundation payouts, V1/V2 contract payouts).
  • Extends the SQLite schema (siacoin_elements) with origin columns (via init.sql and migration v9), plus encoding helpers and storage wiring in addSiacoinElements, and adds Store.DecorateConsensusBlock to read and expose origin data.
  • Adds new public API types (ConsensusBlock, decorated transaction/input/output types), routes /consensus/blocks/:id through DecorateConsensusBlock, wires the store into api.NewServer, and adds tests for DecorateConsensusBlock and API usage updates.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
wallet/update.go Adds SiacoinElementSource, SiacoinOrigin, and CreatedSiacoinElement, extends AppliedState, and augments applyChainUpdate to compute and attach UTXO origins for all relevant siacoin creation paths.
persist/sqlite/migrations.go Adds migrateVersion9 to introduce origin_source, origin_transaction_id, and origin_transaction_index columns to siacoin_elements.
persist/sqlite/init.sql Updates the initial schema for siacoin_elements to include the new origin columns and comments describing their purpose.
persist/sqlite/encoding.go Adds generic nullDecodable[T] to support scanning nullable Sia-encoded values (used for nullable origin IDs).
persist/sqlite/consensus.go Switches addSiacoinElements to accept wallet.CreatedSiacoinElement and persist origin fields; adds Store.DecorateConsensusBlock to build api.ConsensusBlock by querying UTXO origins and decorating siacoin inputs (V1 and V2).
persist/sqlite/consensus_test.go Adds TestDecorateConsensusBlock with multiple subtests covering NULL vs complete origin fields for V1/V2 inputs and missing-element error handling.
cmd/walletd/node.go Passes the SQLite store into api.NewServer so the API can call DecorateConsensusBlock.
api/server.go Introduces a Store interface, extends the server struct to hold it, changes /consensus/blocks/:id to return a decorated ConsensusBlock via DecorateConsensusBlock, and updates NewServer to accept the store.
api/api.go Defines ConsensusSiacoinInput, ConsensusV2SiacoinInput, ConsensusSiacoinOutput, ConsensusTransaction, ConsensusV2Transaction, ConsensusV2BlockData, and ConsensusBlock to represent decorated consensus data in the HTTP API.
api/api_test.go Updates tests to pass a store into NewServer and tweaks a time equality check to use Time.Equal instead of ==.
.changeset/added_siacoin_input_origin_to_consensusblock.md Records a minor-version changeset describing the addition of siacoin input origin data to the consensus/block API.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@peterjan peterjan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

peterjan
peterjan previously approved these changes Feb 3, 2026
ChrisSchinnerl
ChrisSchinnerl previously approved these changes Feb 3, 2026
@n8mgr n8mgr dismissed stale reviews from ChrisSchinnerl and peterjan via d92b97c February 3, 2026 19:03
@n8mgr n8mgr requested a review from ChrisSchinnerl February 4, 2026 14:13
@n8mgr n8mgr merged commit 50ea36a into master Feb 5, 2026
12 checks passed
@n8mgr n8mgr deleted the nate/utxo-source branch February 5, 2026 15:23
@github-project-automation github-project-automation bot moved this from In Progress to Done in Sia Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants