GithubHelp home page GithubHelp logo

cryptobuks / counterparty-gui Goto Github PK

View Code? Open in Web Editor NEW

This project forked from counterpartyxcp/counterparty-gui

0.0 1.0 0.0 1.11 MB

GUI for counterparty-lib

License: MIT License

QMake 0.44% Python 78.47% QML 21.09%

counterparty-gui's Introduction

counterparty-gui

Description

counterparty-gui is a PyQT5 GUI for counterparty-lib.

Requirements

Installation and usage

With installer

Download and execute Windows (or MacOS installer) installer.

From source

$ git clone https://github.com/CounterpartyXCP/counterparty-gui.git
$ cd counterparty-gui
$ pip3 install -r requirements.txt
$ python3 setup.py install
$ ./counterparty-gui.py --help

Plugins

In counterparty-gui everything is a plugin. The core application only manages the left menu. Each plugin adds one or more items in this menu. When the user clicks on one of these items, the core application displays the corresponding plugin in the main window.

A plugin is defined by the following conventions:

  • it must live in the folder plugins/{PLUGIN_NAME}/

  • PLUGIN_NAME folder must contains at least one file index.qml that contains the QML root object

  • the root object in index.qml must contains 3 javascript callbacks:

    • init(), called once, when the application initialises plugins.
    • onMenuAction(itemValue), called when the user clicks on a menu item that belongs to the plugin.
    • onMessage(messageName, messageData), for now called only when a new block is parsed by the Counterparty server with messageName equal to new_block.
  • the root object in index.qml must contains a property root.menu. It contains the list of items to dsplay in the left menu and can be populated in the init() callback.

  • the QML context contains:

    • an instance of CounterpartydAPI (core/api.py) to make any RPC call to the counterpartyd API or the Wallet with Javascript,
    • an instance of GUI (core/gui.py) to display messages or ask confirmations.

Example:

	function sendAsset() {
		// prepare the query
        var query = {
            'method': 'create_send',
            'params': {
                'source':  sendFormComp.source,
                'destination': sendFormComp.destination,
                'asset': root.currentAsset,
                'quantity': sendFormComp.quantity
            }
        }

        // prepare the confirmation message
        var confirmMessage = "Do you really want to send " +
                             sendFormComp.quantity + " " + root.currentAsset +
                             " to " + sendFormComp.destination;

        if (GUI.confirm("Confirm send", confirmMessage)) {
            // Compose transaction
            var unsigned_hex = xcpApi.call(query);
            if (unsigned_hex) {
                // Sign transaction
                var signed_hex = xcpApi.call({'method': 'sign_raw_transaction', 'params': {'tx_hex': unsigned_hex}});
                if (signed_hex) {
                    // Broadcast transaction
                    var tx_hash = xcpApi.call({'method': 'send_raw_transaction', 'params': {'tx_hex': signed_hex}});
                    // display transaction hash
                    if (tx_hash) {
                        GUI.alert("Transaction done", tx_hash);
                    }
                }
            }
        }
    }

counterparty-gui's People

Contributors

rippler avatar wseng avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.