nochowderforyou / clams

Clam Project
MIT License
62 stars 58 forks source link

"listunspent" is missing an output #175

Closed dooglus closed 9 years ago

dooglus commented 9 years ago

I just found a problem with one of my wallets:

$ clamd getbalance
100.98150000
$ clamd listunspent
[
    {
        "txid" : "4b669d099edc650be18f19695fad64057eb5aded6f1a8f0f55f2f47601acfbf3",
        "vout" : 0,
        "address" : "xBwvEjQKwPZ5BxsfTSmAjTnQhVgXCoQryW",
        "scriptPubKey" : "76a91427f568e9f2ccb24eeee9532c83aa1a7f5eee21f588ac",
        "amount" : 0.00010000,
        "confirmations" : 9163
    }
]
$ clamd gettransaction 4b669d099edc650be18f19695fad64057eb5aded6f1a8f0f55f2f47601acfbf3 | grep -A25 '^    "vout' | grep -A1 -e value -e address | grep -v -- --
            "value" : 0.00010000,
            "n" : 0,
                "addresses" : [
                    "xBwvEjQKwPZ5BxsfTSmAjTnQhVgXCoQryW"
            "value" : 100.98140000,
            "n" : 1,
                "addresses" : [
                    "xQ1F485bxrsPudaWLUNmrTtpJ3UrXLhuzJ"
$ clamd validateaddress xBwvEjQKwPZ5BxsfTSmAjTnQhVgXCoQryW | grep mine
    "ismine" : true,
$ clamd validateaddress xQ1F485bxrsPudaWLUNmrTtpJ3UrXLhuzJ | grep mine
    "ismine" : true,
$ 

The wallet has only two unspent outputs, both from the same transaction. Only one of them is showing up when I run "listunspent".

When I try to spend 1 CLAM from the 100 CLAM balance, it fails:

$ clamd sendtoaddress xX7935NaJ3S5JDppHCVkbaBxi9tSNiiPy1 1
error: {"code":-4,"message":"Error: Transaction creation failed!"}
$ 

The debug.log shows:

2015-02-28 20:46:09 CWallet::SelectCoinsMinConf failed: sum of lower outputs (0.0001) < target (1.0001), and no other outputs
2015-02-28 20:46:09 CWallet::SelectCoins failed: no way to select coins worth 1.0001
2015-02-28 20:46:09 CWallet::CreateTransaction failed: coin selection failed
2015-02-28 20:46:09 SendMoney() : Error: Transaction creation failed!

I'm wondering if this is a result of #157.

dooglus commented 9 years ago

Oh, it's not related to #157.

The problem is this line in wallet.cpp:

                (!nMaxStakeValue || pcoin->vout[i].nValue <= nMaxStakeValue) &&

it's filtering all outputs greater than the -maxstakevalue even when not selecting for staking.

dooglus commented 9 years ago

Fixed in a89b1a75.