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

feat(maya): add destination address screen #1248

Merged
merged 19 commits into from
Jan 26, 2024

Conversation

HashEngineering
Copy link
Collaborator

@HashEngineering HashEngineering commented Jan 17, 2024

Issue being fixed or feature implemented

Add an address input screen that handles the selected currency.

AddressInputFragment was moved to common to serve as a base class for Address Input Screens.

Related PR's and Dependencies

Screenshots / Videos

How Has This Been Tested?

  • QA (Mobile Team)

Checklist:

  • I have performed a self-review of my own code and added comments where necessary
  • I have added or updated relevant unit/integration/functional/e2e tests

@HashEngineering HashEngineering self-assigned this Jan 17, 2024
@HashEngineering HashEngineering changed the base branch from master to feature-maya January 17, 2024 16:33
@HashEngineering HashEngineering marked this pull request as ready for review January 25, 2024 17:17
Comment on lines +24 to +26
open class AddressParser(pattern: String, val params: NetworkParameters?) {
companion object {
val PATTERN_BITCOIN_ADDRESS = "[${Base58.ALPHABET.joinToString(separator = "")}]{20,40}"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was moved from wallet but changed to a class that can handle different patterns.

Comment on lines +70 to +72
protected open fun verifyAddress(addressCandidate: String) {
params?.let { Address.fromString(params, addressCandidate) }
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is open so subclasses can verify the address in different ways besides what works for Dash.

Comment on lines +28 to +36
/**
* <p>Implementation of the Bech32 encoding.</p>
*
* <p>See <a href="https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki">BIP350</a> and
* <a href="https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki">BIP173</a> for details.</p>
*/
public class Bech32 {
/** The Bech32 character set for encoding. */
private static final String CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this was taken from bitcoinj 0.16.x. Newer bitcoin addresses use this format along with many other currencies.

Comment on lines +24 to +30
class BitcoinAddressParser(params: NetworkParameters) : AddressParser(PATTERN_BITCOIN_ADDRESS, params) {
private val bech32Parser = Bech32AddressParser(39, 59, params)

override fun exactMatch(inputText: String): Boolean {
return super.exactMatch(inputText) || bech32Parser.exactMatch(inputText)
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Bitcoin addressed include Base58 and Bech32 formats.

Comment on lines -96 to 94
public final class ScanActivity extends LockScreenActivity
public final class ScanActivity extends SecureActivity
implements SurfaceTextureListener, ActivityCompat.OnRequestPermissionsResultCallback {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ScanActivity was translated into Kotlin in #1248

Comment on lines -92 to +101
builder.append(script.getToAddress(Constants.NETWORK_PARAMETERS));
builder.append(script.getToAddress(params));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Remove dependency on the global NETWORK_PARAMETERS

return toString(MainNetParams.get());
}

public String toString(NetworkParameters params) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

specifying MainNetParams can result in incorrect display of addresses

Copy link
Member

@Syn-McJ Syn-McJ left a comment

Choose a reason for hiding this comment

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

Looks great

@HashEngineering HashEngineering merged commit 12291bb into feature-maya Jan 26, 2024
2 checks passed
@Syn-McJ Syn-McJ deleted the feature-maya-dest-address branch February 9, 2024 04:21
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