mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-27 15:31:31 +00:00
Merge branch 'master' of github.com:spesmilo/electrum
This commit is contained in:
commit
fed76bfffc
4 changed files with 29 additions and 7 deletions
|
@ -86,16 +86,16 @@ To create binaries, create the 'packages' directory::
|
||||||
|
|
||||||
This directory contains the python dependencies used by Electrum.
|
This directory contains the python dependencies used by Electrum.
|
||||||
|
|
||||||
Mac OS X
|
Mac OS X / macOS
|
||||||
--------
|
--------
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
# On MacPorts installs:
|
# On MacPorts installs:
|
||||||
sudo python setup-release.py py2app
|
sudo python3 setup-release.py py2app
|
||||||
|
|
||||||
# On Homebrew installs:
|
# On Homebrew installs:
|
||||||
ARCHFLAGS="-arch i386 -arch x86_64" sudo python setup-release.py py2app --includes sip
|
ARCHFLAGS="-arch i386 -arch x86_64" sudo python3 setup-release.py py2app --includes sip
|
||||||
|
|
||||||
sudo hdiutil create -fs HFS+ -volname "Electrum" -srcfolder dist/Electrum.app dist/electrum-VERSION-macosx.dmg
|
sudo hdiutil create -fs HFS+ -volname "Electrum" -srcfolder dist/Electrum.app dist/electrum-VERSION-macosx.dmg
|
||||||
|
|
||||||
|
|
|
@ -611,6 +611,10 @@ def verify_message(address, sig, message):
|
||||||
print_error("Verification error: {0}".format(e))
|
print_error("Verification error: {0}".format(e))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def sign_message_with_wif_privkey(sec, message):
|
||||||
|
key = regenerate_key(sec)
|
||||||
|
compressed = is_compressed(sec)
|
||||||
|
return key.sign_message(message, compressed)
|
||||||
|
|
||||||
def encrypt_message(message, pubkey):
|
def encrypt_message(message, pubkey):
|
||||||
return EC_KEY.encrypt_message(message, bfh(pubkey))
|
return EC_KEY.encrypt_message(message, bfh(pubkey))
|
||||||
|
|
|
@ -88,9 +88,7 @@ class Software_KeyStore(KeyStore):
|
||||||
|
|
||||||
def sign_message(self, sequence, message, password):
|
def sign_message(self, sequence, message, password):
|
||||||
sec = self.get_private_key(sequence, password)
|
sec = self.get_private_key(sequence, password)
|
||||||
key = regenerate_key(sec)
|
return sign_message_with_wif_privkey(sec, message)
|
||||||
compressed = is_compressed(sec)
|
|
||||||
return key.sign_message(message, compressed)
|
|
||||||
|
|
||||||
def decrypt_message(self, sequence, message, password):
|
def decrypt_message(self, sequence, message, password):
|
||||||
sec = self.get_private_key(sequence, password)
|
sec = self.get_private_key(sequence, password)
|
||||||
|
|
|
@ -3,6 +3,7 @@ from __future__ import division
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import base64
|
||||||
import six
|
import six
|
||||||
import unittest
|
import unittest
|
||||||
import sys
|
import sys
|
||||||
|
@ -13,7 +14,8 @@ from lib.bitcoin import (
|
||||||
bip32_root, bip32_public_derivation, bip32_private_derivation, pw_encode,
|
bip32_root, bip32_public_derivation, bip32_private_derivation, pw_encode,
|
||||||
pw_decode, Hash, public_key_from_private_key, address_from_private_key,
|
pw_decode, Hash, public_key_from_private_key, address_from_private_key,
|
||||||
is_address, is_private_key, xpub_from_xprv, is_new_seed, is_old_seed,
|
is_address, is_private_key, xpub_from_xprv, is_new_seed, is_old_seed,
|
||||||
var_int, op_push, address_to_script)
|
var_int, op_push, address_to_script, sign_message_with_wif_privkey,
|
||||||
|
verify_message)
|
||||||
from lib.util import bfh
|
from lib.util import bfh
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -55,6 +57,24 @@ class Test_bitcoin(unittest.TestCase):
|
||||||
#print signature
|
#print signature
|
||||||
EC_KEY.verify_message(eck, signature, message)
|
EC_KEY.verify_message(eck, signature, message)
|
||||||
|
|
||||||
|
def test_msg_signing(self):
|
||||||
|
msg1 = b'Chancellor on brink of second bailout for banks'
|
||||||
|
msg2 = b'Electrum'
|
||||||
|
|
||||||
|
sig1 = sign_message_with_wif_privkey(
|
||||||
|
'L1TnU2zbNaAqMoVh65Cyvmcjzbrj41Gs9iTLcWbpJCMynXuap6UN', msg1)
|
||||||
|
sig2 = sign_message_with_wif_privkey(
|
||||||
|
'KzyK8J8eQDLdFtd2Cr2K5w5YFKg6EnAudbGahzMvq5dVSpwyheCa', msg2)
|
||||||
|
|
||||||
|
sig1_b64 = base64.b64encode(sig1)
|
||||||
|
sig2_b64 = base64.b64encode(sig2)
|
||||||
|
|
||||||
|
self.assertEqual(sig1_b64, b'H/9jMOnj4MFbH3d7t4yCQ9i7DgZU/VZ278w3+ySv2F4yIsdqjsc5ng3kmN8OZAThgyfCZOQxZCWza9V5XzlVY0Y=')
|
||||||
|
self.assertEqual(sig2_b64, b'H/9tRQQ2cB/nv02yj6klatxGnrrDTfslM+0YOoUBHlkvHsAYhx+ldRNAPslSj/VI3nwjP2veNhqqidVlkr7IsFI=')
|
||||||
|
|
||||||
|
self.assertTrue(verify_message('15hETetDmcXm1mM4sEf7U2KXC9hDHFMSzz', sig1, msg1))
|
||||||
|
self.assertTrue(verify_message('1LcXfWmCJmvqgpFKDBRhjyN3QqzmawmEAj', sig2, msg2))
|
||||||
|
|
||||||
def test_bip32(self):
|
def test_bip32(self):
|
||||||
# see https://en.bitcoin.it/wiki/BIP_0032_TestVectors
|
# see https://en.bitcoin.it/wiki/BIP_0032_TestVectors
|
||||||
xpub, xprv = self._do_test_bip32("000102030405060708090a0b0c0d0e0f", "m/0'/1/2'/2/1000000000")
|
xpub, xprv = self._do_test_bip32("000102030405060708090a0b0c0d0e0f", "m/0'/1/2'/2/1000000000")
|
||||||
|
|
Loading…
Add table
Reference in a new issue