Page MenuHomePhabricator

[Cashtab] add message signing function
ClosedPublic

Authored by emack on Nov 1 2021, 13:57.

Details

Reviewers
bytesofman
Group Reviewers
Restricted Project
Commits
rABC14b62e9817ae: [Cashtab] add message signing function
Summary
  • Adds a new function for the user to sign messages using the current active wallet.
  • New signPkMessage function in useBCH.js which calls the signMessageWithPrivKey function
  • New collapsable form added to Send.js, which then passes BCH, fundingWif and message to useBCH.js, which subsequently calls BCH.BitcoinCash.signMessageWithPrivKey(pk, message) to sign the message and returns the corresponding signature.
Test Plan
  • npm start
  • navigate to the Send tab and un-collapse the Sign Message form
  • ensure the Sign Message button is disabled when no input is entered
  • ensure the Sign Message button is disabled when input is entered but is then deleted
  • ensure the Sign Message button is disabled when input is greater than 150 characters
  • input message between 1-150 characters then click the sign message button, okay the dialog and note the successful notification and signature returned
  • click on the signature field after a signature has been generated and verify it has copied to clipboard
  • without moving away from the same screen, sign another message and ensure the 'Copied to clipboard' message disappears, before clicking on the newly generated signature and verify the new signature is now copied to clipboard
  • open electrumABC wallet
  • verify signature in the electrumABC wallet
  • verify cross browser compatibility in firefox
  • npm run extension
  • verify the above works in extension mode

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emack requested review of this revision.Nov 1 2021, 13:57
bytesofman requested changes to this revision.Nov 1 2021, 23:08

This is great!

I think the UI needs some tweaks before going live. Not sure if a modal is the best way to do this.

I like the UI on Electrum. Showing 3 fields: message, address, and signature. Then signature is populated after the user clicks "sign."

Reconstruct this in the cashtab collapse. The "Message" field is already there. Create an "address" field that is auto-populated with the active wallet's address. Also add a "signature" field that is only filled out after the user clicks "Sign."

web/cashtab/src/components/Send/Send.js
365 ↗(On Diff #30719)

Add this notification to src/components/Common/Notifications.js and import it here

378 ↗(On Diff #30719)

Use the generic error notification from src/components/Common/Notifications.js

608 ↗(On Diff #30719)

I think leaving this at "Sign Message" is best, okay to assume it's with the active wallet

This revision now requires changes to proceed.Nov 1 2021, 23:08

Will need to make the "Message" and "signature" fields longer text inputs. Add a copy paste button on the "signature" field.

emack marked 3 inline comments as done.
  • restructured the 'Sign Message' feature to align to the Electrum wallet UI
  • moved message signing notification logic into Notifications.js and re-imported into Send.js
  • used generic error notification from Notifications.js
  • clicking on the Signature Textarea field now acts as a Copy To Clipboard feature
  • increased minimum rows to Message and Signature fields for longer text displays
  • updated form panel header to 'Sign Message'
This revision is now accepted and ready to land.Nov 4 2021, 19:49
This revision was automatically updated to reflect the committed changes.