Skip to content
This repository has been archived by the owner on Apr 16, 2023. It is now read-only.

Allow Arbitrary Data in Transaction Extra Nonce via Wallet-API #931

Merged
merged 1 commit into from Nov 16, 2019
Merged

Allow Arbitrary Data in Transaction Extra Nonce via Wallet-API #931

merged 1 commit into from Nov 16, 2019

Conversation

brandonlehmann
Copy link
Collaborator

@brandonlehmann brandonlehmann commented Nov 13, 2019

This allows for the addition of arbitrary hexadecimal data to be added to a transaction nonce via wallet-api.

The additional body parameter extra has been added to support this.

Once supplied, the data is encoded behind a special nonce tag (127) and appended to the nonce such that:

Example: https://explorer.turtlecoin.lol/transaction.html?hash=5591fc3bb7384d304341066b214635687c615c860b17024d8cdb593e23aae017

Note: This does not remove the 1,024 byte limit for the TX_EXTRA so that limit still applies.

This matches how I handled this in turtlecoin-utils

@brandonlehmann brandonlehmann added the ENHANCEMENT new feature or request label Nov 13, 2019
src/walletbackend/Transfer.cpp Outdated Show resolved Hide resolved
src/walletbackend/Transfer.cpp Show resolved Hide resolved
src/walletbackend/WalletBackend.cpp Show resolved Hide resolved
Copy link

@zpalmtree zpalmtree left a comment

Choose a reason for hiding this comment

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

This parsing code looks pretty good to me, but have you tested it with slightly too short/too long lengths? It's very easy to get off by one errors in code like this.

src/walletbackend/Transfer.cpp Outdated Show resolved Hide resolved
src/utilities/ParseExtra.cpp Show resolved Hide resolved
src/utilities/ParseExtra.cpp Outdated Show resolved Hide resolved
@brandonlehmann brandonlehmann changed the title Allow Arbitrary Data in Transaction Extra Nonce via Wallet-API WIP: Allow Arbitrary Data in Transaction Extra Nonce via Wallet-API Nov 15, 2019
Extra data supplied must be in hexadecimal form.
@brandonlehmann
Copy link
Collaborator Author

brandonlehmann commented Nov 15, 2019

This parsing code looks pretty good to me, but have you tested it with slightly too short/too long lengths? It's very easy to get off by one errors in code like this.

I've ran it through as many tests as I possibly can of long/short values and while it does not throw an error -- improperly constructed fields will lead to unexpected behavior.

Example: If you put the public key behind the nonce field, and you say the nonce field is 25-bytes long but only supply 24-bytes, the public key will not be read as the identifier 01 will be considered part of the nonce field. Little things like that. It's pretty much the same issue as if someone were to construct extra with garbage data at the front and the parser would find 01 and the next 32-bytes are considered the public key -- although the real public key is farther back in the array. Garbage in, garbage out.

All that being said, I've moved this to a WIP as I'd like to extend wallet-api to be able to return this information when getting transaction information; however, I haven't started on that just yet. We'll call that Phase 2 in another PR

@brandonlehmann brandonlehmann changed the title WIP: Allow Arbitrary Data in Transaction Extra Nonce via Wallet-API Allow Arbitrary Data in Transaction Extra Nonce via Wallet-API Nov 16, 2019
@brandonlehmann
Copy link
Collaborator Author

Removed WIP tag. Storing and retrieving the data in wallets, as an option, will be addressed in another PR.

@zpalmtree zpalmtree merged commit ecea323 into turtlecoin:development Nov 16, 2019
LeoStehlik added a commit to derogold/derogold that referenced this pull request Nov 24, 2019
@brandonlehmann brandonlehmann deleted the sending_extra_data_via_wallet-api branch November 29, 2019 13:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ENHANCEMENT new feature or request
Projects
None yet
3 participants