mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-25 12:17:22 +00:00
Fix large balance issues.
This commit is contained in:
committed by
Alex Hart
parent
3554f82ea3
commit
5e8d324860
@@ -5,6 +5,7 @@ import androidx.annotation.NonNull;
|
||||
import org.thoughtcrime.securesms.payments.proto.MobileCoinLedger;
|
||||
import org.whispersystems.signalservice.api.payments.Money;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -18,8 +19,8 @@ public final class MobileCoinLedgerWrapper {
|
||||
private final Balance balance;
|
||||
|
||||
public MobileCoinLedgerWrapper(@NonNull MobileCoinLedger ledger) {
|
||||
Money.MobileCoin fullAmount = Money.picoMobileCoin(ledger.balance);
|
||||
Money.MobileCoin transferableAmount = Money.picoMobileCoin(ledger.transferableBalance);
|
||||
Money.MobileCoin fullAmount = ledger.balance.size() > 0 ? Money.picoMobileCoin(new BigInteger(ledger.balance.toByteArray())) : Money.picoMobileCoin(ledger.deprecatedBalance);
|
||||
Money.MobileCoin transferableAmount = ledger.transferableBalance.size() > 0 ? Money.picoMobileCoin(new BigInteger(ledger.transferableBalance.toByteArray())) : Money.picoMobileCoin(ledger.deprecatedTransferableBalance);
|
||||
|
||||
this.ledger = ledger;
|
||||
this.balance = new Balance(fullAmount, transferableAmount, ledger.asOfTimeStamp);
|
||||
@@ -54,7 +55,7 @@ public final class MobileCoinLedgerWrapper {
|
||||
}
|
||||
|
||||
public @NonNull Money.MobileCoin getValue() {
|
||||
return Money.picoMobileCoin(ownedTXO.amount);
|
||||
return ownedTXO.amount.size() > 0 ? Money.picoMobileCoin(new BigInteger(ownedTXO.amount.toByteArray())) : Money.picoMobileCoin(ownedTXO.deprecatedAmount);
|
||||
}
|
||||
|
||||
public @NonNull ByteString getKeyImage() {
|
||||
|
||||
@@ -165,7 +165,7 @@ public final class Wallet {
|
||||
for (OwnedTxOut txOut : accountSnapshot.getAccountActivity().getAllTokenTxOuts(TokenId.MOB)) {
|
||||
final Amount txOutAmount = txOut.getAmount();
|
||||
MobileCoinLedger.OwnedTXO.Builder txoBuilder = new MobileCoinLedger.OwnedTXO.Builder()
|
||||
.amount(Uint64Util.bigIntegerToUInt64(txOutAmount.getValue()))
|
||||
.amount(ByteString.of(txOutAmount.getValue().toByteArray()))
|
||||
.receivedInBlock(getBlock(txOut.getReceivedBlockIndex(), txOut.getReceivedBlockTimestamp()))
|
||||
.keyImage(ByteString.of(txOut.getKeyImage().getData()))
|
||||
.publicKey(ByteString.of(txOut.getPublicKey().getKeyBytes()));
|
||||
@@ -198,8 +198,8 @@ public final class Wallet {
|
||||
|
||||
builder.spentTxos(spentTxos)
|
||||
.unspentTxos(unspentTxos)
|
||||
.balance(Uint64Util.bigIntegerToUInt64(totalUnspent))
|
||||
.transferableBalance(Uint64Util.bigIntegerToUInt64(accountSnapshot.getTransferableAmount(minimumTxFee).getValue()))
|
||||
.balance(ByteString.of(totalUnspent.toByteArray()))
|
||||
.transferableBalance(ByteString.of(accountSnapshot.getTransferableAmount(minimumTxFee).getValue().toByteArray()))
|
||||
.asOfTimeStamp(asOfTimestamp)
|
||||
.highestBlock(new MobileCoinLedger.Block.Builder()
|
||||
.blockNumber(highestBlockIndex.longValue())
|
||||
|
||||
Reference in New Issue
Block a user