remove remote wallet (broken, will be replaced)

This commit is contained in:
thomasv 2012-10-05 15:49:03 +02:00
parent c479261043
commit 880b08f337
4 changed files with 0 additions and 177 deletions

View File

@ -115,7 +115,6 @@ if __name__ == '__main__':
parser.add_option("-f", "--fee", dest="tx_fee", default="0.005", help="set tx fee")
parser.add_option("-s", "--fromaddr", dest="from_addr", default=None, help="set source address for payto/mktx. if it isn't in the wallet, it will ask for the private key unless supplied in the format public_key:private_key. It's not saved in the wallet.")
parser.add_option("-c", "--changeaddr", dest="change_addr", default=None, help="set the change address for payto/mktx. default is a spare address, or the source address if it's not in the wallet")
parser.add_option("-r", "--remote", dest="remote_url", default=None, help="URL of a remote wallet")
parser.add_option("-p", "--proxy", dest="proxy", default=None, help="set proxy [type:]host[:port], where type is socks4,socks5 or http")
options, args = parser.parse_args()
@ -125,7 +124,6 @@ if __name__ == '__main__':
wallet = Wallet()
wallet.set_path(options.wallet_path)
wallet.read()
wallet.remote_url = options.remote_url
if len(args)==0:
url = None

View File

@ -315,7 +315,6 @@ class Wallet:
self.tx_history = {}
self.imported_keys = {}
self.remote_url = None
self.was_updated = True
self.blocks = -1
@ -615,26 +614,9 @@ class Wallet:
else:
new_addresses.append( self.create_new_address(False) )
if self.remote_url:
num = self.get_remote_number()
while len(self.addresses)<num:
new_addresses.append( self.create_new_address(False) )
return new_addresses
def get_remote_number(self):
import jsonrpclib
server = jsonrpclib.Server(self.remote_url)
out = server.getnum()
return out
def get_remote_mpk(self):
import jsonrpclib
server = jsonrpclib.Server(self.remote_url)
out = server.getkey()
return out
def is_found(self):
return (len(self.change_addresses) > 1 ) or ( len(self.addresses) > self.gap_limit )
@ -730,8 +712,6 @@ class Wallet:
if self.seed_version != SEED_VERSION:
raise ValueError("This wallet seed is deprecated. Please run upgrade.py for a diagnostic.")
if self.remote_url: assert self.master_public_key.encode('hex') == self.get_remote_mpk()
self.file_exists = True

View File

@ -1,24 +0,0 @@
<?
require_once 'jsonrpcphp/includes/jsonRPCClient.php';
echo "<pre>\n";
echo "This page demonstrates the generation of new addresses by a neutralized Electrum wallet.\n\n";
echo "A neutralized wallet does not contain the seed that allows to generate private keys.\nIt contains a master public key that allows to create new addresses.\n\n";
echo "An attacker getting access to the neutralized wallet cannot steal the bitcoins.\n";
echo "The full wallet (with seed) is not stored on the webserver.\n\n";
echo "<form action=\"\" method=\"post\"><input type=\"submit\" name=\"submit\" value=\"Get new address\"/></form> ";
if($_POST['submit']) {
$daemon = new jsonRPCClient('http://foo:bar@ecdsa.org:8444/');
try{
$r = $daemon->getnewaddress();
if($r) {
echo '<br/>';
echo "<a href='bitcoin:$r'>bitcoin:$r</a>\n\n";
}
} catch(Exception $e) {
echo "error: cannot reach wallet daemon";
}
}
echo "</pre>";
?>

View File

@ -1,131 +0,0 @@
#!/usr/bin/env python
#
# Electrum - lightweight Bitcoin client
# Copyright (C) 2011 thomasv@gitorious
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import time, thread, sys, socket
# see http://code.google.com/p/jsonrpclib/
import jsonrpclib
from wallet import Wallet
try:
from lib.util import print_error
except ImportError:
from electrum.util import print_error
"""
Simple wallet daemon for webservers.
- generates new addresses on request
- private keys are not needed in order to generate new addresses. A neutralized wallet can be used (seed removed)
- no gap limit: use 'getnum' to know how many addresses have been created.
todo:
- return the max gap
- add expiration date
"""
host = 'ecdsa.org'
port = 8444
wallet_path = 'wallet_path'
username = 'foo'
password = 'bar'
wallet = Wallet()
stopping = False
from jsonrpclib.SimpleJSONRPCServer import SimpleJSONRPCRequestHandler
import SimpleXMLRPCServer
class authHandler(SimpleJSONRPCRequestHandler):
def parse_request(self):
if SimpleXMLRPCServer.SimpleXMLRPCRequestHandler.parse_request(self):
if self.authenticate(self.headers):
return True
else:
self.send_error(401, 'Authentication failed')
return False
def authenticate(self, headers):
from base64 import b64decode
basic, _, encoded = headers.get('Authorization').partition(' ')
assert basic == 'Basic', 'Only basic authentication supported'
x_username, _, x_password = b64decode(encoded).partition(':')
return username == x_username and password == x_password
def do_stop():
global stopping
stopping = True
def get_new_address():
a = wallet.create_new_address(False)
wallet.save()
return a
def get_num():
return len(wallet.addresses)
def get_mpk():
return wallet.master_public_key.encode('hex')
if __name__ == '__main__':
if len(sys.argv)>1:
import jsonrpclib
server = jsonrpclib.Server('http://%s:%s@%s:%d'%(username, password, host, port))
cmd = sys.argv[1]
try:
if cmd == 'getnum':
out = server.getnum()
elif cmd == 'getkey':
out = server.getkey()
elif cmd == 'getnewaddress':
out = server.getnewaddress()
elif cmd == 'stop':
out = server.stop()
except socket.error:
print_error("Server not running")
sys.exit(1)
print out
sys.exit(0)
else:
wallet.set_path(wallet_path)
wallet.read()
def server_thread():
from SocketServer import ThreadingMixIn
from jsonrpclib.SimpleJSONRPCServer import SimpleJSONRPCServer
server = SimpleJSONRPCServer(( host, port), requestHandler=authHandler)
server.register_function(get_new_address, 'getnewaddress')
server.register_function(get_num, 'getnum')
server.register_function(get_mpk, 'getkey')
server.register_function(do_stop, 'stop')
server.serve_forever()
thread.start_new_thread(server_thread, ())
while not stopping: time.sleep(0.1)