Skip to content

Commit

Permalink
Merge pull request #5639 from jmacxx/litecoin_account_segwit
Browse files Browse the repository at this point in the history
Allow LTC accounts to use segwit addresses
  • Loading branch information
ripcurlx authored Aug 1, 2021
2 parents 6cc4a81 + c7c660e commit 5bcc207
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions assets/src/main/java/bisq/asset/coins/Litecoin.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,20 @@

package bisq.asset.coins;

import bisq.asset.Base58AddressValidator;
import bisq.asset.BitcoinAddressValidator;
import bisq.asset.Coin;
import bisq.asset.NetworkParametersAdapter;

public class Litecoin extends Coin {
public Litecoin() {
super("Litecoin", "LTC", new Base58AddressValidator(new LitecoinMainNetParams()), Network.MAINNET);
super("Litecoin", "LTC", new BitcoinAddressValidator(new LitecoinMainNetParams()), Network.MAINNET);
}

public static class LitecoinMainNetParams extends NetworkParametersAdapter {
public LitecoinMainNetParams() {
this.addressHeader = 48;
this.p2shHeader = 5;
this.p2shHeader = 50;
this.segwitAddressHrp = "ltc";
}
}
}
4 changes: 4 additions & 0 deletions assets/src/test/java/bisq/asset/coins/LitecoinTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ public void testValidAddresses() {
assertValidAddress("Lg3PX8wRWmApFCoCMAsPF5P9dPHYQHEWKW");
assertValidAddress("LTuoeY6RBHV3n3cfhXVVTbJbxzxnXs9ofm");
assertValidAddress("LgfapHEPhZbRF9pMd5WPT35hFXcZS1USrW");
assertValidAddress("ltc1qxtm55gultqzhqzl2p3ks50hg2478y3hehuj6dz");
assertValidAddress("MGEW4aba3tnrVtVhGcmoqqHaLt5ymPSLPi");
}

@Test
public void testInvalidAddresses() {
assertInvalidAddress("1LgfapHEPhZbRF9pMd5WPT35hFXcZS1USrW");
assertInvalidAddress("LgfapHEPhZbdRF9pMd5WPT35hFXcZS1USrW");
assertInvalidAddress("LgfapHEPhZbRF9pMd5WPT35hFXcZS1USrW#");
assertInvalidAddress("bc1qxtm55gultqzhqzl2p3ks50hg2478y3hehuj6dz");
assertInvalidAddress("MGEW4aba3tnrVtVhGcmoqqHaLt5ymPSLPW");
}
}

0 comments on commit 5bcc207

Please sign in to comment.