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

Avoid provably unspendable outputs #50

Closed
wants to merge 1 commit into from

Conversation

crisdut
Copy link
Member

@crisdut crisdut commented Sep 12, 2022

Description

I made tests with RGB, and the PSBT always generate a 'provably unspendable' bitcoins after mining.

This situation occurred because the 'btc-cold construct' adds satoshis remaining in the taproot output, even setting the value in the change address.

I changed the method to spend only the fee and add the value remaining at the change address. See example bellow:

187035864-e0f98632-6cd8-4f5b-94d7-259a7c046238

The nonstd output is the outpoint used to anchor the RGB asset.

PS: I talked about this situation in another PR (link here and here)

Copy link
Member

@dr-orlovsky dr-orlovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I right that the problem is only related to the PSBTs containing OpRet commitments?

Please see my review comment. We need to move all checks into command-lines, no prints should happen inside the library code. This will also help to solve the compexity of the review: too many identation changes such that the actual logic that was added/changed remains hard to find.

@crisdut
Copy link
Member Author

crisdut commented Sep 18, 2022

Am I right that the problem is only related to the PSBTs containing OpRet commitments?

No, this occurs with TapRet commitments as well.

Example: https://mempool.space/testnet/tx/94dd3f7eb24d63306917796b363f0bb6addc3647a4e5838560020508ea3c1e4f

Please see my review comment. We need to move all checks into command-lines, no prints should happen inside the library code. This will also help to solve the compexity of the review: too many identation changes such that the actual logic that was added/changed remains hard to find.

Sorry about this mistakes, I will fix this and push again.

@crisdut crisdut force-pushed the fix/avoid-unspentable branch from e4db696 to 4f9df2a Compare September 24, 2022 22:46
@crisdut
Copy link
Member Author

crisdut commented Sep 24, 2022

Hi @dr-orlovsky,

I followed your recommendations and move the validation to command-line.

@crisdut
Copy link
Member Author

crisdut commented Sep 26, 2022

Am I right that the problem is only related to the PSBTs containing OpRet commitments?

About TapRet:

I think the problem occurs because the tapret commitment is added directly into ScriptPubKey instead of a most-right leaft of the taptree, inside in "normal" P2TR ScriptPubKey. See below:

Expected ScriptPubKey
image

Current ScriptPubKey
image

Could you confirm my assumption?

If the assumption is correct, I will investigate more and try to solve it in another PR (probably in another project).

Copy link
Member

@dr-orlovsky dr-orlovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for being unclear, what I ment is that the library should return a proper error, which has to be printed in the cli tool, but the change output still should be generated on the lib side. Otherwise it will be impossible to use the lib from the wallets since they would have to duplicate the change creation logic.

@crisdut
Copy link
Member Author

crisdut commented Sep 28, 2022

Sorry for being unclear, what I ment is that the library should return a proper error, which has to be printed in the cli tool, but the change output still should be generated on the lib side. Otherwise it will be impossible to use the lib from the wallets since they would have to duplicate the change creation logic.

Don't worry, It's make sense!

I'll treat this event as a error. However, I am investigating the problem I mentioned above.

@crisdut crisdut force-pushed the fix/avoid-unspentable branch from 4f9df2a to e648f03 Compare September 29, 2022 00:48
@crisdut crisdut closed this Sep 29, 2022
@crisdut
Copy link
Member Author

crisdut commented Sep 29, 2022

I will close this PR for now, I found the bug above in bp-dbc repo.

I will start tests with both methods (opret and tapret). If the problem persists, I will reopen the PR.

Thanks

@cryptoquick
Copy link
Member

@crisdut Which bug is that? I just checked https://github.com/BP-WG/bp-core/issues

@crisdut
Copy link
Member Author

crisdut commented Sep 29, 2022

Oh, sorry, @cryptoquick, I wasn't clear.

I found the bug in code of the bp-dbc, not in issues of the bp-dbc repo.

I think the error is here. The code writes the commitment directly in the output script, but the correct way is to write it in the most-right leaf of the taptree.

This method is called inside of the method rgb-cli finalize.

@cryptoquick
Copy link
Member

@crisdut Wow, good find! I don't think I would have noticed that if I was just glancing at the code. I'd be very curious if that'd resolve the issue.

@louneskmt
Copy link
Contributor

Hey @crisdut! Any update on this issue? Maybe it would be better to open one directly on bp-core to track it.

@cryptoquick
Copy link
Member

Hey @crisdut! Any update on this issue? Maybe it would be better to open one directly on bp-core to track it.

@crisdut did some digging recently and has opened two issues on this:
https://github.com/BP-WG/bp-core/discussions/20
and
#53
Though, @dr-orlovsky hasn't yet had a chance to review, probably because he's been out giving talks on RGB :)

@crisdut
Copy link
Member Author

crisdut commented Oct 17, 2022

Hey @crisdut! Any update on this issue? Maybe it would be better to open one directly on bp-core to track it.

@crisdut did some digging recently and has opened two issues on this: BP-WG/bp-core#20 and #53 Though, @dr-orlovsky hasn't yet had a chance to review, probably because he's been out giving talks on RGB :)

Yes, I see.

Well, I will publish my PR about TapRet in this week.

I will open other PRs to complete the workflow with LNPBP stack.

@crisdut
Copy link
Member Author

crisdut commented Oct 26, 2022

Hi @cryptoquick and @louneskmt,

I updated the discuss: https://github.com/BP-WG/bp-core/discussions/20#discussioncomment-3966106

@crisdut crisdut deleted the fix/avoid-unspentable branch November 24, 2022 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants