Skip to content
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

timestamp timelocks are not satisfied #642

Open
LLFourn opened this issue Jun 28, 2022 · 9 comments
Open

timestamp timelocks are not satisfied #642

LLFourn opened this issue Jun 28, 2022 · 9 comments
Assignees
Labels
bug Something isn't working module-wallet
Milestone

Comments

@LLFourn
Copy link
Contributor

LLFourn commented Jun 28, 2022

It looks like the logic of finalize_psbt only checks if height based timelocks are satisfied:

                  match desc.satisfy(
                        &mut tmp_input,
                        (
                            PsbtInputSatisfier::new(psbt, n),
                            After::new(current_height, false),
                            Older::new(current_height, create_height, false),
                        ),
                    ) {

In addition, we should check satisfaction of timestamp based timelocks. I will fix this in bdk_core but I thought this was worth noting and fixing ahead of then.

@LLFourn LLFourn added the bug Something isn't working label Jun 28, 2022
@wszdexdrf
Copy link
Contributor

Maybe I could work on this.

@LLFourn
Copy link
Contributor Author

LLFourn commented Jul 6, 2022

Sure. To do this strictly correctly you need to know the "median time past": https://github.com/bitcoin/bitcoin/blob/a4e066af8573dcefb11dff120e1c09e8cf7f40c2/src/chain.h#L290-L302

I think an implementation on latest block timestamp would be better than nothing though?

@LLFourn
Copy link
Contributor Author

LLFourn commented Jul 12, 2022

Maybe relevant: rust-bitcoin/rust-miniscript#408

@wszdexdrf
Copy link
Contributor

I have reached a small hiccup. I was going to get blocktimes (for median time past) from the blockchain object, but then realised there is no way of actually accessing the blockchain inside finalize_psbt (no reference passed as an argument). What should we do here?

@LLFourn
Copy link
Contributor Author

LLFourn commented Jul 12, 2022

I have reached a small hiccup. I was going to get blocktimes (for median time past) from the blockchain object, but then realised there is no way of actually accessing the blockchain inside finalize_psbt (no reference passed as an argument). What should we do here?

I think just use the last sync height rather than the median time past thingo. Should give pretty good approximation and very rarely make something valid when it is not (and it would not be invalid for long).

(this implies we need to store the time as well as height in DB)

@afilini
Copy link
Member

afilini commented Sep 23, 2022

Wait, I'm a bit lost on this: the PR says that this is actually not a problem because miniscript correctly checks for the timestamps as well, so I guess we could close this issue, right?

Or did anybody ever encounter some actual issue trying to finalize a tx with timestamps?

@notmandatory
Copy link
Member

Added to alpha release, need to confirm miniscript correctly checks for the timestamps and if so close. Otherwise need to see if/how to fix.

@nondiremanuel
Copy link

Need a check to see if it remains in alpha @notmandatory

@notmandatory
Copy link
Member

notmandatory commented May 6, 2024

@ValuedMammal per your note in discord. I found a "threshold" test that includes timelocks in the rust-miniscript plan module, but we're not yet using this. It's possible we don't have any tests right now that confirm timestamp timelocks are satisfied. But it should be possible to create a test similar to the one in the plan module: https://github.com/rust-bitcoin/rust-miniscript/blob/45904881e0d6f27f8b81ab310c4739cc14429a9b/src/plan.rs#L863

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working module-wallet
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

7 participants
@afilini @LLFourn @notmandatory @danielabrozzoni @nondiremanuel @wszdexdrf and others