-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[Rust/Bitcoin/Utxo] Great Migration towards tw_bitcoin and tw_utxo
#3382
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
satoshiotomakan
requested changes
Sep 18, 2023
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.
Only minor comments
satoshiotomakan
approved these changes
Sep 19, 2023
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.
LGTM 🔥
Milerius
approved these changes
Sep 19, 2023
satoshiotomakan
pushed a commit
that referenced
this pull request
Oct 6, 2023
dfinity-ryancroote
pushed a commit
to dfinity-ryancroote/wallet-core
that referenced
this pull request
Oct 6, 2023
12 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Alright, major PR incoming 🥳 This undertaking was quite extensive - almost more so than BRC20 was - but we have reached a promising milestone. I have iteratively refined the protobuf structures until I discovered a design pattern that aligns seamlessly with the Bitcoin/UTXO workflow.
This PR includes:
Modular Separation: Isolate the Bitcoin and UTXO specific logic into separate
tw_bitcoinandtw_utxomodules. This clean separation allows us to repurposetw_utxofor other chains/forks that employ the same UTXO model.Enhanced Protobuf Structures: Introduce refined Protobuf structures to facilitate more efficient and less error-prone transaction creation, thereby minimizing the need for frequent back-and-forth adjustments.
Integration of
tw_coin_entry: Incorporate Sergey's work ontw_coin_entryintotw_bitcoin. This integration is engineered to:Backwards Compatibility Maintenance: We are committed to maintaining support for the current
SigningInputandTransactionPlan, ensuring that existing protobuf structures can continue to leverage this library. This compatibility is achieved by wrapping the legacySigningInputandTransactionPlanover the new structures. While substantial progress has been made on this front, some final touches are still pending.The Current State
UPDATE 2023-08-28: There are two things that still need to be tested that are unfortunately not really straightforward to test, meaning I'll need to use another library (in Python probably) and reconstruct it there. The current implementation here is probably okay considering that the underlying
rust-bitcoinlibrary handles that part, but still. Most likely a separate PR should be opened for that:WIP: kind of stuck here, signature fails to verify in test environmentSignSingle,AllPlusAnyoneCanPay, etc.)UPDATE 2023-08-31: Added explicit tests for:
State of
tw_bitcoinCoinEntryparse_addressExpected to be straightforward to implementDonederive_addressExpected to be straightforward to implementDonepreimage_hashescompilesignpreimage_hashes-> signs sighashes ->compilejson_signerplan_builderExpected to be straightforward to implementDoneExpected to be straightforward to implementDoneExpected to be straightforward to implement, similar to BRC20 transfersDoneYet to be testedDoneYet to be testedDonetw_build_p2pkh_scripttw_build_p2wpkh_scripttw_build_p2tr_key_path_scripttw_build_brc20_transfer_inscriptiontw_bitcoin_build_nft_inscriptionStraightforward, analogous to the BRC20 implementationDonetw_taproot_build_and_sign_transactionNear completionDoneRegarding tests, I have integrated the existing tests we already have for
tw_bitcoin, and all of them function correctly. However, since our goal is to use this crate for all Bitcoin transactions, and not just BRC20, we need to expand our testing to be more general and thorough.What is done:
Precise tests required for:
SigningInputandTransactionPlanfor legacy protobuf.Sequencefeatures (replace-by-fee, etc.)tw_utxou32(?)State of
tw_utxotw_utxowith interface analogous totw_coin_entry.preimage_hashescompileFrom the perspective of
tw_utxo, it has no concepts of transaction types (P2PKH, P2WPKH, etc.) but only works with scriptSig, Witness, etc., in an opaque form.Regarding tests: