mirror of
https://github.com/mollyim/monero-wallet-sdk.git
synced 2024-12-24 23:19:23 -05:00
lib: fix balance for pending transfers to own wallet
This commit is contained in:
parent
4cf0059739
commit
ec4ebe6f78
@ -428,6 +428,13 @@ void Wallet::captureTxHistorySnapshot(std::vector<TxInfo>& snapshot) {
|
||||
for (const auto& pair: upds) {
|
||||
const auto& upd = pair.second.m_pd;
|
||||
bool double_spend_seen = pair.second.m_double_spend_seen; // Unused
|
||||
// Skip unconfirmed transfers sent to our own wallet.
|
||||
auto it = std::find_if(
|
||||
utxs.begin(), utxs.end(),
|
||||
[&](const std::pair<crypto::hash, wallet2::unconfirmed_transfer_details>& utx) {
|
||||
return utx.first == upd.m_tx_hash;
|
||||
});
|
||||
if (it != utxs.end()) continue;
|
||||
// Denormalize individual amounts sent to a single subaddress in a single tx.
|
||||
for (uint64_t amount: upd.m_amounts) {
|
||||
snapshot.emplace_back(upd.m_tx_hash, TxInfo::INCOMING);
|
||||
@ -435,7 +442,6 @@ void Wallet::captureTxHistorySnapshot(std::vector<TxInfo>& snapshot) {
|
||||
recv.m_subaddress_major = upd.m_subaddr_index.major;
|
||||
recv.m_subaddress_minor = upd.m_subaddr_index.minor;
|
||||
recv.m_amount = amount;
|
||||
recv.m_height = upd.m_block_height;
|
||||
recv.m_unlock_time = upd.m_unlock_time;
|
||||
recv.m_timestamp = upd.m_timestamp;
|
||||
recv.m_fee = upd.m_fee;
|
||||
|
@ -176,6 +176,10 @@ internal class WalletNative private constructor(
|
||||
}
|
||||
|
||||
override fun createPayment(request: PaymentRequest, callback: ITransferCallback) {
|
||||
if (request.paymentDetails.any { it.recipientAddress.network != network }) {
|
||||
callback.onUnexpectedError("Recipient address is on a different network")
|
||||
return
|
||||
}
|
||||
scope.launch(singleThreadedDispatcher) {
|
||||
val (amounts, addresses) = request.paymentDetails.map {
|
||||
it.amount.atomicUnits to it.recipientAddress.address
|
||||
|
@ -117,12 +117,12 @@ private fun List<TxInfo>.createTransaction(
|
||||
else blockchainContext.resolveUnlockTime(unlockTime)
|
||||
}
|
||||
|
||||
val receivedEnotes = enoteByTxId.getOrDefault(txHash, emptyList()).toSet()
|
||||
val receivedEnotes = enoteByTxId.getOrDefault(txHash, emptyList())
|
||||
|
||||
val outTxs = filter { !it.incoming }
|
||||
|
||||
val spentKeyImages = outTxs.mapNotNull { it.keyImage }
|
||||
val sentEnotes = enoteByKeyImage.filterKeys { ki -> ki in spentKeyImages }.values.toSet()
|
||||
val sentEnotes = enoteByKeyImage.filterKeys { ki -> ki in spentKeyImages }.values
|
||||
|
||||
val payments = outTxs.mapNotNull { it.toPaymentDetail() }
|
||||
|
||||
@ -131,8 +131,8 @@ private fun List<TxInfo>.createTransaction(
|
||||
state = determineTxState(),
|
||||
network = blockchainContext.network,
|
||||
timeLock = timeLock,
|
||||
sent = sentEnotes,
|
||||
received = receivedEnotes,
|
||||
sent = sentEnotes.toSet(),
|
||||
received = receivedEnotes.toSet(),
|
||||
payments = payments,
|
||||
fee = MoneroAmount(atomicUnits = fee),
|
||||
change = MoneroAmount(atomicUnits = change),
|
||||
|
Loading…
Reference in New Issue
Block a user