Advertisement
Guest User

Untitled

a guest
Jan 29th, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.08 KB | None | 0 0
  1. diff -aur Electrum-1.9.5-old/lib/transaction.py Electrum-1.9.5/lib/transaction.py
  2. --- Electrum-1.9.5-old/lib/transaction.py 2013-11-12 11:12:10.000000000 +0000
  3. +++ Electrum-1.9.5/lib/transaction.py 2013-12-19 13:08:55.255383097 +0000
  4. @@ -453,7 +453,8 @@
  5.  
  6. elif for_sig==i:
  7. if txin.get('redeemScript'):
  8. - script = txin['redeemScript'] # p2sh uses the inner script
  9. + # txin['redeemScript'] the hell it does # p2sh uses the inner script
  10. + script = txin['redeemScript']
  11. else:
  12. script = txin['scriptPubKey'] # scriptsig
  13. else:
  14. @@ -466,16 +467,16 @@
  15. for output in outputs:
  16. addr, amount = output
  17. s += int_to_hex( amount, 8) # amount
  18. - addrtype, hash_160 = bc_address_to_hash_160(addr)
  19. + addrtype, hash_160_value = bc_address_to_hash_160(addr)
  20. if addrtype == 0:
  21. script = '76a9' # op_dup, op_hash_160
  22. script += '14' # push 0x14 bytes
  23. - script += hash_160.encode('hex')
  24. + script += hash_160_value.encode('hex')
  25. script += '88ac' # op_equalverify, op_checksig
  26. elif addrtype == 5:
  27. script = 'a9' # op_hash_160
  28. script += '14' # push 0x14 bytes
  29. - script += hash_160.encode('hex')
  30. + script += hash_160_value.encode('hex')
  31. script += '87' # op_equal
  32. else:
  33. raise
  34. @@ -526,9 +527,14 @@
  35. secexp = pkey.secret
  36. private_key = ecdsa.SigningKey.from_secret_exponent( secexp, curve = SECP256k1 )
  37. public_key = private_key.get_verifying_key()
  38. + #print ( "using transaction:" )
  39. + #print ( tx_for_sig );
  40. + #print ( "now hashing" )
  41. + #print Hash( tx_for_sig.decode('hex') )[::-1].encode( 'hex' )
  42. + #print private_key.to_string().encode( 'hex' )
  43. sig = private_key.sign_digest_deterministic( Hash( tx_for_sig.decode('hex') ), hashfunc=hashlib.sha256, sigencode = ecdsa.util.sigencode_der )
  44. assert public_key.verify_digest( sig, Hash( tx_for_sig.decode('hex') ), sigdecode = ecdsa.util.sigdecode_der)
  45. - signatures.append( sig.encode('hex') )
  46. + signatures.insert( 0, sig.encode('hex') )
  47. print_error("adding signature for", pubkey)
  48.  
  49. txin["signatures"] = signatures
  50. @@ -721,9 +727,12 @@
  51. def add_input_info(self, input_info):
  52. for i, txin in enumerate(self.inputs):
  53. item = input_info[i]
  54. - txin['address'] = item['address']
  55. - txin['signatures'] = item['signatures']
  56. + txin['address'] = item.get('address')
  57. + if( 'signatures' in item ) :
  58. + txin['signatures'] = item.get['signatures']
  59. txin['scriptPubKey'] = item['scriptPubKey']
  60. - txin['redeemScript'] = item.get('redeemScript')
  61. + if 'redeemScript' in item :
  62. + txin['redeemScript'] = item['redeemScript']
  63. + txin['address'] = hash_160_to_bc_address(hash_160(item['redeemScript']) )
  64. txin['redeemPubkey'] = item.get('redeemPubkey')
  65. txin['KeyID'] = item.get('KeyID')
  66. diff -aur Electrum-1.9.5-old/lib/wallet.py Electrum-1.9.5/lib/wallet.py
  67. --- Electrum-1.9.5-old/lib/wallet.py 2013-11-22 16:49:54.000000000 +0000
  68. +++ Electrum-1.9.5/lib/wallet.py 2013-12-19 04:05:11.584964217 +0000
  69. @@ -711,21 +711,25 @@
  70. if address in self.imported_keys.keys():
  71. out.append( pw_decode( self.imported_keys[address], password ) )
  72. else:
  73. - account, sequence = self.get_address_index(address)
  74. - if account == 0:
  75. - pk = self.accounts[account].get_private_key(seed, sequence)
  76. - out.append(pk)
  77. - return out
  78. -
  79. - # assert address == self.accounts[account].get_address(*sequence)
  80. - rs = self.rebase_sequence( account, sequence)
  81. - for root, public_sequence in rs:
  82. -
  83. - if root not in self.master_private_keys.keys(): continue
  84. - master_k = self.get_master_private_key(root, password)
  85. - master_c, _, _ = self.master_public_keys[root]
  86. - pk = bip32_private_key( public_sequence, master_k.decode('hex'), master_c.decode('hex'))
  87. - out.append(pk)
  88. + try :
  89. + account, sequence = self.get_address_index(address)
  90. + if account == 0:
  91. + pk = self.accounts[account].get_private_key(seed, sequence)
  92. + out.append(pk)
  93. + return out
  94. +
  95. + # assert address == self.accounts[account].get_address(*sequence)
  96. + rs = self.rebase_sequence( account, sequence)
  97. + for root, public_sequence in rs:
  98. +
  99. + if root not in self.master_private_keys.keys(): continue
  100. + master_k = self.get_master_private_key(root, password)
  101. + master_c, _, _ = self.master_public_keys[root]
  102. + pk = bip32_private_key( public_sequence, master_k.decode('hex'), master_c.decode('hex'))
  103. + out.append(pk)
  104. + except:
  105. + #ignore all errors in here
  106. + return []
  107.  
  108. return out
  109.  
  110. @@ -740,6 +744,8 @@
  111. if address in self.imported_keys.keys():
  112. txin['redeemPubkey'] = pubkey
  113.  
  114. +
  115. +
  116.  
  117. def add_keypairs_from_KeyID(self, tx, keypairs, password):
  118. for txin in tx.inputs:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement