Updated on 2026-08-14
This commit is contained in:
parent
a731ddba76
commit
f95c6c4fe8
3 changed files with 43 additions and 1 deletions
|
|
@ -319,8 +319,13 @@ public class BtcEngine extends CoinEngine {
|
|||
}
|
||||
|
||||
public Uri getShareWalletURI(TangemCard mCard) {
|
||||
if (mCard.getDenomination() != null) {
|
||||
return Uri.parse("bitcoin:" + mCard.getWallet() + "?amount=" + BTCUtils.satoshiToBtc(mCard.getDenomination()));
|
||||
} else {
|
||||
return Uri.parse("bitcoin:" + mCard.getWallet());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean CheckAmountValie(TangemCard mCard, String amountValue, String feeValue, Long minFeeInInternalUnits) {
|
||||
Long fee = null;
|
||||
|
|
|
|||
|
|
@ -1122,6 +1122,19 @@ public class TangemCard {
|
|||
offlineBalance = null;
|
||||
}
|
||||
|
||||
private byte[] Denomination;
|
||||
|
||||
public void setDenomination(byte[] denomination) {
|
||||
this.Denomination = denomination;
|
||||
}
|
||||
|
||||
public byte[] getDenomination() {
|
||||
return Denomination;
|
||||
}
|
||||
|
||||
public void clearDenomination() {
|
||||
Denomination = null;
|
||||
}
|
||||
public void setError(String error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
|
@ -1206,6 +1219,8 @@ public class TangemCard {
|
|||
|
||||
if (getOfflineBalance() != null) B.putByteArray("OfflineBalance", getOfflineBalance());
|
||||
|
||||
if (getDenomination() != null) B.putByteArray("Denomination", getDenomination());
|
||||
|
||||
if (getIssuerData() != null && getIssuerDataSignature() != null) {
|
||||
B.putByteArray("IssuerData", getIssuerData());
|
||||
B.putByteArray("IssuerDataSignature", getIssuerDataSignature());
|
||||
|
|
@ -1288,6 +1303,9 @@ public class TangemCard {
|
|||
if (B.containsKey("OfflineBalance")) setOfflineBalance(B.getByteArray("OfflineBalance"));
|
||||
else clearOfflineBalance();
|
||||
|
||||
if (B.containsKey("Denomination")) setDenomination(B.getByteArray("Denomination"));
|
||||
else clearDenomination();
|
||||
|
||||
if (B.containsKey("IssuerData"))
|
||||
setIssuerData(B.getByteArray("IssuerData"), B.getByteArray("IssuerDataSignature"));
|
||||
else setIssuerData(null, null);
|
||||
|
|
@ -1360,3 +1378,4 @@ public class TangemCard {
|
|||
|
||||
public EncryptionMode encryptionMode = EncryptionMode.None;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,9 +15,12 @@ import com.tangem.domain.wallet.UnspentOutputInfo;
|
|||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.math.RoundingMode;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
|
@ -100,6 +103,20 @@ public final class BTCUtils {
|
|||
return new String(hexChars);
|
||||
}
|
||||
|
||||
public static String satoshiToBtc(byte[] satoshi)
|
||||
{
|
||||
satoshi = reverse(satoshi);
|
||||
|
||||
BigInteger num = new BigInteger(1, satoshi);
|
||||
BigDecimal dec = new BigDecimal(num);
|
||||
dec = dec.setScale(8, RoundingMode.DOWN);
|
||||
dec = dec.divide(new BigDecimal("100000000"));
|
||||
|
||||
String pattern = "#0.00000000";
|
||||
DecimalFormat myFormatter = new DecimalFormat(pattern);
|
||||
String output = myFormatter.format(dec);
|
||||
return output;
|
||||
}
|
||||
|
||||
public static byte[] buildTXForSign(String myAddress, String outputAddress, String changeAddress, ArrayList<UnspentOutputInfo> unspentOutputs, int currentInputPos, long amount, long change) throws BitcoinException, IOException {
|
||||
byte[] myScript = Transaction.Script.buildOutput(myAddress).bytes;
|
||||
|
|
@ -491,3 +508,4 @@ public final class BTCUtils {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue