badger-cash / badger

Your gateway to the world of Bitcoin Cash (BCH) apps
https://badger.bitcoin.com/
MIT License
63 stars 47 forks source link

Allow `web4bch.bch.personal.sign` to sign text messages/strings. #236

Open modenero opened 4 years ago

modenero commented 4 years ago

What problem are you trying to solve? I'd like my users to be able to sign BCH messages for an off-chain application. However, after reviewing the code, it appears that the only signature support is for CashID requests.

Describe the solution you'd like Similar to Ethereum's MetaMask, which uses web3.eth.personal.sign, I'd like to be able to use something similar to web4bch.bch.personal.sign to accomplish the same goal.

Additional context Currently when attempting to execute the command:

        window.web4bch.bch.sign(
            'hello world',
            window.web4bch.bch.defaultAccount,
            (err, res) => {
                console.log('SIGN ERROR', err)
                console.log('SIGN RESULT', res)
            }
        )

the result is SIGN ERROR Error: Error: WalletMiddleware - Invalid "from" address.

By reversing the order of the parameters to:

        window.web4bch.bch.sign(
            window.web4bch.bch.defaultAccount,
            'hello world',
            (err, res) => {
                console.log('SIGN ERROR', err)
                console.log('SIGN RESULT', res)
            }
        )

Badger will open a signature page, however, the window is NOT rendered correctly, or really at all; making any further action impossible and requiring the plugin to be "manually" reset in the browser.


It's entirely possible that personal.sign has been removed/disabled from the Badger extension. I've also sent an inquiry to badger@bitcoin.com regarding the status of this feature.

Thank you for your time and consideration in this matter...
Cheers!