Skip to content

Commit

Permalink
Merge pull request spesmilo#3 from wozz/electrum-doge
Browse files Browse the repository at this point in the history
Merge Upstream
  • Loading branch information
paybee committed Apr 18, 2014
2 parents 4005aed + 6bebbf1 commit 11b9bf1
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 229 deletions.
1 change: 1 addition & 0 deletions electrum-doge
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ if __name__ == '__main__':
if not wallet:
sys.exit("Error: Invalid seed")
wallet.save_seed(password)
wallet.create_accounts(password)

if not options.offline:
network = Network(config)
Expand Down
12 changes: 6 additions & 6 deletions gui/qt/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,24 +409,24 @@ def notify_transactions(self):
return

print_error("Notifying GUI")
if len(self.network.interface.pending_transactions_for_notifications) > 0:
if len(self.network.pending_transactions_for_notifications) > 0:
# Combine the transactions if there are more then three
tx_amount = len(self.network.interface.pending_transactions_for_notifications)
tx_amount = len(self.network.pending_transactions_for_notifications)
if(tx_amount >= 3):
total_amount = 0
for tx in self.network.interface.pending_transactions_for_notifications:
for tx in self.network.pending_transactions_for_notifications:
is_relevant, is_mine, v, fee = self.wallet.get_tx_value(tx)
if(v > 0):
total_amount += v

self.notify(_("%(txs)s new transactions received. Total amount received in the new transactions %(amount)s %(unit)s") \
% { 'txs' : tx_amount, 'amount' : self.format_amount(total_amount), 'unit' : self.base_unit()})

self.network.interface.pending_transactions_for_notifications = []
self.network.pending_transactions_for_notifications = []
else:
for tx in self.network.interface.pending_transactions_for_notifications:
for tx in self.network.pending_transactions_for_notifications:
if tx:
self.network.interface.pending_transactions_for_notifications.remove(tx)
self.network.pending_transactions_for_notifications.remove(tx)
is_relevant, is_mine, v, fee = self.wallet.get_tx_value(tx)
if(v > 0):
self.notify(_("New transaction received. %(amount)s %(unit)s") % { 'amount' : self.format_amount(v), 'unit' : self.base_unit()})
Expand Down
5 changes: 4 additions & 1 deletion gui/qt/transaction_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ def add_io(self, vbox):
vbox.addWidget(QLabel("LockTime: %d\n" % self.tx.locktime))

vbox.addWidget(QLabel(_("Inputs")))
lines = map(lambda x: x.get('prevout_hash') + ":%d"%x.get('prevout_n') + u'\t' + "%s"%x.get('address') , self.tx.inputs )
def format_input(x):
_hash = x.get('prevout_hash')
return _hash[0:16] + '...' + _hash[-8:] + ":%d"%x.get('prevout_n') + u'\t' + "%s"%x.get('address')
lines = map(format_input, self.tx.inputs )
i_text = QTextEdit()
i_text.setText('\n'.join(lines))
i_text.setReadOnly(True)
Expand Down
5 changes: 3 additions & 2 deletions lib/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import json
import Queue
from network import Network
from util import print_msg
from util import print_msg, print_stderr
from simple_config import SimpleConfig


Expand All @@ -45,6 +45,7 @@ def __init__(self, config = {}):
self.subscriptions = {}
self.debug = False
self.lock = threading.Lock()
self.pending_transactions_for_notifications = []


def start(self, start_daemon=False):
Expand All @@ -60,7 +61,7 @@ def start(self, start_daemon=False):
return False

elif not daemon_started:
print "Starting daemon [%s]"%self.config.get('server')
print_stderr( "Starting daemon [%s]"%self.config.get('server'))
daemon_started = True
pid = os.fork()
if (pid == 0): # The first child.
Expand Down
3 changes: 1 addition & 2 deletions lib/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def __init__(self, server, config = None):
#json
self.message_id = 0
self.unanswered_requests = {}
self.pending_transactions_for_notifications= []

# parse server
self.server = server
Expand Down Expand Up @@ -397,7 +396,7 @@ def getaddrinfo(*args):
print_error("certificate has expired:", cert_path)
os.unlink(cert_path)
else:
print_msg("wrong certificate", self.host)
print_error("wrong certificate", self.host)
return
except Exception:
print_error("wrap_socket failed", self.host)
Expand Down
1 change: 1 addition & 0 deletions lib/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def __init__(self, config = {}):
self.subscriptions = {}
self.subscriptions[self.on_banner] = [('server.banner',[])]
self.subscriptions[self.on_peers] = [('server.peers.subscribe',[])]
self.pending_transactions_for_notifications = []


def is_connected(self):
Expand Down
15 changes: 10 additions & 5 deletions lib/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,19 +301,23 @@ def get_address_from_input_script(bytes):
except Exception:
# coinbase transactions raise an exception
print_error("cannot find address in input script", bytes.encode('hex'))
return [], [], "(None)"
return [], {}, "(None)"

# payto_pubkey
match = [ opcodes.OP_PUSHDATA4 ]
if match_decoded(decoded, match):
return None, None, "(pubkey)"
return None, {}, "(pubkey)"

# non-generated TxIn transactions push a signature
# (seventy-something bytes) and then their public key
# (65 bytes) onto the stack:
match = [ opcodes.OP_PUSHDATA4, opcodes.OP_PUSHDATA4 ]
if match_decoded(decoded, match):
return None, None, public_key_to_bc_address(decoded[1][1])
sig = decoded[0][1].encode('hex')
assert sig[-2:] == '01'
sig = sig[:-2]
pubkey = decoded[1][1].encode('hex')
return [pubkey], {pubkey:sig}, public_key_to_bc_address(pubkey.decode('hex'))

# p2sh transaction, 2 of n
match = [ opcodes.OP_0 ]
Expand Down Expand Up @@ -341,7 +345,7 @@ def get_address_from_input_script(bytes):
return pubkeys, signatures, hash_160_to_bc_address(hash_160(redeemScript), 5)

print_error("cannot find address in input script", bytes.encode('hex'))
return [], [], "(None)"
return [], {}, "(None)"



Expand Down Expand Up @@ -384,7 +388,7 @@ def __str__(self):

@classmethod
def from_io(klass, inputs, outputs):
raw = klass.serialize(inputs, outputs, for_sig = -1) # for_sig=-1 means do not sign
raw = klass.serialize(inputs, outputs, for_sig = None) # for_sig=-1 means do not sign
self = klass(raw)
self.inputs = inputs
self.outputs = outputs
Expand Down Expand Up @@ -589,6 +593,7 @@ def parse_input(self, vds):
address = None

d['address'] = address
d['pubkeys'] = pubkeys
d['signatures'] = signatures
return d

Expand Down
4 changes: 4 additions & 0 deletions lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ def set_verbosity(b):
global is_verbose
is_verbose = b


def print_error(*args):
if not is_verbose: return
print_stderr(*args)

def print_stderr(*args):
args = [str(item) for item in args]
sys.stderr.write(" ".join(args) + "\n")
sys.stderr.flush()
Expand Down
2 changes: 1 addition & 1 deletion lib/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ELECTRUM_VERSION = "1.9.8" # version of the client package
ELECTRUM_VERSION = "1.9.8.1" # version of the client package
PROTOCOL_VERSION = '0.9' # protocol version requested
NEW_SEED_VERSION = 7 # bip32 wallets
OLD_SEED_VERSION = 4 # old electrum deterministic generation
Expand Down
4 changes: 2 additions & 2 deletions lib/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ def receive_tx_callback(self, tx_hash, tx, tx_height):
print_error("received transaction that is no longer referenced in history", tx_hash)
return
self.transactions[tx_hash] = tx
self.network.interface.pending_transactions_for_notifications.append(tx)
self.network.pending_transactions_for_notifications.append(tx)
self.save_transactions()
if self.verifier and tx_height>0:
self.verifier.add(tx_hash, tx_height)
Expand Down Expand Up @@ -1261,7 +1261,7 @@ def sendtx(self, tx):
def send_tx(self, tx):
# asynchronous
self.tx_event.clear()
self.network.interface.send([('blockchain.transaction.broadcast', [str(tx)])], self.on_broadcast)
self.network.send([('blockchain.transaction.broadcast', [str(tx)])], self.on_broadcast)
return tx.hash()

def on_broadcast(self, i, r):
Expand Down
205 changes: 0 additions & 205 deletions plugins/aliases.py

This file was deleted.

Loading

0 comments on commit 11b9bf1

Please sign in to comment.