Skip to content

Commit

Permalink
add dcr recipient and mempool txs
Browse files Browse the repository at this point in the history
  • Loading branch information
buck54321 committed Feb 27, 2024
1 parent 508a35c commit 44eae6a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions client/asset/dcr/dcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -5710,7 +5710,8 @@ func (dcr *ExchangeWallet) checkPendingTxs(ctx context.Context, tip uint64) {
blockToQuery = tip - blockQueryBuffer
}

recentTxs, err := dcr.wallet.ListSinceBlock(ctx, int32(blockToQuery), int32(tip), int32(tip))
const rangeEndMempool = -1
recentTxs, err := dcr.wallet.ListSinceBlock(ctx, int32(blockToQuery), rangeEndMempool, int32(tip))
if err != nil {
dcr.log.Errorf("Error listing transactions since block %d: %v", blockToQuery, err)
recentTxs = nil
Expand Down Expand Up @@ -5748,7 +5749,12 @@ func (dcr *ExchangeWallet) checkPendingTxs(ctx context.Context, tip uint64) {
}
}

dcr.addTxToHistory(txType, txHash, toAtoms(tx.Amount), fee, nil, nil, true)
var addr *string
if txType == asset.Receive {
addr = &tx.Address
}

dcr.addTxToHistory(txType, txHash, toAtoms(tx.Amount), fee, nil, addr, true)
}

for _, tx := range recentTxs {
Expand Down Expand Up @@ -6071,6 +6077,10 @@ func (dcr *ExchangeWallet) monitorBlocks(ctx context.Context) {
if walletTip == nil {
// Mempool tx seen.
dcr.emitBalance()
dcr.tipMtx.RLock()
tipHeight := uint64(dcr.currentTip.height)
dcr.tipMtx.RUnlock()
go dcr.checkPendingTxs(ctx, tipHeight)
continue
}
if queuedBlock != nil && walletTip.height >= queuedBlock.height {
Expand Down

0 comments on commit 44eae6a

Please sign in to comment.