Skip to content

Commit

Permalink
Merge pull request #5820 from jmacxx/grin_slatepack
Browse files Browse the repository at this point in the history
Changes required for GRIN re-listing
  • Loading branch information
ripcurlx authored Nov 11, 2021
2 parents 284eaf2 + 5bf7bba commit de5805c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 117 deletions.
102 changes: 0 additions & 102 deletions assets/src/main/java/bisq/asset/GrinAddressValidator.java

This file was deleted.

29 changes: 27 additions & 2 deletions assets/src/main/java/bisq/asset/coins/Grin.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,39 @@

package bisq.asset.coins;

import bisq.asset.AddressValidationResult;
import bisq.asset.AddressValidator;
import bisq.asset.AltCoinAccountDisclaimer;
import bisq.asset.Coin;
import bisq.asset.GrinAddressValidator;

import org.bitcoinj.core.AddressFormatException;
import org.bitcoinj.core.Bech32;

@AltCoinAccountDisclaimer("account.altcoin.popup.grin.msg")
public class Grin extends Coin {

static String coinName = "Grin";

public Grin() {
super("Grin", "GRIN", new GrinAddressValidator());
super(coinName, coinName.toUpperCase(), new GrinAddressValidator());
}

public static class GrinAddressValidator implements AddressValidator {

@Override
public AddressValidationResult validate(String address) {
try {
Bech32.Bech32Data bechData = Bech32.decode(address);
if (!bechData.hrp.equals(coinName.toLowerCase())) {
return AddressValidationResult.invalidAddress(String.format("invalid address prefix %x", bechData.hrp));
}
if (bechData.data.length != 52) {
return AddressValidationResult.invalidAddress(String.format("invalid address length %x", bechData.data.length));
}
return AddressValidationResult.validAddress();
} catch (AddressFormatException e) {
return AddressValidationResult.invalidStructure();
}
}
}
}
26 changes: 19 additions & 7 deletions assets/src/test/java/bisq/asset/coins/GrinTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,29 @@ public GrinTest() {

@Test
public void testValidAddresses() {
// grinbox
assertValidAddress("gVvk7rLBg3r3qoWYL3VsREnBbooT7nynxx5HtDvUWCJUaNCnddvY");
assertValidAddress("grinbox://gVtWzX5NTLCBkyNV19QVdnLXue13heAVRD36sfkGD6xpqy7k7e4a");
assertValidAddress("gVw9TWimGFXRjoDXWhWxeNQbu84ZpLkvnenkKvA5aJeDo31eM5tC@somerelay.com");
assertValidAddress("gVw9TWimGFXRjoDXWhWxeNQbu84ZpLkvnenkKvA5aJeDo31eM5tC@somerelay.com:1220");
assertValidAddress("grinbox://gVwjSsYW5vvHpK4AunJ5piKhhQTV6V3Jb818Uqs6PdC3SsB36AsA@somerelay.com");
assertValidAddress("grinbox://gVwjSsYW5vvHpK4AunJ5piKhhQTV6V3Jb818Uqs6PdC3SsB36AsA@somerelay.com:1220");
// valid slatepack addresses
assertValidAddress("grin1ephxt0u33rz9zpl7exer2awfr9s9ae28qsx7908q2zq03uv3sj7suqdule");
assertValidAddress("grin1wwg5k80qje0lw32ldttgl52lew0ucmv64zux27pzanl0a2ku85ps5gxafa");
assertValidAddress("grin1mdxxaz8g5zc4fhqcvcu79c0sp3md9j2f6tt5cxde78scjatkh3zqzrgl9r");
assertValidAddress("grin17whxsfzj3su0rtpd3hkcjt3hlatvc89dpc9syvrmq2shhnhc9f6sehqe3x");
assertValidAddress("grin1cq636ment795xn68knzu0ewp73f3zdlgv6dsqv8x7vf2v0j4ek5sk6nmk3");
assertValidAddress("grin1wm78wjsf2ws507hea4zqrcywxltjwhtgfrwzhdrr9l80l7tpz5fsj58lk0");
assertValidAddress("grin1jezf3lkcexvj3ydjwanan6khs42fr4036guh0c4vkc04fyxarl6svjzuuh");
}

@Test
public void testInvalidAddresses() {
// invalid slatepack address (bech32 format invalid)
assertInvalidAddress("grin1p4fuklglxqsgg602hu4c4jl4aunu5tynyf4lkg96ezh3jefzpy6swshp5x"); // from 0015-slatepack.md#slatepackaddress

// grinbox
assertInvalidAddress("gVvk7rLBg3r3qoWYL3VsREnBbooT7nynxx5HtDvUWCJUaNCnddvY");
assertInvalidAddress("grinbox://gVtWzX5NTLCBkyNV19QVdnLXue13heAVRD36sfkGD6xpqy7k7e4a");
assertInvalidAddress("gVw9TWimGFXRjoDXWhWxeNQbu84ZpLkvnenkKvA5aJeDo31eM5tC@somerelay.com");
assertInvalidAddress("gVw9TWimGFXRjoDXWhWxeNQbu84ZpLkvnenkKvA5aJeDo31eM5tC@somerelay.com:1220");
assertInvalidAddress("grinbox://gVwjSsYW5vvHpK4AunJ5piKhhQTV6V3Jb818Uqs6PdC3SsB36AsA@somerelay.com");
assertInvalidAddress("grinbox://gVwjSsYW5vvHpK4AunJ5piKhhQTV6V3Jb818Uqs6PdC3SsB36AsA@somerelay.com:1220");

// valid IP:port addresses but not supported in Bisq
assertInvalidAddress("0.0.0.0:8080");
assertInvalidAddress("173.194.34.134:8080");
Expand Down
10 changes: 4 additions & 6 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1729,15 +1729,13 @@ account.altcoin.popup.XZC.msg=When using Zcoin you can only use the transparent
the untraceable addresses, because the mediator or arbitrator would not be able to verify the transaction with untraceable addresses at a block explorer.
# suppress inspection "UnusedProperty"
account.altcoin.popup.grin.msg=GRIN requires an interactive process between the sender and receiver to create the \
transaction. Be sure to follow the instructions from the GRIN project web page to reliably send and receive GRIN \
(the receiver needs to be online or at least be online during a certain time frame). \n\n\
Bisq supports only the Grinbox (Wallet713) wallet URL format. \n\n\
transaction. Be sure to follow the instructions from the GRIN project web page [HYPERLINK:https://grin.mw] to reliably send and receive GRIN. \
More information on transacting GRIN can be found here [HYPERLINK:https://docs.grin.mw/about-grin/transactions/].\n\n\
The GRIN sender is required to provide proof that they have sent GRIN successfully. If the wallet cannot provide that proof, a \
potential dispute will be resolved in favor of the GRIN receiver. Please be sure that you use the \
latest Grinbox software which supports the transaction proof and that you understand the process of transferring and \
latest GRIN software which supports the transaction proof and that you understand the process of transferring and \
receiving GRIN as well as how to create the proof. \n\n\
See https://github.com/vault713/wallet713/blob/master/docs/usage.md#transaction-proofs-grinbox-only for more \
information about the Grinbox proof tool.
See [HYPERLINK:https://bisq.wiki/Trading_GRIN] for more information about trading GRIN on Bisq.
# suppress inspection "UnusedProperty"
account.altcoin.popup.beam.msg=BEAM requires an interactive process between the sender and receiver to create the \
transaction. \n\n\
Expand Down

0 comments on commit de5805c

Please sign in to comment.