Skip to content

feat: add remove signature methods for Transaction and related unit tests#1218

Merged
rwalworth merged 5 commits intohiero-ledger:mainfrom
Kubikusik:AddRemoveSignaturesMethods
Mar 13, 2026
Merged

feat: add remove signature methods for Transaction and related unit tests#1218
rwalworth merged 5 commits intohiero-ledger:mainfrom
Kubikusik:AddRemoveSignaturesMethods

Conversation

@Kubikusik
Copy link
Copy Markdown
Contributor

Description:

Add support for removing specific or all signatures from a frozen Transaction.

  • Added removeSignature(publicKey) to remove signatures associated with a specific public key.
  • Added removeAllSignatures() to clear all signatures from a transaction.
  • Added unit tests covering single-signer, multi-signer, and error-handling scenarios.

Related issue(s):

Fixes #771

Notes for reviewer:

When a signature is removed, explicitly clears mTransactions and removes "stale" auto-generated signatures from the sigmap.
This ensures that the next time getTransactionSize() or makeRequest() is called, the SDK cleanly regenerates signatures for the remaining keys instead of creating duplicate entries in the signature map.
Tested with ED25519 keys, also added separate test for ECDSAsecp256k1 keys' case.

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

Signed-off-by: kubikusik <jakubmical@student.agh.edu.pl>
…ctions in TransactionUnitTests

Signed-off-by: kubikusik <jakubmical@student.agh.edu.pl>
@Kubikusik
Copy link
Copy Markdown
Contributor Author

Hey, sorry to say, but I'm honestly unsure about how to deal with the higher than desired cyclomatic compliexity and length of the functions. I hope its okay to ask about a direction with those issues.

@Kubikusik Kubikusik marked this pull request as ready for review March 10, 2026 20:35
@Kubikusik Kubikusik requested review from a team as code owners March 10, 2026 20:35
@Kubikusik Kubikusik requested a review from gsstoykov March 10, 2026 20:35
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 10, 2026

Hey @Kubikusik 👋 thanks for the PR!
I'm your friendly PR Helper Bot 🤖 and I'll be riding shotgun on this one, keeping track of your PR's status to help you get it approved and merged.

This comment updates automatically as you push changes -- think of it as your PR's live scoreboard!
Here's the latest:


PR Checks

DCO Sign-off -- All commits have valid sign-offs. Nice work!


GPG Signature -- All commits have verified GPG signatures. Locked and loaded!


Merge Conflicts -- No merge conflicts detected. Smooth sailing!


Issue Link -- Linked to #771 (assigned to you).


🎉 All checks passed! Your PR is ready for review. Great job!

@github-actions github-actions bot added the status: needs review The pull request is ready for maintainer review label Mar 10, 2026
Copy link
Copy Markdown
Contributor

@rwalworth rwalworth left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @Kubikusik! The implementation is solid - both methods are functionally correct, the test coverage is thorough, and you've handled the internal state management (clearing mTransactions, removing stale auto-generated signatures) thoughtfully. Regarding your question about cyclomatic complexity - of course it's okay to ask! I left a comment on the code with a concrete suggestion. The main thing is to extract the duplicated signature byte extraction logic into a shared helper function, which should bring the complexity and length down for both methods. Once that's addressed, we should be good to go! Let me know if you have any questions.

@rwalworth rwalworth added status: needs revision A pull request that requires changes before merge and removed status: needs review The pull request is ready for maintainer review labels Mar 10, 2026
@github-actions github-actions bot added status: needs review The pull request is ready for maintainer review and removed status: needs revision A pull request that requires changes before merge labels Mar 10, 2026
@Kubikusik Kubikusik force-pushed the AddRemoveSignaturesMethods branch from 784474a to 30a86a3 Compare March 10, 2026 23:13
Signed-off-by: kubikusik <jakubmical@student.agh.edu.pl>
@Kubikusik Kubikusik force-pushed the AddRemoveSignaturesMethods branch from 30a86a3 to 483ff7b Compare March 10, 2026 23:15
@Kubikusik
Copy link
Copy Markdown
Contributor Author

Ok, i think i have implemented the proposed solution. Please, do inform me of any more potential improvements. (Its a great way for me to learn after all).

@Kubikusik Kubikusik requested a review from rwalworth March 10, 2026 23:17
rwalworth
rwalworth previously approved these changes Mar 10, 2026
Copy link
Copy Markdown
Contributor

@rwalworth rwalworth left a comment

Choose a reason for hiding this comment

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

Nice work on the helper extraction @Kubikusik, the code reads much cleaner now! Since you asked about more potential improvements, I left a few suggestions below for additional test cases that would strengthen the coverage. These aren't blocking (the existing tests cover all the cases from the issue) but they'd exercise some important code paths that aren't covered yet. Let me know what you think!

@Kubikusik
Copy link
Copy Markdown
Contributor Author

So, I added the mentioned tests, it also showed that i forgot to clear sigmap if sigpairs is empty (2 bytes discrepancy), so fixed that (good test idea, thanks!)

@Kubikusik Kubikusik requested a review from rwalworth March 11, 2026 07:42
…map in removeSignature

Signed-off-by: kubikusik <jakubmical@student.agh.edu.pl>
@Kubikusik Kubikusik force-pushed the AddRemoveSignaturesMethods branch from 89c9288 to 2792fd9 Compare March 11, 2026 07:50
Copy link
Copy Markdown
Contributor

@rwalworth rwalworth left a comment

Choose a reason for hiding this comment

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

Nice work @Kubikusik, the additional tests you added caught a real bug with the empty sigmap clearing, which is exactly the kind of thing these edge-case tests are meant to surface! The implementation is correct, well-tested, and covers all the requirements from the issue. One small thing left to fix and then I'll run the workflows and merge!

@Kubikusik Kubikusik requested a review from rwalworth March 11, 2026 23:01
Copy link
Copy Markdown
Contributor

@rwalworth rwalworth left a comment

Choose a reason for hiding this comment

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

LGTM @Kubikusik - the implementation is solid, the tests are thorough, and you've addressed every piece of feedback along the way. Running the workflows and merging, thank you for the great work on this! 🎉

rwalworth
rwalworth previously approved these changes Mar 12, 2026
Copy link
Copy Markdown
Contributor

@rwalworth rwalworth left a comment

Choose a reason for hiding this comment

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

LGTM @Kubikusik! The implementation is correct, the test coverage is excellent, and you've addressed all the feedback cleanly through each iteration. I'll run the workflows and merge!

@rwalworth rwalworth dismissed their stale review March 12, 2026 03:17

Duplicate review — see earlier approval.

Copy link
Copy Markdown
Contributor

@rwalworth rwalworth left a comment

Choose a reason for hiding this comment

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

Actually, it looks like the Code / Lint (sdk, src/sdk/main) check is failing because of a formatting change to an unrelated declaration in Transaction.h. It looks like the determineStatus line wrapping was accidentally reformatted. Please revert it to the original formatting so clang-format-17 is happy.

@rwalworth rwalworth added status: needs revision A pull request that requires changes before merge and removed status: needs review The pull request is ready for maintainer review labels Mar 12, 2026
Signed-off-by: kubikusik <jakubmical@student.agh.edu.pl>
@Kubikusik Kubikusik force-pushed the AddRemoveSignaturesMethods branch from a2591b0 to 762298e Compare March 12, 2026 16:35
@github-actions github-actions bot added status: needs review The pull request is ready for maintainer review and removed status: needs revision A pull request that requires changes before merge labels Mar 12, 2026
@Kubikusik Kubikusik requested a review from rwalworth March 12, 2026 16:37
@rwalworth rwalworth merged commit 092d8f6 into hiero-ledger:main Mar 13, 2026
15 of 17 checks passed
@rwalworth rwalworth removed the status: needs review The pull request is ready for maintainer review label Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Beginner]: Add removeSignature and removeAllSignatures Methods

2 participants