diff --git a/lbry/lbry/wallet/__init__.py b/lbry/lbry/wallet/__init__.py index ae3591f9d..5bda0326e 100644 --- a/lbry/lbry/wallet/__init__.py +++ b/lbry/lbry/wallet/__init__.py @@ -2,7 +2,7 @@ __node_daemon__ = 'lbrycrdd' __node_cli__ = 'lbrycrd-cli' __node_bin__ = '' __node_url__ = ( - 'https://github.com/lbryio/lbrycrd/releases/download/v0.12.4.1/lbrycrd-linux.zip' + 'https://github.com/lbryio/lbrycrd/releases/download/v0.17.2.1/lbrycrd-linux.zip' ) __spvserver__ = 'lbry.wallet.server.coin.LBCRegTest' diff --git a/lbry/lbry/wallet/server/coin.py b/lbry/lbry/wallet/server/coin.py index 29bd4e4d6..a97ff4871 100644 --- a/lbry/lbry/wallet/server/coin.py +++ b/lbry/lbry/wallet/server/coin.py @@ -102,7 +102,7 @@ class LBC(Coin): ''' Overrides electrumx hashX from script by extracting addresses from claim scripts. ''' - if script and script[0] == OpCodes.OP_RETURN: + if script and script[0] == OpCodes.OP_RETURN or not script: return None if script[0] in [ OutputScript.OP_CLAIM_NAME, diff --git a/lbry/tests/integration/test_wallet_server_sessions.py b/lbry/tests/integration/test_wallet_server_sessions.py index b2e9c779d..b07595b3f 100644 --- a/lbry/tests/integration/test_wallet_server_sessions.py +++ b/lbry/tests/integration/test_wallet_server_sessions.py @@ -33,6 +33,14 @@ class TestSessionBloat(IntegrationTestCase): self.assertEqual(len(self.conductor.spv_node.server.session_mgr.sessions), 0) +class TestSegwitServer(IntegrationTestCase): + LEDGER = lbry.wallet + ENABLE_SEGWIT = True + + async def test_at_least_it_starts(self): + await asyncio.wait_for(self.ledger.network.get_headers(0, 1), 1.0) + + class TestHeadersComponent(CommandTestCase): LEDGER = lbry.wallet diff --git a/torba/torba/client/basescript.py b/torba/torba/client/basescript.py index 560525c09..5ca1d0c00 100644 --- a/torba/torba/client/basescript.py +++ b/torba/torba/client/basescript.py @@ -255,7 +255,7 @@ class Template: self.opcodes = opcodes def parse(self, tokens): - return Parser(self.opcodes, tokens).parse().values + return Parser(self.opcodes, tokens).parse().values if self.opcodes else {} def generate(self, values): source = BCDataStream() @@ -288,6 +288,8 @@ class Script: templates: List[Template] = [] + NO_SCRIPT = Template('no_script', None) # special case + def __init__(self, source=None, template=None, values=None, template_hint=None): self.source = source self._template = template @@ -318,6 +320,8 @@ class Script: def parse(self, template_hint=None): tokens = self.tokens + if not tokens and not template_hint: + template_hint = self.NO_SCRIPT for template in chain((template_hint,), self.templates): if not template: continue diff --git a/torba/torba/orchstr8/node.py b/torba/torba/orchstr8/node.py index b0a38ecc6..b89899684 100644 --- a/torba/torba/orchstr8/node.py +++ b/torba/torba/orchstr8/node.py @@ -67,12 +67,14 @@ def set_logging(ledger_module, level, handler=None): class Conductor: - def __init__(self, ledger_module=None, manager_module=None, verbosity=logging.WARNING): + def __init__(self, ledger_module=None, manager_module=None, verbosity=logging.WARNING, + enable_segwit=False): self.ledger_module = ledger_module or get_ledger_from_environment() self.manager_module = manager_module or get_manager_from_environment() self.spv_module = get_spvserver_from_ledger(self.ledger_module) self.blockchain_node = get_blockchain_node_from_ledger(self.ledger_module) + self.blockchain_node.segwit_enabled = enable_segwit self.spv_node = SPVNode(self.spv_module) self.wallet_node = WalletNode(self.manager_module, self.ledger_module.RegTestLedger) @@ -256,7 +258,7 @@ class BlockchainProcess(asyncio.SubprocessProtocol): class BlockchainNode: - def __init__(self, url, daemon, cli): + def __init__(self, url, daemon, cli, segwit_enabled=False): self.latest_release_url = url self.project_dir = os.path.dirname(os.path.dirname(__file__)) self.bin_dir = os.path.join(self.project_dir, 'bin') @@ -272,6 +274,7 @@ class BlockchainNode: self.rpcport = 9245 + 2 # avoid conflict with default rpc port self.rpcuser = 'rpcuser' self.rpcpassword = 'rpcpassword' + self.segwit_enabled = segwit_enabled @property def rpc_url(self): @@ -325,12 +328,14 @@ class BlockchainNode: self.data_path = tempfile.mkdtemp() loop = asyncio.get_event_loop() asyncio.get_child_watcher().attach_loop(loop) - command = ( + command = [ self.daemon_bin, f'-datadir={self.data_path}', '-printtoconsole', '-regtest', '-server', '-txindex', f'-rpcuser={self.rpcuser}', f'-rpcpassword={self.rpcpassword}', f'-rpcport={self.rpcport}', f'-port={self.peerport}' - ) + ] + if not self.segwit_enabled: + command.extend(['-addresstype=legacy', '-vbparams=segwit:0:999999999999']) self.log.info(' '.join(command)) self.transport, self.protocol = await loop.subprocess_exec( BlockchainProcess, *command diff --git a/torba/torba/testcase.py b/torba/torba/testcase.py index 42390ee07..b7c9ccbba 100644 --- a/torba/torba/testcase.py +++ b/torba/torba/testcase.py @@ -185,6 +185,7 @@ class IntegrationTestCase(AsyncioTestCase): LEDGER = None MANAGER = None + ENABLE_SEGWIT = False VERBOSITY = logging.WARN def __init__(self, *args, **kwargs): @@ -199,7 +200,8 @@ class IntegrationTestCase(AsyncioTestCase): async def asyncSetUp(self): self.conductor = Conductor( - ledger_module=self.LEDGER, manager_module=self.MANAGER, verbosity=self.VERBOSITY + ledger_module=self.LEDGER, manager_module=self.MANAGER, verbosity=self.VERBOSITY, + enable_segwit=self.ENABLE_SEGWIT ) await self.conductor.start_blockchain() self.addCleanup(self.conductor.stop_blockchain)