-
Notifications
You must be signed in to change notification settings - Fork 56
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
Add StakeTransaction #2401
base: 2.0-base
Are you sure you want to change the base?
Add StakeTransaction #2401
Conversation
c64ab6d
to
e724019
Compare
// TODO: Move validations to a visitor | ||
// // Execute visitor | ||
// if let Some(visitor) = &mut visitor { | ||
// let transaction = Transaction::ValueTransfer(transaction.clone()); | ||
// visitor.visit(&(transaction, fee, weight)); | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
// #[serde(rename = "stake")] | ||
// Stake(StakeData), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uncomment?
2cc250d
to
a21c0a8
Compare
/// # use witnet_data_structures::chain::{TransactionsPool, Hash}; | ||
/// # use witnet_data_structures::transaction::{Transaction, StakeTransaction}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these comented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it's also comented in the other examples
let out_value = &st_tx.body.output.value | ||
- &st_tx | ||
.body | ||
.change | ||
.clone() | ||
.unwrap_or(Default::default()) | ||
.value; | ||
|
||
if out_value > in_value { | ||
Err(TransactionError::NegativeFee.into()) | ||
} else { | ||
Ok(in_value - out_value) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get this logic. Why subtracting the change? The change is also part of the transaction value.
failure::Error, | ||
> { | ||
// Check that the amount of coins to stake is equal or greater than the minimum allowed | ||
if st_tx.body.output.value < MIN_STAKE_NANOWITS { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my former comment on consistency of ?
vs. return
syntax inside the same function.
626ca59
to
3c9c2fa
Compare
Validations
Transaction
Block