Ejemplo n.º 1
0
 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):
     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)
Ejemplo n.º 3
0
 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
     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()
Ejemplo n.º 4
0
    def validate(self):
        nodeid_valid = False
        if self._nodeid:
            if not self._wallet.wallet.config.get('use_gossip', False):
                self._peer = hardcoded_trampoline_nodes()[self._nodeid]
                nodeid_valid = True
            else:
                try:
                    node_pubkey, host_port = extract_nodeid(self._nodeid)
                    host, port = host_port.split(':', 1)
                    self._peer = LNPeerAddr(host, int(port), node_pubkey)
                    nodeid_valid = True
                except ConnStringFormatError as e:
                    self.validationError.emit('invalid_nodeid', repr(e))
                except ValueError as e:
                    self.validationError.emit('invalid_nodeid', repr(e))

        if not nodeid_valid:
            self._valid = False
            self.validChanged.emit()
            return

        self._logger.debug('amount=%s' % str(self._amount))
        if not self._amount or not (self._amount.satsInt > 0
                                    or self._amount.isMax):
            self._valid = False
            self.validChanged.emit()
            return

        self._valid = True
        self.validChanged.emit()
 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()