print(" ")
print("Controller 1: Coordinator")
print(" ")

print("Load the mapping object - connecting to S3")
s3 = boto3.resource('s3')
s3.Bucket('gtsa-mapping').download_file('map.json', 'map.json')

map_obj = am.MapDB(2, 3)
map_obj.load_json('map.json')
fmass = map_obj.get_total_mass()
print("    Total mass: " + str("%.3f" % fmass))
print("    Timestamp: " + str(map_obj.get_time()) + " (" +
      datetime.fromtimestamp(map_obj.get_time()).strftime('%c') + ")")
con_keys = am.ConPubKey()
con_keys.load_json('controllers.json')
key_list = con_keys.list_keys()
if map_obj.verify_multisig(key_list):
    print("    Signatures verified")
else:
    print("    Verification failed")
print(" ")

print("Connecting to Ocean client")
print(" ")
rpcport = 8332
rpcuser = '******'
rpcpassword = '******'
url = 'http://' + rpcuser + ':' + rpcpassword + '@localhost:' + str(rpcport)
ocean = rpc.RPCHost(url)
Exemplo n.º 2
0
    def __init__(self, parent=None):
        super(AMapping, self).__init__(parent)

        self.new_map = am.MapDB(2, 3)
        self.old_map = am.MapDB(2, 3)

        self.con_pubkeys = am.ConPubKey()

        self.title = 'Asset Mapping Interface'
        self.left = 10
        self.top = 10
        self.width = 1000
        self.height = 540

        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        self.oldMapping = QGroupBox("Current Mapping")
        self.oldMapView = QTreeView()
        self.oldMapView.setRootIsDecorated(False)
        self.oldMapView.setAlternatingRowColors(True)

        oldMapLayout = QHBoxLayout()
        oldMapLayout.addWidget(self.oldMapView)
        self.oldMapping.setLayout(oldMapLayout)

        self.oldModel = self.createMapModel(self)
        self.oldMapView.setModel(self.oldModel)

        self.newMapping = QGroupBox("New Mapping")
        self.newMapView = QTreeView()
        self.newMapView.setRootIsDecorated(False)
        self.newMapView.setAlternatingRowColors(True)

        newMapLayout = QHBoxLayout()
        newMapLayout.addWidget(self.newMapView)
        self.newMapping.setLayout(newMapLayout)

        self.newModel = self.createMapModel(self)
        self.newMapView.setModel(self.newModel)

        self.oldMapView.setColumnWidth(0, 50)
        self.newMapView.setColumnWidth(0, 50)

        self.issueButton = QPushButton("&Issue Asset")
        self.issueButton.show()
        self.addButton = QPushButton("&Add Asset")
        self.addButton.show()
        self.removeButton = QPushButton("&Remove Asset")
        self.removeButton.show()
        self.findButton = QPushButton("&Find Asset")
        self.findButton.show()
        self.tokenButton = QPushButton("&Token Report")
        self.tokenButton.show()
        self.remapButton = QPushButton("&Redemeption")
        self.remapButton.show()

        self.oldMassButton = QPushButton("&Mass Check")
        self.oldMassButton.show()
        self.loadOldButton = QPushButton("&Load File")
        self.loadOldButton.show()
        self.downloadButton = QPushButton("&Download")
        self.downloadButton.show()

        self.newMassButton = QPushButton("&Mass Check")
        self.newMassButton.show()
        self.loadNewButton = QPushButton("&Load File")
        self.loadNewButton.show()
        self.uploadButton = QPushButton("&Upload")
        self.uploadButton.show()

        self.sigButton = QPushButton("&Signatures")
        self.sigButton.show()

        self.saveButton = QPushButton("&Save JSON")
        self.saveButton.setToolTip("Save JSON to a file")
        self.saveButton.show()

        self.settingsButton = QPushButton("&Settings")
        self.settingsButton.setToolTip("Settings and configuration options")
        self.settingsButton.show()

        #        self.dialog = IssueAssetDialog()
        self.addAssetDlog = AddAssetDialog()
        self.tokenDlog = TokenDialog()
        #        self.dialog = SignaturesDialog()
        #        self.dialog = RemapDialog()
        #        self.dialog = OldMassDialog()
        #        self.dialog = NewMassDialog()

        self.oldMapMass = QLabel("Mass:")
        self.oldMapTime = QLabel("Time:")
        self.oldMapSigs = QLabel("Signatures:")
        self.newMapMass = QLabel("Mass:")
        self.newMapTime = QLabel("Time:")
        self.newMapSigs = QLabel("Signatures:")

        self.conStatus = QLabel("Ocean:")

        self.issueButton.clicked.connect(self.issueAsset)
        self.addButton.clicked.connect(self.addAsset)
        self.removeButton.clicked.connect(self.removeAsset)
        self.findButton.clicked.connect(self.findAsset)
        self.tokenButton.clicked.connect(self.tokenReport)
        self.remapButton.clicked.connect(self.remapAssets)
        self.oldMassButton.clicked.connect(self.oldMassAsset)
        self.loadOldButton.clicked.connect(self.loadOldMap)
        self.downloadButton.clicked.connect(self.downloadMap)
        self.newMassButton.clicked.connect(self.newMassAsset)
        self.loadNewButton.clicked.connect(self.loadNewMap)
        self.uploadButton.clicked.connect(self.uploadMap)
        self.sigButton.clicked.connect(self.signatures)
        self.saveButton.clicked.connect(self.saveMap)
        self.settingsButton.clicked.connect(self.settings)

        buttonLayout1 = QVBoxLayout()
        buttonLayout1.addWidget(self.issueButton)
        buttonLayout1.addWidget(self.addButton)
        buttonLayout1.addWidget(self.removeButton)
        buttonLayout1.addWidget(self.findButton)
        buttonLayout1.addWidget(self.tokenButton)
        buttonLayout1.addWidget(self.remapButton)
        buttonLayout1.addWidget(self.sigButton)
        buttonLayout1.addWidget(self.saveButton)
        buttonLayout1.addWidget(self.settingsButton)
        buttonLayout1.addStretch()

        buttonLayout2 = QHBoxLayout()
        buttonLayout2.addWidget(self.oldMassButton)
        buttonLayout2.addWidget(self.loadOldButton)
        buttonLayout2.addWidget(self.downloadButton)

        buttonLayout3 = QHBoxLayout()
        buttonLayout3.addWidget(self.newMassButton)
        buttonLayout3.addWidget(self.loadNewButton)
        buttonLayout3.addWidget(self.uploadButton)

        oldMapSummary = QVBoxLayout()
        oldMapSummary.addWidget(self.oldMapMass)
        oldMapSummary.addWidget(self.oldMapTime)
        oldMapSummary.addWidget(self.oldMapSigs)
        newMapSummary = QVBoxLayout()
        newMapSummary.addWidget(self.newMapMass)
        newMapSummary.addWidget(self.newMapTime)
        newMapSummary.addWidget(self.newMapSigs)

        mainLayout = QGridLayout()
        mainLayout.addWidget(self.oldMapping, 0, 0)
        mainLayout.addWidget(self.newMapping, 0, 1)
        mainLayout.addLayout(buttonLayout1, 0, 2)
        mainLayout.addLayout(oldMapSummary, 1, 0)
        mainLayout.addLayout(buttonLayout2, 2, 0)
        mainLayout.addLayout(newMapSummary, 1, 1)
        mainLayout.addLayout(buttonLayout3, 2, 1)

        self.setLayout(mainLayout)