Updated on 2026-08-14
This commit is contained in:
parent
cdc2a7f9ca
commit
6fd0284a58
167 changed files with 33 additions and 12998 deletions
|
|
@ -6,8 +6,6 @@ import android.util.Log;
|
|||
|
||||
import com.ripple.core.coretypes.AccountID;
|
||||
import com.ripple.core.coretypes.uint.UInt32;
|
||||
import com.ripple.core.types.known.tx.signed.SignedTransaction;
|
||||
import com.ripple.core.types.known.tx.txns.Payment;
|
||||
import com.ripple.crypto.ecdsa.ECDSASignature;
|
||||
import com.ripple.encodings.addresses.Addresses;
|
||||
import com.ripple.utils.HashUtils;
|
||||
|
|
@ -26,10 +24,6 @@ import com.tangem.util.CryptoUtil;
|
|||
import com.tangem.util.DecimalDigitsInputFilter;
|
||||
import com.tangem.wallet.R;
|
||||
|
||||
import org.spongycastle.asn1.ASN1EncodableVector;
|
||||
import org.spongycastle.asn1.ASN1Integer;
|
||||
import org.spongycastle.asn1.DERSequence;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
|
|
@ -364,7 +358,7 @@ public class XrpEngine extends CoinEngine {
|
|||
|
||||
fee = Long.toString(convertToInternalAmount(feeValue).longValueExact());
|
||||
|
||||
Payment payment = new Payment();
|
||||
XrpPayment payment = new XrpPayment();
|
||||
|
||||
// Put `as` AccountID field Account, `Object` o
|
||||
payment.as(AccountID.Account, coinData.getWallet());
|
||||
|
|
@ -373,7 +367,7 @@ public class XrpEngine extends CoinEngine {
|
|||
payment.as(UInt32.Sequence, coinData.getSequence());
|
||||
payment.as(com.ripple.core.coretypes.Amount.Fee, fee);
|
||||
|
||||
SignedTransaction signedTx = payment.prepare(canonisePubKey(ctx.getCard().getWalletPublicKeyRar()));
|
||||
XrpSignedTransaction signedTx = payment.prepare(canonisePubKey(ctx.getCard().getWalletPublicKeyRar()));
|
||||
|
||||
return new SignTask.TransactionToSign() {
|
||||
|
||||
|
|
@ -449,8 +443,7 @@ public class XrpEngine extends CoinEngine {
|
|||
throw new Exception("Invalid wallet address in answer!");
|
||||
}
|
||||
coinData.setBalanceConfirmed(Long.parseLong(rippleResponse.getResult().getAccount_data().getBalance()));
|
||||
}
|
||||
else if (rippleResponse.getResult().getError_code().equals(19)) // "Account not found"
|
||||
} else if (rippleResponse.getResult().getError_code().equals(19)) // "Account not found"
|
||||
coinData.setAccountNotFound(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
package com.tangem.domain.wallet.xrp;
|
||||
|
||||
import com.ripple.core.types.known.tx.txns.Payment;
|
||||
|
||||
public class XrpPayment extends Payment {
|
||||
|
||||
public XrpPayment() {
|
||||
super();
|
||||
}
|
||||
|
||||
public XrpSignedTransaction prepare(byte[] pubKeyBytes) {
|
||||
XrpSignedTransaction tx = XrpSignedTransaction.fromTx(this);
|
||||
tx.prepare(pubKeyBytes);
|
||||
return tx;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
package com.tangem.domain.wallet.xrp;
|
||||
|
||||
import com.ripple.core.coretypes.Amount;
|
||||
import com.ripple.core.coretypes.Blob;
|
||||
import com.ripple.core.coretypes.STObject;
|
||||
import com.ripple.core.coretypes.hash.HalfSha512;
|
||||
import com.ripple.core.coretypes.hash.prefixes.HashPrefix;
|
||||
import com.ripple.core.coretypes.uint.UInt32;
|
||||
import com.ripple.core.serialized.BytesList;
|
||||
import com.ripple.core.serialized.MultiSink;
|
||||
import com.ripple.core.types.known.tx.Transaction;
|
||||
import com.ripple.core.types.known.tx.signed.SignedTransaction;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class XrpSignedTransaction extends SignedTransaction {
|
||||
private XrpSignedTransaction(Transaction of) {
|
||||
txn = (Transaction) STObject.fromBytes(of.toBytes());
|
||||
}
|
||||
|
||||
protected XrpSignedTransaction() {
|
||||
}
|
||||
|
||||
public static XrpSignedTransaction fromTx(Transaction tx) {
|
||||
return new XrpSignedTransaction(tx);
|
||||
}
|
||||
|
||||
public void prepare(byte[] pubKeyBytes) {
|
||||
prepare(pubKeyBytes, null, null, null);
|
||||
}
|
||||
|
||||
public void prepare(byte[] pubKeyBytes,
|
||||
Amount fee,
|
||||
UInt32 Sequence,
|
||||
UInt32 lastLedgerSequence) {
|
||||
|
||||
Blob pubKey = new Blob(pubKeyBytes);
|
||||
|
||||
// This won't always be specified
|
||||
if (lastLedgerSequence != null) {
|
||||
txn.put(UInt32.LastLedgerSequence, lastLedgerSequence);
|
||||
}
|
||||
if (Sequence != null) {
|
||||
txn.put(UInt32.Sequence, Sequence);
|
||||
}
|
||||
if (fee != null) {
|
||||
txn.put(Amount.Fee, fee);
|
||||
}
|
||||
|
||||
txn.signingPubKey(pubKey);
|
||||
|
||||
if (Transaction.CANONICAL_FLAG_DEPLOYED) {
|
||||
txn.setCanonicalSignatureFlag();
|
||||
}
|
||||
|
||||
txn.checkFormat();
|
||||
signingData = txn.signingData();
|
||||
if (previousSigningData != null && Arrays.equals(signingData, previousSigningData)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void addSign(byte[] signature) {
|
||||
try {
|
||||
txn.txnSignature(new Blob(signature));
|
||||
|
||||
BytesList blob = new BytesList();
|
||||
HalfSha512 id = HalfSha512.prefixed256(HashPrefix.transactionID);
|
||||
|
||||
txn.toBytesSink(new MultiSink(blob, id));
|
||||
tx_blob = blob.bytesHex();
|
||||
hash = id.finish();
|
||||
} catch (Exception e) {
|
||||
// electric paranoia
|
||||
previousSigningData = null;
|
||||
throw new RuntimeException(e);
|
||||
} /*else {*/
|
||||
previousSigningData = signingData;
|
||||
// }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue