URI: 
       tfix publish_request - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 357c405ac66435c32bd353445c52d139b8165cf5
   DIR parent d3679301132bb53496d57e137a99922a7d47d01c
  HTML Author: ThomasV <thomasv@gitorious>
       Date:   Mon,  8 Jun 2015 13:21:13 +0200
       
       fix publish_request
       
       Diffstat:
         M lib/paymentrequest.py               |      21 ---------------------
         M lib/wallet.py                       |      26 +++++++++++++++++++++-----
       
       2 files changed, 21 insertions(+), 26 deletions(-)
       ---
   DIR diff --git a/lib/paymentrequest.py b/lib/paymentrequest.py
       t@@ -307,27 +307,6 @@ def make_request(config, req):
            return make_payment_request(outputs, message, time, time + expiration if expiration else None, key_path, cert_path)
        
        
       -def publish_request(config, addr, req):
       -    import shutil, os
       -    rdir = config.get('requests_dir')
       -    if not rdir:
       -        return
       -    if not os.path.exists(rdir):
       -        os.mkdir(rdir)
       -    index = os.path.join(rdir, 'index.html')
       -    if not os.path.exists(index):
       -        src = os.path.join(os.path.dirname(__file__), 'www', 'index.html')
       -        shutil.copy(src, index)
       -    key = req.get('id', addr)
       -    pr = make_request(config, req)
       -    path = os.path.join(rdir, key + '.bip70')
       -    with open(path, 'w') as f:
       -        f.write(pr)
       -    with open(os.path.join(rdir, key + '.json'), 'w') as f:
       -        f.write(json.dumps(req))
       -    req['path'] = path
       -    return req
       -
        
        
        class InvoiceStore(object):
   DIR diff --git a/lib/wallet.py b/lib/wallet.py
       t@@ -1270,16 +1270,32 @@ class Abstract_Wallet(object):
                return status
        
            def add_payment_request(self, addr, amount, message, expiration, config):
       -        import paymentrequest
       +        import paymentrequest, shutil, os
                timestamp = int(time.time())
                _id = Hash(addr + "%d"%timestamp).encode('hex')[0:10]
                r = {'time':timestamp, 'amount':amount, 'expiration':expiration, 'address':addr, 'memo':message, 'id':_id}
                self.receive_requests[addr] = r
       -        self.set_label(addr, message) # should be a default label
       -        if config.get('requests_dir'):
       -            paymentrequest.publish_request(config, addr, r)
                self.storage.put('receive_requests2', self.receive_requests)
       -        return self.get_payment_request(addr, config)
       +        self.set_label(addr, message) # should be a default label
       +        rdir = config.get('requests_dir')
       +        req = self.get_payment_request(addr, config)
       +        if rdir:
       +            if not os.path.exists(rdir):
       +                os.mkdir(rdir)
       +            index = os.path.join(rdir, 'index.html')
       +            if not os.path.exists(index):
       +                src = os.path.join(os.path.dirname(__file__), 'www', 'index.html')
       +                shutil.copy(src, index)
       +            key = req.get('id', addr)
       +            pr = paymentrequest.make_request(config, req)
       +            path = os.path.join(rdir, key + '.bip70')
       +            with open(path, 'w') as f:
       +                f.write(pr)
       +            # reload
       +            req = self.get_payment_request(addr, config)
       +            with open(os.path.join(rdir, key + '.json'), 'w') as f:
       +                f.write(json.dumps(req))
       +        return req
        
            def remove_payment_request(self, addr, config):
                if addr not in self.receive_requests: