Addressed passed via CLI no longer needs to be a checksum address; can just be a regular hex address. Bob can now pass it.

pull/1040/head
jMyles 2019-05-17 13:44:53 -04:00 committed by Kieran Prasch
parent 03396602c5
commit 54826e3d74
No known key found for this signature in database
GPG Key ID: 199AB839D4125A62
3 changed files with 22 additions and 13 deletions

View File

@ -14,7 +14,7 @@ from nucypher.config.characters import AliceConfiguration
@click.command()
@click.argument('action')
@click.option('--checksum-address', help="Run with a specified account", type=EIP55_CHECKSUM_ADDRESS)
@click.option('--pay-with', help="Run with a specified account", type=EIP55_CHECKSUM_ADDRESS)
@click.option('--teacher-uri', help="An Ursula URI to start learning from (seednode)", type=click.STRING)
@click.option('--min-stake', help="The minimum stake the teacher must have to be a teacher", type=click.INT, default=0)
@click.option('--discovery-port', help="The host port to run node discovery services on", type=NETWORK_PORT, default=9151) # TODO
@ -38,7 +38,7 @@ from nucypher.config.characters import AliceConfiguration
@nucypher_click_config
def alice(click_config,
action,
checksum_address,
pay_with,
teacher_uri,
min_stake,
http_port,
@ -78,7 +78,7 @@ def alice(click_config,
new_alice_config = AliceConfiguration.generate(password=click_config.get_password(confirm=True),
config_root=config_root,
checksum_public_address=checksum_address,
checksum_public_address=pay_with,
rest_host="localhost",
domains={network} if network else None,
federated_only=federated_only,
@ -107,7 +107,7 @@ def alice(click_config,
domains={network} if network else None,
network_middleware=click_config.middleware,
rest_port=discovery_port,
checksum_public_address=checksum_address,
checksum_public_address=pay_with,
provider_uri=provider_uri)
except FileNotFoundError:
return actions.handle_missing_configuration_file(character_config_class=AliceConfiguration,

View File

@ -4,17 +4,20 @@ from nucypher.characters.banners import BOB_BANNER
from nucypher.characters.control.emitters import IPCStdoutEmitter
from nucypher.cli import actions, painting
from nucypher.cli.config import nucypher_click_config
from nucypher.cli.types import NETWORK_PORT, EXISTING_READABLE_FILE
from nucypher.cli.types import NETWORK_PORT, EXISTING_READABLE_FILE, EIP55_CHECKSUM_ADDRESS
from nucypher.config.characters import BobConfiguration
from nucypher.config.constants import DEFAULT_CONFIG_ROOT
from nucypher.crypto.powers import DecryptingPower
@click.command()
@click.argument('action')
@click.option('--pay-with', help="Run with a specified account", type=EIP55_CHECKSUM_ADDRESS)
@click.option('--teacher-uri', help="An Ursula URI to start learning from (seednode)", type=click.STRING)
@click.option('--quiet', '-Q', help="Disable logging", is_flag=True)
@click.option('--min-stake', help="The minimum stake the teacher must have to be a teacher", type=click.INT, default=0)
@click.option('--discovery-port', help="The host port to run node discovery services on", type=NETWORK_PORT, default=6151) # TODO
@click.option('--discovery-port', help="The host port to run node discovery services on", type=NETWORK_PORT,
default=6151) # TODO
@click.option('--http-port', help="The host port to run Moe HTTP services on", type=NETWORK_PORT, default=11151) # TODO
@click.option('--federated-only', '-F', help="Connect only to federated nodes", is_flag=True)
@click.option('--network', help="Network Domain Name", type=click.STRING)
@ -26,7 +29,8 @@ from nucypher.crypto.powers import DecryptingPower
@click.option('--dev', '-d', help="Enable development mode", is_flag=True)
@click.option('--force', help="Don't ask for confirmation", is_flag=True)
@click.option('--dry-run', '-x', help="Execute normally without actually starting the node", is_flag=True)
@click.option('--policy-encrypting-key', help="Encrypting Public Key for Policy as hexadecimal string", type=click.STRING)
@click.option('--policy-encrypting-key', help="Encrypting Public Key for Policy as hexadecimal string",
type=click.STRING)
@click.option('--alice-verifying-key', help="Alice's verifying key as a hexadecimal string", type=click.STRING)
@click.option('--message-kit', help="The message kit unicode string encoded in base64", type=click.STRING)
@nucypher_click_config
@ -41,6 +45,7 @@ def bob(click_config,
network,
config_root,
config_file,
pay_with,
provider_uri,
registry_filepath,
dev,
@ -63,11 +68,12 @@ def bob(click_config,
if dev:
raise click.BadArgumentUsage("Cannot create a persistent development character")
if not config_root: # Flag
if not config_root: # Flag
config_root = click_config.config_file # Envvar
new_bob_config = BobConfiguration.generate(password=click_config.get_password(confirm=True),
config_root=config_root or click_config,
config_root=config_root or DEFAULT_CONFIG_ROOT,
checksum_public_address=pay_with,
rest_host="localhost",
domains={network} if network else None,
federated_only=federated_only,
@ -87,6 +93,7 @@ def bob(click_config,
domains={network},
provider_uri=provider_uri,
federated_only=True,
checksum_public_address=pay_with,
network_middleware=click_config.middleware)
else:
@ -94,6 +101,7 @@ def bob(click_config,
bob_config = BobConfiguration.from_configuration_file(
filepath=config_file,
domains={network} if network else None,
checksum_public_address=pay_with,
rest_port=discovery_port,
provider_uri=provider_uri,
network_middleware=click_config.middleware)

View File

@ -18,7 +18,7 @@ along with nucypher. If not, see <https://www.gnu.org/licenses/>.
from ipaddress import ip_address
import click
from eth_utils import is_checksum_address
from eth_utils import is_checksum_address, to_checksum_address
from nucypher.blockchain.economics import TokenEconomics
from nucypher.blockchain.eth.token import NU
@ -28,9 +28,10 @@ class ChecksumAddress(click.ParamType):
name = 'checksum_public_address'
def convert(self, value, param, ctx):
if is_checksum_address(value):
return value
self.fail('{} is not a valid EIP-55 checksum address'.format(value, param, ctx))
# if is_checksum_address(value):
# return value
return to_checksum_address(value=value)
# self.fail('{} is not a valid EIP-55 checksum address'.format(value, param, ctx))
class IPv4Address(click.ParamType):