-
Notifications
You must be signed in to change notification settings - Fork 14
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 example using implementing Extension
for APO emulation
#32
base: master
Are you sure you want to change the base?
Conversation
All other descriptor APIs only deal with sane miniscripts
Ideally, we want to do using more granular components defined in the library. As a simple example, this implements apo as a single fragment.
@@ -1022,7 +1022,8 @@ impl_from_str!( | |||
Ok(tr) => Ok(Descriptor::Tr(tr)), | |||
Err(_) => { | |||
// Try parsing with extensions | |||
let tr = Tr::<Pk, T>::from_str(s)?; | |||
// descriptors are always parsed insane. This will improve once we use upstream ExtParams Api. | |||
let tr = Tr::<Pk, T>::from_str_insane(s)?; |
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.
In acced27:
This is a bit eyebrow-raising. This means that Descriptor::from_str
will no longer enforce any sanity rules when parsing tapscripts?
This is fine if it's temporary and we're going to fix it when we bring ExtParams
down, but the comment should have the text FIXME
in it so that we have a reminder to deal with it.
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.
Sorry, this comment was wrong/incomplete. This was meant to covenant descriptors should be parsed as insane
because they are not safe(in the sense there is no signature guarding it).
Parsing regular descriptors should work as expected.
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.
Okay, perfect. Can you update the comment?
/// The data that needs to be signed in apo + all. | ||
/// We can decompose this into into individual parts for fixing version, amt, script pubkey | ||
/// | ||
/// This structure is onyl an example of how one might implement extension. We do pay any |
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.
In 66aeb41:
nit onyl
should be only
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.
Also do pay
should be do not pay
I think :)
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.
Lol :)
|
||
use opcodes::all::*; | ||
builder = builder | ||
.push_opcode(OP_INSPECTVERSION).push_slice(&self.version.to_le_bytes()).push_opcode(OP_EQUALVERIFY) |
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.
In 66aeb41:
I would really prefer that all the .push_
methods got their own line.
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.
Ok, on closer reading I see that the reason is that you've got INSEPECTXXX <XXX> EQV
all on one line ... so I feel less strongly. But I'd still suggest breaking it up across separate lines and maybe adding comments in between to separate the sections.
This looks great! Super cool to see how APO works. One thing that confuses me here is that it seems you're only validating the one input -- is this how APO is supposed to work? This seems like it's SighashAll + ANYONECANPAY + ANYPREVOUT rather than just all+apo. It also seems unfortunate that you need to commit to the target data in the scriptpubkey, but for an example implementation I think that's fine. (I think what we'd actually like to do is add a Done reviewing 66aeb41. |
APO is similar to ACP, but not that we do not commit to the previous outpoint here. If this was ACP, we would be committing to Outpoint. |
Follows BIP118, without fixing the annex. Annex introspection is not currently supported.