def main():
    from hathor.cli.util import create_parser
    from hathor.crypto.util import get_private_key_from_bytes

    parser = create_parser()

    parser.add_argument('data',
                        nargs='+',
                        help='Encode data in oracle format.')
    parser.add_argument(
        '--keyfile', help='Path to a private key file, used to sign the data')
    args = parser.parse_args()

    binary_data = b''

    for d in args.data:
        [t, _data] = d.split(':')
        if t == 'int':
            b = encode_int(_data)
        elif t == 'str':
            b = encode_str(_data)
        else:
            print('wrong data type {}'.format(d))
            return 1

        binary_data += (bytes([len(b)]) + b)

    print('data (base64):', base64.b64encode(binary_data).decode('utf-8'))

    with open(args.keyfile, 'r') as key_file:
        private_key_bytes = base64.b64decode(key_file.read())
    private_key = get_private_key_from_bytes(private_key_bytes)
    signature = private_key.sign(binary_data, ec.ECDSA(hashes.SHA256()))
    print('signature (base64):', base64.b64encode(signature).decode('utf-8'))
Exemple #2
0
def create_parser() -> ArgumentParser:
    from hathor.cli.util import create_parser
    parser = create_parser()
    parser.add_argument('--address', help='Address to send funds to', type=str, required=False)
    parser.add_argument('--host', help='Hostname of Stratum server', type=str, required=True)
    parser.add_argument('--port', help='Port of Stratum server', type=int, required=True)
    parser.add_argument('--nproc', help='Number of mining processes', type=int)
    return parser
def create_parser() -> ArgumentParser:
    from hathor.cli.util import create_parser
    parser = create_parser()
    parser.add_argument('partial_tx', type=str, help='Tx to be signed in hex')
    parser.add_argument('private_key',
                        type=str,
                        help='Encrypted private key in hex')
    return parser
Exemple #4
0
def create_parser() -> ArgumentParser:
    from hathor.cli.util import create_parser
    parser = create_parser()
    parser.add_argument('--count',
                        type=int,
                        default=20,
                        help='Number of keys/addresses (default=20)')
    parser.add_argument('--directory', help='Wallet directory')
    return parser
def create_parser() -> ArgumentParser:
    from hathor.cli.util import create_parser
    parser = create_parser()
    parser.add_argument('partial_tx', type=str, help='Tx to spend multisig fund')
    parser.add_argument(
        'signatures', type=str,
        help='Signatures in hex of the private keys in the same order as the public keys (separated by a comma)')
    parser.add_argument('redeem_script', type=str, help='Redeem script in hex')
    return parser
Exemple #6
0
def create_parser() -> ArgumentParser:
    from hathor.cli.util import create_parser
    parser = create_parser()
    parser.add_argument('url', help='URL to get mining bytes')
    parser.add_argument('--init-delay',
                        type=float,
                        help='Wait N seconds before starting (in seconds)',
                        default=None)
    parser.add_argument('--sleep',
                        type=float,
                        help='Sleep every 2 seconds (in seconds)')
    parser.add_argument('--count',
                        type=int,
                        help='Quantity of blocks to be mined')
    return parser
Exemple #7
0
def main():
    from hathor.cli.util import create_parser
    from hathor.crypto.util import get_hash160, get_private_key_bytes, get_public_key_bytes_compressed

    parser = create_parser()

    parser.add_argument('filepath', help='Create a new private key in the given file')
    args = parser.parse_args()

    new_key = ec.generate_private_key(ec.SECP256K1(), default_backend())
    private_key_bytes = get_private_key_bytes(new_key)
    with open(args.filepath, 'w') as key_file:
        key_file.write(base64.b64encode(private_key_bytes).decode('utf-8'))
        print('key created!')
    public_key_bytes = get_public_key_bytes_compressed(new_key.public_key())
    print('base64 pubkey hash:', base64.b64encode(get_hash160(public_key_bytes)).decode('utf-8'))
def create_parser() -> ArgumentParser:
    from hathor.cli.util import create_parser
    parser = create_parser()
    parser.add_argument('signatures_required',
                        type=int,
                        help='Mimimum quantity of signatures required')
    parser.add_argument('--pubkey_count',
                        type=int,
                        help='Quantity of public keys in the multisig')
    parser.add_argument('--public_keys',
                        type=str,
                        help='Public keys in hex separated by comma')
    parser.add_argument('--dir',
                        type=str,
                        help='Directory of key pair wallet keys')
    return parser
Exemple #9
0
def main() -> None:
    from hathor.cli.util import create_parser
    parser = create_parser()
    parser.add_argument('url', help='URL of the full-node API')
    parser.add_argument('-g',
                        action='store_true',
                        help='Group small CPU percent')
    parser.add_argument('--alias', help='Alias to the server')
    args = parser.parse_args(sys.argv[1:])

    # data = fetch_data(args.url)
    # print_screen(data, print_fn=print, group_small_cpu_percent=True)

    loop = asyncio.get_event_loop()
    fetcher = ProfileAPIClient(loop, args.url)
    ScreenManager(loop, fetcher, alias=args.alias)
    loop.run_forever()
def main():
    import argparse
    import sys

    from hathor.cli.util import create_parser

    parser = create_parser()
    parser.add_argument('-k',
                        '--rate-multiplier',
                        type=float,
                        default=1.0,
                        help='How much to multiply all rates by (float)')
    parser.add_argument(
        '-i',
        '--input-openapi-json',
        type=argparse.FileType('r', encoding='UTF-8'),
        default=None,
        help=
        'Input file with OpenAPI json, if not specified the spec is generated on-the-fly'
    )
    parser.add_argument(
        '--fallback-visibility',
        type=Visibility,
        default=Visibility.PRIVATE,
        help=
        'Set the visibility for paths without `x-visibility`, defaults to private'
    )
    parser.add_argument(
        '--disable-rate-limits',
        type=bool,
        default=False,
        help='Disable including rate-limits in the config, defaults to False')
    parser.add_argument('out',
                        type=argparse.FileType('w', encoding='UTF-8'),
                        default=sys.stdout,
                        nargs='?',
                        help='Output file where nginx config will be written')
    args = parser.parse_args()

    openapi = get_openapi(args.input_openapi_json)
    generate_nginx_config(openapi,
                          out_file=args.out,
                          rate_k=args.rate_multiplier,
                          fallback_visibility=args.fallback_visibility,
                          disable_rate_limits=args.disable_rate_limits)
def main():
    from hathor.cli.util import create_parser
    from hathor.crypto.util import get_hash160, get_private_key_from_bytes, get_public_key_bytes_compressed

    parser = create_parser()

    parser.add_argument('filepath',
                        help='Get public key hash given the private key file')
    args = parser.parse_args()

    with open(args.filepath, 'r') as key_file:
        private_key_bytes = base64.b64decode(key_file.read())
    private_key = get_private_key_from_bytes(private_key_bytes)
    public_key_bytes = get_public_key_bytes_compressed(
        private_key.public_key())
    print('base64:', base64.b64encode(public_key_bytes).decode('utf-8'))
    print('hash base64:',
          base64.b64encode(get_hash160(public_key_bytes)).decode('utf-8'))
Exemple #12
0
def main():
    import argparse

    from hathor.cli.util import create_parser

    parser = create_parser()
    parser.add_argument('--indent',
                        type=int,
                        default=None,
                        help='Number of spaces to use for indentation')
    parser.add_argument('out',
                        type=argparse.FileType('w', encoding='UTF-8'),
                        default=DEFAULT_OUTPUT_PATH,
                        nargs='?',
                        help='Output file where OpenSPI json will be written')
    args = parser.parse_args()

    openapi = get_openapi_dict()
    json.dump(openapi, args.out, indent=args.indent)
Exemple #13
0
def create_parser() -> ArgumentParser:
    from hathor.cli.util import create_parser
    parser = create_parser()
    parser.add_argument(
        '--url', help='URL to access tx storage in case the hash was passed')
    parser.add_argument('--hash', help='Hash of tx to create a twin')
    parser.add_argument('--raw_tx', help='Raw tx to create a twin')
    parser.add_argument('--human',
                        action='store_true',
                        help='Print in human readable (json)')
    parser.add_argument(
        '--parents',
        action='store_true',
        help='Change the parents, so they can have different accumulated weight'
    )
    parser.add_argument('--weight',
                        type=int,
                        help='Weight of twin transaction')
    return parser
Exemple #14
0
def create_parser() -> ArgumentParser:
    from hathor.cli.util import create_parser
    parser = create_parser()
    parser.add_argument('url', help='URL to get mining bytes')
    parser.add_argument('--address', action='append')
    parser.add_argument('--value', action='append')
    parser.add_argument('--rate', type=float, help='tx/s')
    parser.add_argument('--weight', type=float, help='Weight')
    parser.add_argument('--count',
                        type=int,
                        help='Quantity of txs to be generated')
    parser.add_argument(
        '--timestamp',
        action='append',
        choices=['client', 'server'],
        help='If the tx timestamp '
        'should be set on the client or server. If this parameter is not given, server will set '
        'the timestamp as part of regular tx creation')
    parser.add_argument('--profiler',
                        action='store_true',
                        default=False,
                        help='Enable profiling')
    return parser
def create_parser() -> ArgumentParser:
    from hathor.cli.util import create_parser
    parser = create_parser()
    parser.add_argument('--port',
                        help='Port of Stratum server',
                        type=int,
                        required=True)
    parser.add_argument('--hathor-stratum',
                        help='Endpoint of the Hathor Stratum',
                        type=str,
                        required=True)
    parser.add_argument('--hathor-address',
                        help='Hathor address to send funds to',
                        type=str,
                        required=False)
    parser.add_argument('--bitcoin-rpc',
                        help='Endpoint of the Bitcoin RPC',
                        type=str,
                        required=True)
    parser.add_argument('--bitcoin-address',
                        help='Bitcoin address to send funds to',
                        type=str,
                        required=False)
    return parser
def create_parser() -> ArgumentParser:
    from hathor.cli.util import create_parser
    parser = create_parser()
    parser.add_argument('--port',
                        help='Port of Stratum server',
                        type=int,
                        required=True)
    parser.add_argument('--status',
                        help='Port of Status server',
                        type=int,
                        required=False)
    parser.add_argument('--debug-listen',
                        help='Port to listen for Debug API',
                        type=int,
                        required=False)
    parser.add_argument('--hathor-api',
                        help='Endpoint of the Hathor API (without version)',
                        type=str,
                        required=True)
    parser.add_argument('--hathor-address',
                        help='Hathor address to send funds to',
                        type=str,
                        required=False)
    parser.add_argument('--bitcoin-rpc',
                        help='Endpoint of the Bitcoin RPC',
                        type=str,
                        required=True)
    parser.add_argument('--bitcoin-address',
                        help='Bitcoin address to send funds to',
                        type=str,
                        required=False)
    parser.add_argument('--min-diff',
                        help='Minimum difficulty to set for jobs',
                        type=int,
                        required=False)
    return parser
def main():
    parser = create_parser()
    args = parser.parse_args()
    priv_key_password = getpass.getpass(prompt='Password to decrypt the private key:')
    execute(args, priv_key_password)
Exemple #18
0
def main():
    parser = create_parser()
    args = parser.parse_args()
    execute(args)
Exemple #19
0
    def create_parser(self) -> ArgumentParser:
        from hathor.cli.util import create_parser
        parser = create_parser()

        parser.add_argument('--hostname', help='Hostname used to be accessed by other peers')
        parser.add_argument('--auto-hostname', action='store_true', help='Try to discover the hostname automatically')
        parser.add_argument('--unsafe-mode',
                            help='Enable unsafe parameters. **NEVER USE IT IN PRODUCTION ENVIRONMENT**')
        parser.add_argument('--testnet', action='store_true', help='Connect to Hathor testnet')
        parser.add_argument('--test-mode-tx-weight', action='store_true',
                            help='Reduces tx weight to 1 for testing purposes')
        parser.add_argument('--dns', action='append', help='Seed DNS')
        parser.add_argument('--peer', help='json file with peer info')
        parser.add_argument('--listen', action='append', default=[],
                            help='Address to listen for new connections (eg: tcp:8000)')
        parser.add_argument('--bootstrap', action='append', help='Address to connect to (eg: tcp:127.0.0.1:8000')
        parser.add_argument('--status', type=int, help='Port to run status server')
        parser.add_argument('--stratum', type=int, help='Port to run stratum server')
        parser.add_argument('--data', help='Data directory')
        storage = parser.add_mutually_exclusive_group()
        storage.add_argument('--rocksdb-storage', action='store_true', help='Use RocksDB storage backend (default)')
        storage.add_argument('--memory-storage', action='store_true', help='Do not use any storage')
        storage.add_argument('--json-storage', action='store_true', help='Use legacy JSON storage (not recommended)')
        parser.add_argument('--rocksdb-cache', type=int, help='RocksDB block-table cache size (bytes)', default=None)
        parser.add_argument('--wallet', help='Set wallet type. Options are hd (Hierarchical Deterministic) or keypair',
                            default=None)
        parser.add_argument('--wallet-enable-api', action='store_true',
                            help='Enable wallet API. Must be used with --wallet.'),
        parser.add_argument('--words', help='Words used to generate the seed for HD Wallet')
        parser.add_argument('--passphrase', action='store_true',
                            help='Passphrase used to generate the seed for HD Wallet')
        parser.add_argument('--unlock-wallet', action='store_true', help='Ask for password to unlock wallet')
        parser.add_argument('--wallet-index', action='store_true',
                            help='Create an index of transactions by address and allow searching queries')
        parser.add_argument('--prometheus', action='store_true', help='Send metric data to Prometheus')
        parser.add_argument('--cache', action='store_true', help='Use cache for tx storage')
        parser.add_argument('--cache-size', type=int, help='Number of txs to keep on cache')
        parser.add_argument('--cache-interval', type=int, help='Cache flush interval')
        parser.add_argument('--recursion-limit', type=int, help='Set python recursion limit')
        parser.add_argument('--allow-mining-without-peers', action='store_true', help='Allow mining without peers')
        fvargs = parser.add_mutually_exclusive_group()
        fvargs.add_argument('--x-full-verification', action='store_true', help='Fully validate the local database')
        fvargs.add_argument('--x-fast-init-beta', action='store_true',
                            help='Execute a fast initialization, which skips some transaction verifications. '
                            'This is still a beta feature as it may cause issues when restarting the full node '
                            'after a crash.')
        parser.add_argument('--procname-prefix', help='Add a prefix to the process name', default='')
        parser.add_argument('--allow-non-standard-script', action='store_true', help='Accept non-standard scripts on '
                            '/push-tx API')
        parser.add_argument('--max-output-script-size', type=int, default=None, help='Custom max accepted script size '
                            'on /push-tx API')
        parser.add_argument('--sentry-dsn', help='Sentry DSN')
        parser.add_argument('--enable-debug-api', action='store_true', help='Enable _debug/* endpoints')
        parser.add_argument('--enable-crash-api', action='store_true', help='Enable _crash/* endpoints')
        v2args = parser.add_mutually_exclusive_group()
        v2args.add_argument('--x-sync-bridge', action='store_true',
                            help='Enable support for running both sync protocols. DO NOT ENABLE, IT WILL BREAK.')
        v2args.add_argument('--x-sync-v2-only', action='store_true',
                            help='Disable support for running sync-v1. DO NOT ENABLE, IT WILL BREAK.')
        parser.add_argument('--x-localhost-only', action='store_true', help='Only connect to peers on localhost')
        parser.add_argument('--x-rocksdb-indexes', action='store_true', help='Use RocksDB indexes (currently opt-in)')
        return parser
