radiancy/tx/
input.rs

1
2use wallet::utils::hash_pubkey;
3
4#[derive(Clone, Serialize, Deserialize, Debug)]
5pub struct TXInput {
6    pub txid: Vec<u8>,
7    pub vout_idx: i32, // vout_idx from blockchain
8    pub signature: Vec<u8>,
9    pub pub_key: Vec<u8>
10}
11
12impl TXInput {
13    pub fn can_unlock_output_with(self, unlocking_data: String) -> bool {
14        return self.signature == unlocking_data.into_bytes();
15    }
16
17    pub fn uses_key(self, pubkey_hash: Vec<u8>) -> bool {
18        let locking_hash = hash_pubkey(self.pub_key);
19        
20        return locking_hash.eq(&pubkey_hash);
21    }
22}