URI: 
       tuse serialized format in signtx - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 64ad3fc28c671f6295136c1a0053a879762eb6c4
   DIR parent 5da3cab24b2a9b93e92f2febf0cae43d7287763c
  HTML Author: thomasv <thomasv@gitorious>
       Date:   Sun, 24 Feb 2013 21:31:11 +0100
       
       use serialized format in signtx
       
       Diffstat:
         M electrum                            |      18 +++++++-----------
         M lib/bitcoin.py                      |       1 +
         M lib/wallet.py                       |       9 ++++-----
       
       3 files changed, 12 insertions(+), 16 deletions(-)
       ---
   DIR diff --git a/electrum b/electrum
       t@@ -464,6 +464,7 @@ if __name__ == '__main__':
                        f.write(repr({'seed':wallet.seed, 'imported_keys':wallet.imported_keys})+"\n")
                        f.close()
                        wallet.seed = ''
       +                wallet.config.set_key('seed','', True)
                        for k in wallet.imported_keys.keys(): wallet.imported_keys[k] = ''
                        wallet.save()
                        print_msg("Done.")
       t@@ -636,7 +637,7 @@ if __name__ == '__main__':
                    r, h = wallet.sendtx( tx )
                    print_msg(h)
                else:
       -            print_msg(tx)
       +            print_json({"hex":str(tx), "complete":tx.is_complete})
        
                if is_temporary:
                    wallet.imported_keys.pop(from_addr)
       t@@ -644,13 +645,8 @@ if __name__ == '__main__':
                wallet.save()
        
            elif cmd == 'signtx':
       -        filename = args[1]
       -        f = open(filename, 'r')
       -        d = ast.literal_eval(f.read())
       -        f.close()
       -        inputs = d['inputs']
       -        outputs = d['outputs']
       -        tx = wallet.signed_tx( inputs, outputs, password )
       +        tx = Transaction(args[1])
       +        tx = wallet.sign_tx( tx, password )
                print_msg(tx)
        
            elif cmd == 'sendtx':
       t@@ -761,9 +757,9 @@ if __name__ == '__main__':
                    else:
                        if wallet.transactions.get(txid):
                            # lookup in my own list of transactions
       -                    txout = wallet.transactions[txid]['outputs'][index]
       -                    txin['address'] = txout['address']
       -                    txin['raw_output_script'] = txout['raw_output_script']
       +                    txout = wallet.transactions[txid].outputs[index]
       +                    txin['address'] = txout[0]
       +                    #txin['raw_output_script'] = txout['raw_output_script']
        
                        else:
                            # if neither, we might want to get it from the server..
   DIR diff --git a/lib/bitcoin.py b/lib/bitcoin.py
       t@@ -476,6 +476,7 @@ class Transaction:
            def from_io(klass, inputs, outputs):
                raw = klass.serialize(inputs, outputs, for_sig = -1) # for_sig=-1 means do not sign
                self = klass(raw)
       +        self.is_complete = False
                self.inputs = inputs
                self.outputs = outputs
                return self
   DIR diff --git a/lib/wallet.py b/lib/wallet.py
       t@@ -665,10 +665,11 @@ class Wallet:
                    print_error( "Sending change to", change_addr )
                outputs = self.add_tx_change(outputs, amount, fee, total, change_addr)
        
       +        tx = Transaction.from_io(inputs, outputs)
                if not self.seed:
       -            return repr({'inputs':inputs, 'outputs':outputs})
       +            return tx
                
       -        tx = self.signed_tx(inputs, outputs, password)
       +        self.sign_tx(tx, password)
        
                for address, x in outputs:
                    if address not in self.addressbook and not self.is_mine(address):
       t@@ -680,15 +681,13 @@ class Wallet:
        
                return tx
        
       -    def signed_tx(self, inputs, outputs, password):
       -        tx = Transaction.from_io(inputs, outputs)
       +    def sign_tx(self, tx, password):
                private_keys = {}
                for txin in tx.inputs:
                    addr = txin['address']
                    sec = self.get_private_key(addr, password)
                    private_keys[addr] = sec
                tx.sign(private_keys)
       -        return str(tx)
        
            def sendtx(self, tx):
                # synchronous