I made a lot of progress on the stake function for Qt today. I can see why no one did it in the past, it's a real pain

but will be cool when done.
Also, forum.yacoin.org is now live. Thanks to Sahtor for doing all the work to get it going again!
I know your pain Joe_Bowers. I tried totaling up up all the inputs eligible for staking in CWallet::CreateCoinStake (in wallet.cpp) then printing the result out the log each time it's called. But the total just jumps around randomly. I can't figure out if there is a bug in that function, or I just don't understand how that function goes about finding inputs that should be checked for possible POS block generation. There is supposed to be some unpredictability function so people can't game their POS blocks for some kind of timed attack. Perhaps that's whats making it tricky to understand.
Is it possible to run the wallet in a debugger and watch how it works?
Sure there is. Follow the instructions at
https://github.com/yacoin/yacoin/blob/master/doc/build-msw.txt. At step 26 use Makefile.Debug instead of Makefile.Release
c:\yacoin>mingw32-make -f Makefile.Debug
c:\yacoin>cd debug
c:\yacoin\debug>copy ..\release\*.dll .
c:\yacoin\debug>gdb yacoin-qt.exe
(gdb) list CWallet::CreateCoinStake
1373 return CreateTransaction(vecSend, wtxNew, reservekey, nFeeRet, coinControl);
1374 }
1375
1376 // ppcoin: create coin stake transaction
1377 bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64 nSearchInterval, CTransaction
& txNew)
1378 {
1379 // The following split & combine thresholds are important to security
1380 // Should not be adjusted if you don't understand the consequences
1381 static unsigned int nStakeSplitAge = (60 * 60 * 24 * 90);
1382 int64 nCombineThreshold = GetProofOfWorkReward(GetLastBlockIndex(pindexBest, false)->nBits) / 3;
(gdb) b 1381
Breakpoint 1 at 0x491442: file src\wallet.cpp, line 1381.
(gdb) run
This will take longer then usual because we are running in debug mode. When it finally fires up you will get:
Breakpoint 1,CWallet::CreateCoinstake......
(gdb) list
......
(gdb) n
1384 CBigNum bnTargetPerCoinDay;
(gdb) print nStakeSplitAge
$1 = 7776000
(gdb)