-
Notifications
You must be signed in to change notification settings - Fork 169
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
Conversation
open class AddressParser(pattern: String, val params: NetworkParameters?) { | ||
companion object { | ||
val PATTERN_BITCOIN_ADDRESS = "[${Base58.ALPHABET.joinToString(separator = "")}]{20,40}" |
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 was moved from wallet
but changed to a class that can handle different patterns.
protected open fun verifyAddress(addressCandidate: String) { | ||
params?.let { Address.fromString(params, addressCandidate) } | ||
} |
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 is open so subclasses can verify the address in different ways besides what works for Dash.
/** | ||
* <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"; |
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 was taken from bitcoinj
0.16.x. Newer bitcoin addresses use this format along with many other currencies.
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) | ||
} | ||
|
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.
Bitcoin addressed include Base58 and Bech32 formats.
public final class ScanActivity extends LockScreenActivity | ||
public final class ScanActivity extends SecureActivity | ||
implements SurfaceTextureListener, ActivityCompat.OnRequestPermissionsResultCallback { |
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.
ScanActivity was translated into Kotlin in #1248
builder.append(script.getToAddress(Constants.NETWORK_PARAMETERS)); | ||
builder.append(script.getToAddress(params)); |
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.
Remove dependency on the global NETWORK_PARAMETERS
return toString(MainNetParams.get()); | ||
} | ||
|
||
public String toString(NetworkParameters params) { |
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.
specifying MainNetParams
can result in incorrect display of addresses
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.
Looks great
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?
Checklist: