Пример #1
1
def draw_input_window(state, window, rpc_queue):
    color = curses.color_pair(1)
    if 'testnet' in state:
        if state['testnet']: color = curses.color_pair(2)

    window.clear()
    window.addstr(0, 1, g.rpc_deamon + "-ncurses " + g.version + " [transaction input mode]", color + curses.A_BOLD)
    window.addstr(1, 1, "please enter txid", curses.A_BOLD)
    window.refresh()

    entered_txid = getstr.getstr(67, 3, 1) # w, y, x

    if len(entered_txid) == 64: # TODO: better checking for valid txid here
        s = {'txid': entered_txid}
        rpc_queue.put(s)

        window.addstr(5, 1, "waiting for transaction (will stall here if not found)", color + curses.A_BOLD)
        window.refresh()
        state['mode'] = 'tx'

    else:
        window.addstr(5, 1, "not a valid txid", color + curses.A_BOLD)
        window.refresh()

        time.sleep(0.5)

        window.clear()
        window.refresh()
        state['mode'] = "monitor"
Пример #2
1
def draw_input_box(state, window, rpcc):
    entered_command = getstr.getstr(state['x'], state['y']-2, 1) # w, y, x

    if entered_command == "":
        pass
    else:
        raw_params = entered_command.split()
        method = raw_params[0]

        # TODO: figure out how to encode properly for submission; this is hacky.
        params = []
        for raw_param in raw_params[1:]:
            if raw_param.isdigit():
                params.append(int(raw_param))
            elif raw_param == "false" or raw_param == "False":
                params.append(False)
            elif raw_param == "true" or raw_param == "True":
                params.append(True)
            else:
                try:
                    params.append(decimal.Decimal(raw_param))
                except:
                    params.append(raw_param)

        try:
            resp = rpcc.sync_request(method, *params)
            state['console']['rbuffer'].append(resp.result)
        except:
            state['console']['rbuffer'].append("ERROR")

        state['console']['cbuffer'].append("{}{}".format(method, tuple(params)))
        state['console']['offset'] = 0

        draw_window(state, window)
Пример #3
1
def draw_input_box(state, rpc_queue):
    entered_command = getstr.getstr(state['x'], state['y']-2, 1) # w, y, x

    if entered_command == "":
        pass
    else:
        s = {'consolecommand': entered_command}
        rpc_queue.put(s)
Пример #4
0
def draw_input_box(state, window, rpcc):
    entered_command = getstr.getstr(state['x'], state['y'] - 2, 1)  # w, y, x

    if entered_command == "":
        pass
    else:
        raw_params = entered_command.split()
        method = raw_params[0]

        # TODO: figure out how to encode properly for submission; this is hacky.
        params = []
        for raw_param in raw_params[1:]:
            if raw_param.isdigit():
                params.append(int(raw_param))
            elif raw_param == "false" or raw_param == "False":
                params.append(False)
            elif raw_param == "true" or raw_param == "True":
                params.append(True)
            else:
                try:
                    params.append(decimal.Decimal(raw_param))
                except:
                    params.append(raw_param)

        try:
            resp = rpcc.sync_request(method, *params)
            state['console']['rbuffer'].append(resp.result)
        except:
            state['console']['rbuffer'].append("ERROR")

        state['console']['cbuffer'].append("{}{}".format(
            method, tuple(params)))
        state['console']['offset'] = 0

        draw_window(state, window)
Пример #5
0
def draw_input_window(state, window, rpcc):
    color = curses.color_pair(1)
    if 'testnet' in state:
        if state['testnet']: color = curses.color_pair(2)

    window.clear()
    window.addstr(
        0, 1, "bitcoind-ncurses " + g.version + " [transaction input mode]",
        color + curses.A_BOLD)
    window.addstr(1, 1, "please enter txid", curses.A_BOLD)
    window.refresh()

    entered_txid = getstr.getstr(67, 3, 1)  # w, y, x

    if len(entered_txid) == 64:  # TODO: better checking for valid txid here
        s = {'txid': entered_txid}
        rpcc.request("getrawtransaction", entered_txid, 1)

        window.addstr(
            5, 1, "waiting for transaction (will stall here if not found)",
            color + curses.A_BOLD)
        window.refresh()
        state['mode'] = 'tx'

    else:
        window.addstr(5, 1, "not a valid txid", color + curses.A_BOLD)
        window.refresh()

        gevent.sleep(0.5)

        window.clear()
        window.refresh()
        state['mode'] = "monitor"
Пример #6
0
def draw_input_box(state, rpc_queue):
    entered_command = getstr.getstr(state["x"], state["y"] - 2, 1)  # w, y, x

    if entered_command == "":
        pass
    else:
        s = {"consolecommand": entered_command}
        rpc_queue.put(s)
