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

bitcoin: implement bitcoin view #534

Merged
merged 13 commits into from
Mar 3, 2021
Merged

bitcoin: implement bitcoin view #534

merged 13 commits into from
Mar 3, 2021

Conversation

pkova
Copy link
Contributor

@pkova pkova commented Nov 24, 2020

@pkova
Copy link
Contributor Author

pkova commented Nov 24, 2020

Checking with a real bitcoin dude:

@timlucmiptev BIP-174 PSBT:s are the right tool for the job regarding unsigned transactions, right?

Edit: the answer is yes


const [signedTx, setSignedTx] = useState();

const privKey = urbitWallet.unsafeGet().bitcoin.keys.private;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we don't have urbitWallet here, just explode. It's checked in Point.js, wanted to give these keys as props to my component but didn't figure out how to do it with this routing setup.

@pkova
Copy link
Contributor Author

pkova commented Nov 24, 2020

Out of band todos for this one after discussing with @jalehman and @timlucmiptev:

  1. Exposition for the bitcoin screen.
  2. Remove unnecessary @ux dojo formatting.
  3. Proper xPub formatting.
  4. Sync how bitcoinjs-lib handles PSBT:s with @timlucmiptev.

@galenwp
Copy link

galenwp commented Nov 24, 2020

very cool

@Fang-
Copy link
Member

Fang- commented Nov 30, 2020

Might be interesting to look at #522, would be nice if landscape and other clients could open directly into the relevant Bitcoin flow in Bridge, instead of requiring manual user input beyond their login details.

@jalehman
Copy link
Member

Might be interesting to look at #522, would be nice if landscape and other clients could open directly into the relevant Bitcoin flow in Bridge, instead of requiring manual user input beyond their login details.

Great point @Fang- — this is an ideal use-case.

@pkova
Copy link
Contributor Author

pkova commented Dec 1, 2020

Fixed all the todos listed above, the exposition text might need some work though. This is now more easily runnable since urbit/urbit-key-generation#92 is in, but generating suitable PSBT:s from the xPub is a little bit of a pain. I used https://github.com/Coldcard/psbt_faker.

Gonna look at the stuff @Fang- posted next.

Comment on lines 104 to 105
{' ' + pointName}. You can paste it to Landscape to generate an
unsigned transaction.
Copy link
Member

Choose a reason for hiding this comment

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

I'd remove the reference to Landscape here.

Copy link
Member

Choose a reason for hiding this comment

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

From the copy here in general, it's also not clear what this does. What kind of transaction will Landscape generate? Why do I need to go somewhere else to generate that, when it looks like I have all my cryptographic information right here?

@jalehman jalehman requested a review from urcades February 4, 2021 16:05
Copy link
Member

@Fang- Fang- left a comment

Choose a reason for hiding this comment

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

Not sure how to test this, I can't get psbt_faker to give me anything I can paste in here to make it work.

Looking at the flow now, #522 might not be ideal for this, since you're going bridge->landscape->bridge instead of just landscape->bridge, and needing to log in twice is a bit awkward...

return (
<HexInput
type="text"
placeholder=""
Copy link
Member

Choose a reason for hiding this comment

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

Consider adding a placeholder, or simply letting this fall through to HexInput's PLACEHOLDER_HEX (though I guess that might get confusing, wrt leading 0x).

src/lib/validators.js Outdated Show resolved Hide resolved
src/lib/validators.js Show resolved Hide resolved
src/lib/validators.js Show resolved Hide resolved
src/views/Bitcoin.js Outdated Show resolved Hide resolved
src/views/Bitcoin.js Outdated Show resolved Hide resolved
src/views/Bitcoin.js Outdated Show resolved Hide resolved
src/views/Bitcoin.js Outdated Show resolved Hide resolved
src/views/Point.js Show resolved Hide resolved
This commit allows bridge to sign a PSBT when one or more of the inputs are able
to be signed by our bitcoin wallet. This allows Bridge to potentially be used
in some multisig setups.
The bitcoin wallet is derived from the master ticket, not a point.
@Fang-
Copy link
Member

Fang- commented Feb 24, 2021

Paging @urcades, @jyng. Still pending design review, and input on how to present access to this. It's a bit weird to display this on the individual point page, but we might also not want to open the points overview page just for this. (Currently, point overview is only shown if you control multiple points or have stars in lockup, otherwise skipping straight to the individual point page.)

Changes so far look good @pkova. There's still a couple unresolved review items from last time, but they're all small ones. I'll probably touch this soon, for flows integration, so that landscape can open Bridge into this.

@Fang-
Copy link
Member

Fang- commented Feb 25, 2021

I went ahead and integrated #522 into this, in 514f31c on the m/btc-flow branch.
No idea how to get the form to process the given initialValues instead of just showing them in the form. Maybe we want an explicit "sign this" button anyway, or maybe there's a way to be clever about form behavior? cc @liam-fitzgerald

Edit: turns out this is only relevant in the error reporting case, so maybe not as important to make this fluid. Logging in with the flow set up throws you into this screen nearly instantly:

image

@urcades
Copy link

urcades commented Feb 26, 2021

pulling in the PR now locally, will check this out and review soon

@Fang-
Copy link
Member

Fang- commented Feb 26, 2021

For the record, the "try it out" instructions that worked for me:

  1. log in as some point,
  2. open the bitcoin view,
  3. copy out the zpub, convert it to an xpub using this page
  4. use psbt_faker to generate a fake tx, psbt_faker test.psbt 'xpubPasteItHere' -6
  5. copy the contents of test.psbt into the input field in bridge

@urcades lmk if you need any bridge setup or testing help, I'll be around.

@urcades
Copy link

urcades commented Feb 27, 2021

Hello, I've been unable to serve the built bridge interface, but I've been given enough background to provide some feedback on the current interface (shown above).

Right now, here's a rough sketch of the basic progression we expect when performing a bitcoin transaction:

Screen Shot 2021-02-26 at 8 09 04 PM

The leftmost screen in this image displays the last stage/step of the "Landscape Crypto Invoicing" flow, which is to produce an unsigned transaction hash, which would be auto-copied to the user's clipboard (or manually copied, if auto-copying is blocked for some reason) upon clicking the "Copy Transaction and Sign in Bridge" button.

This button would open up a window to bridge.

After logging in using whatever method a pilot has associated with their Urbit ID, they should be brought immediately to the bitcoin page shown above. The copied transaction can then be copied into the "Unsigned Transaction" field.

We should add an explicit button under this field so that an urbit pilot can explicitly press a "Sign Transaction" button after pasting the transaction in the field to produce the signed transaction hash.

This modified form design can be structured as such:

Screen Shot 2021-02-26 at 9 03 15 PM

Basically, I think we should make the two sections for 1) Setting Extended Pubkey in Landscape and 2) Transaction Signing very, very distinct, and make it obvious that the first section is set only once (when setting up a wallet), while the second section is used every time a transaction is made.

Also, the second signing section should really have distinct 'states' for each stage of the signing process.

Would appreciate any feedback on the above.

Also improve copywriting from design feedback, and sign transaction with
explicit button.
@Fang- Fang- changed the base branch from master to bitcoin March 3, 2021 21:00
Copy link
Member

@Fang- Fang- left a comment

Choose a reason for hiding this comment

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

Alright, after talking out of band, I think this is all good now. Thanks so much for your work and patience @pkova!

Merging this into a bitcoin branch for flows integration, final touches etc.

@Fang- Fang- merged commit 9916088 into urbit:bitcoin Mar 3, 2021
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.

5 participants