Skip to content
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 support for Nimiq Albatross PoS transaction serialization #4110

Merged

Conversation

sisou
Copy link
Contributor

@sisou sisou commented Nov 14, 2024

Description

The transaction format for both signing and sending changed slightly for Nimiq Albatross PoS, to encode optional sender data and support more signature methods (now also supports ECDSA and WebAuthn).

How to test

To test, connect your wallet to a Nimiq PoS testnet node (provided in our joined Telegram channel). To be valid in the testnet, the NETWORK_ID has to be set to 5.

Types of changes

  • Breaking change: update transaction serialization for signing and sending

Checklist

  • Create pull request as draft initially, unless its complete.
  • Add tests to cover changes as needed.
  • Update documentation as needed.
  • If there is a related Issue, mention it in the description.

If you're adding a new blockchain

  • I have read the guidelines for adding a new blockchain.

Copy link
Collaborator

@satoshiotomakan satoshiotomakan left a comment

Choose a reason for hiding this comment

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

I'll add the required changes in a separate PR, thank you!

@@ -42,6 +43,7 @@ std::vector<uint8_t> Transaction::getPreImage() const {
encode32BE(vsh, data);
data.push_back(NETWORK_ID);
data.push_back(EMPTY_FLAGS);
data.push_back(0x00); // Sender Data size (+ 0 bytes of data)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please add a link to the source code somewhere at the beginning of the function?
https://github.com/nimiq/core-rs-albatross/blame/b8ed402c9096ffb54afea52347b91ab7831e75de/primitives/transaction/src/lib.rs#L582

@@ -9,13 +9,14 @@

namespace TW::Nimiq {

const uint8_t NETWORK_ID = 42;
const uint8_t NETWORK_ID = 24;
const uint8_t EMPTY_FLAGS = 0;

std::vector<uint8_t> Transaction::serialize() const {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please add a link to the source code somewhere at the beginning of the function?
https://github.com/nimiq/core-rs-albatross/blame/b8ed402c9096ffb54afea52347b91ab7831e75de/primitives/transaction/src/lib.rs#L699

const uint8_t EMPTY_FLAGS = 0;

std::vector<uint8_t> Transaction::serialize() const {
std::vector<uint8_t> data;

data.push_back(0x00); // Basic TX type
data.push_back(0x00); // Signature Proof type and flags (Ed25519 type and no flags)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should add an if statement here to avoid breaking changes

@satoshiotomakan satoshiotomakan changed the base branch from master to s/nimiq-albatross November 18, 2024 15:31
@satoshiotomakan satoshiotomakan merged commit 5cc17bb into trustwallet:s/nimiq-albatross Nov 18, 2024
12 checks passed
satoshiotomakan added a commit that referenced this pull request Nov 18, 2024
* Add support for Nimiq Albatross PoS transaction serialization (#4110)

* Update Nimiq Transaction encoding for Albatross PoS

* Update tests

* [Nimiq]: Add networkId parameter to SigningInput

* [Nimiq]: Fix iOS test

* [Nimiq]: Fix invalid integer type cast

* [Nimiq]: Fix iOS test

---------

Co-authored-by: Sören Schwert <[email protected]>
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.

2 participants