def test_extract_nodeid(self): with self.assertRaises(ConnStringFormatError): extract_nodeid("00" * 32 + "@localhost") with self.assertRaises(ConnStringFormatError): extract_nodeid("00" * 33 + "@") self.assertEqual(extract_nodeid("00" * 33 + "@localhost"), (b"\x00" * 33, "localhost"))
def _open_channel(self, x, conn_str, amount): if not x: return lnworker = self.app.wallet.lnworker coins = self.app.wallet.get_spendable_coins(None, nonlocal_only=True) node_id, rest = extract_nodeid(conn_str) make_tx = lambda rbf: lnworker.mktx_for_open_channel( coins=coins, funding_sat=amount, node_id=node_id, fee_est=None) on_pay = lambda tx: self.app.protected('Create a new channel?', self.do_open_channel, (tx, conn_str)) d = ConfirmTxDialog( self.app, amount = amount, make_tx=make_tx, on_pay=on_pay, show_final=False) d.open()
def open_channel(self): if not self.pubkey or not self.amount: self.app.show_info(_('All fields must be filled out')) return if self.use_gossip: conn_str = self.pubkey if self.ipport: conn_str += '@' + self.ipport.strip() else: conn_str = str(self.trampolines[self.pubkey]) amount = '!' if self.is_max else self.app.get_amount(self.amount) self.dismiss() lnworker = self.app.wallet.lnworker try: node_id, rest = extract_nodeid(conn_str) except ConnStringFormatError as e: self.app.show_error(_('Problem opening channel: ') + '\n' + str(e)) return if lnworker.has_conflicting_backup_with(node_id): msg = messages.MGS_CONFLICTING_BACKUP_INSTANCE d = Question(msg, lambda x: self._open_channel(x, conn_str, amount)) d.open() else: self._open_channel(True, conn_str, amount)