Hi ZmnSCPxj,
The rate-limiting algorithm would be relatively straightforward. I documented the rate-limiting part of the algorithm below, perhaps they can evoke new ideas of how to make this MAST-able or otherwise implement this in a privacy preserving way.
Something like the following:
=> Create an output at block height [h0] with the following properties:
Serving as input at any block height, the maximum amount is limited to [limit] sats; // This rule introduces [limit] and is permanent and always copied over to a change output
Serving as input at a block height < [h0 + window], the maximum amount is limited to [limit - 0] sats; // [limit - 0] to emphasize that nothing was spent yet and no window has started.
=> A transaction occurs at block height [h1], spending [h1_spent].
The payment output created at [h1] is not encumbered and of value [h1_spent]; // Note, this is the first encumbered transaction so [h1] is the first block of the first window
The change output created at block height [h1] must be encumbered as follows:
Serving as input at any block height, the maximum amount is limited to [limit] sats; // Permanent rule repeats
Serving as input at a block height < [h1 + window], the maximum amount is limited to [limit - h1_spent] // Second permanent rule reduces spendable amount until height [h1 + window] by [h1_spent]
=> A second transaction occurs at block height [h2], spending [h2_spent].
The payment output created at [h2] is not encumbered and of value [h2_spent]; // Second transaction, so a second window starts at [h2]
The change output created at block height [h2] must be encumbered as follows:
Serving as input at any block height, the maximum amount is limited to [limit] sats; // Permanent rule repeats
Serving as input at a block height < [h1 + window], the max amount is limited to [limit - h1_spent - h2_spent] // Reduce spendable amount between [h1] and [h1 + window] by an additional [h2_spent]
Serving as input in range [h1 + window] <= block height < [h2 + window], the max amount is limited to [limit - h2_spent] // First payment no longer inside this window so [h1_spent] no longer subtracted
... and so on. A rule that pertains to a block height < the current block height can be abandoned, keeping the number of rules equal to the number of transactions that exist within the oldest still active window.
Zac