-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add OP_REVAULT, example usages #4
base: jamesob-23-02-opvault
Are you sure you want to change the base?
Add OP_REVAULT, example usages #4
Conversation
5aecff4
to
bc1e8f1
Compare
could also have OP_REVAULT push residual on stack. Could allow wallet authors to re-arrange which order OP_REVAULT/OP_VAULT are given, allowing the witness stack to give revault value instead of trigger value? Slightly more symmetrical, maybe nice. you'd have to handle the corner cases where the final residual on the stack ends up being 0, however. |
Of course, once you get "residual" values in either case, you can directly access the input value:
|
* <code><revault-amount></code> is an up to 7-byte CScriptNum-encoded number indicating the number of satoshis being revaulted. | ||
** If this value does not decode to a valid CScriptNum, script execution when spending this output MUST fail and terminate immediately. | ||
** If this value is not greater than or equal to 0, script execution when spending this output MUST fail and terminate immediately. | ||
** If this value is non-zero but <code><revault-vout-idx></code> is negative, script execution when spending this output MUST fail and terminate immediately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If going forward with this, I'd change the logic to what sanket suggested:
- if no revault exists, use
-1
for index - if revault amount is non-0, index must not be
-1
same with trigger values
previously a 0-valued invocation would have allowed output index malleability
…_REVAULT chaining
Eh, math is broken, you can't actually do OP_1ADD unless the entire utxo is smaller than ~2.1 BTC. You're going to have to add ======= If you swap which opcode pushes residual, args for common case should probably be moved around to save bytes and make basic vaults just as easy as before: This PR's current idea:
OP_VAULT needs single push for CTV hash, that's it
============ If OP_REVAULT pushes residual instead, and OP_VAULT pushes 0x01:
|
hacky MVP percentage based idea: Aside: I like the idea of the collateral being able to go to a "different destination" as well, vs the unvault itself. i.e., the collateral OP_VAULT invocation could put the value in another script that is spendable via unique arbitrary policy. Collateral is just a requirement that more sats should go to some policy of the vault's choosing. Collateral could be immediately swept by another system, or put back into another unvault immediately, if desired. |
I've surely made some off-by-ones on the fancier usages, but this should demonstrate that it works. I'm not a stack manipulation expert.
Very small spec change, and enables some interesting behavior.