-
Notifications
You must be signed in to change notification settings - Fork 59
Create UtxoData
and check coinbase maturity
#440
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
Conversation
I have added the same `UtxoData` struct from PR vinteumorg#300, but with an additional `is_coinbase` flag. We get the flag from the utreexo leaf header code, just like the utxo creation height. The utxo creation unix time is not computed nor used anywhere (covered at vinteumorg#300). Most of this diff is refactoring `TxOut` to `UtxoData` in functions. I'm generally not using a `UtxoMap` type alias in order to keep the map types explicit on a first look. The `Consensus::verify_transaction` now checks the spent coinbase tx outputs maturity. `ChainParams` has a constant for the maturity period but it's always 100 regardless of the network.
c
The reason to create
I`m considerating a total refactor of #300 instead of dealing with conflicts. |
Yeah, in this case I would prefer the explicitness of |
Im totally neutral about it because i had to reimplement some funcs just because it was a type alias, so im not sure if its worth the change... BTW, Tested locally and everything runs fine. have you done some blocks validation to certify this ? |
The sync must work since the only consensus change is: // A coinbase output created at height n can only be spent at height >= n + 100
if utxo.is_coinbase && (height < utxo.creation_height + 100) {
return Err(tx_err!(txid, CoinbaseNotMatured))?;
} |
Checked the code for this rule: It looks the exactly same so: ACK cc022a0 |
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've successfully completed IBD on this branch. But a nice follow up would be some tests for the negative case (i.e. invalid spents)
ACK cc022a0
What is the purpose of this pull request?
Which crates are being modified?
Description
I have added the same
UtxoData
struct from PR #300, but with an additionalis_coinbase
flag. We get the flag from the utreexo leaf header code, just like the utxo creation height. The utxo creation unix time is not computed nor used anywhere (covered at #300).The
Consensus::verify_transaction
now checks the spent coinbase tx outputs maturity.ChainParams
has a constant for the maturity period but it's always 100 regardless of the network.Notes to the reviewers
Most of this diff is refactoring
TxOut
toUtxoData
in functions. I'm generally not using aUtxoMap
type alias in order to keep the map types explicit on a first look.This PR should should make #300 more focused on the timelock checks and unix time computation, and less so on refactors.