trustwallet / wallet-core

Cross-platform, cross-blockchain wallet library.
https://developer.trustwallet.com/wallet-core
Apache License 2.0
2.86k stars 1.6k forks source link

[Rust] Support Taproot, Ordinals and BRC20 #3178

Closed lamafab closed 1 year ago

lamafab commented 1 year ago

UPDATE: PR for this is here: https://github.com/trustwallet/wallet-core/pull/3233

About

In order to implement BRC20, we need to support the Ordinal protocol, which requires Taproot. Respectively, wallet-core must be able to create "inscriptions".

From the docs:

Inscription content is entirely on-chain, stored in taproot script-path spend scripts. Taproot scripts have very few restrictions on their content, and additionally receive the witness discount, making inscription content storage relatively economical.

Since taproot script spends can only be made from existing taproot outputs, inscriptions are made using a two-phase commit/reveal procedure. First, in the commit transaction, a taproot output committing to a script containing the inscription content is created. Second, in the reveal transaction, the output created by the commit transaction is spent, revealing the inscription content on-chain.

Inscriptions are created with the following Bitcoin script (which never executes):

OP_FALSE
OP_IF
  OP_PUSH "ord"
  OP_1
  OP_PUSH "text/plain;charset=utf-8"
  OP_0
  OP_PUSH "Hello, world!"
OP_ENDIF

Related:

Task List

Part 1:


UPDATE 2023-05-26 I found a Rust project that implements many of Bitcoin mechanisms: https://github.com/rust-bitcoin/rust-bitcoin/ I'm using this to build a MVP as of now and digging through the source code. We can still decide on whether we want to include the full library or strip out the parts that we need.

For the sake of completeness, we should eventually work on this:

Part 2:

vccomnet commented 1 year ago

Hi lamafab, Thank you for your great work. I would like to know when the development can be completed and released?

lamafab commented 1 year ago

@vccomnet just opened this last night -> https://github.com/trustwallet/wallet-core/pull/3233, almost there!

lamafab commented 1 year ago

It's done

weixuefeng commented 1 year ago

Can i generate taproot address with wallet-core now? i uesd @trustwallet/wallet-core, how can i use it?

Milerius commented 1 year ago

Hey @weixuefeng no it's not possible, there is the current status:

hanxianlong commented 11 months ago

Hey @weixuefeng no it's not possible, there is the current status:

  • Support for BRC20 transfers, sending and receiving:

    • [x] Implemented and tested in Wallet Core.
    • [x] Publicly exposed (high priority).
  • Support for P2WPKH (Segwit), sending and receiving:

    • [x] Implemented and tested in Wallet Core.
    • [x] Publicly exposed
  • Support for P2TR key-path (Taproot), sending and receiving:

    • [x] Implemented and tested in Wallet Core.
    • [x] Publicly exposed via C interface (low priority).

Hi Milerius, is it exposed to C interface now? can I generate taproot address in the iOS App or Android App?

lamafab commented 11 months ago

Hey @hanxianlong, it's not exposed yet. We're planning this for Q1 2024.