Replace UTXO::is_internal with script_type

This means less conversion and logic mapping from bool to ScriptType and
back again.
This commit is contained in:
LLFourn
2020-12-04 10:37:58 +11:00
parent a89dd85833
commit 8dcb75dfa4
10 changed files with 54 additions and 75 deletions

View File

@@ -566,8 +566,8 @@ impl ChangeSpendPolicy {
pub(crate) fn is_satisfied_by(&self, utxo: &UTXO) -> bool {
match self {
ChangeSpendPolicy::ChangeAllowed => true,
ChangeSpendPolicy::OnlyChange => utxo.is_internal,
ChangeSpendPolicy::ChangeForbidden => !utxo.is_internal,
ChangeSpendPolicy::OnlyChange => utxo.script_type == ScriptType::Internal,
ChangeSpendPolicy::ChangeForbidden => utxo.script_type == ScriptType::External,
}
}
}
@@ -662,7 +662,7 @@ mod test {
vout: 0,
},
txout: Default::default(),
is_internal: false,
script_type: ScriptType::External,
},
UTXO {
outpoint: OutPoint {
@@ -670,7 +670,7 @@ mod test {
vout: 1,
},
txout: Default::default(),
is_internal: true,
script_type: ScriptType::Internal,
},
]
}
@@ -695,7 +695,7 @@ mod test {
.collect::<Vec<_>>();
assert_eq!(filtered.len(), 1);
assert_eq!(filtered[0].is_internal, false);
assert_eq!(filtered[0].script_type, ScriptType::External);
}
#[test]
@@ -707,7 +707,7 @@ mod test {
.collect::<Vec<_>>();
assert_eq!(filtered.len(), 1);
assert_eq!(filtered[0].is_internal, true);
assert_eq!(filtered[0].script_type, ScriptType::Internal);
}
#[test]