Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BREAKING CHANGE] refactor: remove the tx parameter from the sign method in the Signer trait #110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/traits/default_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,13 +614,7 @@ impl Signer for SecpCkbRawKeySigner {
id.len() == 20 && self.keys.contains_key(&H160::from_slice(id).unwrap())
}

fn sign(
&self,
id: &[u8],
message: &[u8],
recoverable: bool,
_tx: &TransactionView,
) -> Result<Bytes, SignerError> {
fn sign(&self, id: &[u8], message: &[u8], recoverable: bool) -> Result<Bytes, SignerError> {
if !self.match_id(id) {
return Err(SignerError::IdNotFound);
}
Expand Down
8 changes: 1 addition & 7 deletions src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,7 @@ pub trait Signer {
/// different length of message:
/// * secp256k1 => 256bits
/// * RSA => 512bits (when key size is 1024bits)
fn sign(
&self,
id: &[u8],
message: &[u8],
recoverable: bool,
tx: &TransactionView,
) -> Result<Bytes, SignerError>;
fn sign(&self, id: &[u8], message: &[u8], recoverable: bool) -> Result<Bytes, SignerError>;
}

/// Transaction dependency provider errors
Expand Down
10 changes: 5 additions & 5 deletions src/unlock/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl SecpSighashScriptSigner {
let zero_lock = Bytes::from(vec![0u8; 65]);
let message = generate_message(&tx_new, script_group, zero_lock)?;

let signature = self.signer.sign(owner_id, message.as_ref(), true, tx)?;
let signature = self.signer.sign(owner_id, message.as_ref(), true)?;

// Put signature into witness
let witness_data = witnesses[witness_idx].raw_data();
Expand Down Expand Up @@ -313,7 +313,7 @@ impl ScriptSigner for SecpMultisigScriptSigner {
.sighash_addresses
.iter()
.filter(|id| self.signer.match_id(id.as_bytes()))
.map(|id| self.signer.sign(id.as_bytes(), message.as_ref(), true, tx))
.map(|id| self.signer.sign(id.as_bytes(), message.as_ref(), true))
.collect::<Result<Vec<_>, SignerError>>()?;
// Put signature into witness
let witness_idx = script_group.input_indices[0];
Expand Down Expand Up @@ -579,7 +579,7 @@ impl OmniLockScriptSigner {
.sighash_addresses
.iter()
.filter(|id| self.signer.match_id(id.as_bytes()))
.map(|id| self.signer.sign(id.as_bytes(), message.as_ref(), true, tx))
.map(|id| self.signer.sign(id.as_bytes(), message.as_ref(), true))
.collect::<Result<Vec<_>, SignerError>>()?;
// Put signature into witness
let witness_idx = script_group.input_indices[0];
Expand Down Expand Up @@ -662,7 +662,7 @@ impl OmniLockScriptSigner {

let signature = self
.signer
.sign(id.auth_content().as_ref(), message.as_ref(), true, tx)?;
.sign(id.auth_content().as_ref(), message.as_ref(), true)?;

// Put signature into witness
let witness_data = witnesses[witness_idx].raw_data();
Expand Down Expand Up @@ -783,7 +783,7 @@ impl ScriptSigner for OmniLockScriptSigner {

let signature =
self.signer
.sign(id.auth_content().as_ref(), message.as_ref(), true, tx)?;
.sign(id.auth_content().as_ref(), message.as_ref(), true)?;

// Put signature into witness
let witness_data = witnesses[witness_idx].raw_data();
Expand Down
Loading