Updated on 2026-08-14
This commit is contained in:
parent
d36c77d0ac
commit
3c06fb5644
10 changed files with 215 additions and 0 deletions
8
app/src/main/java/com/tangem/domain/BitcoinCashNode.kt
Normal file
8
app/src/main/java/com/tangem/domain/BitcoinCashNode.kt
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
package com.tangem.domain
|
||||
|
||||
enum class BitcoinCashNode(val host: String, val port: Int) {
|
||||
n1("electrumx-bch.cryptonermal.net", 50001),
|
||||
n2("abc1.hsmiths.com", 60001),
|
||||
n3("electrum.imaginary.cash", 50001),
|
||||
n4("35.157.238.5", 51001),
|
||||
}
|
||||
13
app/src/main/java/com/tangem/domain/LitecoinNode.kt
Normal file
13
app/src/main/java/com/tangem/domain/LitecoinNode.kt
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package com.tangem.domain
|
||||
|
||||
enum class LitecoinNode(val host: String, val port: Int) {
|
||||
n1("ltc.rentonisk.com", 50001),
|
||||
n2("backup.electrum-ltc.org", 50001),
|
||||
n3("node.ispol.sk", 50003),
|
||||
n4("electrum-ltc.wilv.in", 50001),
|
||||
n5("ltc01.knas.systems", 50003),
|
||||
n6("electrumx.nmdps.net", 9433),
|
||||
n7("e-3.claudioboxx.com", 50003),
|
||||
n8("electrum.ltc.xurious.com", 50001),
|
||||
n9("e-1.claudioboxx.com", 50003),
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.tangem.domain.wallet.BitcoinCash;
|
||||
|
||||
// Helper class for CashAddr
|
||||
|
||||
public class BitcoinCashAddressDecodedParts {
|
||||
|
||||
String prefix;
|
||||
|
||||
BitcoinCashAddressType addressType;
|
||||
|
||||
byte[] hash;
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public BitcoinCashAddressType getAddressType() {
|
||||
return addressType;
|
||||
}
|
||||
|
||||
public void setAddressType(BitcoinCashAddressType addressType) {
|
||||
this.addressType = addressType;
|
||||
}
|
||||
|
||||
public byte[] getHash() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
public void setHash(byte[] hash) {
|
||||
this.hash = hash;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.tangem.domain.wallet.BitcoinCash;
|
||||
|
||||
|
||||
/**
|
||||
* Copyright (c) 2018 Tobias Brandt
|
||||
*
|
||||
* Distributed under the MIT software license, see the accompanying file LICENSE
|
||||
* or http://www.opensource.org/licenses/mit-license.php.
|
||||
*/
|
||||
public enum BitcoinCashAddressType {
|
||||
|
||||
P2PKH((byte) 0), P2SH((byte) 8);
|
||||
|
||||
private final byte versionByte;
|
||||
|
||||
BitcoinCashAddressType(byte versionByte) {
|
||||
this.versionByte = versionByte;
|
||||
}
|
||||
|
||||
public byte getVersionByte() {
|
||||
return versionByte;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
package com.tangem.domain.wallet.BitcoinCash;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2018 Tobias Brandt
|
||||
*
|
||||
* Distributed under the MIT software license, see the accompanying file LICENSE
|
||||
* or http://www.opensource.org/licenses/mit-license.php.
|
||||
*/
|
||||
public class BitcoinCashBase32 {
|
||||
|
||||
public static final String CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
|
||||
|
||||
private static final char[] CHARS = CHARSET.toCharArray();
|
||||
|
||||
private static Map<Character, Integer> charPositionMap;
|
||||
static {
|
||||
charPositionMap = new HashMap<>();
|
||||
for (int i = 0; i < CHARS.length; i++) {
|
||||
charPositionMap.put(CHARS[i], i);
|
||||
}
|
||||
if (charPositionMap.size() != 32) {
|
||||
throw new RuntimeException("The charset must contain 32 unique characters.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a byte array as base32 string. This method assumes that all bytes
|
||||
* are only from 0-31
|
||||
*
|
||||
* @param byteArray
|
||||
* @return
|
||||
*/
|
||||
public static String encode(byte[] byteArray) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
for (int i = 0; i < byteArray.length; i++) {
|
||||
int val = (int) byteArray[i];
|
||||
|
||||
if (val < 0 || val > 31) {
|
||||
throw new RuntimeException("This method assumes that all bytes are only from 0-31. Was: " + val);
|
||||
}
|
||||
|
||||
sb.append(CHARS[val]);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a base32 string back to the byte array representation
|
||||
*
|
||||
* @param base32String
|
||||
* @return
|
||||
*/
|
||||
public static byte[] decode(String base32String) {
|
||||
byte[] bytes = new byte[base32String.length()];
|
||||
|
||||
char[] charArray = base32String.toCharArray();
|
||||
for (int i = 0; i < charArray.length; i++) {
|
||||
Integer position = charPositionMap.get(charArray[i]);
|
||||
if (position == null) {
|
||||
throw new RuntimeException("There seems to be an invalid char: " + charArray[i]);
|
||||
}
|
||||
bytes[i] = (byte) ((int) position);
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package com.tangem.domain.wallet.BitcoinCash;
|
||||
/**
|
||||
* Copyright (c) 2018 Tobias Brandt
|
||||
*
|
||||
* Copyright (c) 2017 Pieter Wuille
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
public class BitcoinCashBitArrayConverter {
|
||||
|
||||
public static byte[] convertBits(byte[] bytes8Bits, int from, int to, boolean strictMode) {
|
||||
int length = (int) (strictMode ? Math.floor((double) bytes8Bits.length * from / to)
|
||||
: Math.ceil((double) bytes8Bits.length * from / to));
|
||||
int mask = ((1 << to) - 1) & 0xff;
|
||||
byte[] result = new byte[length];
|
||||
int index = 0;
|
||||
int accumulator = 0;
|
||||
int bits = 0;
|
||||
for (int i = 0; i < bytes8Bits.length; i++) {
|
||||
byte value = bytes8Bits[i];
|
||||
accumulator = (((accumulator & 0xff) << from) | (value & 0xff));
|
||||
bits += from;
|
||||
while (bits >= to) {
|
||||
bits -= to;
|
||||
result[index] = (byte) ((accumulator >> bits) & mask);
|
||||
++index;
|
||||
}
|
||||
}
|
||||
if (!strictMode) {
|
||||
if (bits > 0) {
|
||||
result[index] = (byte) ((accumulator << (to - bits)) & mask);
|
||||
++index;
|
||||
}
|
||||
} else {
|
||||
if (!(bits < from && ((accumulator << (to - bits)) & mask) == 0)) {
|
||||
throw new RuntimeException("Strict mode was used but input couldn't be converted without padding");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
BIN
app/src/main/res/drawable/card_ru024.png
Normal file
BIN
app/src/main/res/drawable/card_ru024.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 113 KiB |
BIN
app/src/main/res/drawable/card_ru028.png
Normal file
BIN
app/src/main/res/drawable/card_ru028.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 49 KiB |
BIN
app/src/main/res/drawable/card_ru029.png
Normal file
BIN
app/src/main/res/drawable/card_ru029.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 63 KiB |
BIN
app/src/main/res/drawable/card_ru030.png
Normal file
BIN
app/src/main/res/drawable/card_ru030.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 68 KiB |
Loading…
Add table
Add a link
Reference in a new issue