Skip to content

Conversation

@hebasto
Copy link
Member

@hebasto hebasto commented Oct 26, 2021

Coldcard firmware v4.1.3+ supports wallet export via descriptors:

This PR adds a new command importfromcoldcard for the bitcoin-wallet tool which creates a new wallet and fills it with the provided descriptors.

Usage example:

$ src/bitcoin-wallet -wallet=MyNewShinyCC -dumpfile=/home/hebasto/Coldcard/bitcoin-core.txt importfromcoldcard

To point to the "bitcoin-core.txt" file, the -dumpfile option is re-used.

Also the created wallet is forced for rescanning, to guarantee the access to all transactions even for wallets that were previously used some time before being imported into Bitcoin Core.

TODO (not here):

  • add tests for the importfromcoldcard command to the tool_wallet.py functional test
  • add the same functionality to the GUI

Based on #23349.

@hebasto
Copy link
Member Author

hebasto commented Oct 26, 2021

Coldcard firmware v4.1.3+ supports wallet export via descriptors.
@doc-hex
Copy link

doc-hex commented Oct 26, 2021

  • looks useful and simple enough

@nvk
Copy link

nvk commented Oct 26, 2021

@hebasto thanks for this, nice to see HW <=> Core getting easier.

@jamesob
Copy link
Contributor

jamesob commented Oct 26, 2021

Concept ACK

Copy link
Contributor

@mjdietzx mjdietzx left a comment

Choose a reason for hiding this comment

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

Very cool‼️ One comment/question


std::string line;
while (std::getline(file, line)) {
if (line.substr(0, 22) == "importdescriptors \'[{\"") break;
Copy link
Contributor

Choose a reason for hiding this comment

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

What are your thoughts on using regex from the standard library for this? https://www.cplusplus.com/reference/regex/

As someone not familiar w/ coldcard files, it would be much easier for me to understand this (ie the hardcoded string positions here, and at L138). It could possibly simplify this a bit and make it easier to read if we pulled the descriptor from the file w/ a regex

@achow101
Copy link
Member

-0 on adding device specific code into Core.

@Sjors
Copy link
Member

Sjors commented Oct 27, 2021

The Coldcard produces a command that the user can copy-paste into the console to perform the import. This PR parses the text file with that command and does the import instead. That seems strange.

I would prefer to see something a bit more generic. E.g. ColdCard and other devices could produce a text file with just descriptors in it, and/or some other wallet metadata. And then we could import that.

@fanquake
Copy link
Member

-0 on adding device specific code into Core.
I would prefer to see something a bit more generic

I agree. Wouldn't the HWI or a similar project be a better place for this? I don't really think we should be adding vendor specific code/calls into Bitcoin Core utilities. Or, if it is going to be done, it should be done in some very generic way, otherwise we're likely going to just end up with a bunch of importfrom* calls, and more interfaces / backwards compat / supported devices to have to worry about.

@jamesob
Copy link
Contributor

jamesob commented Oct 27, 2021

I would prefer to see something a bit more generic. E.g. ColdCard and other devices could produce a text file with just descriptors in it, and/or some other wallet metadata. And then we could import that.

In hindsight, coldcard fan though I may be, I think @Sjors and @fanquake are right here. Burdening Core with parsing a potentially-unlimited number of vendor-specific data formats doesn't seem right.

@nvk
Copy link

nvk commented Oct 27, 2021

Selfishly all I want is easy with my preferred tool. But yes, a more vendor neutral approach makes sense. It seems that supporting core is not priority for most vendors, so I really have no good suggestions. Maybe the patch could be generalized to import a series of any commands and/or we could change CC to export comments (#) on all the other lines in the file, etc...

@hebasto
Copy link
Member Author

hebasto commented Oct 27, 2021

Wouldn't the HWI or a similar project be a better place for this?

No. It's practically infeasible for a non-tech-savvy person to create a safe setup of "Bitcoin Core + python HWI" on a new Windows laptop. I tested this scenario many times IRL with different users ((

Also we should not recommend to such a type of users to use Bitcoin Core GUI console at all.

I would prefer to see something a bit more generic. E.g. ColdCard and other devices could produce a text file with just descriptors in it, and/or some other wallet metadata. And then we could import that.

Tend to agree.

Copy link
Member

@luke-jr luke-jr left a comment

Choose a reason for hiding this comment

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

Suggest making a BIP for the format, and renaming this to something vendor-neutral.

@lsilva01
Copy link
Contributor

I agree.

Suggest making a BIP for the format, and renaming this to something vendor-neutral.

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 1, 2021

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #23497 (Add src/node/ and src/wallet/ code to node:: and wallet:: namespaces by ryanofsky)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@laanwj
Copy link
Member

laanwj commented Nov 8, 2021

-0 on adding device specific code into Core.

Yes. I'm all for making the flows easy to use with hardware wallets, but supporting specific hardware seems to go a step too far. Also, we don't have the test framework (e.g. device simulation) set up for use-cases like this.

No. It's practically infeasible for a non-tech-savvy person to create a safe setup of "Bitcoin Core + python HWI" on a new Windows laptop. I tested this scenario many times IRL with different users ((

So then we need to make that process easier. We could even ship the distribution with HWI. This cannot be an argument for absorbing HWI's functionality into this repository.

@meshcollider
Copy link
Contributor

Absolutely agree with the above comments, its definitely an excellent goal to improve integration with hardware wallets but not at the expense of burdening this repository with a bunch of case handling. Look forward to a vendor-independent proposal 👍

@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 3, 2021

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

@fanquake
Copy link
Member

What's the state of this PR? From the discussion the current approach is not going to be merged, so I think this should either be closed, or at least drafted, until the approach is changed.

@hebasto hebasto marked this pull request as draft December 27, 2021 08:56
@hebasto
Copy link
Member Author

hebasto commented Dec 27, 2021

What's the state of this PR? From the discussion the current approach is not going to be merged, so I think this should either be closed, or at least drafted, until the approach is changed.

Drafted.

@hebasto hebasto closed this Mar 24, 2022
luke-jr pushed a commit to luke-jr/bitcoin that referenced this pull request May 21, 2022
Coldcard firmware v4.1.3+ supports wallet export via descriptors.

Github-Pull: bitcoin#23362
Rebased-From: 8076f8d
@bitcoin bitcoin locked and limited conversation to collaborators Mar 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.