Пример #7
0
def draw_input_box(state, rpc_queue):
    entered_command = getstr.getstr(state['x'], state['y'] - 2, 1)  # w, y, x

    if entered_command == "":
        pass
    else:
        s = {'consolecommand': entered_command}
        rpc_queue.put(s)
Пример #8
0
def draw_input_box(state, rpc_queue):
    entered_command = getstr.getstr(
        state['x'], state['y'] - 2, 1, '',
        state['console']['cbuffer'][0::1]).strip()  # w, y, x

    if entered_command == "":
        pass
    else:
        s = {'consolecommand': entered_command}
        rpc_queue.put(s)
        footer.draw_window(state, rpc_queue)
Пример #9
0
def draw_input_window(state, window, rpc_queue):
    color = curses.color_pair(1)
    if 'testnet' in state:
        if state['testnet']: color = curses.color_pair(2)

    window.clear()
    window.addstr(0, 1, "bitcoind-ncurses " + g.version + " [block input mode]", color + curses.A_BOLD)
    window.addstr(1, 1, "please enter block height or hash", curses.A_BOLD)
    window.addstr(2, 1, "or timestamp (accepted formats: YYYY-MM-DD hh:mm:ss, YYYY-MM-DD)", curses.A_BOLD)
    window.refresh()

    entered_block = getstr.getstr(67, 4, 1) # w, y, x
    entered_block_timestamp = 0

    try:
        entered_block_time = time.strptime(entered_block, "%Y-%m-%d")
        entered_block_timestamp = calendar.timegm(entered_block_time)
    except: pass

    try: 
        entered_block_time = time.strptime(entered_block, "%Y-%m-%d %H:%M:%S")
        entered_block_timestamp = calendar.timegm(entered_block_time)
    except: pass

    if entered_block_timestamp:
        s = {'findblockbytimestamp': entered_block_timestamp} 
        rpc_queue.put(s)

        window.addstr(5, 1, "waiting for block (will stall here if not found)", color + curses.A_BOLD)
        window.refresh()
        state['mode'] = "block"

    elif len(entered_block) == 64:
        s = {'getblock': entered_block}
        rpc_queue.put(s)

        window.addstr(5, 1, "waiting for block (will stall here if not found)", color + curses.A_BOLD)
        window.refresh()
        state['mode'] = "block"

    elif (len(entered_block) < 7) and entered_block.isdigit() and (int(entered_block) <= state['blockcount']):
        if entered_block in state['blocks']:
            state['blocks']['browse_height'] = int(entered_block)
            state['mode'] = "block"
            draw_window(state, window)
        else:
            s = {'getblockhash': int(entered_block)}
            rpc_queue.put(s)

            window.addstr(5, 1, "waiting for block (will stall here if not found)", color + curses.A_BOLD)
            window.refresh()
            state['mode'] = "block"
            state['blocks']['browse_height'] = int(entered_block)

    else:
        window.addstr(5, 1, "not a valid hash, height, or timestamp format", color + curses.A_BOLD)
        window.refresh()

        time.sleep(0.5)

        window.clear()
        window.refresh()
        state['mode'] = "monitor"
Пример #10
0
def draw_input_window(state, window, rpc_queue):
    color = curses.color_pair(1)
    if 'testnet' in state:
        if state['testnet']: color = curses.color_pair(2)

    window.clear()
    window.addstr(0, 1,
                  "bitcoind-ncurses " + g.version + " [block input mode]",
                  color + curses.A_BOLD)
    window.addstr(1, 1, "please enter block height or hash", curses.A_BOLD)
    window.addstr(
        2, 1,
        "or timestamp (accepted formats: YYYY-MM-DD hh:mm:ss, YYYY-MM-DD)",
        curses.A_BOLD)
    window.refresh()

    entered_block = getstr.getstr(67, 4, 1)  # w, y, x
    entered_block_timestamp = 0

    try:
        entered_block_time = time.strptime(entered_block, "%Y-%m-%d")
        entered_block_timestamp = calendar.timegm(entered_block_time)
    except:
        pass

    try:
        entered_block_time = time.strptime(entered_block, "%Y-%m-%d %H:%M:%S")
        entered_block_timestamp = calendar.timegm(entered_block_time)
    except:
        pass

    if entered_block_timestamp:
        s = {'findblockbytimestamp': entered_block_timestamp}
        rpc_queue.put(s)

        window.addstr(5, 1, "waiting for block (will stall here if not found)",
                      color + curses.A_BOLD)
        window.refresh()
        state['mode'] = "block"

    elif len(entered_block) == 64:
        s = {'getblock': entered_block}
        rpc_queue.put(s)

        window.addstr(5, 1, "waiting for block (will stall here if not found)",
                      color + curses.A_BOLD)
        window.refresh()
        state['mode'] = "block"

    elif (len(entered_block) < 7) and entered_block.isdigit() and (
            int(entered_block) <= state['blockcount']):
        if entered_block in state['blocks']:
            state['blocks']['browse_height'] = int(entered_block)
            state['mode'] = "block"
            draw_window(state, window)
        else:
            s = {'getblockhash': int(entered_block)}
            rpc_queue.put(s)

            window.addstr(5, 1,
                          "waiting for block (will stall here if not found)",
                          color + curses.A_BOLD)
            window.refresh()
            state['mode'] = "block"
            state['blocks']['browse_height'] = int(entered_block)

    else:
        window.addstr(5, 1, "not a valid hash, height, or timestamp format",
                      color + curses.A_BOLD)
        window.refresh()

        time.sleep(0.5)

        window.clear()
        window.refresh()
        state['mode'] = "monitor"
Пример #11
0
def draw_send_coins_window(state, window, rpc_queue):
	color = curses.color_pair(1)
	unit = g.coin_unit
	if g.testnet:
		color = curses.color_pair(2)
		unit = g.coin_unit_test

	UI = getstr.UserInput(window, "send " + unit + " mode")

	if 'balance' in state and g.y >= 14:
		display_string = "Current balance: " + "%0.8f" % state['balance'] + " " + unit
		if 'unconfirmedbalance' in state:
			if state['unconfirmedbalance'] != 0:
				display_string += " (+" + "%0.8f" % state['unconfirmedbalance'] + " unconf)"
		if 'unconfirmed_balance' in state:
			if state['unconfirmed_balance'] != 0:
				display_string += " (+" + "%0.8f" % state['unconfirmed_balance'] + " unconf)"
		UI.addline(display_string)

	if 'walletinfo' in state:
		if 'paytxfee' in state['walletinfo'] and g.y >= 15:
			display_string = "Current transaction fee: " + "%0.8f" % state['walletinfo']['paytxfee'] + " " + unit + " per kB"
			UI.addline(display_string, curses.A_NORMAL)

	if 'estimatefee' in state and g.y >= 17:
		display_string = "Estimatefee: "
		for item in state['estimatefee']:
			if item['value'] > 0:
				display_string += "{:0.8f}".format(item['value']) + " " + unit + " per kB (" + str(item['blocks']) + (" blocks) " if int(item['blocks']) > 1 else " block) ")
		UI.addline(display_string, curses.A_NORMAL)

	err_msg = ""
	abort = False

	UI.addline("Please enter amount of " + unit + " so send:", curses.A_BOLD)
	try:
		amount = float(UI.getstr(32))
	except ValueError:
		amount = -1
	
	if amount > 0:

		state['newtransaction']['amount'] = "%0.8f" % amount

		UI.addline("Please enter receiving address:", curses.A_BOLD)
		try:
			address = UI.getstr(54).strip()
		except:
			abort = True

		if check_address(address) and not abort:

			state['newtransaction']['address'] = address
			
			UI.addline("Please enter a comment on the transaction (optional):", curses.A_BOLD)
			try:
				comment = UI.getstr(128).strip()
			except:
				abort = True

			if not abort:

				state['newtransaction']['comment'] = comment
				
				UI.addline("Please enter a comment on the recipient (optional):", curses.A_BOLD)
				try:
					comment_to = UI.getstr(128).strip()
				except:
					abort = True

				if not abort:

					state['newtransaction']['comment_to'] = comment_to
				
					if g.y >= 19:
						UI.addline()
					if g.y >= 16:
						UI.addline("You will send " + "{:0.8f}".format(amount) + " " + unit + " (+ fee) to the address '" + address + "'")
					if g.y >= 18:
						UI.addline()

					encrypted = False
					if 'walletinfo' in state:
						if 'unlocked_until' in state['walletinfo']:
							encrypted = True

					if encrypted:
						UI.addline("Please confirm this transaction by providing your wallet's passphrase:", curses.A_BOLD)
						try:
							password = getstr.getstr(128, UI._y, 1, "*")
							pass
						except:
							abort = True
					else:
						abort = not UI.continue_yesno(False)
						UI._y -= 1

					if not abort:

						if encrypted:
							if g.y >= 18:
								UI.addline()
							s = {'walletpassphrase': password}
							rpc_queue.put(s)
							UI.addmessageline("Unlocking wallet and sending transaction...", color + curses.A_BOLD)
						else:
							if g.y >= 17:
								UI.addline()
							s = {'sendtoaddress': {'address': address, 'amount': str(amount), 'comment': comment, 'comment_to': comment_to}}
							rpc_queue.put(s)
							UI.addmessageline("Sending transaction...", color + curses.A_BOLD)
						state['wallet']['y'] = UI._y

		else:
			err_msg = "Invalid receiving address."
			abort = True

	else:
		err_msg = "Invalid amount."
		abort = True

	if abort:
		UI.addmessageline(err_msg + " Aborting.", color + curses.A_BOLD)
		UI.clear()
		state['wallet']['mode'] = 'addresses'
		rpc_queue.put('listsinceblock')