Skip to content

Commit

Permalink
Fix valid_dao_withdraw_transaction panic
Browse files Browse the repository at this point in the history
  • Loading branch information
eval-exec committed Oct 11, 2023
1 parent 385bc89 commit a35205a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions verification/src/transaction_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ impl CapacityVerifier {
// withdraw transactions.
// cellbase's outputs are verified by RewardVerifier
// DAO withdraw transaction is verified via the type script of DAO cells
if !(self.resolved_transaction.is_cellbase() || self.valid_dao_withdraw_transaction()) {
if !self.resolved_transaction.is_cellbase() && !self.valid_dao_withdraw_transaction() {
let inputs_sum = self.resolved_transaction.inputs_capacity()?;
let outputs_sum = self.resolved_transaction.outputs_capacity()?;

Expand Down Expand Up @@ -585,10 +585,16 @@ impl CapacityVerifier {
.resolved_inputs
.iter()
.any(|cell_meta| {
cell_uses_dao_type_script(
&cell_meta.cell_output,
self.dao_type_hash.as_ref().expect("No dao system cell"),
)
cell_meta
.cell_output
.type_()
.to_opt()
.map(|t| {
Into::<u8>::into(t.hash_type()) == Into::<u8>::into(ScriptHashType::Type)
&& &t.code_hash()
== self.dao_type_hash.as_ref().expect("No dao system cell")
})
.unwrap_or(false)
})
}
}
Expand Down

0 comments on commit a35205a

Please sign in to comment.