-
Notifications
You must be signed in to change notification settings - Fork 27
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
Create the signature facilities for arbitrary messages #1521
Conversation
d6f20d6
to
517812c
Compare
3eb14dd
to
c7e361e
Compare
address: String, | ||
) -> WRpcResult<SignedArbitraryMessage, N> { | ||
let config = ControllerConfig { in_top_x_mb: 5 }; // irrelevant | ||
let destination = Address::from_str(&self.chain_config, &address) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Address::from_str
function is a bit strange - it calls decode_object
, ignores its result and stores the original string inside Address
, on which you later call decode_object
again.
I suggest to introduce a separate function decode_object_from_str
in Address:
pub fn decode_object_from_str(address: &str, cfg: &ChainConfig) -> Result<T, AddressError> {
let data = encoding::decode(address)?;
// here goes the rest of the body of the current "decode_object"
}
pub fn decode_object(&self, cfg: &ChainConfig) -> Result<T, AddressError> {
Self::decode_object_from_str(&self.address, cfg)
}
and use it here and in similar places below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from_str needs to ensure that the encoding is valid. That's why we do it like that.
common/src/chain/transaction/signature/inputsig/arbitrary_message/mod.rs
Outdated
Show resolved
Hide resolved
common/src/chain/transaction/signature/inputsig/arbitrary_message/mod.rs
Outdated
Show resolved
Hide resolved
common/src/chain/transaction/signature/inputsig/arbitrary_message/mod.rs
Outdated
Show resolved
Hide resolved
3c22d3d
to
b8c7dc7
Compare
No description provided.