Exemplo n.º 1
0
    def save_current_masternode(self, as_new=False):
        """Save the masternode that is being viewed.

        If as_new is True, a new masternode will be created.
        """
        delegate_privkey = str(self.masternode_editor.delegate_key_edit.text())
        if not delegate_privkey:
            self.show_warning(_('Delegate private key is empty.'),
                              title=_('Warning'))
            return

        try:
            delegate_pubkey = self.manager.import_masternode_delegate(
                delegate_privkey)
        except Exception:
            # Show an error if the private key is invalid and not an empty string.
            if delegate_privkey:
                self.show_warning(_('Ignoring invalid delegate private key.'),
                                  title=_('Warning'))
            delegate_pubkey = ''

        alias = str(self.masternode_editor.alias_edit.text())
        # Construct a new masternode.
        if as_new:
            kwargs = self.masternode_editor.get_masternode_args()
            kwargs['delegate_key'] = delegate_pubkey
            del kwargs['vin']
            self.mapper.revert()
            self.masternodes_widget.add_masternode(
                MasternodeAnnounce(**kwargs))
        else:
            self.mapper.submit()
        self.manager.save()
        self.masternodes_widget.select_masternode(alias)
Exemplo n.º 2
0
    def test_create_and_sign(self):
        collateral_pub = '038ae57bd0fa5b45640e771614ec571c7326a2266c78bb444f1971c85188411ba1'  # 1Feczj12KEioQTrXhd4zUUdmijxzwXfdcE
        delegate_pub = '02526201c87c1b4630aabbd04572eec3e2545e442503e57e60880fafcc1f684dbc'  # 1NLwcP3gVQPZHUdjKVrU9J4v4jRSYsB4Dj
        protocol_version = 70103

        ip = '0.0.0.0'
        port = 20000
        addr = NetworkAddress(ip=ip, port=port)

        vin = {
            'prevout_hash': '00' * 32,
            'prevout_n': 0,
            'scriptSig': '',
            'sequence': 0xffffffff
        }

        last_ping = MasternodePing(vin=vin, block_hash='ff' * 32)

        announce = MasternodeAnnounce(vin=vin,
                                      addr=addr,
                                      collateral_key=collateral_pub,
                                      delegate_key=delegate_pub,
                                      protocol_version=protocol_version,
                                      last_ping=last_ping)

        collateral_wif = '5K4hm916sRw93k9eoSf4XfHvUmi4ZyEpfMMT7yprvWPhTCc7wcJ'
        delegate_wif = '5HsgYSCySd34BySFqo1CDaYHJVdHy1yqBXk3dGy9ABB3B4Pos3T'
        announce.last_ping.sign(delegate_wif, bfh(delegate_pub), 1461858375)
        sig = announce.sign(collateral_wif, 1461858375)

        address = '1Feczj12KEioQTrXhd4zUUdmijxzwXfdcE'
        self.assertTrue(announce.verify(address))
        self.assertTrue(
            ecc.verify_message_with_address(address, sig,
                                            announce.serialize_for_sig()))
Exemplo n.º 3
0
    def __init__(self, manager, parent):
        super(MasternodeDialog, self).__init__(parent)
        Logger.__init__(self)
        self.gui = parent
        self.manager = manager
        self.setWindowTitle(_('Masternode Manager'))

        self.waiting_dialog = None
        self.create_layout()
        # Create a default masternode if none are present.
        if len(self.manager.masternodes) == 0:
            self.masternodes_widget.add_masternode(
                MasternodeAnnounce(alias='default'), save=False)
        self.masternodes_widget.view.selectRow(0)

        mn_list = self.gui.dip3_tab.mn_list
        if mn_list:
            mn_list.register_callback(self.on_mn_list_diff_updated,
                                      ['mn-list-diff-updated'])
        self.diff_updated.connect(self.on_diff_updated)