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

fix(network): drop the [2,…] message tag wrapper from the rejection reason #548

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

michalrus
Copy link

The bug

Currently, the rejection reason is always prefixed with 8202, because the entire d.input() is copied there. And d.input() always contains the whole input.

An (incorrect) example of a FeeTooSmallUTxO error:

82                                      # array(2)
   02                                   # unsigned(2)
   81                                   # array(1)
      82                                # array(2)
         06                             # unsigned(6)
         82                             # array(2)
            82                          # array(2)
               01                       # unsigned(1)
               82                       # array(2)
                  00                    # unsigned(0)
                  83                    # array(3)
                     06                 # unsigned(6)
                     1B 000000025050D4DD # unsigned(9937409245)
                     1A 003D0E39        # unsigned(4001337)
            82                          # array(2)
               01                       # unsigned(1)
               82                       # array(2)
                  00                    # unsigned(0)
                  83                    # array(3)
                     05                 # unsigned(5)
                     1A 0002851D        # unsigned(165149)
                     19 0539            # unsigned(1337)

This is not correct, because the first 2 bytes representing [2, …] are just a tag for Message::RejectTx, which we already give to the user, so the information is currently encoded twice.

The above example should have started on line 3 (3rd byte).

The fix

We need to:

  • offset d.input() in RejectReason by the current d.position(),

  • I've also moved d.set_position(_) – it's the cleanest to have it in the decoder for RejectReason, so that it behaves like other well-formed decoders, i.e. increments the current .pos.

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

Successfully merging this pull request may close these issues.

2 participants