Closed vasaf closed 1 year ago
bitcoinrb
currently only supports message signing using P2PKH addresses, like Bitcoin Core.
Message signing using bech32 addresses has been proposed as BIP-322, but it has not been widely adopted yet. If a Test Vector for this BIP is available, it may be implemented in bitcoinrb.
Sorry for the delay, we can now create BIP-322 based signatures like bellow:
private_key = Bitcoin::Key.from_wif('L3VFeEujGtevx9w18HD1fhRbCH67Az2dpCymeRE1SoPK6XQtaN2k')
addr = private_key.to_p2wpkh # bc1q9vza2e8x573nczrlzms0wvx3gsqjx7vavgkx0l
signature = Bitcoin::MessageSign.sign_message(
private_key,
'message',
format: Bitcoin::MessageSign::FORMAT_SIMPLE,
address: addr)
When using
Bitcoin::MessageSign.verify_message
to verifysegwit bech32
(bitcoin address beginning with bc1), an errorAddress has no key
is thrown. No issues with legacy address.What would be the direction to have this working with the newer addresses?
Thanks 👍