Cannot spend coinbase for N blocks (#111)
* use head_header in add_to_memory_pool * add COINBASE_MATURITY const to consensus * add coinbase maturity (wip) validaton rule to validate_block * add coinbase maturity check to validate_block * map errors in adapters - specific errors still wip * reworked so adapter translates chain errors to pool errors (core errors not required) * add test for spending immature coinbase in memory pool * wip - add test to cover spending coinbase output in chain.process_block * added test coverage around process_block - we have a problem with coinbase output commitments * add a comment on the failing test * process_block will now fail validation if we attempt to spend coinbase that has not yet matured (remember to use a new reward_key for every block). test coverage in place to verify this
This commit is contained in:
committed by
Ignotus Peverell
parent
6493468959
commit
95a92eefc9
@@ -76,11 +76,11 @@ impl ApiEndpoint for OutputApi {
|
||||
debug!("GET output {}", id);
|
||||
let c = util::from_hex(id.clone()).map_err(|_| Error::Argument(format!("Not a valid commitment: {}", id)))?;
|
||||
|
||||
match self.chain.get_unspent(&Commitment::from_vec(c)) {
|
||||
Some(utxo) => Ok(utxo),
|
||||
None => Err(Error::NotFound),
|
||||
}
|
||||
|
||||
// TODO - can probably clean up the error mapping here
|
||||
match self.chain.get_unspent(&Commitment::from_vec(c)) {
|
||||
Ok(utxo) => Ok(utxo),
|
||||
Err(_) => Err(Error::NotFound),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user