Subject: Re: [bitcoin-dev] Exploring: limiting transaction output amount as a function of total input value

From: ZmnSCPxj <[email-masked]>
Date: Tue, 10 Aug 2021 02:17:47 +0000

fromGood morning Zac,

With some work, what you want can be implemented, to some extent, today, without changes to consensus.

The point you want, I believe, is to have two sets of keys:

* A long-term-storage keyset, in "cold" storage.
* A short-term-spending keyset, in "warm" storage, controlling only a small amount of funds.

What you can do would be:

* Put all your funds in a single UTXO, with an k-of-n of your cold keys (ideally P2TR, or some P2WSH k-of-n).
* Put your cold keys online, and sign a transaction spending the above UTXO, and spending most of it to a new address that is a tweaked k-of-n of your cold keys, and a smaller output (up to the limit you want) controlled by the k-of-n of your warm keys.
  * Keep this transaction offchain, in your warm storage.
* Put your cold keys back offline.
* When you need to spend using your warm keys, bring the above transaction onchain, then spend from the budget as needed.

If you need to have some estimated amount of usable funds for every future unit of time, just create a chain of transactions with future `nLockTime`.

                                  nLocktime +1day  nLockTime +2day
                  +------------+   +------------+   +------------+
     cold UTXO -->|    cold TXO|-->|    cold TXO|-->|    cold TXO|--> etc.
                  |            |   |            |   |            |
                  |    warm TXO|   |    warm TXO|   |    warm TXO|
                  +------------+   +------------+   +------------+

Pre-sign the above transactions, store the pre-signed transactions in warm storage together with your warm keys.
Then put the cold keys back offline.

Then from today to tomorrow, you can spend only the first warm TXO.
>From tomorrow to the day after, you can spend only the first two warm TXOs.
And so on.

If tomorrow your warm keys are stolen, you can bring the cold keys online to claim the second cold TXO and limit your fund loss to only just the first two warm TXOs.

The above is bulky, but it has the advantage of not using any special opcodes or features (improving privacy, especially with P2TR which would in theory allow k-of-n/n-of-n to be indistinguishable from 1-of-1), and using just `nLockTime`, which is much easier to hide since most modern wallets will set `nLockTime` to recent block heights.

Regards,
ZmnSCPxj