Skip to content

Commit 65c3c62

Browse files
author
Liu Chuankai
committed
chore: 🤖 Add Err for not configure open transaction list
1 parent 840f9d7 commit 65c3c62

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

‎src/unlock/opentx/mod.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ pub enum OpenTxError {
3030

3131
#[error(transparent)]
3232
VerificationError(#[from] VerificationError),
33-
#[error("witness field not exist")]
34-
WitnessMissing,
33+
#[error("Open transaction input list not configured.")]
34+
InputListConfigMissing,
3535
#[error("lock field of witness not exist")]
3636
WitnessLockMissing,
3737
#[error("signature not exist")]

‎src/unlock/signer.rs‎

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,15 @@ impl OmniLockScriptSigner {
562562

563563
let zero_lock = self.config.zero_lock(self.unlock_mode)?;
564564
let zero_lock_len = zero_lock.len();
565-
let (message, open_sig_data) = if let Some(opentx_wit) = self.config.get_opentx_input() {
566-
let reader = OpenTxReader::new(&tx_new, tx_dep_provider, script_group)?;
567-
opentx_wit.generate_message(&reader)?
565+
let (message, open_sig_data) = if self.config.is_opentx_mode() {
566+
if let Some(opentx_wit) = self.config.get_opentx_input() {
567+
let reader = OpenTxReader::new(&tx_new, tx_dep_provider, script_group)?;
568+
opentx_wit.generate_message(&reader)?
569+
} else {
570+
return Err(ScriptSignError::OpenTxError(
571+
OpenTxError::InputListConfigMissing,
572+
));
573+
}
568574
} else {
569575
(
570576
generate_message(&tx_new, script_group, zero_lock)?,
@@ -692,9 +698,14 @@ impl OmniLockScriptSigner {
692698
} else {
693699
WitnessArgs::from_slice(witness_data.as_ref())?
694700
};
695-
696-
if let Some(opentx_wit) = self.config.get_opentx_input() {
697-
signature = opentx_wit.build_opentx_sig(open_sig_data, signature);
701+
if self.config.is_opentx_mode() {
702+
if let Some(opentx_wit) = self.config.get_opentx_input() {
703+
signature = opentx_wit.build_opentx_sig(open_sig_data, signature);
704+
} else {
705+
return Err(ScriptSignError::OpenTxError(
706+
OpenTxError::InputListConfigMissing,
707+
));
708+
}
698709
}
699710
let lock = Self::build_witness_lock(current_witness.lock(), signature)?;
700711
current_witness = current_witness.as_builder().lock(Some(lock).pack()).build();
@@ -830,9 +841,14 @@ impl ScriptSigner for OmniLockScriptSigner {
830841
} else {
831842
WitnessArgs::from_slice(witness_data.as_ref())?
832843
};
833-
834-
if let Some(opentx_wit) = self.config.get_opentx_input() {
835-
signature = opentx_wit.build_opentx_sig(open_sig_data, signature);
844+
if self.config.is_opentx_mode() {
845+
if let Some(opentx_wit) = self.config.get_opentx_input() {
846+
signature = opentx_wit.build_opentx_sig(open_sig_data, signature);
847+
} else {
848+
return Err(ScriptSignError::OpenTxError(
849+
OpenTxError::InputListConfigMissing,
850+
));
851+
}
836852
}
837853
let lock = Self::build_witness_lock(current_witness.lock(), signature)?;
838854

0 commit comments

Comments
 (0)