internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: spesmilo/electrum

Issue:
remove tray icon when exiting on windows
The windows tray icon doesn't get removed when exiting electrum. It stays in the tray until you hover it with the mouse. If you open and close electrum several times this is happening:
![tray](https://f.cloud.github.com/assets/5296073/1574516/5364b9aa-513f-11e3-8cc3-700f0eca93ec.png)



Discussion:
+1 Yes, it is true. I can verify this bug. Windows 7 x64. 
By the way: new icon is absolutely illegible on dark backgrounds.

I got a fix under way


Resolving patch:
diff --git a/gui/qt/lite_window.py b/gui/qt/lite_window.py
--- a/gui/qt/lite_window.py
+++ b/gui/qt/lite_window.py
@@ -355,8 +355,7 @@ def toggle_theme(self, theme_name):
     def closeEvent(self, event):
         g = self.geometry()
         self.config.set_key("winpos-lite", [g.left(),g.top(),g.width(),g.height()],True)
-        
-        super(MiniWindow, self).closeEvent(event)
+        self.actuator.g.closeEvent(event)
         qApp.quit()
 
     def set_payment_fields(self, dest_address, amount):
diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
--- a/gui/qt/main_window.py
+++ b/gui/qt/main_window.py
@@ -2137,6 +2137,7 @@ def run_network_dialog(self):
         NetworkDialog(self.wallet.network, self.config, self).do_exec()
 
     def closeEvent(self, event):
+        self.tray.hide()
         g = self.geometry()
         self.config.set_key("winpos-qt", [g.left(),g.top(),g.width(),g.height()], True)
         self.save_column_widths()


Test patch:
Repository: spesmilo/electrum

Issue:
btchip making tx: 'BTChipWallet' object has no attribute 'lastFee'
no output on console. just this popup when I try to send a tx.

![image](https://cloud.githubusercontent.com/assets/589745/4325668/81a4c898-3f67-11e4-87bc-69347362f622.png)



Discussion:

Resolving patch:
diff --git a/plugins/btchipwallet.py b/plugins/btchipwallet.py
--- a/plugins/btchipwallet.py
+++ b/plugins/btchipwallet.py
@@ -303,12 +303,6 @@ def sign_message(self, address, message, password):
 
         return b64encode(chr(27 + 4 + (signature[0] & 0x01)) + r + s) 
 
-    def choose_tx_inputs( self, amount, fixed_fee, num_outputs, domain = None, coins = None ):
-        # Overloaded to get the fee, as BTChip recomputes the change amount
-        inputs, total, fee = super(BTChipWallet, self).choose_tx_inputs(amount, fixed_fee, num_outputs, domain, coins)
-        self.lastFee = fee
-        return inputs, total, fee
-
     def sign_transaction(self, tx, keypairs, password):
         if tx.error or tx.is_complete():
             return        
@@ -368,7 +362,7 @@ def sign_transaction(self, tx, keypairs, password):
                 self.get_client().startUntrustedTransaction(firstTransaction, inputIndex, 
                 trustedInputs, redeemScripts[inputIndex])
                 outputData = self.get_client().finalizeInput(output, format_satoshis(outputAmount), 
-                format_satoshis(self.lastFee), changePath)
+                format_satoshis(self.get_tx_fee(tx)), changePath)
                 if firstTransaction:
                     transactionOutput = outputData['outputData']
                 if outputData['confirmationNeeded']:                


Test patch:
Repository: spesmilo/electrum

Issue:
btchip: message signing not implemented
I noticed signing messages is not implemented with the BTChip plugin

electrum even connects the device and prompts for a PIN, but then says this:

![image](https://cloud.githubusercontent.com/assets/589745/4344538/a7a97c20-4096-11e4-84f0-02765803fc2b.png)



Discussion:

Resolving patch:
diff --git a/plugins/btchipwallet.py b/plugins/btchipwallet.py
--- a/plugins/btchipwallet.py
+++ b/plugins/btchipwallet.py
@@ -45,8 +45,7 @@ def description(self):
     def __init__(self, gui, name):
         BasePlugin.__init__(self, gui, name)
         self._is_available = self._init()
-        self.wallet = None
-        self.signing = False
+        self.wallet = None        
         electrum.wallet.wallet_types.append(('hardware', 'btchip', _("BTChip wallet"), BTChipWallet))
 
 
@@ -107,6 +106,7 @@ def __init__(self, storage):
         self.client = None
         self.mpk = None
         self.device_checked = False
+        self.signing = False
 
     def give_error(self, message, clear_client = False):
         if not self.signing:


Test patch:
Repository: spesmilo/electrum

Issue:
BTChip: exception and 'hang' on private key export
Just to see what would happen, I tried Wallet -> private keys -> export with a btchip wallet open.

This happened on the console:

```
Traceback (most recent call last):
  File "/mnt/maui/home/nick/bitcoin/electrum/lib/plugins.py", line 51, in run_hook
    r = f(*args)
  File "/mnt/maui/home/nick/bitcoin/electrum/plugins/labels.py", line 66, in load_wallet
    mpk = self.wallet.get_master_public_key()
  File "/mnt/maui/home/nick/bitcoin/electrum/plugins/btchipwallet.py", line 255, in get_master_public_key
    self.mpk = self.get_public_key("44'/0'")
  File "/mnt/maui/home/nick/bitcoin/electrum/plugins/btchipwallet.py", line 225, in get_public_key
    self.get_client() # prompt for the PIN before displaying the dialog if necessary
  File "/mnt/maui/home/nick/bitcoin/electrum/plugins/btchipwallet.py", line 202, in get_client
    raise Exception("Could not connect to your BTChip dongle. Please verify access permissions, PIN, or unplug the dongle and plug it again")
Exception: Could not connect to your BTChip dongle. Please verify access permissions, PIN, or unplug the dongle and plug it again
Exception in thread Thread-21:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib64/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/mnt/maui/home/nick/bitcoin/electrum/gui/qt/main_window.py", line 2296, in privkeys_thread
    private_keys[addr] = "\n".join(self.wallet.get_private_key(addr, password))
  File "/mnt/maui/home/nick/bitcoin/electrum/lib/wallet.py", line 359, in get_private_key
    return self.accounts[account_id].get_private_key(sequence, self, password)
KeyError: u'1'
```

while the gui 'hung' at:

![image](https://cloud.githubusercontent.com/assets/589745/4344529/459ea794-4096-11e4-85bf-1504be76b2f8.png)



Discussion:

Resolving patch:
diff --git a/plugins/btchipwallet.py b/plugins/btchipwallet.py
--- a/plugins/btchipwallet.py
+++ b/plugins/btchipwallet.py
@@ -219,6 +219,9 @@ def derive_xkeys(self, root, derivation, password):
         xpub = self.get_public_key(derivation)
         return xpub, None
 
+    def get_private_key(self, address, password):
+        return []
+
     def get_public_key(self, bip32_path):
         # S-L-O-W - we don't handle the fingerprint directly, so compute it manually from the previous node        
         # This only happens once so it's bearable


Test patch:
Repository: spesmilo/electrum

Issue:
Hardcoded icon path in launcher for GNU/Linux systems
Hi,

currently the icon path specified in the created _.desktop_ launcher file is set to: 
_Icon=/usr/share/app-install/icons/electrum.png_ 

(see https://github.com/spesmilo/electrum/blob/bc3013caf0d3d6a35290e9cc9e51125b7d03d14c/electrum.desktop)

This prevents icon theming without editing the launcher file.

I'd like to ask you to change the icon location as well as the icon path line in the launcher according to the freedesktop.org standards.

Please find more info here:
http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
https://github.com/Foggalong/hardcode-fixer/wiki/What,-Why-&-How

---

According to the above resources standard icon locations are:

_/usr/share/icons/hicolor/[size]/apps/[icon name]_
_~/.local/share/icons/hicolor/[size]/apps/[icon name]_
_/usr/share/pixmaps/[icon name]_

The standard icon line in the .desktop launcher is:
_Icon=[icon name]_      (without full path, without file extension)

for instance
**Icon=electrum**  
(for an icon _electrum.svg_ or _electrum.png_ stored in standard location)

Could you please move the icon to one of those locations and adjust the icon path in the .desktop file accordingly?



Discussion:
sure, can you write a pull request?

Alright, will do it tomorrow, touching _setup.py_ and _electrum.desktop_.


Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -21,7 +21,7 @@
     usr_share = os.path.join(sys.prefix, "share")
     data_files += [
         (os.path.join(usr_share, 'applications/'), ['electrum.desktop']),
-        (os.path.join(usr_share, 'app-install', 'icons/'), ['icons/electrum.png'])
+        (os.path.join(usr_share, 'pixmaps/'), ['icons/electrum.png'])
     ]
 
 


Test patch:
Repository: spesmilo/electrum

Issue:
Wrong ussage of comma for URI Creation in spanish locale (Ubuntu)
With the help of kyuupichan, we found that Electrum uses the computer locale to create the URI, which causes problems when user specifies an amount and the locale is in Spanish (or any other comma for decimal locale), example:

bitcoin:1CDyoGTyQaFggjUPhJetsLtQMi8xVEjpM3?amount=1,01&message=Payment%20test

As you can see, the URI is made using comma instead of dot, which makes the URI invalid. Please make the electrum locale independent so it won't conflict when the user selects Spanish locale on his OS installation.



Discussion:
We shouldn't be using locale when creating URIs


Resolving patch:
diff --git a/lib/util.py b/lib/util.py
--- a/lib/util.py
+++ b/lib/util.py
@@ -104,8 +104,10 @@ def user_dir():
         #raise Exception("No home directory found in environment variables.")
         return
 
-
-
+def format_satoshis_plain(x):
+    '''Display a satoshi amount in BTC with 8 decimal places.  Always
+       uses a '.' as a decimal point and has no thousands separator'''
+    return "{:.8f}".format(x / 100000000.0)
 
 def format_satoshis(x, is_diff=False, num_zeros = 0, decimal_point = 8, whitespaces=False):
     from locale import localeconv
@@ -273,7 +275,7 @@ def create_URI(addr, amount, message):
         return ""
     query = []
     if amount:
-        query.append('amount=%s'%format_satoshis(amount))
+        query.append('amount=%s'%format_satoshis_plain(amount))
     if message:
         if type(message) == unicode:
             message = message.encode('utf8')


Test patch:
Repository: spesmilo/electrum

Issue:
daemon not working properly because of repr()
There are two instances of repr() in daemon.py.  This is causing the daemon history bug we discussed last night.  At least a part of the problem is that some strings are unicode and some aren't.

The repr() usage seems to be a hack in order to get items in a set.  I'm thinking of alternative solutions.

daemon not working properly because of repr()
There are two instances of repr() in daemon.py.  This is causing the daemon history bug we discussed last night.  At least a part of the problem is that some strings are unicode and some aren't.

The repr() usage seems to be a hack in order to get items in a set.  I'm thinking of alternative solutions.



Discussion:

Resolving patch:
diff --git a/lib/daemon.py b/lib/daemon.py
--- a/lib/daemon.py
+++ b/lib/daemon.py
@@ -24,6 +24,7 @@
 import traceback
 import json
 import Queue
+from collections import defaultdict
 
 import util
 from network import Network
@@ -73,7 +74,7 @@ def __init__(self, server, s):
         self.client_pipe = util.SocketPipe(s)
         self.response_queue = Queue.Queue()
         self.server.add_client(self)
-        self.subscriptions = set()
+        self.subscriptions = defaultdict(list)
 
     def reading_thread(self):
         while self.is_running():
@@ -90,7 +91,7 @@ def reading_thread(self):
                 self.server.stop()
                 continue
             if method[-10:] == '.subscribe':
-                self.subscriptions.add(repr((method, params)))
+                self.subscriptions[method].append(params)
             self.server.send_request(self, request)
 
     def run(self):
@@ -167,7 +168,7 @@ def run(self):
                 m = response.get('method')
                 v = response.get('params')
                 for client in self.clients:
-                    if repr((m, v)) in client.subscriptions or m == 'network.status':
+                    if m == 'network.status' or v in client.subscriptions.get(m, []):
                         client.response_queue.put(response)
         self.network.stop()
         print_error("server exiting")


Test patch:
Repository: spesmilo/electrum

Issue:
allow non-root installation on Linux
I want to install Electrum on my Ubuntu machine in my user's `$HOME` directory, i.e., not via `sudo`.  If I run the command

```
pip install https://download.electrum.org/2.5.4/Electrum-2.5.4.tar.gz
```

I get an error when the installation tries to create a desktop shortcut:

```
copying electrum.desktop -> /usr/share/applications/

error: [Errno 13] Permission denied: '/usr/share/applications/electrum.desktop'
```

Maybe the installation script could `try` if this copy operation works, and try again at `$HOME/.local/share/applications` (or, better, `$XDG_DATA_HOME/applications`) in case it doesn't.

If you agree this would make sense and point me to the file where I would need to do this, I'd be happy to provide a PR.



Discussion:
PS: I should add that as it stands, the installation fails; at least I cannot find any executable `electrum` script, i.e. in `~/.local/bin`.

did you get a recent version of pip and try with the --user option?

using stock pip from Ubuntu 14.04:

```
$ pip --version
pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)
```

And yes, used `--user` but forgot to put it when copy-pasting.

can you try without pip?
 'python setup.py install --user' 

Thanks for the suggestion, but this also doesn't work:

```
$ python setup.py install --user
[...]
running install_data
copying electrum.desktop -> /usr/share/applications/
error: [Errno 13] Permission denied:
```

'/usr/share/applications/electrum.desktop'

ok, in that case I think you should update setuptools


Resolving patch:
diff --git a/setup.py b/setup.py
old mode 100644
new mode 100755
--- a/setup.py
+++ b/setup.py
@@ -17,6 +17,11 @@
 
 if platform.system() in ['Linux', 'FreeBSD', 'DragonFly']:
     usr_share = os.path.join(sys.prefix, "share")
+    if not os.access(usr_share, os.W_OK):
+        if 'XDG_DATA_HOME' in os.environ.keys():
+            usr_share = os.environ['$XDG_DATA_HOME']
+        else:
+            usr_share = os.path.expanduser('~/.local/share')
     data_files += [
         (os.path.join(usr_share, 'applications/'), ['electrum.desktop']),
         (os.path.join(usr_share, 'pixmaps/'), ['icons/electrum.png'])


Test patch:
Repository: spesmilo/electrum

Issue:
Feature request: Label colour - History Window
The transaction amount of outgoing transactions, when viewed in the history window, is coloured red. 

It would be a nice if the label of these transactions could be coloured the same red colour so that they stand out more against the other incoming transactions. 

Not a big issue but would be a 'nice to have'.



Discussion:

Resolving patch:
diff --git a/gui/qt/history_widget.py b/gui/qt/history_widget.py
--- a/gui/qt/history_widget.py
+++ b/gui/qt/history_widget.py
@@ -92,6 +92,7 @@ def on_update(self):
                 if i!=2:
                     item.setFont(i, QFont(MONOSPACE_FONT))
             if value < 0:
+                item.setForeground(3, QBrush(QColor("#BC1E1E")))
                 item.setForeground(4, QBrush(QColor("#BC1E1E")))
             if tx_hash:
                 item.setData(0, Qt.UserRole, tx_hash)


Test patch:
Repository: spesmilo/electrum

Issue:
HTTPS cert expired on LabelSync server
The cert on https://sync.bytesized-hosting.com:9090/ has expired and the LabelSync plugin stopped working 


Discussion:
looks like the person didn't set up the renewal cronjob correctly...

In case that person comes on here:

https://certbot.eff.org/  (This is the new name for "Let's Encrypt")

1. Choose the server software and the system.
2. Read the instructions.

Lately their packages come auto-matically with an automated cronjob to check for renewal every 2 hours (the script exits immediately if the cert is not up for renewal, so it is ok to be frequent.)

https://certbot.eff.org/#ubuntuother-apache

from this example on ubuntu based apache

`./path/to/certbot-auto renew --quiet --no-self-upgrade` and FYI --quiet --no-self-upgrade both work on the old lets-encrypt packages too, just change "certbot" with "lets-encrypt" and place this exact same one liner in your crontab or systemd. (I had permission problems when setting up my own, so I suggest using root crontab.)
ping @maran 

Resolving patch:
diff --git a/plugins/labels/labels.py b/plugins/labels/labels.py
--- a/plugins/labels/labels.py
+++ b/plugins/labels/labels.py
@@ -5,7 +5,6 @@
 import sys
 import traceback
 
-import aes
 import base64
 
 import electrum
@@ -19,7 +18,7 @@ class LabelsPlugin(BasePlugin):
 
     def __init__(self, parent, config, name):
         BasePlugin.__init__(self, parent, config, name)
-        self.target_host = 'sync.bytesized-hosting.com:9090'
+        self.target_host = 'labels.bauerj.eu'
         self.wallets = {}
 
     def encode(self, wallet, msg):


Test patch:
Repository: pydanny/cookiecutter-djangopackage

Issue:
setup.py shouldn't import package
The setup.py file does an import on the package itself, in order to get the version.

This becomes an issue if doing "import mypackage" ends up importing other things, especially dependencies (e.g. `mypackage/__init__.py` imports `mydependency` directly or indirectly). The end result can be that setup.py cannot run unless dependencies are already installed.

This means that often a package become uninstallable (with something like pip, which runs setup.py to get a list of dependencies), unless dependencies are installed previously.

The problem is often not apparent to the package maintainer as well, because they rarely install the package from scratch.

If this is fixed, bumpversion config will also need to be fixed.



Discussion:
Totally agree. Django-avatar has an implementation of this. https://github.com/grantmcconnaughey/django-avatar/blob/master/setup.py

I'm a huge :+1: for this upgrade. My problem is that I don't have time to do any open source right now besides reviewing simple, clean, very atomic pull requests. If one can be submitted for this issue, I'll make the time to review it.


Resolving patch:
diff --git a/{{cookiecutter.repo_name}}/setup.py b/{{cookiecutter.repo_name}}/setup.py
--- a/{{cookiecutter.repo_name}}/setup.py
+++ b/{{cookiecutter.repo_name}}/setup.py
@@ -1,17 +1,25 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
-
 import os
+import re
 import sys
 
-import {{ cookiecutter.app_name }}
-
 try:
     from setuptools import setup
 except ImportError:
     from distutils.core import setup
 
-version = {{ cookiecutter.app_name }}.__version__
+
+def get_version(*file_paths):
+    filename = os.path.join(os.path.dirname(__file__), *parts)
+    version_file = open(filename).read()
+    version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
+                              version_file, re.M)
+    if version_match:
+        return version_match.group(1)
+    raise RuntimeError('Unable to find version string.')
+
+version = get_version('{{ cookiecutter.app_name }}', '__init__.py')
 
 if sys.argv[-1] == 'publish':
     try:
@@ -62,6 +70,6 @@
         'Programming Language :: Python :: 3',
         'Programming Language :: Python :: 3.3',
         'Programming Language :: Python :: 3.4',
-        'Programming Language :: Python :: 3.5',        
+        'Programming Language :: Python :: 3.5',
     ],
 )


Test patch:
Repository: pydanny/cookiecutter-djangopackage

Issue:
Add codecov to rendered package
Needs:
- Addition to generated `travis-ci.yml`
- Basic instructions for using codecov
- Badge in README.rst



Discussion:

Resolving patch:
diff --git a/{{cookiecutter.repo_name}}/setup.py b/{{cookiecutter.repo_name}}/setup.py
--- a/{{cookiecutter.repo_name}}/setup.py
+++ b/{{cookiecutter.repo_name}}/setup.py
@@ -27,6 +27,7 @@ def get_version(*file_paths):
         return version_match.group(1)
     raise RuntimeError('Unable to find version string.')
 
+
 version = get_version("{{ cookiecutter.app_name }}", "__init__.py")
 
 


Test patch:
diff --git a/{{cookiecutter.repo_name}}/requirements_test.txt b/{{cookiecutter.repo_name}}/requirements_test.txt
--- a/{{cookiecutter.repo_name}}/requirements_test.txt
+++ b/{{cookiecutter.repo_name}}/requirements_test.txt
@@ -2,6 +2,7 @@ coverage==4.2
 mock>=1.0.1
 flake8>=2.1.0
 tox>=1.7.0
+codecov>=2.0.0
 {% if cookiecutter.models != "Comma-separated list of models" %}django-model-utils>=2.0{% endif %}
 
 # Additional test requirements go here
Repository: pydanny/cookiecutter-djangopackage

Issue:
Test in Python 3.2 fails in Travis
It seems, that Python 3.2 is not supported by `PIP` anymore (https://pip.pypa.io/en/stable/installing/). This causes Travis tests to fail in default configuration with:
```
 File "/home/travis/virtualenv/python3.5.2/lib/python3.5/site-packages/virtualenv_support/pip-9.0.1-py2.py3-none-any.whl/pip/_vendor/requests/models.py", line 856
    http_error_msg = u'%s Client Error: %s for url: %s' % (self.status_code, reason, self.url)
                                                      ^
SyntaxError: invalid syntax
```



Discussion:
Here is what @ssteinerx posted under original wrong-placed issue (https://github.com/pydanny/cookiecutter-django/issues/982):

Regardless of pip's own support, Python 3.2 support was officially dropped by Django at the end of 2016.

The tests on 3.2 should be removed.

https://docs.djangoproject.com/en/1.10/faq/install/

What Python version can I use with Django?

Django version	Python versions
1.8	2.7, 3.2 **(until the end of 2016)**, 3.3, 3.4, 3.5
1.9, 1.10	2.7, 3.4, 3.5
1.11	2.7, 3.4, 3.5, 3.6
2.0	3.5+
I second this, dropped 3.2 from tox.ini and .python-version
Probably need to get it out of setup.py if it's there as well.

S

On Jan 11, 2017, at 4:33 PM, Ryan Castner wrote:

> I second this, dropped 3.2 from tox.ini and .python-version
> 
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub, or mute the thread.
> 



Resolving patch:
diff --git a/{{cookiecutter.repo_name}}/setup.py b/{{cookiecutter.repo_name}}/setup.py
--- a/{{cookiecutter.repo_name}}/setup.py
+++ b/{{cookiecutter.repo_name}}/setup.py
@@ -80,7 +80,6 @@ def get_version(*file_paths):
         'Programming Language :: Python :: 2',
         'Programming Language :: Python :: 2.7',
         'Programming Language :: Python :: 3',{% if '1.8' in cookiecutter.django_versions %}
-        'Programming Language :: Python :: 3.2',
         'Programming Language :: Python :: 3.3',{% endif %}
         'Programming Language :: Python :: 3.4',
         'Programming Language :: Python :: 3.5',


Test patch: