Merge branch 'development' into jsonrpc

This commit is contained in:
Jack 2016-03-15 23:02:06 -04:00
commit 4e34f861c9
7 changed files with 111 additions and 94 deletions

View file

@ -1,38 +1,14 @@
Prerequisites
-------------
To use the LBRYWallet, which enables spending and accepting LBRYcrds in exchange for data, the
LBRYcrd application (insert link to LBRYcrd website here) must be installed and running. If
this is not desired, the testing client can be used to simulate trading points, which is
built into LBRYnet.
on Ubuntu:
```
sudo apt-get install libgmp3-dev build-essential python-dev python-pip
```
Getting the source
------------------
Don't you already have it?
Setting up the environment
#### Installing lbrynet on Linux
--------------------------
It's recommended that you use a virtualenv
The following packages are necessary (the following are their names on Ubuntu):
libgmp3-dev build-essential python2.7 python2.7-dev python-pip
```
sudo apt-get install python-virtualenv
cd <source base directory>
virtualenv .
source bin/activate
```
To install them on Ubuntu:
sudo apt-get install libgmp3-dev build-essential python2.7 python2.7-dev python-pip
(to deactivate the virtualenv, enter 'deactivate')
```
python setup.py install
python setup.py build bdist_egg
sudo python setup.py install
```
this will install all of the libraries and a few applications

View file

@ -37,7 +37,7 @@ See [INSTALL](INSTALL.md)
## Developers
Documentation: doc.lbry.io
Source code: trac.lbry.io/browser
Source code: https://github.com/lbryio/lbry
To contribute to the development of LBRYnet or lbrynet-console, contact jimmy@lbry.io

View file

