mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 15:00:30 +01:00
Merge branch 'ZencashOfficial-Development' into Development
Merge Zencash PR 919
This commit is contained in:
commit
0087e19db9
2 changed files with 50 additions and 0 deletions
|
@ -30,6 +30,7 @@ import io.bisq.gui.util.validation.params.PNCParams;
|
|||
import io.bisq.gui.util.validation.params.PivxParams;
|
||||
import io.bisq.gui.util.validation.params.btc.BtcMainNetParams;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bitcoinj.core.Base58;
|
||||
import org.bitcoinj.core.Address;
|
||||
import org.bitcoinj.core.AddressFormatException;
|
||||
import org.bitcoinj.params.MainNetParams;
|
||||
|
@ -262,6 +263,38 @@ public final class AltCoinAddressValidator extends InputValidator {
|
|||
} else {
|
||||
return regexTestFailed;
|
||||
}
|
||||
case "ZEN":
|
||||
try {
|
||||
// Get the non Base58 form of the address and the bytecode of the first two bytes
|
||||
byte [] byteAddress = Base58.decodeChecked(input);
|
||||
int version0 = byteAddress[0] & 0xFF;
|
||||
int version1 = byteAddress[1] & 0xFF;
|
||||
|
||||
// We only support public ("zn" (0x20,0x89), "t1" (0x1C,0xB8))
|
||||
// and multisig ("zs" (0x20,0x96), "t3" (0x1C,0xBD)) addresses
|
||||
|
||||
// Fail for private addresses
|
||||
if (version0 == 0x16 && version1 == 0x9A) {
|
||||
// Address starts with "zc"
|
||||
return new ValidationResult(false, Res.get("validation.altcoin.zAddressesNotSupported"));
|
||||
}
|
||||
else if (version0 == 0x1C && (version1 == 0xB8 || version1 == 0xBD)) {
|
||||
// "t1" or "t3" address
|
||||
return new ValidationResult(true);
|
||||
}
|
||||
else if (version0 == 0x20 && (version1 == 0x89 || version1 == 0x96)) {
|
||||
// "zn" or "zs" address
|
||||
return new ValidationResult(true);
|
||||
}
|
||||
else {
|
||||
// Unknown Type
|
||||
return new ValidationResult(false);
|
||||
}
|
||||
}
|
||||
catch (AddressFormatException e) {
|
||||
// Unhandled Exception (probably a checksum error)
|
||||
return new ValidationResult(false);
|
||||
}
|
||||
default:
|
||||
log.debug("Validation for AltCoinAddress not implemented yet. currencyCode: " + currencyCode);
|
||||
return validationResult;
|
||||
|
|
|
@ -149,4 +149,21 @@ public class AltCoinAddressValidatorTest {
|
|||
assertFalse(validator.validate("PD57PGdk69yioZ6FD3zFNzVUeJhMMMKti4").isValid);
|
||||
assertFalse(validator.validate("PD57PG").isValid);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testZEN() {
|
||||
AltCoinAddressValidator validator = new AltCoinAddressValidator();
|
||||
validator.setCurrencyCode("ZEN");
|
||||
|
||||
assertTrue(validator.validate("znk62Ey7ptTyHgYLaLDTEwhLF6uN1DXTBfa").isValid);
|
||||
assertTrue(validator.validate("znTqzi5rTXf6KJnX5tLaC5CMGHfeWJwy1c7").isValid);
|
||||
assertTrue(validator.validate("t1V9h2P9n4sYg629Xn4jVDPySJJxGmPb1HK").isValid); // Random address from ZCash blockchain
|
||||
assertTrue(validator.validate("t3Ut4KUq2ZSMTPNE67pBU5LqYCi2q36KpXQ").isValid); // Random address from ZCash blockchain
|
||||
|
||||
assertFalse(validator.validate("zcKffBrza1cirFY47aKvXiV411NZMscf7zUY5bD1HwvkoQvKHgpxLYUHtMCLqBAeif1VwHmMjrMAKNrdCknCVqCzRNizHUq").isValid);
|
||||
assertFalse(validator.validate("AFTqzi5rTXf6KJnX5tLaC5CMGHfeWJwy1c7").isValid);
|
||||
assertFalse(validator.validate("zig-zag").isValid);
|
||||
assertFalse(validator.validate("0123456789").isValid);
|
||||
assertFalse(validator.validate("").isValid);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue