H2: Replace (List<Coin>, List<Key>) tuple with SigningCoin record#913
Open
DavidGershony wants to merge 1 commit into
Open
H2: Replace (List<Coin>, List<Key>) tuple with SigningCoin record#913DavidGershony wants to merge 1 commit into
DavidGershony wants to merge 1 commit into
Conversation
Introduce a strongly-typed SigningCoin record that pairs each Coin with its corresponding signing Key, eliminating the unsafe parallel-list pattern where coins and keys could become mismatched by index. - Add SigningCoin record to IWalletOperations - Change GetUnspentOutputsForTransaction return type to List<SigningCoin> - Refactor all callers in WalletOperations to use sc.Coin / sc.Key - Remove index-based iteration in favor of direct sc.Key access - Add outpoint to error messages (instead of opaque index) - Update all test mocks to return List<SigningCoin>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the unsafe
(List<Coin>?, List<Key>)tuple return type with a strongly-typedSigningCoinrecord that pairs each coin with its signing key, eliminating the possibility of index-based mismatches.Problem
GetUnspentOutputsForTransactionreturned two parallel lists — coins and keys — indexed in lockstep. If the lists ever got out of sync (e.g., by a future refactor that filters one but not the other), the wrong key would sign the wrong input, producing an invalid transaction with no compile-time protection.Solution
csharp public record SigningCoin(Coin Coin, Key Key);sc.Coinandsc.KeyList<SigningCoin>Files Changed
SigningCoinrecord; change return typeSigningCoinTesting
All 154 shared tests pass.