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

Add utility methods for multisig script #30

Merged
merged 2 commits into from
Mar 4, 2021

Conversation

Yamaguchi
Copy link
Contributor

Add utility methods for multisig script.

  • Script::get_multisig_pubkeys
  • Script::is_multisig
  • Script::type_string

@Yamaguchi
Copy link
Contributor Author

These methods is used esplora-tapyrus(chaintope/esplora-tapyrus#9)

pub fn get_multisig_pubkeys(&self) -> Result<(i32, Vec<PublicKey>), MultisigError> {
if !self.is_multisig() {
return Err(MultisigError::IsNotMultisig);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this check, all later InvalidRequiredSigCount and InvalidPublicKey errors are also IsNotMultisig.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove InvalidRequiredSigCount and InvalidPublicKey

} else {
"nonstandard".to_string()
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum AddressType is defined in src/util/address.rs and Display trait for string notation is implemented. How about extends it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method(type_string) is also intended to return script types including non-p2pkh or non-p2sh such as 'OP_RETURN ...'., while AddressType can not be defined for non-standard or op_return script.

Tapyrus-Core implementation: https://github.com/chaintope/tapyrus-core/blob/0a69fa72d394d7cf9119a718f8385f88c5323866/src/script/standard.cpp#L32

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(But we should update AddressType later because AddressType doesnt include colored coin address)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for non-standard or op_return script.

Right. Is it a script type rather than an address type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add struct ScriptType (cf188c4)

@Yamaguchi Yamaguchi force-pushed the feature/multisig_methods branch from 4d30674 to c1dfce2 Compare March 1, 2021 06:25
@Yamaguchi Yamaguchi requested a review from azuchi March 1, 2021 07:26
@azuchi azuchi merged commit 4dd181a into chaintope:master Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants