Skip to content

Commit

Permalink
fix(wallet): correct change checks in transaction builder (#5235)
Browse files Browse the repository at this point in the history
Description
---
Fix mislabelled transaction builder checks for change params

Motivation and Context
---
Previous code just checked the private nonce 3 times
```rust
        Self::check_value("Change script", &self.private_nonce, &mut message);
        Self::check_value("Change input data", &self.private_nonce, &mut message);
        Self::check_value("Change script private key", &self.private_nonce, &mut message);
```

None of the change builder fields are required.

How Has This Been Tested?
---
N/A Change has no effect on builder behaviour

<!-- Does this include a breaking change? If so, include this line as a
footer -->
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a
database, resync the chain -->
  • Loading branch information
sdbondi committed Mar 15, 2023
1 parent acfecfb commit 768a0cf
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,7 @@ impl SenderTransactionInitializer {
Self::check_value("Missing Lock Height", &self.lock_height, &mut message);
Self::check_value("Missing Fee per gram", &self.fee_per_gram, &mut message);
Self::check_value("Missing Offset", &self.offset, &mut message);
Self::check_value("Change script", &self.private_nonce, &mut message);
Self::check_value("Change input data", &self.private_nonce, &mut message);
Self::check_value("Change script private key", &self.private_nonce, &mut message);
Self::check_value("Missing private nonce", &self.private_nonce, &mut message);

if !message.is_empty() {
return self.build_err(&message.join(","));
Expand Down Expand Up @@ -731,8 +729,7 @@ mod test {
// We should have a bunch of fields missing still, but we can recover and continue
assert_eq!(
err.message,
"Missing Lock Height,Missing Fee per gram,Missing Offset,Change script,Change input data,Change script \
private key"
"Missing Lock Height,Missing Fee per gram,Missing Offset,Missing private nonce"
);

let mut builder = err.builder;
Expand Down

0 comments on commit 768a0cf

Please sign in to comment.