CWallet::CreateCoinStake nCombineThreshold question

Hi peercoin devs,

Can someone explain to me what this code does:

https://github.com/ppcoin/ppcoin/blob/develop/src/wallet.cpp#L1361

Thanx for your help

This line computes the stake combination threshold, i.e. one third of the reward of the last POW block.

It is used when a small utxo of an address mints a POS block.
The program tries to add more utxos from the same address as inputs of the coinstake transaction, and combines them in the output with the rewards for all the inputs.

There are limits to this merging of stakes in a coinstake transaction:

  • the extra inputs must be at least 90 days old
  • the maximum number of inputs is 100
  • the total number of coins of the inputs must be under the combination threshold

By combining many small stakes into a bigger one, minting a block can be a dust reduction process.

You can check the following thread to see an example of stake combination (and why a POS block can have a negative reward, which seems strange if you don’t know about this combination thing).
https://www.peercointalk.org/index.php?topic=2869.0

[quote=“glv, post:2, topic:3467”]This line computes the stake combination threshold, i.e. one third of the reward of the last POW block.

It is used when a small utxo of an address mints a POS block.
The program tries to add more utxos from the same address as inputs of the coinstake transaction, and combines them in the output with the rewards for all the inputs.

There are limits to this merging of stakes in a coinstake transaction:

  • the extra inputs must be at least 90 days old
  • the maximum number of inputs is 100
  • the total number of coins of the inputs must be under the combination threshold

By combining many small stakes into a bigger one, minting a block can be a dust reduction process.

You can check the following thread to see an example of stake combination (and why a POS block can have a negative reward, which seems strange if you don’t know about this combination thing).
https://www.peercointalk.org/index.php?topic=2869.0[/quote]

Hi glv, thanx for your detailed answer.

It looks like all these rules are not verified when a block is received:

https://github.com/ppcoin/ppcoin/blob/v0.4.0ppc/src/main.cpp#L1829

or am I missing something?

Thanx again for your help.

PS:
I created a #peercoin-wizards freenode IRC channel where peercoin devs could gather together to exchange about peercoin development, what do you think?

[quote=“mably, post:3, topic:3467”]It looks like all these rules are not verified when a block is received:

https://github.com/ppcoin/ppcoin/blob/v0.4.0ppc/src/main.cpp#L1829[/quote]

Yes, apparently this is not checked when a new POS block is received.
I don’t know if is a missing verification, or if it is the intended behavior.
Maybe Sunny can tell us…

Didn’t kac- show that you can even combine an output of a different address?

I remember neither splitting nor combining is enforced by protocol. Probably they should just be regarded as some wallet features.

[quote=“mhps, post:5, topic:3467”]Didn’t kac- show that you can even combine an output of a different address?

I remember neither splitting nor combining is enforced by protocol. Probably they should just be regarded as some wallet features.[/quote]

Yep exactly, it’s just that the peercoin standard client doesn’t allow you to do it when minting. As far as I know by reading the code, it’s not enforced by protocol.

If such behavior (splitting, combining) is allowed and can be regarded as wallet features, it should be written down somewhere. It could allow us to implement some new fancy wallet utilities.

May be SK or sigmike could share their point of view about that.

Hi everybody,

I am trying to build a diagram describing peercoin PoS mechanism:

The idea here is to be able to understand how Peercoin works without having to read the code.

It’s probably full of errors or inaccuracies. Feel free to correct me.

Just hoping I won’t have to throw it all over board :wink:

EDIT: Diagram in HTML format (with clickable links and zoom buttons)
EDIT2: updated thumbnail