Esempio n. 1
0
    def __init__(self):
        Tk.__init__(self)

        self.configfile = set_options()
        self.defaultvalues = {
            "gui-host": config.GUI_HOST,
            "gui-port": config.GUI_PORT,
            "gui-user": config.GUI_USER,
            "gui-password": config.GUI_PASSWORD,

            "bitcoind-rpc-connect": config.BITCOIND_RPC_CONNECT,
            "bitcoind-rpc-port": config.BITCOIND_RPC_PORT,
            "bitcoind-rpc-user": config.BITCOIND_RPC_USER,
            "bitcoind-rpc-password": config.BITCOIND_RPC_PASSWORD
        }

        self.allkeys = [
            "gui-host", "gui-port", "gui-user", "gui-password", 
            "bitcoind-rpc-connect", "bitcoind-rpc-port", "bitcoind-rpc-user", "bitcoind-rpc-password"
        ]
        self.configpath = os.path.join(config.DATA_DIR, 'counterpartyd.conf')       

        self.title("Counterparty Wallet Manager")
        self.protocol("WM_DELETE_WINDOW", self.quit) 

        menu = Frame(self)     

        self.switch_button = Button(menu, text='START PARTY!', command=self.switch_party)
        self.switch_button.pack(side=LEFT)
        self.party_started = False

        open_button = Button(menu, text='OPEN WALLET', command=self.open_wallet)
        open_button.pack(side=LEFT)

        quit_button = Button(menu, text='QUIT', command=self.quit)
        quit_button.pack(side=RIGHT)

        quit_button = Button(menu, text='CONFIG', command=self.open_config)
        quit_button.pack(side=RIGHT)

        menu.pack(fill=X, padx=15, pady=5)

        self.text_widget = Text(self, borderwidth=2, relief=GROOVE, highlightcolor="white")
        
        self.text_widget.pack(fill=BOTH, expand=1, padx=15, pady=5)

        sys.stdout = TextWidgetOut(self.text_widget, sys.stdout)
        sys.stderr = TextWidgetOut(self.text_widget, sys.stderr)

        self.ws_subprocess = None
        self.xcpd_subprocess = None
        self.logthread = []

        self.python_path = "python"; #TODO: find another way to know i we are in .app
        if 'Contents/Resources/' in os.path.abspath(os.path.dirname(__file__)):
            self.python_path = "../MacOS/python"
Esempio n. 2
0
 def open_config(self):
     config_dialog = ConfigDialog(self, title="Configuration", configfile=self.configfile, 
                                 defaultvalues=self.defaultvalues, allkeys=self.allkeys, configpath=self.configpath)
     if config_dialog.changed:
         self.configfile = set_options()
         print("Configuration saved.")
         if self.party_started:
             print("Restarting Party!")       
             self.stop_party()
             self.start_party()
     else:
         print("Configuration has not changed.")
Esempio n. 3
0
 def open_config(self):
     config_dialog = ConfigDialog(self,
                                  title="Configuration",
                                  configfile=self.configfile,
                                  defaultvalues=self.defaultvalues,
                                  allkeys=self.allkeys,
                                  configpath=self.configpath)
     if config_dialog.changed:
         self.configfile = set_options()
         print("Configuration saved.")
         if self.party_started:
             print("Restarting Party!")
             self.stop_party()
             self.start_party()
     else:
         print("Configuration has not changed.")
Esempio n. 4
0
import os
import decimal
import time
import json
import logging
import bottle
from bottle import route, run, template, Bottle, request, static_file, redirect, error, hook, response, abort, auth_basic

from counterpartyd.lib import (config, util, exceptions, bitcoin)
from counterpartyd.lib import (send, order, btcpay, issuance, broadcast, bet,
                               dividend, burn, cancel, callback)

from helpers import set_options, init_logging, D, S, DecimalEncoder, connect_to_db, check_auth, wallet_unlock

app = Bottle()
set_options()
init_logging()
db = connect_to_db(10000)


@app.route('/<filename:path>')
@auth_basic(check_auth)
def send_static(filename):
    return static_file(filename, root=config.GUI_DIR)


@app.route('/')
@auth_basic(check_auth)
def index():
    return static_file("counterpartygui.html", root=config.GUI_DIR)
Esempio n. 5
0
import json
import logging
import functools
import requests as httpclient
from requests.auth import HTTPBasicAuth

import bottle
from bottle import route, run, template, Bottle, request, static_file, redirect, error, hook, response, abort, HTTPError

from counterpartyd.lib import (config, util, exceptions, bitcoin)
from counterpartyd.lib import (send, order, btcpay, issuance, broadcast, bet, dividend, burn, cancel, callback)

from helpers import set_options, init_logging, D, S, DecimalEncoder, connect_to_db, wallet_unlock, write_pid

app = Bottle()
set_options()
init_logging()
db = connect_to_db(10000)


counterpartyd_params = {
    'send': ['source', 'destination', 'quantity', 'asset'],
    'order': ['source', 'give_quantity', 'give_asset', 'get_quantity', 'get_asset', 'expiration', 'fee_fraction_required', 'fee_fraction_provided'],
    'btcpay': ['order_match_id'],
    'cancel': ['offer_hash'],
    'issuance': ['source', 'transfer_destination', 'asset_name', 'quantity', 'divisible', 'callable', 'call_date', 'call_price', 'description'],
    'dividend': ['source', 'asset', 'quantity_per_share', 'dividend_asset'],
    'callback': ['source', 'asset', 'fraction_per_share'],
    'broadcast': ['source', 'text', 'value', 'fee_fraction'],
    'bet': ['source', 'feed_address', 'bet_type', 'deadline', 'wager', 'counterwager', 'target_value', 'leverage', 'expiration']
}
Esempio n. 6
0
    def __init__(self):
        Tk.__init__(self)

        self.configfile = set_options()
        self.defaultvalues = {
            "gui-host": config.GUI_HOST,
            "gui-port": config.GUI_PORT,
            "gui-user": config.GUI_USER,
            "gui-password": config.GUI_PASSWORD,
            "bitcoind-rpc-connect": config.BITCOIND_RPC_CONNECT,
            "bitcoind-rpc-port": config.BITCOIND_RPC_PORT,
            "bitcoind-rpc-user": config.BITCOIND_RPC_USER,
            "bitcoind-rpc-password": config.BITCOIND_RPC_PASSWORD
        }

        self.allkeys = [
            "gui-host", "gui-port", "gui-user", "gui-password",
            "bitcoind-rpc-connect", "bitcoind-rpc-port", "bitcoind-rpc-user",
            "bitcoind-rpc-password"
        ]
        self.configpath = os.path.join(config.DATA_DIR, 'counterpartyd.conf')

        self.title("Counterparty Wallet Manager")
        self.protocol("WM_DELETE_WINDOW", self.quit)

        menu = Frame(self)

        self.switch_button = Button(menu,
                                    text='START PARTY!',
                                    command=self.switch_party)
        self.switch_button.pack(side=LEFT)
        self.party_started = False

        open_button = Button(menu,
                             text='OPEN WALLET',
                             command=self.open_wallet)
        open_button.pack(side=LEFT)

        quit_button = Button(menu, text='QUIT', command=self.quit)
        quit_button.pack(side=RIGHT)

        quit_button = Button(menu, text='CONFIG', command=self.open_config)
        quit_button.pack(side=RIGHT)

        menu.pack(fill=X, padx=15, pady=5)

        self.text_widget = Text(self,
                                borderwidth=2,
                                relief=GROOVE,
                                highlightcolor="white")

        self.text_widget.pack(fill=BOTH, expand=1, padx=15, pady=5)

        sys.stdout = TextWidgetOut(self.text_widget, sys.stdout)
        sys.stderr = TextWidgetOut(self.text_widget, sys.stderr)

        self.ws_subprocess = None
        self.xcpd_subprocess = None
        self.logthread = []

        self.python_path = "python"
        #TODO: find another way to know i we are in .app
        if 'Contents/Resources/' in os.path.abspath(os.path.dirname(__file__)):
            self.python_path = "../MacOS/python"