Skip to content

Commit cb48dda

Browse files
committed
provide a new_unspendable implementation for provided verifiers
1 parent 4c20e59 commit cb48dda

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

tuxedo-core/src/verifier.rs

+8
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ impl Verifier for Unspendable {
7676
fn verify(&self, _simplified_tx: &[u8], _: u32, _: &()) -> bool {
7777
false
7878
}
79+
80+
fn new_unspendable() -> Option<Self> {
81+
Some(Self)
82+
}
7983
}
8084

8185
// Idea: It could be useful to allow delay deciding whether the redemption should succeed
@@ -96,6 +100,10 @@ impl Verifier for TestVerifier {
96100
fn verify(&self, _simplified_tx: &[u8], _: u32, _: &()) -> bool {
97101
self.verifies
98102
}
103+
104+
fn new_unspendable() -> Option<Self> {
105+
Some(Self { verifies: false })
106+
}
99107
}
100108

101109
#[cfg(test)]

tuxedo-core/src/verifier/multi_signature.rs

+7
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ impl Verifier for ThresholdMultiSignature {
9696

9797
valid_sigs.len() >= self.threshold.into()
9898
}
99+
100+
fn new_unspendable() -> Option<Self> {
101+
Some(Self {
102+
threshold: 1,
103+
signatories: Vec::new(),
104+
})
105+
}
99106
}
100107

101108
#[cfg(test)]

tuxedo-core/src/verifier/simple_signature.rs

+10
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ impl Verifier for Sr25519Signature {
4949
fn verify(&self, simplified_tx: &[u8], _: u32, sig: &Signature) -> bool {
5050
sp_io::crypto::sr25519_verify(sig, simplified_tx, &Public::from_h256(self.owner_pubkey))
5151
}
52+
53+
fn new_unspendable() -> Option<Self> {
54+
Some(Self::new(H256::zero()))
55+
}
5256
}
5357

5458
/// Pay To Public Key Hash (P2PKH)
@@ -70,6 +74,12 @@ impl Verifier for P2PKH {
7074
BlakeTwo256::hash(pubkey) == self.owner_pubkey_hash
7175
&& sp_io::crypto::sr25519_verify(signature, simplified_tx, pubkey)
7276
}
77+
78+
fn new_unspendable() -> Option<Self> {
79+
Some(Self {
80+
owner_pubkey_hash: H256::zero(),
81+
})
82+
}
7383
}
7484

7585
#[cfg(test)]

0 commit comments

Comments
 (0)