Exemple #20
0
def main():
    parser = create_parser()
    args = parser.parse_args()
    passwd = getpass.getpass(prompt='Wallet password:')
    execute(args, passwd)
Exemple #21
0
def create_parser() -> ArgumentParser:
    from hathor.cli.util import create_parser
    parser = create_parser()
    parser.add_argument('--language', help='Words language')
    parser.add_argument('--count', type=int, help='Word count')
    return parser
def create_parser() -> ArgumentParser:
    from hathor.cli.util import create_parser
    parser = create_parser()
    parser.add_argument('title', help='Title of the dashboard')
    parser.add_argument('--data_source', help='Name of data source')
    return parser
Exemple #23
0
    def create_parser(self) -> ArgumentParser:
        from hathor.cli.util import create_parser
        parser = create_parser()

        parser.add_argument('--hostname',
                            help='Hostname used to be accessed by other peers')
        parser.add_argument('--auto-hostname',
                            action='store_true',
                            help='Try to discover the hostname automatically')
        parser.add_argument('--testnet',
                            action='store_true',
                            help='Connect to Hathor testnet')
        parser.add_argument('--test-mode-tx-weight',
                            action='store_true',
                            help='Reduces tx weight to 1 for testing purposes')
        parser.add_argument('--dns', action='append', help='Seed DNS')
        parser.add_argument('--peer', help='json file with peer info')
        parser.add_argument(
            '--listen',
            action='append',
            default=[],
            help='Address to listen for new connections (eg: tcp:8000)')
        parser.add_argument(
            '--bootstrap',
            action='append',
            help='Address to connect to (eg: tcp:127.0.0.1:8000')
        parser.add_argument('--status',
                            type=int,
                            help='Port to run status server')
        parser.add_argument('--stratum',
                            type=int,
                            help='Port to run stratum server')
        parser.add_argument('--data', help='Data directory')
        parser.add_argument('--rocksdb-storage',
                            action='store_true',
                            help='Use RocksDB storage backend')
        parser.add_argument(
            '--wallet',
            help=
            'Set wallet type. Options are hd (Hierarchical Deterministic) or keypair',
            default=None)
        parser.add_argument(
            '--wallet-enable-api',
            action='store_true',
            help='Enable wallet API. Must be used with --wallet.'),
        parser.add_argument(
            '--words', help='Words used to generate the seed for HD Wallet')
        parser.add_argument(
            '--passphrase',
            action='store_true',
            help='Passphrase used to generate the seed for HD Wallet')
        parser.add_argument('--unlock-wallet',
                            action='store_true',
                            help='Ask for password to unlock wallet')
        parser.add_argument(
            '--wallet-index',
            action='store_true',
            help=
            'Create an index of transactions by address and allow searching queries'
        )
        parser.add_argument('--prometheus',
                            action='store_true',
                            help='Send metric data to Prometheus')
        parser.add_argument('--cache',
                            action='store_true',
                            help='Use cache for tx storage')
        parser.add_argument('--cache-size',
                            type=int,
                            help='Number of txs to keep on cache')
        parser.add_argument('--cache-interval',
                            type=int,
                            help='Cache flush interval')
        parser.add_argument('--recursion-limit',
                            type=int,
                            help='Set python recursion limit')
        parser.add_argument('--allow-mining-without-peers',
                            action='store_true',
                            help='Allow mining without peers')
        parser.add_argument('--min-block-weight',
                            type=int,
                            help='Minimum weight for blocks')
        return parser