Updated on 2026-08-14
This commit is contained in:
parent
0193926e46
commit
9f9c5db55e
14 changed files with 581 additions and 476 deletions
|
|
@ -267,8 +267,8 @@ public final class BCHUtils {
|
|||
ArrayList<UnspentOutputInfo> unspentOutputs = new ArrayList<>();
|
||||
|
||||
for (BtcData.UnspentTransaction current : rawTxList) {
|
||||
byte[] rawTxByte = BCHUtils.fromHex(current.Raw);
|
||||
if (rawTxByte == null || current.Raw.isEmpty()) {
|
||||
byte[] rawTxByte = BCHUtils.fromHex(current.script);
|
||||
if (rawTxByte == null || current.script.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -190,8 +190,8 @@ public final class BTCUtils {
|
|||
ArrayList<UnspentOutputInfo> unspentOutputs = new ArrayList<>();
|
||||
|
||||
for (BtcData.UnspentTransaction current : rawTxList) {
|
||||
byte[] rawTxByte = BTCUtils.fromHex(current.Raw);
|
||||
if (rawTxByte == null || current.Raw.isEmpty()) {
|
||||
byte[] rawTxByte = BTCUtils.fromHex(current.script);
|
||||
if (rawTxByte == null || current.script.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -591,8 +591,8 @@ public class BtcCashEngine extends CoinEngine {
|
|||
JSONObject jsUnspent = jsUnspentArray.getJSONObject(i);
|
||||
BtcData.UnspentTransaction trUnspent = new BtcData.UnspentTransaction();
|
||||
trUnspent.txID = jsUnspent.getString("tx_hash");
|
||||
trUnspent.Amount = jsUnspent.getLong("value");
|
||||
trUnspent.Height = jsUnspent.getInt("height");
|
||||
trUnspent.amount = jsUnspent.getLong("value");
|
||||
trUnspent.outputN = jsUnspent.getInt("height");
|
||||
coinData.getUnspentTransactions().add(trUnspent);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
|
|
@ -623,7 +623,7 @@ public class BtcCashEngine extends CoinEngine {
|
|||
String raw = electrumRequest.getResultString();
|
||||
for (BtcData.UnspentTransaction tx : coinData.getUnspentTransactions()) {
|
||||
if (tx.txID.equals(txHash))
|
||||
tx.Raw = raw;
|
||||
tx.script = raw;
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
|||
|
|
@ -17,14 +17,16 @@ public class BtcData extends CoinData {
|
|||
|
||||
private Long balanceConfirmed, balanceUnconfirmed;
|
||||
|
||||
private boolean useBlockcypher = false;
|
||||
|
||||
public String getUnspentInputsDescription() {
|
||||
try {
|
||||
int gatheredUnspents = 0;
|
||||
if( unspentTransactions==null ) return "";
|
||||
for (int i = 0; i < unspentTransactions.size(); i++) {
|
||||
if (unspentTransactions.get(i).Raw != null && unspentTransactions.get(i).Raw.length() > 1) gatheredUnspents++;
|
||||
if (unspentTransactions.get(i).script != null && unspentTransactions.get(i).script.length() > 1) gatheredUnspents++;
|
||||
}
|
||||
return String.valueOf(unspentTransactions.size()) + " unspents (" + String.valueOf(gatheredUnspents) + " received)";
|
||||
return unspentTransactions.size() + " unspents (" + gatheredUnspents + " received)";
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
@ -35,24 +37,24 @@ public class BtcData extends CoinData {
|
|||
|
||||
public static class UnspentTransaction {
|
||||
public String txID;
|
||||
public Long Amount;
|
||||
public Integer Height;
|
||||
public String Raw = "";
|
||||
public Long amount;
|
||||
public Integer outputN;
|
||||
public String script = "";
|
||||
|
||||
public Bundle getAsBundle() {
|
||||
Bundle B = new Bundle();
|
||||
B.putString("txID", txID);
|
||||
B.putLong("Amount", Amount);
|
||||
B.putInt("Height", Height);
|
||||
B.putString("Raw", Raw);
|
||||
B.putLong("Amount", amount);
|
||||
B.putInt("OutputN", outputN);
|
||||
B.putString("Script", script);
|
||||
return B;
|
||||
}
|
||||
|
||||
public void loadFromBundle(Bundle B) {
|
||||
txID = B.getString("txID");
|
||||
Amount = B.getLong("Amount");
|
||||
Height = B.getInt("Height");
|
||||
Raw = B.getString("Raw");
|
||||
amount = B.getLong("Amount");
|
||||
outputN = B.getInt("OutputN");
|
||||
script = B.getString("Script");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -83,6 +85,7 @@ public class BtcData extends CoinData {
|
|||
i++;
|
||||
}
|
||||
}
|
||||
if (B.containsKey("UseBlockcypher")) useBlockcypher = B.getBoolean("UseBlockcypher");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -98,6 +101,7 @@ public class BtcData extends CoinData {
|
|||
}
|
||||
if (balanceConfirmed != null) B.putLong("BalanceConfirmed", balanceConfirmed);
|
||||
if (balanceUnconfirmed != null) B.putLong("BalanceUnconfirmed", balanceUnconfirmed);
|
||||
if (useBlockcypher) B.putBoolean("UseBlockcypher", true);
|
||||
} catch (Exception e) {
|
||||
Log.e("Can't save to bundle ", e.getMessage());
|
||||
}
|
||||
|
|
@ -131,4 +135,11 @@ public class BtcData extends CoinData {
|
|||
return balanceConfirmed != null || balanceUnconfirmed != null;
|
||||
}
|
||||
|
||||
public boolean isUseBlockcypher() {
|
||||
return useBlockcypher;
|
||||
}
|
||||
|
||||
public void setUseBlockcypher(boolean useBlockcypher) {
|
||||
this.useBlockcypher = useBlockcypher;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -22,7 +22,7 @@ public class CardanoData extends CoinData {
|
|||
// int gatheredUnspents = 0;
|
||||
if( unspentOutputs ==null ) return "";
|
||||
// for (int i = 0; i < unspentOutputs.size(); i++) {
|
||||
// if (unspentOutputs.get(i).Raw != null && unspentOutputs.get(i).Raw.length() > 1) gatheredUnspents++;
|
||||
// if (unspentOutputs.get(i).script != null && unspentOutputs.get(i).script.length() > 1) gatheredUnspents++;
|
||||
// }
|
||||
return String.valueOf(unspentOutputs.size()) + " unspents";// (" + String.valueOf(gatheredUnspents) + " received)";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -525,7 +525,7 @@ public class DucatusEngine extends BtcEngine {
|
|||
String txHash = new String(BTCUtils.reverse(CryptoUtil.doubleSha256(BTCUtils.fromHex(raw)))); //TODO: check
|
||||
for (BtcData.UnspentTransaction tx : coinData.getUnspentTransactions()) {
|
||||
if (tx.txID.equals(txHash))
|
||||
tx.Raw = raw;
|
||||
tx.script = raw;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
@ -548,8 +548,8 @@ public class DucatusEngine extends BtcEngine {
|
|||
for (InsightResponse utxo : utxoList) {
|
||||
BtcData.UnspentTransaction trUnspent = new BtcData.UnspentTransaction();
|
||||
trUnspent.txID = utxo.getTxid();
|
||||
trUnspent.Amount = utxo.getSatoshis();
|
||||
trUnspent.Height = utxo.getHeight();
|
||||
trUnspent.amount = utxo.getSatoshis();
|
||||
trUnspent.outputN = utxo.getHeight();
|
||||
coinData.getUnspentTransactions().add(trUnspent);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -336,8 +336,8 @@ public class EosEngine extends CoinEngine {
|
|||
// return address;
|
||||
|
||||
// byte[] csum = Ripemd160.from(pkCompressed).bytes();
|
||||
// csum = Raw.copy(csum, 0, 4);
|
||||
// byte[] addy = Raw.concat(pkCompressed, csum);
|
||||
// csum = script.copy(csum, 0, 4);
|
||||
// byte[] addy = script.concat(pkCompressed, csum);
|
||||
// StringBuffer bf = new StringBuffer("EOS");
|
||||
// bf.append(Base58.encode(addy));
|
||||
// return bf.toString() + " " + address;
|
||||
|
|
|
|||
|
|
@ -2,15 +2,11 @@ package com.tangem.wallet.ltc;
|
|||
|
||||
import android.net.Uri;
|
||||
import android.text.InputFilter;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tangem.data.network.ElectrumRequest;
|
||||
import com.tangem.data.network.ServerApiElectrum;
|
||||
import com.tangem.wallet.BTCUtils;
|
||||
import com.tangem.wallet.BalanceValidator;
|
||||
import com.tangem.wallet.Base58;
|
||||
import com.tangem.wallet.CoinData;
|
||||
import com.tangem.wallet.CoinEngine;
|
||||
import com.tangem.wallet.TangemContext;
|
||||
import com.tangem.wallet.Transaction;
|
||||
import com.tangem.wallet.UnspentOutputInfo;
|
||||
|
|
@ -25,8 +21,6 @@ import com.tangem.util.DecimalDigitsInputFilter;
|
|||
import com.tangem.util.DerEncodingUtil;
|
||||
import com.tangem.wallet.R;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
|
@ -36,7 +30,6 @@ import java.security.NoSuchAlgorithmException;
|
|||
import java.security.NoSuchProviderException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class LtcEngine extends BtcEngine {
|
||||
private static final String TAG = LtcEngine.class.getSimpleName();
|
||||
|
|
@ -402,7 +395,7 @@ public class LtcEngine extends BtcEngine {
|
|||
byte[] pbKey = ctx.getCard().getWalletPublicKey();
|
||||
|
||||
for (BtcData.UnspentTransaction utxo : coinData.getUnspentTransactions()) {
|
||||
unspentOutputs.add(new UnspentOutputInfo(BTCUtils.fromHex(utxo.txID), new Transaction.Script(BTCUtils.fromHex(utxo.Raw)), utxo.Amount, utxo.Height, -1, utxo.txID, null));
|
||||
unspentOutputs.add(new UnspentOutputInfo(BTCUtils.fromHex(utxo.txID), new Transaction.Script(BTCUtils.fromHex(utxo.script)), utxo.amount, utxo.outputN, -1, utxo.txID, null));
|
||||
}
|
||||
|
||||
long fullAmount = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue