Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gui/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import android

from chainkey import SimpleConfig, Wallet, WalletStorage, format_satoshis, mnemonic_encode, mnemonic_decode
from chainkey.bitcoin import is_valid
from chainkey.base58 import is_valid
from chainkey import util
from decimal import Decimal
import datetime, re
Expand Down
2 changes: 1 addition & 1 deletion gui/gtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from gi.repository import Gtk, Gdk, GObject, cairo
from decimal import Decimal
from chainkey.util import print_error
from chainkey.bitcoin import is_valid
from chainkey.base58 import is_valid
from chainkey import WalletStorage, Wallet

Gdk.threads_init()
Expand Down
33 changes: 33 additions & 0 deletions gui/qt/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from PyQt4 import QtCore
from PyQt4 import QtGui
from chainkey import util
from chainkey import chainparams


if platform.system() == 'Windows':
Expand All @@ -19,10 +20,13 @@ class Console(QtGui.QPlainTextEdit):
def __init__(self, prompt='>> ', startup_message='', parent=None):
QtGui.QPlainTextEdit.__init__(self, parent)

self.parent = parent
self.prompt = prompt
self.history = []
self.namespace = {}
self.construct = []
# this will be changed in updateNamespace()
self.general_help = lambda: 'Encompass console'

self.setGeometry(50, 75, 600, 400)
self.setWordWrapMode(QtGui.QTextOption.WrapAnywhere)
Expand All @@ -33,6 +37,15 @@ def __init__(self, prompt='>> ', startup_message='', parent=None):
self.updateNamespace({'run':self.run_script})
self.set_json(False)

# Console needs its own setchain method.
def setchain(self, chaincode):
"""Set the chain that your wallet is currently using."""
if not chainparams.is_known_chain(chaincode):
return "Invalid chain"
elif chaincode == chainparams.get_active_chain().code:
return "Selected chain is already active"
self.parent.emit(QtCore.SIGNAL('change_currency'), chaincode)

def set_json(self, b):
self.is_json = b

Expand All @@ -46,6 +59,26 @@ def run_script(self, filename):


def updateNamespace(self, namespace):
# special help function
general_help = namespace.get('help')
if general_help:
self.general_help = general_help
def help(command_name=None):
if command_name:
help_str = command_name.__doc__
else:
help_str = '\n\n'.join([
self.general_help(),
'Use help(<command>) to see the help for a command.'])
# We print the string instead of returning it, so that newlines work.
if help_str:
self.appendPlainText(help_str)
namespace['help'] = help

# another special function - setchain
if namespace.get('setchain'):
namespace['setchain'] = self.setchain

self.namespace.update(namespace)

def showMessage(self, message):
Expand Down
2 changes: 1 addition & 1 deletion gui/qt/lite_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from decimal import Decimal as D
from chainkey.util import get_resource_path as rsrc
from chainkey.bitcoin import is_valid
from chainkey.base58 import is_valid
from chainkey.i18n import _
import decimal
import json
Expand Down
24 changes: 17 additions & 7 deletions gui/qt/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
from PyQt4.QtCore import *
import PyQt4.QtCore as QtCore

from chainkey.bitcoin import MIN_RELAY_TX_FEE, is_valid
from chainkey.bitcoin import MIN_RELAY_TX_FEE
from chainkey.base58 import is_valid
from chainkey.plugins import run_hook

import icons_rc
Expand Down Expand Up @@ -895,7 +896,7 @@ def toggle_qr_window(self):


def receive_at(self, addr):
if not bitcoin.is_address(addr):
if not base58.is_address(addr):
return
self.tabs.setCurrentIndex(2)
self.receive_address_e.setText(addr)
Expand Down Expand Up @@ -1138,7 +1139,7 @@ def read_send_tab(self):
return
if type == 'op_return':
continue
if type == 'address' and not bitcoin.is_address(addr):
if type == 'address' and not base58.is_address(addr):
QMessageBox.warning(self, _('Error'), _('Invalid coin Address'), _('OK'))
return
if amount is None:
Expand Down Expand Up @@ -1757,7 +1758,7 @@ def update_contacts_tab(self):

def create_console_tab(self):
from console import Console
self.console = console = Console()
self.console = console = Console(parent=self)
console.setObjectName("console_tab")
return console

Expand All @@ -1773,7 +1774,16 @@ def update_console(self):
c = commands.Commands(self.config, self.wallet, self.network, lambda: self.console.set_json(True))
methods = {}
def mkfunc(f, method):
return lambda *args: apply( f, (method, args, self.password_dialog ))
def func_wrapper(*args):
return f(method, args, self.password_dialog)
# update command docstring so we can use help(command_name)
if getattr(c, method, None):
docstr = getattr(c, method).__doc__
else:
docstr = ''
func_wrapper.__doc__ = docstr
return func_wrapper

for m in dir(c):
if m[0]=='_' or m in ['network','wallet']: continue
methods[m] = mkfunc(c._run, m)
Expand Down Expand Up @@ -2396,7 +2406,7 @@ def do_process_from_csvReader(self, csvReader):
try:
for position, row in enumerate(csvReader):
address = row[0]
if not bitcoin.is_address(address):
if not base58.is_address(address):
errors.append((position, address))
continue
amount = Decimal(row[1])
Expand Down Expand Up @@ -2694,7 +2704,7 @@ def sweep_key_dialog(self):

def get_address():
addr = str(address_e.text())
if bitcoin.is_address(addr):
if base58.is_address(addr):
return addr

def get_pk():
Expand Down
4 changes: 2 additions & 2 deletions gui/qt/paytoedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import re
from decimal import Decimal
from chainkey import bitcoin
from chainkey import base58

RE_ADDRESS = '[1-9A-HJ-NP-Za-km-z]{26,}'
RE_ALIAS = '(.*?)\s*\<([1-9A-HJ-NP-Za-km-z]{26,})\>'
Expand Down Expand Up @@ -88,7 +88,7 @@ def parse_address(self, line):
r = line.strip()
m = re.match('^'+RE_ALIAS+'$', r)
address = m.group(2) if m else r
assert bitcoin.is_address(address)
assert base58.is_address(address)
return address


Expand Down
2 changes: 1 addition & 1 deletion gui/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
_ = lambda x:x
#from i18n import _
from chainkey.util import format_satoshis, set_verbosity
from chainkey.bitcoin import is_valid
from chainkey.base58 import is_valid

from chainkey import Wallet, WalletStorage

Expand Down
5 changes: 3 additions & 2 deletions lib/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import script
import bitcoin
from bitcoin import *
from base58 import public_key_to_bc_address, EncodeBase58Check, DecodeBase58Check
from i18n import _
from transaction import is_extended_pubkey
from util import print_msg
Expand Down Expand Up @@ -347,14 +348,14 @@ def get_xpubkeys(self, for_change, n):
# unsorted
s = ''.join(map(lambda x: util_coin.int_to_hex(x,2), (for_change,n)))
xpubs = self.get_master_pubkeys()
return map(lambda xpub: 'ff' + bitcoin.DecodeBase58Check(xpub).encode('hex') + s, xpubs)
return map(lambda xpub: 'ff' + DecodeBase58Check(xpub).encode('hex') + s, xpubs)

@classmethod
def parse_xpubkey(self, pubkey):
assert is_extended_pubkey(pubkey)
pk = pubkey.decode('hex')
pk = pk[1:]
xkey = bitcoin.EncodeBase58Check(pk[0:78])
xkey = EncodeBase58Check(pk[0:78])
dd = pk[78:]
s = []
while dd:
Expand Down
Loading