• Gavin Andresen's avatar
    Handle "conflicted" transactions properly · 64e9a19b
    Gavin Andresen authored
    Extend CMerkleTx::GetDepthInMainChain with the concept of
    a "conflicted" transaction-- a transaction generated by the wallet
    that is not in the main chain or in the mempool, and, therefore,
    will likely never be confirmed.
    
    GetDepthInMainChain() now returns -1 for conflicted transactions
    (0 for unconfirmed-but-in-the-mempool, and >1 for confirmed).
    
    This makes getbalance, getbalance '*', and listunspent all agree when there are
    mutated transactions in the wallet.
    
    Before:
     listunspent: one 49BTC output
     getbalance: 96 BTC (change counted twice)
     getbalance '*': 46 BTC (spends counted twice)
    
    After: all agree, 49 BTC available to spend.
    64e9a19b
wallet.cpp 68.3 KB