本文整理汇总了Python中bitcoin.SelectParams方法的典型用法代码示例。如果您正苦于以下问题:Python bitcoin.SelectParams方法的具体用法?Python bitcoin.SelectParams怎么用?Python bitcoin.SelectParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bitcoin
的用法示例。
在下文中一共展示了bitcoin.SelectParams方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_multisig_address
# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import SelectParams [as 别名]
def generate_multisig_address(redeemscript: str, testnet: bool = False) -> str:
"""
Generates a P2SH-multisig Bitcoin address from a redeem script
Args:
redeemscript: hex-encoded redeem script
use generate_multisig_redeem_script to create
the redeem script from three compressed public keys
testnet: Should the address be testnet or mainnet?
Example:
TODO
"""
if testnet:
bitcoin.SelectParams('testnet')
redeem_script = CScript(bitcoin.core.x(redeemscript))
addr = P2SHBitcoinAddress.from_redeemScript(redeem_script)
return str(addr)
示例2: validate_request
# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import SelectParams [as 别名]
def validate_request(self) -> None:
"""Validates a signature request
Validates
* the redeem script
* inputs & outputs
* fee
"""
if self.testnet:
SelectParams('testnet')
else:
SelectParams('mainnet')
self._validate_input_groups()
self._validate_outputs()
self._validate_fee()
示例3: do_execute
# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import SelectParams [as 别名]
def do_execute(self):
if self.signing_key is None or self.content_to_verify is None or self.signature_value is None:
return False
message = BitcoinMessage(self.content_to_verify)
try:
lock.acquire()
# obtain lock while modifying global state
bitcoin.SelectParams(chain_to_bitcoin_network(self.chain))
return VerifyMessage(self.signing_key, message, self.signature_value)
finally:
lock.release()
示例4: test_auto_switch_params_decorator
# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import SelectParams [as 别名]
def test_auto_switch_params_decorator(network):
if network.name == 'bitcoin':
assert simple_params_name_return(network) == 'mainnet'
elif network.name == 'test-bitcoin':
assert simple_params_name_return(network) == 'testnet'
else:
assert simple_params_name_return(network) == network.name
bitcoin.SelectParams('mainnet')
示例5: get_config
# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import SelectParams [as 别名]
def get_config():
configure_logger()
p = configargparse.getArgumentParser(default_config_files=[os.path.join(PATH, 'conf.ini'),
'/etc/cert-issuer/conf.ini'])
add_arguments(p)
parsed_config, _ = p.parse_known_args()
if not parsed_config.safe_mode:
logging.warning('Your app is configured to skip the wifi check when the USB is plugged in. Read the '
'documentation to ensure this is what you want, since this is less secure')
# overwrite with enum
parsed_config.chain = Chain.parse_from_chain(parsed_config.chain)
# ensure it's a supported chain
if parsed_config.chain.blockchain_type != BlockchainType.bitcoin and \
parsed_config.chain.blockchain_type != BlockchainType.ethereum and \
parsed_config.chain.blockchain_type != BlockchainType.mock:
raise UnknownChainError(parsed_config.chain.name)
logging.info('This run will try to issue on the %s chain', parsed_config.chain.name)
if parsed_config.chain.blockchain_type == BlockchainType.bitcoin:
bitcoin_chain_for_python_bitcoinlib = parsed_config.chain
if parsed_config.chain == Chain.bitcoin_regtest:
bitcoin_chain_for_python_bitcoinlib = Chain.bitcoin_regtest
bitcoin.SelectParams(chain_to_bitcoin_network(bitcoin_chain_for_python_bitcoinlib))
global CONFIG
CONFIG = parsed_config
return parsed_config
示例6: setUp
# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import SelectParams [as 别名]
def setUp(self):
self.context = Mock()
self.prepare = Prepare(self.context)
bitcoin.SelectParams('regtest')
示例7: main
# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import SelectParams [as 别名]
def main():
cmd_parser = argparse.ArgumentParser(
description='Simcoin a cryptocurrency simulator.',
usage='''<command> [<args>]
The commands are:
nodes creates the {} for a simulation
network creates the {} for a simulation
ticks creates the {} for a simulation
simulate executes a simulation based on the {}, {} and {}
run runs all above commands
multi-run run the simulation multiple times
'''.format(
config.nodes_csv_file_name,
config.network_csv_file_name,
config.ticks_csv_file_name,
config.nodes_csv_file_name,
config.network_csv_file_name,
config.ticks_csv_file_name,
))
cmd_parser.add_argument('command', help='Subcommand to run')
# parse_args defaults to [1:] for args, but you need to
# exclude the rest of the args too, or validation will fail
args = cmd_parser.parse_args(sys.argv[1:2])
command = args.command
if command not in commands:
print('Unrecognized command')
cmd_parser.print_help()
exit(1)
# use dispatch pattern to invoke method with same name
if not os.path.exists(config.data_dir):
os.makedirs(config.data_dir)
bitcoin.SelectParams('regtest')
args = _parse_args()
utils.config_logger(args.verbose)
logging.info("Arguments called with: {}".format(sys.argv))
logging.info("Parsed arguments in simcoin.py: {}".format(args))
logging.info('Executing command={}'.format(command))
commands[command]()