@ -9,20 +9,38 @@ Download the file https://raw.githubusercontent.com/lbryio/lbry-setup/master/lbr
Once it's done building, type:
```
./lbrycrd/src/lbrycrdd -server -daemon
lbrynet-gui
lbrynet-console
```
A window should show up with an entry box
A console application will load, and after a moment you will be presented with a ">" signifying
that the console is ready for commands.
Type wonderfullife into the box, hit go, and choose to stream or save
If it's your first time running lbrynet-console, you should be given some credits to test the
network. If they don't show up within a minute or two, let us know, and we'll send you some.
To stop lbrycrdd: `./lbrycrd/src/lbrycrd-cli stop`
After your credits have shown up, type
```
get wonderfullife
```
into the prompt and hit enter.
You will be asked if you want to cancel, change options, save, and perhaps stream the file.
Enter 's' for save and then hit enter.
The file should start downloading. Enter the command 'status' to check on the status of files
that are in the process of being downloaded.
To stop lbrynet-console, enter the command 'exit'.
## Slightly longer install guide
### Installing lbrycrd from source
### Installing lbrycrd, the full blockchain client
Note: this process takes upwards of an hour and is not necessary to use lbrynet.
```
git clone --depth=1 -b alpha https://github.com/lbryio/lbrycrd.git
@ -89,11 +107,21 @@ sudo python setup.py install
## Slightly longer running guide
###In order to use lbrynet-console or lbrynet-gui, lbyrcrd must be running.
### lbrynet-console can be set to use lbrycrdd instead of the built in lightweight client.
### Running lbrycrd
To run lbrynet-console with lbrycrdd:
If you ran the easy install script, the lbrycrd folder will be in the directory you ran lbry_setup.sh from. Otherwise it is the root of the cloned lbrycrd repository. Go to that directory.
```
lbrynet-console </path/to/lbrycrdd>
```
If lbrycrdd is not already running, lbrynet will launch it at that path, and will shut it down
when lbrynet exits. If lbrycrdd is already running, lbrynet will not launch it and will not
shut it down, but it will connect to it and use it.
### Running lbrycrdd manually
From the lbrycrd directory, run:
```
./src/lbrycrdd -server -daemon
@ -105,37 +133,14 @@ If you want to mine LBC, also use the flag '-gen', so:
./src/lbrycrdd -server -daemon -gen
```
Warning: This will put a heavy load on your CPU
It will take a few minutes for your client to download the whole block chain.
lbrycrdd must be running in order for lbrynet to function.
To shut lbrycrdd down: from the lbrycrd directory, run
To shut lbrycrdd down: from the lbrycrd directory, run:
```
./src/lbrycrd-cli stop
```
### Option 1) Running lbrynet-console
If you used the virtualenv instructions above, make sure the virtualenv is still active. If not, reactivate it according to the instructions above, under "Installing lbrynet from source"
In your terminal: `lbrynet-console`
You should be presented with a prompt.
Watch It's a Wonderful Life via LBRY
Type into the prompt: `get wonderfullife`
To shut it down, press ctrl-c at any time or enter `exit` into the prompt.
### Option 2) Running lbrynet-gui
If you used the virtualenv instructions above, make sure the virtualenv is still active. If not, reactivate it according to the instructions above, under "Installing lbrynet from source"
In your terminal: `lbrynet-gui`
A window should pop up with an entry box. Type `wonderfullife` into the box, hit go, and then choose to save it or stream it.
Enjoy!
Any questions or problems, email jimmy@lbry.io

View file

@ -294,13 +294,35 @@ class LBRYWallet(object):
value = result['value']
try:
value_dict = json.loads(value)
except ValueError:
except (ValueError, TypeError):
return Failure(InvalidStreamInfoError(name))
known_fields = ['stream_hash', 'name', 'description', 'key_fee', 'key_fee_address', 'thumbnail',
'content_license']
'content_license', 'sources', 'fee']
known_sources = ['lbry_sd_hash']
known_fee_types = {'LBC': ['amount', 'address']}
for field in known_fields:
if field in value_dict:
r_dict[field] = value_dict[field]
if field == 'sources':
for source in known_sources:
if source in value_dict[field]:
if source == 'lbry_sd_hash':
r_dict['stream_hash'] = value_dict[field][source]
else:
r_dict[source] = value_dict[field][source]
elif field == 'fee':
fee = value_dict['fee']
if 'type' in fee:
if fee['type'] in known_fee_types:
fee_fields = known_fee_types[fee['type']]
if all([f in fee for f in fee_fields]):
r_dict['key_fee'] = fee['amount']
r_dict['key_fee_address'] = fee['address']
else:
for f in ['key_fee', 'key_fee_address']:
if f in r_dict:
del r_dict[f]
else:
r_dict[field] = value_dict[field]
if 'stream_hash' in r_dict and 'txid' in result:
d = self._save_name_metadata(name, r_dict['stream_hash'], str(result['txid']))
else:
@ -312,14 +334,12 @@ class LBRYWallet(object):
return Failure(UnknownNameError(name))
def claim_name(self, name, sd_hash, amount, description=None, key_fee=None,
key_fee_address=None, thumbnail=None, content_license=None):
value = {"stream_hash": sd_hash}
key_fee_address=None, thumbnail=None, content_license=None):
value = {"sources": {'lbry_sd_hash': sd_hash}}
if description is not None:
value['description'] = description
if key_fee is not None:
value['key_fee'] = key_fee
if key_fee_address is not None:
value['key_fee_address'] = key_fee_address
if key_fee is not None and key_fee_address is not None:
value['fee'] = {'type': 'LBC', 'amount': key_fee, 'address': key_fee_address}
if thumbnail is not None:
value['thumbnail'] = thumbnail
if content_license is not None:
@ -395,9 +415,14 @@ class LBRYWallet(object):
if 'name' in claim and str(claim['name']) == name and 'value' in claim:
try:
value_dict = json.loads(claim['value'])
except ValueError:
except (ValueError, TypeError):
return None
if 'stream_hash' in value_dict and str(value_dict['stream_hash']) == sd_hash:
claim_sd_hash = None
if 'stream_hash' in value_dict:
claim_sd_hash = str(value_dict['stream_hash'])
if 'sources' in value_dict and 'lbrynet_sd_hash' in value_dict['sources']:
claim_sd_hash = str(value_dict['sources']['lbry_sd_hash'])
if claim_sd_hash is not None and claim_sd_hash == sd_hash:
if 'is controlling' in claim and claim['is controlling']:
return name, "valid"
if claim['in claim trie']:
@ -844,7 +869,7 @@ class LBRYumWallet(LBRYWallet):
def setup_network():
self.config = SimpleConfig()
self.network = Network(self.config)
alert.info("Starting the wallet...")
alert.info("Loading the wallet...")
return defer.succeed(self.network.start())
d = setup_network()
@ -857,7 +882,6 @@ class LBRYumWallet(LBRYWallet):
return False
start_check.stop()
if self.network.is_connected():
alert.info("Wallet started.")
network_start_d.callback(True)
else:
network_start_d.errback(ValueError("Failed to connect to network."))
@ -903,9 +927,24 @@ class LBRYumWallet(LBRYWallet):
wallet.synchronize()
self.wallet = wallet
blockchain_caught_d = defer.Deferred()
def check_caught_up():
local_height = self.network.get_local_height()
remote_height = self.network.get_server_height()
if remote_height != 0 and remote_height - local_height <= 5:
alert.info('Wallet loaded.')
catch_up_check.stop()
blockchain_caught_d.callback(True)
catch_up_check = task.LoopingCall(check_caught_up)
d = threads.deferToThread(get_wallet)
d.addCallback(self._save_wallet)
d.addCallback(lambda _: self.wallet.start_threads(self.network))
d.addCallback(lambda _: catch_up_check.start(.1))
d.addCallback(lambda _: blockchain_caught_d)
return d
def _get_cmd_runner(self):

View file

@ -99,7 +99,10 @@ class Bencode(Encoding):
"""
if len(data) == 0:
raise DecodeError, 'Cannot decode empty string'
return self._decodeRecursive(data)[0]
try:
return self._decodeRecursive(data)[0]
except ValueError as e:
raise DecodeError, e.message
@staticmethod
def _decodeRecursive(data, startIndex=0):

View file

@ -29,16 +29,10 @@ class ConsoleControl(basic.LineReceiver):
def send_initial_prompt(self):
self.sendLine("")
self.sendLine("In this early release of LBRY, some functions will not work\n"
"until you have downloaded a full copy of our blockchain. To\n"
"check whether you've caught up with the blockchain, use the\n"
"command 'get-blockchain-status'.\n\n"
"If, for example, you are unable to download some files or\n"
"your balance is showing 0 when you know it shouldn't be, it\n"
"is likely that the culprit is the blockchain.\n\n"
"You should have received 1000 LBC the first time you ran\n"
self.sendLine("You should have received 1000 LBC the first time you ran\n"
"this program. If you did not, let us know! But first give\n"
"them a couple of minutes to show up.\n\n"
"them a moment to show up. The block time is currently 30\n"
"seconds so they should show up within a couple of minutes.\n\n"
"Welcome to lbrynet-console!")
self.sendLine("")
self.sendLine("Enter a command. Try 'get wonderfullife' or 'help' to see more options.")

View file

@ -323,7 +323,7 @@ class GetWalletBalances(CommandHandler):
def _show_time_behind_blockchain(self, rounded_time):
if rounded_time.unit >= RoundedTime.HOUR:
self.console.sendLine("\n\nYour balance may be out of date. This application\n"
"is %s behind the LBC blockchain. It should take a few minutes to\n"
"is %s behind the LBC blockchain. It may take a few minutes to\n"
"catch up the first time you run this early version of LBRY.\n"
"Please be patient =).\n\n" % str(rounded_time))
else:
@ -797,7 +797,7 @@ class AddStream(CommandHandler):
self.console.sendLine("\nThis application is %s behind the LBC blockchain, so some of your\n"
"funds may not be available. Use 'get-blockchain-status' to check if\n"
"your application is up to date with the blockchain.\n\n"
"It should take a few minutes to catch up the first time you run this\n"
"It may take a few minutes to catch up the first time you run this\n"
"early version of LBRY. Please be patient =).\n\n" % str(rounded_time))
def _log_recent_blockchain_time_error_download(self, err):
@ -913,7 +913,7 @@ class AddStreamFromLBRYcrdName(AddStreamFromHash):
self.console.sendLine("\nThis application is %s behind the LBC blockchain, which may be\n"
"preventing this name from being resolved correctly. Use 'get-blockchain-status'\n"
"to check if your application is up to date with the blockchain.\n\n"
"It should take a few minutes to catch up the first time you run\n"
"It may take a few minutes to catch up the first time you run\n"
"this early version of LBRY. Please be patient =).\n\n" % str(rounded_time))
else:
self.console.sendLine("\n")
@ -1850,7 +1850,7 @@ class Publish(CommandHandler):
if rounded_time.unit >= RoundedTime.HOUR:
self.console.sendLine("This application is %s behind the LBC blockchain\n"
"and therefore may not have all of the funds you expect\n"
"available at this time. It should take a few minutes to\n"
"available at this time. It may take a few minutes to\n"
"catch up the first time you run this early version of LBRY.\n"
"Please be patient =).\n" % str(rounded_time))