fix(xrp): Don't set LastLedgerSequence when not provided in SigningInput#4732
Open
MJamalian wants to merge 1 commit intotrustwallet:masterfrom
Open
fix(xrp): Don't set LastLedgerSequence when not provided in SigningInput#4732MJamalian wants to merge 1 commit intotrustwallet:masterfrom
MJamalian wants to merge 1 commit intotrustwallet:masterfrom
Conversation
When `lastLedgerSequence` is not set in SigningInput, the proto default is 0. The Rust migration (trustwallet#4250) unconditionally set this value on the transaction, producing `LastLedgerSequence = 0` which means "expire at ledger 0" — causing immediate transaction expiry on the XRP Ledger. The old C++ implementation correctly omitted the field when not provided. This fix guards both `build_tx_json` and `prepare_builder` paths to only set `LastLedgerSequence` when the input value is non-zero. Fixes trustwallet#4731
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LastLedgerSequenceassignment in bothbuild_tx_jsonandprepare_builderto only set the field when the proto input value is non-zeroNoneand is omitted from serialization, matching the old C++ behaviorProblem
After the C++ → Rust migration in #4250, XRP transactions that don't explicitly set
lastLedgerSequenceinSigningInputgetLastLedgerSequence = 0in the signed output. This means "expire at ledger 0", causing immediate transaction expiry on the XRP Ledger.The root cause is in
protobuf_builder.rs:When
lastLedgerSequenceis not provided, the proto default is0. The conditionfalse || true = truesetsSome(0), andprepare_builderunconditionally sets it. SinceCommonFields.last_ledger_sequenceisOption<u32>withskip_serializing_if = "Option::is_none",Some(0)gets serialized into the transaction.Fix
Only set the field when the input value is non-zero:
Note: the same pattern (
!= 0guard) is already correctly used forsource_tagon line 339.Test plan
last_ledger_sequencevalues)Fixes #4731