LedgerHQ / app-bitcoin-new

Modern Bitcoin Application based on PSBT and Descriptors
Apache License 2.0
93 stars 69 forks source link

feat: Allow multiple data pushes in OP_RETURN output #245

Closed victorkirov closed 4 months ago

victorkirov commented 5 months ago

Currently, the Bitcoin Ledger app only supports OP_RETURN outputs with a single data push. This is a limitation that is not present in the Bitcoin protocol itself, and it would be great to see this limitation removed in the Ledger app.

This would allow for more flexible use of the OP_RETURN output, and would allow for more complex data to be stored in the blockchain.

Primary short term Use case - Support for RUNES Protocol (going live with the next halving):

The Runes protocol aims to introduce a robust fungible token protocol on Bitcoin. It could significantly benefit the ecosystem by attracting more transaction volume, developers, and users. Runes aims to offer a simple, UTXO-based token system that minimizes on-chain footprint and integrates seamlessly with Bitcoin's architecture, avoiding the complexities and limitations of existing token protocols.

Current token solutions on Bitcoin suffer from issues like high complexity, reliance on off-chain data, UTXO proliferation or the need for a native token, which hinders adoption and user experience. Runes proposes a straightforward approach: token balances are held by UTXOs and OP_RETURN outputs are used for protocol messages. This ensures ease of use, reduced onchain footprint & more responsible UTXO management.

Other use cases - Bitcoin ecosystem apps & Bitcoin L2s (Q2 2024):

By enabling multiple data pushes in OP_RETURN outputs, the Ledger app would also support a wider range of applications, including Bitcoin layer 2 networks which rely on them for pegging/bridging operations to and from Bitcoin mainnet.

scienmanas commented 5 months ago

Hi, can you give some idea regarding the project, I saw the good first issue mark and really want to work on issue, can please give me more idea on the and how to start work on it.

victorkirov commented 5 months ago

Hi, can you give some idea regarding the project, I saw the good first issue mark and really want to work on issue, can please give me more idea on the and how to start work on it.

Looks like this logic needs to change: https://github.com/LedgerHQ/app-bitcoin-new/blob/develop/src/common/script.c#L135

victorkirov commented 5 months ago

Here is an example txn which is currently unsignable with Ledger: https://mempool.space/testnet/tx/cf32d8c280ca48b0d0a67335a39ae6fd4fefba9338793c87165ffacf691848a1

The OP_RETURN script being 6a0952554e455f544553541e0203049deebbe8878ad4d50e010b0383480546000080e2aee9a598ff0001, or in ASM:

OP_RETURN
OP_PUSHBYTES_9 52554e455f54455354
OP_PUSHBYTES_30 0203049deebbe8878ad4d50e010b0383480546000080e2aee9a598ff0001
bigspider commented 5 months ago

Note for anyone coming from the Summer of Bitcoin: please note that I will unfortunately not be mentoring this year, and there will be no project related to this repository; so if that was the intention, you should probably look at other projects.

Looks like this logic needs to change: https://github.com/LedgerHQ/app-bitcoin-new/blob/develop/src/common/script.c#L135

Correct, that's the main place.

Of course, due care needs to be taken to check if the new rules affect MAX_OPRETURN_OUTPUT_DESC_SIZE, and one or two tests should be added to cover the new rules.

AlastairPreacher commented 4 months ago

I've just stumbled across this as I realise since starting to buy Runes on BTC (https://support.xverse.app/hc/en-us/articles/26031360456973--Ledger-Device-UNKNOWN-ERROR-0x6a82-Error-Message-When-Minting-or-Sending-Runes).

Unfortunately, there were no warnings on the purchase of items, and my runes are stuck in my xverse wallet. This is somewhat of a big issue - are you able to give an update on when this will be fixed?

Thanks

victorkirov commented 4 months ago

@AlastairPreacher please contact Xverse support via a ticket. We have a solution for you.

AlastairPreacher commented 4 months ago

Hey @victorkirov - that's great to hear. I've reached out to them so await to hear back.

AlastairPreacher commented 4 months ago

Hey @victorkirov there's some confusion going on. Here's the response I received from xverse

Currently, this issue needs to be handled by Ledger. We know they are aware, and we will continue to monitor the progress.
They have also recently updated their website to advise on the current compatibility issues and that they are working on the update.

"While we develop an upgrade for the Ledger Bitcoin app that will enable rune sending with your Ledger device, we recommend [using Xverse](https://www.xverse.app/) as a hot wallet to manage your runes for the time being."

https://support.ledger.com/hc/en-us/articles/18281497320861-How-to-store-and-manage-Bitcoin-runes-with-your-Ledger-device-and-Xverse-wallet?docs=true

Are you able to help?!

My concern is that the xverse wallet was set up selecting ledgerlive is NOT used which is contrary to what is in the link above.

victorkirov commented 4 months ago

@AlastairPreacher Sorry, I thought we built a solution for this. Once the next version of Xverse comes out, you can use Magic Eden to transfer your Runes out or list directly on ME from your Ledger. Listing currently works fine on ME from Ledger but if you try to transfer it will incorrectly tell you that you're going to burn your runes. You can list on ME now if you wish, otherwise, I'd suggest waiting another day or 2 for the new patch and transfering your runes out then.

AlastairPreacher commented 4 months ago

Thanks. I'll wait for the patch to allow me to transfer out as I want to split up the bundles into smaller amounts before selling over time.

Appreciate the additional reply.

eezdev commented 4 months ago

+1

Hi guys, any news on the fix that makes runes transferable from a ledger? I think this is a high priority issue.

Thanks

wfyhehe commented 4 months ago

+1 I updated to the newest version 0.34.2 but still not able to transfer my runes using Xverse+Ledger. Is anyone working on this?

tarunmahe commented 4 months ago

+1

eezdev commented 4 months ago

@AlastairPreacher Sorry, I thought we built a solution for this. Once the next version of Xverse comes out, you can use Magic Eden to transfer your Runes out or list directly on ME from your Ledger. Listing currently works fine on ME from Ledger but if you try to transfer it will incorrectly tell you that you're going to burn your runes. You can list on ME now if you wish, otherwise, I'd suggest waiting another day or 2 for the new patch and transfering your runes out then.

Hi Victor, is xverse working on a workaround to transfer runes using xverse+ME? is there any ETA? Ledger seems very slow to address this and seems going to take ages for a core fix

victorkirov commented 4 months ago

We have a very basic web portal that will allow you to send out your runes from the Ledger address. You can get in touch with support for the details.

As for full Ledger support, @bigspider opened the above PR which will allow full Runes support with Ledger πŸ™Œ πŸŽ‰

eezdev commented 4 months ago

Thanks @victorkirov, @bigspider it's great to see this being fixed!! Do you know when the next release will be published?

Madyson10 commented 4 months ago

hello good afternoon. I sent some tokens to my xverse wallet and I can't withdraw them because I'm using the ledger on it, so what do I do now? It was easy to send it, now I can't get it out. I need a solution.

Madyson10 commented 4 months ago

Tokens Runes

wfyhehe commented 3 months ago

Hi @bigspider. Thanks for your work. Is this included in the newest release? I updated to 0.35.1 today but sending runes is still not working.

victorkirov commented 3 months ago

@wfyhehe this is a Ledger update, not an Xverse one. You will need to wait for the next version of the Ledger Btc app to be released.

bigspider commented 3 months ago

FYI: Version 2.2.3 should go live some time next week. Thanks for your patience.

victorkirov commented 3 months ago

@bigspider Tested and Ledger Rune transfers are working πŸŽ‰ Thanks for getting this through so quickly!