-
Notifications
You must be signed in to change notification settings - Fork 16
Add utxo source #375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add utxo source #375
Conversation
There was a problem hiding this 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/CreatedSiacoinElementin the wallet layer and extendsapplyChainUpdateto 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 inaddSiacoinElements, and addsStore.DecorateConsensusBlockto read and expose origin data. - Adds new public API types (
ConsensusBlock, decorated transaction/input/output types), routes/consensus/blocks/:idthroughDecorateConsensusBlock, wires the store intoapi.NewServer, and adds tests forDecorateConsensusBlockand 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.
peterjan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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.
No description provided.