Skip to content

Commit

Permalink
Rename is_known() to is_hash_preimage_known()
Browse files Browse the repository at this point in the history
Also removed unnecessary function contract_privkey_is_known()
  • Loading branch information
chris-belcher committed Aug 25, 2021
1 parent 570fd8a commit fded48e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
12 changes: 6 additions & 6 deletions src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub trait SwapCoin {
fn verify_contract_tx_receiver_sig(&self, sig: &Signature) -> bool;
fn verify_contract_tx_sender_sig(&self, sig: &Signature) -> bool;
fn apply_privkey(&mut self, privkey: SecretKey) -> Result<(), Error>;
fn is_known(&self) -> bool;
fn is_hash_preimage_known(&self) -> bool;
}

pub fn calculate_maker_pubkey_from_nonce(
Expand Down Expand Up @@ -505,8 +505,8 @@ impl SwapCoin for IncomingSwapCoin {
Ok(())
}

fn is_known(&self) -> bool {
self.contract_privkey_is_known()
fn is_hash_preimage_known(&self) -> bool {
self.hash_preimage.is_some()
}
}

Expand Down Expand Up @@ -555,8 +555,8 @@ impl SwapCoin for OutgoingSwapCoin {
}
}

fn is_known(&self) -> bool {
self.contract_privkey_is_known()
fn is_hash_preimage_known(&self) -> bool {
self.hash_preimage.is_some()
}
}

Expand Down Expand Up @@ -647,7 +647,7 @@ impl SwapCoin for WatchOnlySwapCoin {
}
}

fn is_known(&self) -> bool {
fn is_hash_preimage_known(&self) -> bool {
false
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ fn display_wallet_balance(wallet_file_name: &PathBuf, long_form: Option<bool>) {
if long_form { &"" } else { &txid[58..64] },
utxo.vout,
contract_type,
if swapcoin.is_known() { "known" } else { "unknown" },
if swapcoin.is_hash_preimage_known() { "known" } else { "unknown" },
read_locktime_from_contract(&swapcoin.get_contract_redeemscript())
.expect("unable to read locktime from contract"),
utxo.confirmations,
Expand Down
12 changes: 2 additions & 10 deletions src/wallet_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,6 @@ impl IncomingSwapCoin {
hash_preimage: None,
}
}

pub fn contract_privkey_is_known(&self) -> bool {
self.other_privkey.is_some() || self.hash_preimage.is_some()
}
}

impl OutgoingSwapCoin {
Expand Down Expand Up @@ -188,10 +184,6 @@ impl OutgoingSwapCoin {
hash_preimage: None,
}
}

pub fn contract_privkey_is_known(&self) -> bool {
self.hash_preimage.is_some()
}
}

pub trait WalletSwapCoin {
Expand Down Expand Up @@ -330,7 +322,7 @@ impl Wallet {
Address::p2wsh(script, NETWORK),
contract_tx.input[0].previous_output.txid,
contract_tx.input[0].previous_output.vout,
if coin.is_known() {
if coin.is_hash_preimage_known() {
" known"
} else {
"unknown"
Expand Down Expand Up @@ -811,7 +803,7 @@ impl Wallet {
),
>::new();
let get_hashvalue = |s: &dyn SwapCoin| {
if s.is_known() {
if s.is_hash_preimage_known() {
return None;
}
let swapcoin_hashvalue = read_hashvalue_from_contract(&s.get_contract_redeemscript())
Expand Down

0 comments on commit fded48e

Please sign in to comment.