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 OPT-IN support for SEP0023 #348

Merged
merged 2 commits into from
Jun 10, 2021
Merged

Add OPT-IN support for SEP0023 #348

merged 2 commits into from
Jun 10, 2021

Conversation

tamirms
Copy link
Contributor

@tamirms tamirms commented Jun 8, 2021

Add opt-in support for SEP 23. SEP23 adds a strkey representation (M-strkeys) for MuxedAccounts.

Fixes #343

@tamirms tamirms requested review from 2opremio and Shaptic June 8, 2021 11:11
Copy link
Contributor

@Shaptic Shaptic left a comment

Choose a reason for hiding this comment

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

I'm not a huge fan of the forced AccountConverter pattern, but it does make for a fairly clean way to switch between muxing support being on/off. Otherwise, just minor comments below.

}


public MuxedAccount encode(String account) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This converts an input account string in both G and M-form into a MuxedAccount with only the G-account representation, right? (that is, forcing the Ed25519 discriminant). A docstring here would be 💯

@@ -47,7 +47,7 @@ public boolean getAuthorize() {
}

@Override
org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() {
org.stellar.sdk.xdr.Operation.OperationBody toOperationBody(AccountConverter accountConverter) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Forcing this parameter for operations that don't support muxed accounts is a little awkward to me as an API consumer, but I'm not familiar enough with Java patterns to suggest alternatives.

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 is only used internally. any method which does not have a public modifier is only visible within the SDK.

I just pushed another commit which ensures that, for all public methods that handle account strings, we have two implementations: one which allows you to provide your own account converter and another which uses AccountConverter.disableMuxed() by default

checkNotNull(sourceAccount, "sourceAccount cannot be null");
mSourceAccount = sourceAccount;
public Builder(AccountConverter accountConverter, TransactionBuilderAccount sourceAccount, Network network) {
mAccountConverter = checkNotNull(accountConverter, "accountConverter cannot be null");
Copy link
Contributor

@Shaptic Shaptic Jun 8, 2021

Choose a reason for hiding this comment

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

Maybe a default of null to a non-muxed AccountConverter (since we want opt-in) would be more convenient here as an SDK consumer?

Comment on lines +77 to +78
String source = "MA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVAAAAAAAAAAAAAJLK";
String destination = "MDQNY3PBOJOKYZSRMK2S7LHHGWZIUISD4QORETLMXEWXBI7KFZZMKAAAAAAMV7V2XYGQO";
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have a test case mixing muxed and non-muxed addresses in the same operation.

@@ -84,8 +84,8 @@ public void testNewChallengeRejectsMuxedClientAccount() throws InvalidSep10Chall
timeBounds
);
fail();
} catch (FormatException e) {
assertEquals("Version byte is invalid", e.getMessage());
} catch (InvalidSep10ChallengeException e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this an odd exception for this scenario?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

a sep10 challenge can only be generated using non-muxed accounts. Hence InvalidSep10ChallengeException is thrown when trying to validate a challenge token which has a muxed account

return StrKey.encodeStellarMuxedAccount(account);
}

return StrKey.encodeStellarAccountId(StrKey.muxedAccountToAccountId(account));
Copy link
Contributor

Choose a reason for hiding this comment

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

Just noting here that this is the same behavior as in the JS SDK: force a fully-muxed account to a G-address when enableMuxed = false ✔️

@tamirms tamirms merged commit 67b2690 into master Jun 10, 2021
@tamirms tamirms deleted the opt-in-muxed branch June 10, 2021 07:38
tamirms added a commit that referenced this pull request Jan 7, 2022
Previously, in #348 we added opt in support for muxed.
But, by default, we rendered muxed accounts in their non muxed encoding.
We are now changing the default behavior so that muxed accounts are rendered using ther 'M' address encoding.
tamirms added a commit that referenced this pull request Jan 10, 2022
Previously, in #348 we added opt in support for muxed.
But, by default, we rendered muxed accounts in their non muxed encoding.
We are now changing the default behavior so that muxed accounts are rendered using ther 'M' address encoding.
tamirms added a commit that referenced this pull request Jan 10, 2022
* Support muxed accounts by default.

Previously, in #348 we added opt in support for muxed.
But, by default, we rendered muxed accounts in their non muxed encoding.
We are now changing the default behavior so that muxed accounts are rendered using ther 'M' address encoding.
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.

Add OPT-IN support for SEP0023 (Muxed Accounts M-strkeys)
2 participants