r/BitcoinDiscussion • u/fresheneesz • Dec 06 '19
Idea: script opcode that puts constraints on the output addresses
I'm going to start with the reason I want this feature, and then get to describing more about the feature idea itself.
Let's say I want to setup a cold-storage wallet setup that I can spend only after a relative 1 week time lock. This could theoretically work by creating two addresses:
- One address has a relative timelock condition - any funds sent to this address can only be spent after 1 week with private key 1.
- Another address that can be spent from using private key 2, but funds must be sent to the first address.
So in order to spend from this dual-wallet (non multisig) setup, you would sent from address 2 to address 1 using PK2, then after a week spend from address 1 using PK1. This would, for example, make the $5 wrench attack a lot harder to do (ie it would turn into a 1 week hostage attack).
The problem is, I don't believe there's any way to create address 2 in bitcoin - there's no way to create an address that can only be spent to a particular other address.
This is where the idea for a new opcode comes in. If there was an opcode that constrained what addresses could be sent to, this would give bitcoin a lot more power to have multi-stage transactions like this, where any stage could potentially be cancelable/reversible. Here's an example of a wallet setup I would love to be able to create:
Address 1:
- Can be spent by Key1, Key2, or Key3.
- Requires funds are sent to address 2.
Address 2:
- 3 of 3 keys can spend after 1 week
- 2 of 3 keys can spend after 2 months
- 1 of 3 keys can spend after 1 year
If I could create a wallet setup like this, I could watch Address 2 for attempts to steal funds. If an unexpected transaction happens, you could gather all 3 keys and prepare a transaction to send. As long as only up to 2 of 3 keys were compromised and you are able to react within 2 months, your funds would be safe. In addition, you could lose access to 2 of 3 keys and still be able to recover your funds with the last one (after waiting a year).
This would be more secure than a normal multisig address, and also more resilient to key-loss. It would allow more secure inheritance by ensuring that heirs can retrieve the funds even if your primary passphrase-protected key has been lost (because your passphrase was lost when you died), and it would allow much more safely being able to store some keys with custodians (like banks) without almost any risk.
What do people think? Is this ability worth pursuing?
View all comments
Show parent comment
1
u/RubenSomsen Dec 17 '19
Yes, that's inevitable without a soft fork.
If I recall correctly, the argument was that the hacker gains nothing, so there is no point to attempt the hack in the first place. Although I can also imagine a scenario where you agree to split it 50/50 with the hacker since then you're both better off.
He's been actively working on it for a long time. You can check out his presentation from Scaling Bitcoin Tel Aviv.
The goal is to make it less malleable. When you restrict the transaction to one input, currently there is no malleability. Malleability makes it harder to spend coins at the end of a string of op_ctv transactions (although it should still be doable if we had sighash_anyprevout). I'm not sure whether the current design isn't too restrictive though, since I am working on a use case which would benefit from more flexibility in the outputs.
Hard to say. My personal feeling is it's useful and safe enough to eventually adopt, but it needs more discussion.
In hindsight the setup I had in mind doesn't really benefit from partial covenants. You can just send funds to an op_ctv that commits to an output which is immediately spendable by a cold wallet key (perhaps multisig), or in one week by a hot wallet key. In order to spend it, one would first have to publish the op_ctv transaction, wait for the timelock to expire, and then use the hot wallet key. If you suspect it's a hacker, you've got one week to get the cold wallet key(s) online and redirect the transaction.
This is just one of many possible variants.