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

feat: parse new output script types #73

Open
wants to merge 11 commits into
base: dev
Choose a base branch
from
Open

Conversation

r4mmer
Copy link
Member

@r4mmer r4mmer commented May 28, 2024

Acceptance criteria

  • Identify and parse different output scripts
  • Add support for showing p2sh addresses
  • Add support for showing and confirming data script outputs

@r4mmer r4mmer self-assigned this May 28, 2024
@r4mmer r4mmer changed the title Feat/identify script type feat: parse new output script types May 28, 2024
@r4mmer r4mmer changed the base branch from master to dev May 28, 2024 17:08
r4mmer added 2 commits October 3, 2024 09:06
* origin/dev:
  chore: update linter version
  chore: update CI (#77)
  feat: use correct size limit
  fix: code scanning
  [auto] Add guideline enforcer
  [auto] Add manifest
@r4mmer r4mmer requested a review from pedroferreira1 October 3, 2024 13:31
@@ -76,10 +77,18 @@ size_t parse_output(uint8_t *in, size_t inlen, tx_output_t *output) {
if (!(buffer_read_u8(&buf, &output->token_data) && buffer_read_u16(&buf, &script_len, BE))) {
THROW(TX_STATE_READY);
}
// validate script and extract pubkey hash
validate_p2pkh_script(&buf, script_len);
Copy link
Member

Choose a reason for hiding this comment

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

I didn't find where you moved this validation to. Don't you need it anymore?

#include "opcodes.h"

/**
* Identifies if the given script is P2PKH
Copy link
Member

Choose a reason for hiding this comment

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

Add the expected pattern in the docstring, please.

}

/**
* Identifies if the given script is P2SH
Copy link
Member

Choose a reason for hiding this comment

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

Add the expected pattern in the docstring, please.

return true;
}

bool identify_data_script(buffer_t *in, uint16_t script_len) {
Copy link
Member

Choose a reason for hiding this comment

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

Missing docstring. Also, please add the expected pattern to the docstring.

* Read data from script and store it in `out`
* Returns number of bytes read, 0 if any error occurs.
*/
uint8_t read_data_script(buffer_t *in, uint16_t script_len, uint8_t out[MAX_DATA_SCRIPT_LEN]) {
Copy link
Member

Choose a reason for hiding this comment

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

I couldn't find where you use this function. I was also wondering whether it would be easier to have a parser function that would try to parse and return error otherwise. This would remove the necessity to have both identify_data_script() and read_data_script() methods.

break;
case SCRIPT_DATA:
out->type = SCRIPT_DATA;
// XXX: We currently do not read the actual data from the output
Copy link
Member

Choose a reason for hiding this comment

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

Don't we present it to the user to confirm? Why not?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

3 participants