Compare commits

..
Author SHA1 Message Date
Jack Robison a7f062f9ca rc bump 2019-06-05 14:50:02 -04:00
Jack Robison 7af90d9367 debug 2019-06-05 14:32:45 -04:00
Jack Robison ee68e56e7a version 2019-06-04 22:26:36 -04:00
Thomas Zarebczan 778510f057 add MKV to mime types 2019-06-04 19:40:45 -04:00
Jack Robison 7a91debf48 update torba requirement 2019-06-04 19:39:19 -04:00
Jack Robison a90919a9ba mbps instead of mbs, remove time from connection status 2019-06-04 19:35:34 -04:00
Jack Robison 347415dceb add connection status 2019-06-04 19:34:09 -04:00
Jack Robison fe55187696 0.37.2 2019-05-24 18:59:06 -04:00
Jack Robison db8fb15cc5 0.37.2rc4 2019-05-24 18:12:19 -04:00
Jack Robison a165ad910f improve set_build.py, pin torba version
- adds BUILD_COMMIT to lbrynet.build_type
2019-05-24 18:11:50 -04:00
Jack Robison b711069456 fix false negative with file completed field 2019-05-24 17:31:26 -04:00
Jack Robison c977a672b0 start returning range request bytes at the requested offset 2019-05-24 17:31:26 -04:00
Jack Robison ac5794d96d add blob_lru_cache_size config setting, defaults to 32 2019-05-24 17:31:26 -04:00
60 changed files with 1933 additions and 4046 deletions

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@ Before reporting any issues, please make sure that you're using the latest versi
- App: https://github.com/lbryio/lbry-desktop/releases
- Daemon: https://github.com/lbryio/lbry/releases
We are also available on Discord at https://chat.lbry.com
We are also available on Discord at https://chat.lbry.io
-->
+6 -6
View File
@@ -4,9 +4,7 @@ language: python
python: "3.7"
env:
global:
# must also be updated in wine_build.sh
- TORBA=master
- TORBA=v0.5.4a0
jobs:
include:
@@ -24,6 +22,7 @@ jobs:
install:
- pip install coverage
- pip install git+https://github.com/lbryio/torba.git@${TORBA}#egg=torba
- pip show torba
- pip install -e .
script:
- HOME=/tmp coverage run -p --source=lbrynet -m unittest discover -vv tests.unit
@@ -61,7 +60,7 @@ jobs:
- docker pull lbry/pyinstaller34_32bits:py371
script:
- python scripts/set_build.py
- docker run -v "$(pwd):/src/lbry" lbry/pyinstaller34_32bits:py371 lbry/scripts/wine_build.sh
- docker run -v "$(pwd):/src/lbry" lbry/pyinstaller34_32bits:py371 lbry/scripts/wine_build.sh ${TORBA}
- sudo zip -j dist/lbrynet-windows.zip dist/lbrynet.exe
deploy:
provider: releases
@@ -86,6 +85,7 @@ jobs:
install:
- pip3 install pyinstaller
- pip3 install git+https://github.com/lbryio/torba.git@${TORBA}#egg=torba
- pip3 show torba
- python3 scripts/set_build.py
- pip3 install -e .
script:
@@ -127,7 +127,7 @@ jobs:
script:
- set -e
- echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin
- travis_retry docker build -t lbry/wallet-server:$TRAVIS_TAG -f scripts/Dockerfile.wallet_server --build-arg TORBA_VERSION=${TORBA} .
- travis_retry docker build -t lbry/wallet-server:$TRAVIS_TAG -f scripts/Dockerfile.wallet_server .
- docker push lbry/wallet-server:$TRAVIS_TAG
- if: tag IS blank AND branch = master AND NOT type IN (pull_request)
stage: build
@@ -135,7 +135,7 @@ jobs:
script:
- set -e
- echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin
- travis_retry docker build -t lbry/wallet-server:master -f scripts/Dockerfile.wallet_server --build-arg TORBA_VERSION=${TORBA} .
- travis_retry docker build -t lbry/wallet-server:master -f scripts/Dockerfile.wallet_server .
- docker push lbry/wallet-server:master
cache:
+1 -5
View File
@@ -9,7 +9,7 @@ Here's a video walkthrough of this setup, which is itself hosted by the LBRY net
## Prerequisites
Running `lbrynet` from source requires Python 3.7 or higher. Get the installer for your OS [here](https://www.python.org/downloads/release/python-370/)
Running `lbrynet` from source requires Python 3.6 or higher (3.7 is preferred). Get the installer for your OS [here](https://www.python.org/downloads/release/python-370/)
After installing python 3, you'll need to install some additional libraries depending on your operating system.
@@ -17,10 +17,6 @@ After installing python 3, you'll need to install some additional libraries depe
macOS users will need to install [xcode command line tools](https://developer.xamarin.com/guides/testcloud/calabash/configuring/osx/install-xcode-command-line-tools/) and [homebrew](http://brew.sh/).
These environment variables also need to be set
1. PYTHONUNBUFFERED=1
2. EVENT_NOKQUEUE=1
Remaining dependencies can then be installed by running:
```
+1 -1
View File
@@ -41,7 +41,7 @@ This project is MIT licensed. For the full license, see [LICENSE](LICENSE).
## Security
We take security seriously. Please contact security@lbry.com regarding any security issues. [Our GPG key is here](https://lbry.com/faq/gpg-key) if you need it.
We take security seriously. Please contact security@lbry.com regarding any security issues. [Our GPG key is here](https://lbry.io/faq/gpg-key) if you need it.
## Contact
+128 -278
View File
@@ -41,10 +41,10 @@
"examples": [
{
"title": "Get a file",
"curl": "curl -d'{\"method\": \"get\", \"params\": {\"uri\": \"astream#ffdbe8f44f285fbc4a352763727abd86d17399c1\"}}' http://localhost:5279/",
"lbrynet": "lbrynet get astream#ffdbe8f44f285fbc4a352763727abd86d17399c1",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"get\", \"params\": {\"uri\": \"astream#ffdbe8f44f285fbc4a352763727abd86d17399c1\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 3,\n \"content_fee\": null,\n \"download_directory\": \"/tmp/tmpf06o5qj4\",\n \"download_path\": \"/tmp/tmpf06o5qj4/tmp6h32p99s\",\n \"file_name\": \"tmp6h32p99s\",\n \"height\": 214,\n \"key\": \"1441a34034b2dbc19094f1c7b164680c\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp6h32p99s\",\n \"sd_hash\": \"e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"size\": \"11\"\n }\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"fa78db71b5e4205ec33a69106f9c9528ed9289fa3f8efc51baebe6e514247287:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"016d1a9d18447522cfe3eb8acf4b56a63e7edf2b68fdfdb7869eb7447ab2e61a2d5cdf8199867bda63dd1edc699b7dee31d618198502a11309baff2f6d52104f494ca48ff9e5961c5a00badba23fcfeb010f595fc10a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d703668333270393973180b22186170706c69636174696f6e2f6f637465742d73747265616d3230e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"sd_hash\": \"e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"e5189cf47e5bdecdef6ec77874410bf7d57ac71ccfb4e6588311a7375c890e513be365538d51068fe97a0c21a8e389e0\",\n \"stream_name\": \"tmp6h32p99s\",\n \"streaming_url\": \"http://localhost:5280/stream/e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"suggested_file_name\": \"tmp6h32p99s\",\n \"timestamp\": 1559011814,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"fa78db71b5e4205ec33a69106f9c9528ed9289fa3f8efc51baebe6e514247287\",\n \"written_bytes\": 11\n }\n}"
"curl": "curl -d'{\"method\": \"get\", \"params\": {\"uri\": \"astream#2606a71cd812c77bc3dc76ecc3727e0368b1af6d\"}}' http://localhost:5279/",
"lbrynet": "lbrynet get astream#2606a71cd812c77bc3dc76ecc3727e0368b1af6d",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"get\", \"params\": {\"uri\": \"astream#2606a71cd812c77bc3dc76ecc3727e0368b1af6d\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 3,\n \"content_fee\": null,\n \"download_directory\": \"/tmp/tmpnk2c4f2x\",\n \"download_path\": \"/tmp/tmpnk2c4f2x/tmpip8uriwe\",\n \"file_name\": \"tmpip8uriwe\",\n \"height\": 214,\n \"key\": \"44bb79917c27efbb9014f8bbc78e3eeb\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpip8uriwe\",\n \"sd_hash\": \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"size\": \"11\"\n }\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"b66c49273cb5f48f73f8e626523233da52aa1a64e7a3f90a0f053e7c96e2b5b7:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01f8e2475e79f15c4351f2af263f36c0e8653e1967128556beabb3c0f3216a15825a50d9f22326fff3c4f8b53089ced7fed5b66aaf3eb00db47aba375985ea1440e0ddee48e5ef9e695688f8d31284f25ab37ebc5b0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706970387572697765180b22186170706c69636174696f6e2f6f637465742d73747265616d323006310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"sd_hash\": \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"ef42dee59a9efc14a5611b1bb1a300b2fb5cfb92acf8e9a2034ddf341c42fc9293efef53761751fdcfec53ac74837b6a\",\n \"stream_name\": \"tmpip8uriwe\",\n \"streaming_url\": \"http://localhost:5280/stream/06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"suggested_file_name\": \"tmpip8uriwe\",\n \"timestamp\": 1558113064,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"b66c49273cb5f48f73f8e626523233da52aa1a64e7a3f90a0f053e7c96e2b5b7\",\n \"written_bytes\": 11\n }\n}"
}
]
},
@@ -207,10 +207,10 @@
"examples": [
{
"title": "Publish a file",
"curl": "curl -d'{\"method\": \"publish\", \"params\": {\"name\": \"a-new-stream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmplnj7g2og\", \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"preview\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet publish a-new-stream --bid=1.0 --file_path=/tmp/tmplnj7g2og",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"publish\", \"params\": {\"name\": \"a-new-stream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmplnj7g2og\", \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"preview\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000012889d1e46c544984302aba136dec017885e0586e38b7801486a41905dcd4aa5f010000006a4730440220414a3a00018fc702da22da84e174e2d6e9bd5bcc16d5266cd9dfebc8039fb7c902205a14787a36f74952faee19f4cfb998706c141bffd1e2700941a7ca4e6f1509e1012102a3da85d6f33252605514d4d8be77cc3563e4018cdbdfa5fabb0c8453b49d543effffffff0200e1f50500000000bfb50c612d6e65772d73747265616d4c94000a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706c6e6a3767326f67180b22186170706c69636174696f6e2f6f637465742d73747265616d3230d9b627887a6586daaf55ac395c6826fa372110ced12e01009cf220c9a8a17b7b1b1f1f69e111fda7521e0ccc417e04df6d7576a9148d62b4efdc3423fcd5e5e8d5d414515e06a2f3cc88ace0b46217000000001976a91490b301d61740d27d2f038e9541627e6443378faf88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"msym2SzDUdoUTAXGYttaZ3y6q3zkZ3Rhxw\",\n \"amount\": \"4.947555\",\n \"confirmations\": 4,\n \"height\": 215,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1559011814,\n \"txid\": \"5faad4dc0519a4861480b7386e58e0857801ec6d13ba2a308449546ce4d18928\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mtQXpNQ924yoKNgVCycikXQA9oyBUYnBKL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"cc8839262a966ca7c4855443144ff72dd1cb7be6\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"a-new-stream\",\n \"normalized_name\": \"a-new-stream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://a-new-stream#cc8839262a966ca7c4855443144ff72dd1cb7be6\",\n \"timestamp\": null,\n \"txid\": \"3208677665c12658b28081ceb4aedf6bda0518b244c9b1729148302677bda266\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmplnj7g2og\",\n \"sd_hash\": \"d9b627887a6586daaf55ac395c6826fa372110ced12e01009cf220c9a8a17b7b1b1f1f69e111fda7521e0ccc417e04df\",\n \"size\": \"11\"\n }\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mti43KAeW7RJZxK1zDJVgcYJzUNL3Jqvwv\",\n \"amount\": \"3.923448\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"3208677665c12658b28081ceb4aedf6bda0518b244c9b1729148302677bda266\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.024107\",\n \"total_input\": \"4.947555\",\n \"total_output\": \"4.923448\",\n \"txid\": \"3208677665c12658b28081ceb4aedf6bda0518b244c9b1729148302677bda266\"\n }\n}"
"curl": "curl -d'{\"method\": \"publish\", \"params\": {\"name\": \"a-new-stream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmp_ddtpmtn\", \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"preview\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet publish a-new-stream --bid=1.0 --file_path=/tmp/tmp_ddtpmtn",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"publish\", \"params\": {\"name\": \"a-new-stream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmp_ddtpmtn\", \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"preview\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000111a6b763ecad0030f105b7122e1588d7766b7c447d6e76144d7b88b2e486266a010000006a473044022066605f1c9e25a8a838adb5a53106f0ee2c03de7f0f4eac8016f33cc189ee359a0220202177781095f151f3b6a7bee91b21dc1039b9e3bde1a23dbe67cbd5315dc9e8012102b4376442c145e1283d561a5be188ed37faa10f5d052279e026d165e4098452a1ffffffff0200e1f50500000000bfb50c612d6e65772d73747265616d4c94000a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d705f646474706d746e180b22186170706c69636174696f6e2f6f637465742d73747265616d323064eea681e0895a5ed6d4856424c0658f0dccfc385ecdb7168b0a82006d58b8aaa3b08e683bd7bf6e47201d3704c23a106d7576a914e77e5be57e932140e2ae68632263fc60f82c0ae988ace0b46217000000001976a914d075e70713e8bf2abacacaf9b434c62011b8060188ac00000000\",\n \"inputs\": [\n {\n \"address\": \"n3vDyZVf6EuxN2r6BqLpMgS67f4epzdqZT\",\n \"amount\": \"4.947555\",\n \"confirmations\": 4,\n \"height\": 215,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1558113064,\n \"txid\": \"6a2686e4b2887b4d14766e7d447c6b76d788152e12b705f13000adec63b7a611\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"n2cykwbGgwagYFnVFgAL95H8Sa2ciygBeB\",\n \"amount\": \"1.0\",\n \"claim_id\": \"55b9b81794fb07f18f3a29d7ae42f1c421935913\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"name\": \"a-new-stream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://a-new-stream#55b9b81794fb07f18f3a29d7ae42f1c421935913\",\n \"timestamp\": null,\n \"txid\": \"f1c8710adb72349cbb472af93a4d1e73d5896a7e114b551accb641f896725785\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp_ddtpmtn\",\n \"sd_hash\": \"64eea681e0895a5ed6d4856424c0658f0dccfc385ecdb7168b0a82006d58b8aaa3b08e683bd7bf6e47201d3704c23a10\",\n \"size\": \"11\"\n }\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mzXC5xg5xjmCMzxP7K3gsvHjPstYHvXExH\",\n \"amount\": \"3.923448\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"f1c8710adb72349cbb472af93a4d1e73d5896a7e114b551accb641f896725785\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.024107\",\n \"total_input\": \"4.947555\",\n \"total_output\": \"4.923448\",\n \"txid\": \"f1c8710adb72349cbb472af93a4d1e73d5896a7e114b551accb641f896725785\"\n }\n}"
}
]
},
@@ -229,10 +229,10 @@
"examples": [
{
"title": "Resolve a claim",
"curl": "curl -d'{\"method\": \"resolve\", \"params\": {\"urls\": [\"astream#ffdbe8f44f285fbc4a352763727abd86d17399c1\"]}}' http://localhost:5279/",
"lbrynet": "lbrynet resolve astream#ffdbe8f44f285fbc4a352763727abd86d17399c1",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"resolve\", \"params\": {\"urls\": [\"astream#ffdbe8f44f285fbc4a352763727abd86d17399c1\"]}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"astream#ffdbe8f44f285fbc4a352763727abd86d17399c1\": {\n \"address\": \"mg5Gn2NmJFVpZUU1ScVKf34KXVmJsrxXeu\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#6/astream#f\",\n \"claim_id\": \"ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"claim_op\": \"update\",\n \"confirmations\": 3,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"meta\": {\n \"activation_height\": 213,\n \"creation_height\": 213,\n \"creation_timestamp\": 1559011814,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263187,\n \"is_controlling\": true,\n \"support_amount\": \"0.0\",\n \"trending_global\": 0.0,\n \"trending_group\": 0,\n \"trending_local\": 0.0,\n \"trending_mixed\": 0.0\n },\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"short_url\": \"lbry://astream#f\",\n \"signing_channel\": {\n \"address\": \"muK7TZrirA8yHzxFcXa51W7CjxbAho2Zua\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#6\",\n \"claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"claim_op\": \"update\",\n \"confirmations\": 7,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 209,\n \"claims_in_channel\": 2,\n \"creation_height\": 209,\n \"creation_timestamp\": 1559011813,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263183,\n \"is_controlling\": true,\n \"support_amount\": \"0.0\",\n \"trending_global\": 0.0,\n \"trending_group\": 0,\n \"trending_local\": 0.0,\n \"trending_mixed\": 0.0\n },\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"short_url\": \"lbry://@channel#6\",\n \"timestamp\": 1559011813,\n \"txid\": \"3f665f0ca3cbb19c3c75813a30cd8334d7738a20566f2aa7775ab024d6fedd64\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004eeccdcff00c8336c5d616fee009894e5cbbc2bbf9497021aabbde81beaf8e6edf423de4ff094a8d4e7ea87d9469fd7d3b834b80d9b330d2f7a887108c5ea9268\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1559011814,\n \"txid\": \"fa78db71b5e4205ec33a69106f9c9528ed9289fa3f8efc51baebe6e514247287\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp6h32p99s\",\n \"sd_hash\": \"e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"size\": \"11\"\n }\n },\n \"value_type\": \"stream\"\n }\n }\n}"
"curl": "curl -d'{\"method\": \"resolve\", \"params\": {\"urls\": [\"astream#2606a71cd812c77bc3dc76ecc3727e0368b1af6d\"]}}' http://localhost:5279/",
"lbrynet": "lbrynet resolve astream#2606a71cd812c77bc3dc76ecc3727e0368b1af6d",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"resolve\", \"params\": {\"urls\": [\"astream#2606a71cd812c77bc3dc76ecc3727e0368b1af6d\"]}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"astream#2606a71cd812c77bc3dc76ecc3727e0368b1af6d\": {\n \"certificate\": {\n \"address\": \"mvETNRY6cV97UJLKq9oD1YFQMzRi7ws3x3\",\n \"amount\": \"1.0\",\n \"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"claim_sequence\": -1,\n \"confirmations\": 7,\n \"decoded_claim\": true,\n \"effective_amount\": \"1.0\",\n \"has_signature\": false,\n \"height\": 210,\n \"name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"protobuf\": \"00125a0a583056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c5420b4e6577204368616e6e656c\",\n \"supports\": [],\n \"timestamp\": 1558113063,\n \"txid\": \"beb82ace7faddbb1df58601df0e779865013151379b07428841f08e93c49fc87\",\n \"valid_at_height\": 210,\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c5\",\n \"title\": \"New Channel\"\n }\n },\n \"claim\": {\n \"address\": \"mzVz9QnHzyJ15wCFAYRt7bzLoeoBK83N8J\",\n \"amount\": \"1.0\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"claim_sequence\": -1,\n \"confirmations\": 3,\n \"decoded_claim\": true,\n \"effective_amount\": \"1.0\",\n \"has_signature\": true,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"protobuf\": \"01f8e2475e79f15c4351f2af263f36c0e8653e1967128556beabb3c0f3216a15825a50d9f22326fff3c4f8b53089ced7fed5b66aaf3eb00db47aba375985ea1440e0ddee48e5ef9e695688f8d31284f25ab37ebc5b0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706970387572697765180b22186170706c69636174696f6e2f6f637465742d73747265616d323006310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"signature_is_valid\": true,\n \"signing_channel\": {\n \"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"name\": \"@channel\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c5\",\n \"title\": \"New Channel\"\n }\n },\n \"supports\": [],\n \"timestamp\": 1558113064,\n \"txid\": \"b66c49273cb5f48f73f8e626523233da52aa1a64e7a3f90a0f053e7c96e2b5b7\",\n \"valid_at_height\": 214,\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpip8uriwe\",\n \"sd_hash\": \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"size\": \"11\"\n }\n }\n },\n \"claims_in_channel\": 0\n }\n }\n}"
}
]
},
@@ -254,7 +254,7 @@
"curl": "curl -d'{\"method\": \"status\", \"params\": {}}' http://localhost:5279/",
"lbrynet": "lbrynet status",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"status\", \"params\": {}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blob_manager\": {\n \"finished_blobs\": 0\n },\n \"connection_status\": {\n \"code\": \"connected\",\n \"message\": \"No connection problems detected\"\n },\n \"installation_id\": \"7gjXaLg5SLVuajoAqAUmeXpMgtxbFFiP2zKLKZqHjDpFdFijPEYEvBXxrLMocHHcFD\",\n \"is_running\": true,\n \"skipped_components\": [\n \"dht\",\n \"upnp\",\n \"hash_announcer\",\n \"peer_protocol_server\"\n ],\n \"startup_status\": {\n \"blob_manager\": true,\n \"blockchain_headers\": true,\n \"database\": true,\n \"exchange_rate_manager\": true,\n \"stream_manager\": true,\n \"wallet\": true\n },\n \"stream_manager\": {\n \"managed_files\": 0\n },\n \"wallet\": {\n \"best_blockhash\": \"e03fe663d3d7b14c5608ec36cc0d80639d7dd418b0f4fcadeb8353296b54896e\",\n \"blocks\": 206,\n \"blocks_behind\": 0,\n \"is_encrypted\": false,\n \"is_locked\": false\n }\n }\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blob_manager\": {\n \"finished_blobs\": 0\n },\n \"connection_status\": {\n \"code\": \"connected\",\n \"message\": \"No connection problems detected\"\n },\n \"installation_id\": \"vGHKEdD9oDTsGZQrpSKthuhu37QoTVDeyKWRmqRVoiLdXttQUk2Hcvj94KWaskRkp\",\n \"is_running\": true,\n \"skipped_components\": [\n \"dht\",\n \"upnp\",\n \"hash_announcer\",\n \"peer_protocol_server\"\n ],\n \"startup_status\": {\n \"blob_manager\": true,\n \"blockchain_headers\": true,\n \"database\": true,\n \"exchange_rate_manager\": true,\n \"stream_manager\": true,\n \"wallet\": true\n },\n \"stream_manager\": {\n \"managed_files\": 0\n },\n \"wallet\": {\n \"best_blockhash\": \"2239cabf318b8ddd48d0373c54962651646d5cc1fb70fd2b41e545316a2f69cc\",\n \"blocks\": 206,\n \"blocks_behind\": 0,\n \"is_encrypted\": false,\n \"is_locked\": false\n }\n }\n}"
}
]
},
@@ -276,7 +276,7 @@
"curl": "curl -d'{\"method\": \"version\", \"params\": {}}' http://localhost:5279/",
"lbrynet": "lbrynet version",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"version\", \"params\": {}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"build\": \"dev\",\n \"desktop\": \"GNOME\",\n \"distro\": {\n \"codename\": \"xenial\",\n \"id\": \"ubuntu\",\n \"like\": \"debian\",\n \"version\": \"16.04\",\n \"version_parts\": {\n \"build_number\": \"\",\n \"major\": \"16\",\n \"minor\": \"04\"\n }\n },\n \"lbrynet_version\": \"0.38.0rc2\",\n \"os_release\": \"4.4.0-116-generic\",\n \"os_system\": \"Linux\",\n \"platform\": \"Linux-4.4.0-116-generic-x86_64-with-Ubuntu-16.04-xenial\",\n \"processor\": \"x86_64\",\n \"python_version\": \"3.7.2\"\n }\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"build\": \"dev\",\n \"desktop\": \"ubuntu:GNOME\",\n \"distro\": {\n \"codename\": \"bionic\",\n \"id\": \"ubuntu\",\n \"like\": \"debian\",\n \"version\": \"18.04\",\n \"version_parts\": {\n \"build_number\": \"\",\n \"major\": \"18\",\n \"minor\": \"04\"\n }\n },\n \"lbrynet_version\": \"0.37.1rc1\",\n \"os_release\": \"4.15.15-041515-generic\",\n \"os_system\": \"Linux\",\n \"platform\": \"Linux-4.15.15-041515-generic-x86_64-with-debian-buster-sid\",\n \"processor\": \"x86_64\",\n \"python_version\": \"3.7.0\"\n }\n}"
}
]
}
@@ -324,10 +324,10 @@
"examples": [
{
"title": "Add an account from seed",
"curl": "curl -d'{\"method\": \"account_add\", \"params\": {\"account_name\": \"new account\", \"seed\": \"fetch ripple echo rabbit taxi emerge make tape front issue seven pilot\", \"single_key\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet account add \"new account\" --seed=\"fetch ripple echo rabbit taxi emerge make tape front issue seven pilot\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_add\", \"params\": {\"account_name\": \"new account\", \"seed\": \"fetch ripple echo rabbit taxi emerge make tape front issue seven pilot\", \"single_key\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 1\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"encrypted\": false,\n \"id\": \"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1559011780.6249187,\n \"name\": \"new account\",\n \"private_key\": \"tprv8ZgxMBicQKsPdnBkyQuCYYRiWPCqBbNSqxZDDKeTUBiht5vDSVmV7P7ttPGxWMiiQKgLHfv2TegdUUJeXkNrVrQWdcTQ3YADKsyaiyQrqg1\",\n \"public_key\": \"tpubD6NzVbkrYhZ4XFDYs4Znwx5q5QimLvZMRG9zVqgktTX6iaAz4tb5Hsjm4XHeqm2Vxzjz4XwgtdtF39REpXRV4E284pkvcubqiYABzSrXiGr\",\n \"seed\": \"fetch ripple echo rabbit taxi emerge make tape front issue seven pilot\"\n }\n}"
"curl": "curl -d'{\"method\": \"account_add\", \"params\": {\"account_name\": \"new account\", \"seed\": \"crunch tonight gown dish tell power aspect banana eager blade senior predict\", \"single_key\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet account add \"new account\" --seed=\"crunch tonight gown dish tell power aspect banana eager blade senior predict\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_add\", \"params\": {\"account_name\": \"new account\", \"seed\": \"crunch tonight gown dish tell power aspect banana eager blade senior predict\", \"single_key\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 1\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"encrypted\": false,\n \"id\": \"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1558113030.2059674,\n \"name\": \"new account\",\n \"private_key\": \"tprv8ZgxMBicQKsPdaKbS6ZPteaurN1YPsbVoY1dZGvi962chqdJZgh8sNXsJkZ3EcK8cSPYcPU2MopK88k2ezxK4Ny2tM8P4adR3hoZhixidcM\",\n \"public_key\": \"tpubD6NzVbkrYhZ4X3MPKkDzJ4F2RPXUZCnQNqcQqny1ZMq1YKt5C5Wj3s9jUsYj24LWx9uZi6MHH7g4GcSsCJ7qhxp3J7kWN6Hf2VNQynfDn63\",\n \"seed\": \"crunch tonight gown dish tell power aspect banana eager blade senior predict\"\n }\n}"
}
]
},
@@ -359,9 +359,9 @@
},
{
"title": "Get balance for specific account by id",
"curl": "curl -d'{\"method\": \"account_balance\", \"params\": {\"account_id\": \"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\"}}' http://localhost:5279/",
"lbrynet": "lbrynet account balance \"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_balance\", \"params\": {\"account_id\": \"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\"}}).json()",
"curl": "curl -d'{\"method\": \"account_balance\", \"params\": {\"account_id\": \"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\"}}' http://localhost:5279/",
"lbrynet": "lbrynet account balance \"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_balance\", \"params\": {\"account_id\": \"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": \"2.0\"\n}"
}
]
@@ -390,7 +390,7 @@
"curl": "curl -d'{\"method\": \"account_create\", \"params\": {\"account_name\": \"generated account\", \"single_key\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet account create \"generated account\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_create\", \"params\": {\"account_name\": \"generated account\", \"single_key\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 1\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"encrypted\": false,\n \"id\": \"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1559011780.4394753,\n \"name\": \"generated account\",\n \"private_key\": \"tprv8ZgxMBicQKsPdnBkyQuCYYRiWPCqBbNSqxZDDKeTUBiht5vDSVmV7P7ttPGxWMiiQKgLHfv2TegdUUJeXkNrVrQWdcTQ3YADKsyaiyQrqg1\",\n \"public_key\": \"tpubD6NzVbkrYhZ4XFDYs4Znwx5q5QimLvZMRG9zVqgktTX6iaAz4tb5Hsjm4XHeqm2Vxzjz4XwgtdtF39REpXRV4E284pkvcubqiYABzSrXiGr\",\n \"seed\": \"fetch ripple echo rabbit taxi emerge make tape front issue seven pilot\"\n }\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 1\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"encrypted\": false,\n \"id\": \"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1558113030.1062362,\n \"name\": \"generated account\",\n \"private_key\": \"tprv8ZgxMBicQKsPdaKbS6ZPteaurN1YPsbVoY1dZGvi962chqdJZgh8sNXsJkZ3EcK8cSPYcPU2MopK88k2ezxK4Ny2tM8P4adR3hoZhixidcM\",\n \"public_key\": \"tpubD6NzVbkrYhZ4X3MPKkDzJ4F2RPXUZCnQNqcQqny1ZMq1YKt5C5Wj3s9jUsYj24LWx9uZi6MHH7g4GcSsCJ7qhxp3J7kWN6Hf2VNQynfDn63\",\n \"seed\": \"crunch tonight gown dish tell power aspect banana eager blade senior predict\"\n }\n}"
}
]
},
@@ -473,24 +473,24 @@
"examples": [
{
"title": "Transfer 2 LBC from default account to specific account",
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"to_account\": \"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\", \"amount\": \"2.0\", \"everything\": false, \"broadcast\": true}}' http://localhost:5279/",
"lbrynet": "lbrynet account fund --to_account=\"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\" --amount=2.0 --broadcast",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"to_account\": \"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\", \"amount\": \"2.0\", \"everything\": false, \"broadcast\": true}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001ffa0efb97cc0b1de40104c1efde557888f1d1671c33cf45cf8d4c64407af1747010000006b483045022100f2688e18f3fa85c9efb4cbe14b69ace71439342f24813a7354f259f631ebf382022019db036a72924429eae0c8a74a4069a843ce03943f2ab02eb0f487ac06fd90300121020c2a113a365b5c19849a4b0a970e5d9977b799102e75c6463f9c6e7738a5d289ffffffff0200c2eb0b000000001976a9147a5eb4b44204015136a92a491d80593cdc5d31fe88ac90d7ae2f000000001976a9141891436814e20ce99f77b091edd4cef6d50f1abb88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mu8naFDrK7nHd3a2yCWNEV74A6JmDYsbha\",\n \"amount\": \"10.0\",\n \"confirmations\": 6,\n \"height\": 201,\n \"is_change\": false,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1559011812,\n \"txid\": \"4717af0744c6d4f85cf43cc371161d8f8857e5fd1e4c1040deb1c07cb9efa0ff\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mrfzBjhGDZoCmVeyQ32ryiQ6XbsoaH58uA\",\n \"amount\": \"2.0\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"3ef83205dd764152fc6847fc9c80b94251b5306152d0747d619f8da4e037145b\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mhkrXjG9n4C7EJyH4ooDVVTYm2cjzGZcxS\",\n \"amount\": \"7.999876\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"3ef83205dd764152fc6847fc9c80b94251b5306152d0747d619f8da4e037145b\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000124\",\n \"total_input\": \"10.0\",\n \"total_output\": \"9.999876\",\n \"txid\": \"3ef83205dd764152fc6847fc9c80b94251b5306152d0747d619f8da4e037145b\"\n }\n}"
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"to_account\": \"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\", \"amount\": \"2.0\", \"everything\": false, \"broadcast\": true}}' http://localhost:5279/",
"lbrynet": "lbrynet account fund --to_account=\"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\" --amount=2.0 --broadcast",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"to_account\": \"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\", \"amount\": \"2.0\", \"everything\": false, \"broadcast\": true}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000015f436044c45069272085b4f45103fc58403718a21cb656946fa9e151c9678346010000006a47304402200f5336f7333239b1eb370872f710abd7f0c14874de970c34b6bae24f01877c46022044c41caa2a09ae19d6356f310ec7bcfd7bac3d22a0bddbec5c69a014ef77a4530121030b7ef076179d0a33577a6060401bb3f6e611d6656248e072a3d1bde6e575f7aeffffffff0200c2eb0b000000001976a9149f28eb048487fc797c203b70c722e2624d301b6e88ac90d7ae2f000000001976a914b2d879d3dd87f999a456ba4487515f9fc828601588ac00000000\",\n \"inputs\": [\n {\n \"address\": \"n3hzACYXp2epupNQSa5QFDDUcgprVt5rV1\",\n \"amount\": \"10.0\",\n \"confirmations\": 6,\n \"height\": 201,\n \"is_change\": false,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1558113062,\n \"txid\": \"468367c951e1a96f9456b61ca218374058fc0351f4b48520276950c44460435f\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mv2WkbBYY24ezE3Tj78eJ9NA7TTZNaFSoD\",\n \"amount\": \"2.0\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"5fda031221eba48f6d8947540fbe4a947b39cb713564a9fbe43a5c6e6a9475db\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mwpbuD2xLqHN352Ag1ntMRDpu6bV9PxyLb\",\n \"amount\": \"7.999876\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"5fda031221eba48f6d8947540fbe4a947b39cb713564a9fbe43a5c6e6a9475db\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000124\",\n \"total_input\": \"10.0\",\n \"total_output\": \"9.999876\",\n \"txid\": \"5fda031221eba48f6d8947540fbe4a947b39cb713564a9fbe43a5c6e6a9475db\"\n }\n}"
},
{
"title": "Spread LBC between multiple addresses",
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"to_account\": \"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\", \"from_account\": \"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\", \"amount\": \"1.5\", \"everything\": false, \"outputs\": 2, \"broadcast\": true}}' http://localhost:5279/",
"lbrynet": "lbrynet account fund --to_account=\"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\" --from_account=\"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\" --amount=1.5 --outputs=2 --broadcast",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"to_account\": \"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\", \"from_account\": \"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\", \"amount\": \"1.5\", \"everything\": false, \"outputs\": 2, \"broadcast\": true}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000015b1437e0a48d9f617d74d0526130b55142b9809cfc4768fc524176dd0532f83e000000006a47304402202e9880fa1cda60fbbac822ab39e296b814fbba4490541a4a3e7b23739b83fa0302202b618448620585842149285ee41fa449978e585742156e1bf158aff5e22413fd012102c522a7125129e491b7e86ff1ccf69e3aaab24e30413c8badc0a74e0c469c4d7effffffff03c0687804000000001976a91463447211521da66a083c7aa7cb13ad22a75dcf4488acc0687804000000001976a91463447211521da66a083c7aa7cb13ad22a75dcf4488ac6cb9fa02000000001976a9141a195f71b450e4d6c6a705904ae04c163b40236d88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mrfzBjhGDZoCmVeyQ32ryiQ6XbsoaH58uA\",\n \"amount\": \"2.0\",\n \"confirmations\": 1,\n \"height\": 207,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 0,\n \"timestamp\": 1559011813,\n \"txid\": \"3ef83205dd764152fc6847fc9c80b94251b5306152d0747d619f8da4e037145b\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mpZqBj8pttN7xXQP9FkVfKRSAkGvDd16XD\",\n \"amount\": \"0.75\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"aab140aa385b00d3b0416905fc539a53b2b6a3d8786deefe483c3d92b7769323\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mpZqBj8pttN7xXQP9FkVfKRSAkGvDd16XD\",\n \"amount\": \"0.75\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"aab140aa385b00d3b0416905fc539a53b2b6a3d8786deefe483c3d92b7769323\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mhtxFybjayPc8V4W1AopRw4MiphNA94pHf\",\n \"amount\": \"0.499859\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 2,\n \"timestamp\": null,\n \"txid\": \"aab140aa385b00d3b0416905fc539a53b2b6a3d8786deefe483c3d92b7769323\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000141\",\n \"total_input\": \"2.0\",\n \"total_output\": \"1.999859\",\n \"txid\": \"aab140aa385b00d3b0416905fc539a53b2b6a3d8786deefe483c3d92b7769323\"\n }\n}"
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"to_account\": \"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\", \"from_account\": \"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\", \"amount\": \"1.5\", \"everything\": false, \"outputs\": 2, \"broadcast\": true}}' http://localhost:5279/",
"lbrynet": "lbrynet account fund --to_account=\"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\" --from_account=\"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\" --amount=1.5 --outputs=2 --broadcast",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"to_account\": \"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\", \"from_account\": \"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\", \"amount\": \"1.5\", \"everything\": false, \"outputs\": 2, \"broadcast\": true}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001db75946a6e5c3ae4fba9643571cb397b944abe0f5447896d8fa4eb211203da5f000000006b48304502210096115913c0bd4ec19033357d8503774773a5a4043d2a39c4d3673de621f78679022061a4e89ec0ed28b9d249fffdbe338c702f38c0e29cc7a9b694bd132cae599da701210235a4b0e8a6ac2f816eba77fb31fbb92056799bb91f7d840cd756ff6b8a4b8f6effffffff03c0687804000000001976a914e4b32f7f86b87098278de13fe8d0e759f9d8f5d588acc0687804000000001976a914e4b32f7f86b87098278de13fe8d0e759f9d8f5d588ac6cb9fa02000000001976a9144c2ffba88e18787b9caea7fb9212f5a3dc08e6e588ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mv2WkbBYY24ezE3Tj78eJ9NA7TTZNaFSoD\",\n \"amount\": \"2.0\",\n \"confirmations\": 1,\n \"height\": 207,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 0,\n \"timestamp\": 1558113063,\n \"txid\": \"5fda031221eba48f6d8947540fbe4a947b39cb713564a9fbe43a5c6e6a9475db\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"n2ND1pZp2bzYiwYhq1niiGrAHwykFFR1ar\",\n \"amount\": \"0.75\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"b886771697ee6163f412ac81df2f2a7cafa0849e524feaa7b2283d7f052cee6a\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"n2ND1pZp2bzYiwYhq1niiGrAHwykFFR1ar\",\n \"amount\": \"0.75\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"b886771697ee6163f412ac81df2f2a7cafa0849e524feaa7b2283d7f052cee6a\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mnTo8Z3NzRayC33pkpfsNbcH2Z1x2ZffBt\",\n \"amount\": \"0.499859\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 2,\n \"timestamp\": null,\n \"txid\": \"b886771697ee6163f412ac81df2f2a7cafa0849e524feaa7b2283d7f052cee6a\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000141\",\n \"total_input\": \"2.0\",\n \"total_output\": \"1.999859\",\n \"txid\": \"b886771697ee6163f412ac81df2f2a7cafa0849e524feaa7b2283d7f052cee6a\"\n }\n}"
},
{
"title": "Transfer all LBC to a specified account",
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"from_account\": \"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\", \"everything\": true, \"broadcast\": true}}' http://localhost:5279/",
"lbrynet": "lbrynet account fund --from_account=\"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\" --everything --broadcast",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"from_account\": \"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\", \"everything\": true, \"broadcast\": true}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000003239376b7923d3c48feee6d78d8a3b6b2539a53fc056941b0d3005b38aa40b1aa000000006a47304402202280f476c6c2e030288d6a914fd0a4f25f77a2412646d2221361cee7842d68280220703aa48ce200adfdb9b45fb05911b196d057c8c6416379d245245f032d91bea0012103aaef7f277b51328287432a89023a34fb96e70fd86bbe9cb0dc7b22024252b9cbffffffff239376b7923d3c48feee6d78d8a3b6b2539a53fc056941b0d3005b38aa40b1aa010000006a47304402201500191033e90af3d0523bcd0dc1bf0a2532b2e72dbf2208ec5f03a1d57f68a2022000ec7b41ff2cf20c4fa189d0c77ecab1482a1fc6f3d38e6161f661d8bb1ad0bd012103aaef7f277b51328287432a89023a34fb96e70fd86bbe9cb0dc7b22024252b9cbffffffff239376b7923d3c48feee6d78d8a3b6b2539a53fc056941b0d3005b38aa40b1aa020000006a47304402203729f79259485bf1f8b02a2e0fd47353792108c7424f8b03f30fba2ebf87796302200aa96711e5724a82c51ae049d3d427436ad4fb14ee5f97de5745249f5ae0623f012103de076de4afb59f23e8e7c3cb0f493a1835c59d684c7546ac93fea7bd1e3d2036ffffffff015027eb0b000000001976a914681c30baec28e2aa8d45a228f2a6af2e0a4fcec188ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mpZqBj8pttN7xXQP9FkVfKRSAkGvDd16XD\",\n \"amount\": \"0.75\",\n \"confirmations\": 1,\n \"height\": 208,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 0,\n \"timestamp\": 1559011813,\n \"txid\": \"aab140aa385b00d3b0416905fc539a53b2b6a3d8786deefe483c3d92b7769323\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mpZqBj8pttN7xXQP9FkVfKRSAkGvDd16XD\",\n \"amount\": \"0.75\",\n \"confirmations\": 1,\n \"height\": 208,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1559011813,\n \"txid\": \"aab140aa385b00d3b0416905fc539a53b2b6a3d8786deefe483c3d92b7769323\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mhtxFybjayPc8V4W1AopRw4MiphNA94pHf\",\n \"amount\": \"0.499859\",\n \"confirmations\": 1,\n \"height\": 208,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 2,\n \"timestamp\": 1559011813,\n \"txid\": \"aab140aa385b00d3b0416905fc539a53b2b6a3d8786deefe483c3d92b7769323\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mq1SLhoqW2g3qY1eGpcp2r5Xw1Vf19ocP8\",\n \"amount\": \"1.999604\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"92dae07b857907a41b24e4c1c2e007ef7b8f3ba3b21b936f5a8cdade2d5bafba\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000255\",\n \"total_input\": \"1.999859\",\n \"total_output\": \"1.999604\",\n \"txid\": \"92dae07b857907a41b24e4c1c2e007ef7b8f3ba3b21b936f5a8cdade2d5bafba\"\n }\n}"
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"from_account\": \"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\", \"everything\": true, \"broadcast\": true}}' http://localhost:5279/",
"lbrynet": "lbrynet account fund --from_account=\"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\" --everything --broadcast",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"from_account\": \"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\", \"everything\": true, \"broadcast\": true}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000036aee2c057f3d28b2a7ea4f529e84a0af7c2a2fdf81ac12f46361ee97167786b8000000006a473044022042ac78b8f37cb24fa1da07fb9f713fc0ae93582f9717a05c134e71c53fafda090220359a7f557bfababfaf107cb9985ac0f11596552a7187339633aa0b54a443544e0121034d281614d23f1f45df8cbecbd254968d01607e47d67551f8dd3f20ba131fbb7effffffff6aee2c057f3d28b2a7ea4f529e84a0af7c2a2fdf81ac12f46361ee97167786b8010000006a47304402200dd583a35370f98534d99448719d4d4f78b8d318cf231ddeeaf14633e6442012022023875b8309d3a1572313d9bd4fbd161b946e421a326e48d99ad49fb9be636d8d0121034d281614d23f1f45df8cbecbd254968d01607e47d67551f8dd3f20ba131fbb7effffffff6aee2c057f3d28b2a7ea4f529e84a0af7c2a2fdf81ac12f46361ee97167786b8020000006b483045022100c492cdc27f3e14ea67b54f77339d299c28b6cddb241051b34cbdfbd1f5a005990220615fe4efc3f7e5ce2e8bc01cbeacb54c0b7eeaf9a15d9d5bfeda69176742844b012103760597d5bbbc065f268318b3e1497c6599bc72554e6119c7114e4b92f4e35560ffffffff015027eb0b000000001976a914b0ff6e050d9e8087a65dbbf3fe9c7808e496f0d888ac00000000\",\n \"inputs\": [\n {\n \"address\": \"n2ND1pZp2bzYiwYhq1niiGrAHwykFFR1ar\",\n \"amount\": \"0.75\",\n \"confirmations\": 1,\n \"height\": 208,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 0,\n \"timestamp\": 1558113063,\n \"txid\": \"b886771697ee6163f412ac81df2f2a7cafa0849e524feaa7b2283d7f052cee6a\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"n2ND1pZp2bzYiwYhq1niiGrAHwykFFR1ar\",\n \"amount\": \"0.75\",\n \"confirmations\": 1,\n \"height\": 208,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1558113063,\n \"txid\": \"b886771697ee6163f412ac81df2f2a7cafa0849e524feaa7b2283d7f052cee6a\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mnTo8Z3NzRayC33pkpfsNbcH2Z1x2ZffBt\",\n \"amount\": \"0.499859\",\n \"confirmations\": 1,\n \"height\": 208,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 2,\n \"timestamp\": 1558113063,\n \"txid\": \"b886771697ee6163f412ac81df2f2a7cafa0849e524feaa7b2283d7f052cee6a\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mweqDPRKNNkSLpGP2Kr651TEtQijM4NEVm\",\n \"amount\": \"1.999604\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"1f82bbd70eb481abd74d1c6d820378a6b7d258f03843cc9d986c48c130773fc0\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000255\",\n \"total_input\": \"1.999859\",\n \"total_output\": \"1.999604\",\n \"txid\": \"1f82bbd70eb481abd74d1c6d820378a6b7d258f03843cc9d986c48c130773fc0\"\n }\n}"
}
]
},
@@ -530,7 +530,7 @@
"curl": "curl -d'{\"method\": \"account_list\", \"params\": {\"include_claims\": false, \"show_seed\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet account list",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_list\", \"params\": {\"include_claims\": false, \"show_seed\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"lbc_regtest\": [\n {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 1\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"certificates\": 0,\n \"coins\": 10.0,\n \"encrypted\": false,\n \"id\": \"mhfojdfZKX5A8gZhQro9JTAV9QfLoQtJXZ\",\n \"is_default\": true,\n \"name\": \"Account #mhfojdfZKX5A8gZhQro9JTAV9QfLoQtJXZ\",\n \"public_key\": \"tpubD6NzVbkrYhZ4WcFH7M2ECDxpFfvKSfXk45guPZKAYR9UmebhVusPrtM3qRwbk1P8caZds6fuJj3LNpL5whsk6hTboszKA4oRRXUdDbxqv7K\",\n \"satoshis\": 1000000000\n }\n ]\n }\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"lbc_regtest\": [\n {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 1\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"certificates\": 0,\n \"coins\": 10.0,\n \"encrypted\": false,\n \"id\": \"n3bUWqq67266Y6T8k7TJPwn5Ybqf9K6BM7\",\n \"is_default\": true,\n \"name\": \"Account #n3bUWqq67266Y6T8k7TJPwn5Ybqf9K6BM7\",\n \"public_key\": \"tpubD6NzVbkrYhZ4WeoW66qCtgFYq9giThLdtyLcTkoEKStUAReh46oGjwe8eNNrG57WSUCfruLNodAih54vbpz5dhnJHnhDDwPK4nmpKFur8PY\",\n \"satoshis\": 1000000000\n }\n ]\n }\n}"
}
]
},
@@ -577,10 +577,10 @@
"examples": [
{
"title": "Remove an account",
"curl": "curl -d'{\"method\": \"account_remove\", \"params\": {\"account_id\": \"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\"}}' http://localhost:5279/",
"lbrynet": "lbrynet account remove mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_remove\", \"params\": {\"account_id\": \"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 1\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"encrypted\": false,\n \"id\": \"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1559011780.4394753,\n \"name\": \"generated account\",\n \"private_key\": \"tprv8ZgxMBicQKsPdnBkyQuCYYRiWPCqBbNSqxZDDKeTUBiht5vDSVmV7P7ttPGxWMiiQKgLHfv2TegdUUJeXkNrVrQWdcTQ3YADKsyaiyQrqg1\",\n \"public_key\": \"tpubD6NzVbkrYhZ4XFDYs4Znwx5q5QimLvZMRG9zVqgktTX6iaAz4tb5Hsjm4XHeqm2Vxzjz4XwgtdtF39REpXRV4E284pkvcubqiYABzSrXiGr\",\n \"seed\": \"fetch ripple echo rabbit taxi emerge make tape front issue seven pilot\"\n }\n}"
"curl": "curl -d'{\"method\": \"account_remove\", \"params\": {\"account_id\": \"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\"}}' http://localhost:5279/",
"lbrynet": "lbrynet account remove mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_remove\", \"params\": {\"account_id\": \"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 1\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"encrypted\": false,\n \"id\": \"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1558113030.1062362,\n \"name\": \"generated account\",\n \"private_key\": \"tprv8ZgxMBicQKsPdaKbS6ZPteaurN1YPsbVoY1dZGvi962chqdJZgh8sNXsJkZ3EcK8cSPYcPU2MopK88k2ezxK4Ny2tM8P4adR3hoZhixidcM\",\n \"public_key\": \"tpubD6NzVbkrYhZ4X3MPKkDzJ4F2RPXUZCnQNqcQqny1ZMq1YKt5C5Wj3s9jUsYj24LWx9uZi6MHH7g4GcSsCJ7qhxp3J7kWN6Hf2VNQynfDn63\",\n \"seed\": \"crunch tonight gown dish tell power aspect banana eager blade senior predict\"\n }\n}"
}
]
},
@@ -655,10 +655,10 @@
"examples": [
{
"title": "Modify maximum number of times a change address can be reused",
"curl": "curl -d'{\"method\": \"account_set\", \"params\": {\"account_id\": \"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\", \"default\": false, \"change_max_uses\": 10}}' http://localhost:5279/",
"lbrynet": "lbrynet account set mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W --change_max_uses=10",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_set\", \"params\": {\"account_id\": \"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\", \"default\": false, \"change_max_uses\": 10}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 10\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"encrypted\": false,\n \"id\": \"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1559011780.6901715,\n \"name\": \"new account\",\n \"private_key\": \"tprv8ZgxMBicQKsPdnBkyQuCYYRiWPCqBbNSqxZDDKeTUBiht5vDSVmV7P7ttPGxWMiiQKgLHfv2TegdUUJeXkNrVrQWdcTQ3YADKsyaiyQrqg1\",\n \"public_key\": \"tpubD6NzVbkrYhZ4XFDYs4Znwx5q5QimLvZMRG9zVqgktTX6iaAz4tb5Hsjm4XHeqm2Vxzjz4XwgtdtF39REpXRV4E284pkvcubqiYABzSrXiGr\",\n \"seed\": \"fetch ripple echo rabbit taxi emerge make tape front issue seven pilot\"\n }\n}"
"curl": "curl -d'{\"method\": \"account_set\", \"params\": {\"account_id\": \"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\", \"default\": false, \"change_max_uses\": 10}}' http://localhost:5279/",
"lbrynet": "lbrynet account set mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH --change_max_uses=10",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_set\", \"params\": {\"account_id\": \"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\", \"default\": false, \"change_max_uses\": 10}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 10\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"encrypted\": false,\n \"id\": \"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1558113030.2514572,\n \"name\": \"new account\",\n \"private_key\": \"tprv8ZgxMBicQKsPdaKbS6ZPteaurN1YPsbVoY1dZGvi962chqdJZgh8sNXsJkZ3EcK8cSPYcPU2MopK88k2ezxK4Ny2tM8P4adR3hoZhixidcM\",\n \"public_key\": \"tpubD6NzVbkrYhZ4X3MPKkDzJ4F2RPXUZCnQNqcQqny1ZMq1YKt5C5Wj3s9jUsYj24LWx9uZi6MHH7g4GcSsCJ7qhxp3J7kWN6Hf2VNQynfDn63\",\n \"seed\": \"crunch tonight gown dish tell power aspect banana eager blade senior predict\"\n }\n}"
}
]
},
@@ -708,9 +708,9 @@
"examples": [
{
"title": "Check if address is mine",
"curl": "curl -d'{\"method\": \"address_is_mine\", \"params\": {\"address\": \"mztwZDgaFUnDFbtkxN2VLszuoojQMc6tLQ\"}}' http://localhost:5279/",
"lbrynet": "lbrynet address is_mine mztwZDgaFUnDFbtkxN2VLszuoojQMc6tLQ",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_is_mine\", \"params\": {\"address\": \"mztwZDgaFUnDFbtkxN2VLszuoojQMc6tLQ\"}}).json()",
"curl": "curl -d'{\"method\": \"address_is_mine\", \"params\": {\"address\": \"mzsUgb5dCMh2iFp14dvqZWkLKwt4sfCcmU\"}}' http://localhost:5279/",
"lbrynet": "lbrynet address is_mine mzsUgb5dCMh2iFp14dvqZWkLKwt4sfCcmU",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_is_mine\", \"params\": {\"address\": \"mzsUgb5dCMh2iFp14dvqZWkLKwt4sfCcmU\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": true\n}"
}
]
@@ -738,21 +738,21 @@
"is_required": false
}
],
"returns": " {\n \"page\": \"Page number of the current items.\",\n \"page_size\": \"Number of items to show on a page.\",\n \"total_pages\": \"Total number of pages.\",\n \"total_items\": \"Total number of items.\",\n \"items\": [\n \"an address in base58\"\n ]\n }",
"returns": " {\n \"page\": \"Page number of the current items.\",\n \"page_size\": \"Number of items to show on a page.\",\n \"total_pages\": \"Total number of pages.\",\n \"items\": [\n \"an address in base58\"\n ]\n }",
"examples": [
{
"title": "List addresses in default account",
"curl": "curl -d'{\"method\": \"address_list\", \"params\": {}}' http://localhost:5279/",
"lbrynet": "lbrynet address list",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_list\", \"params\": {}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n \"myK1B8RLzPtaUehDF49F6GzpTNhZJwkuFK\",\n \"mq1SLhoqW2g3qY1eGpcp2r5Xw1Vf19ocP8\",\n \"mr89YuKptsJxtE7izrCoDCdNvLp9KR2EuB\",\n \"n4VUJCJpkWT2Twzhs2dwkSVsVHtDoDkbaH\",\n \"mhkrXjG9n4C7EJyH4ooDVVTYm2cjzGZcxS\",\n \"mnY3oi1Auwp7Cb4CQRGDLoKWwsARVzes45\",\n \"mu8naFDrK7nHd3a2yCWNEV74A6JmDYsbha\",\n \"mnvmas1S7DYha4g7RZeNey87u8nZvVA1xG\",\n \"mxJmDYvcN6kCTos9YRb34jBDmwo14iJmNM\",\n \"mucWfYmDAVZW715d2cite7oc2e8J5PKH4u\",\n \"mg5Gn2NmJFVpZUU1ScVKf34KXVmJsrxXeu\",\n \"mqdCHu4sTh3bZoSTyMwR62i5w3e6U9aBCA\",\n \"mhgGjVVY6kjrAxf2cz1ALfbst6CQhZ72qg\",\n \"n4jxQucHz4BhGRmGSQLakzfwsHd7sN8jwa\",\n \"mztwZDgaFUnDFbtkxN2VLszuoojQMc6tLQ\",\n \"mujvjSMLfTmCxG2gy3ZNpNCFF5A1eF7GuZ\",\n \"muK7TZrirA8yHzxFcXa51W7CjxbAho2Zua\",\n \"mtQXpNQ924yoKNgVCycikXQA9oyBUYnBKL\",\n \"mxEwCiv67J8e9VcwbEc78yGMYxcZfRejMD\",\n \"mtmdn9t48VsD44K6ABAbdDLU8bodawoM4v\",\n \"mrBf6FXC67KD1pgHSjoarmrJC7oiZiEAnN\",\n \"mmCir7XhwDNvcFyPcbbDjrbumrK7FW11rQ\",\n \"mzuNaFAu7QDBfhv5eUi1qxWqEf4FTSdZiV\",\n \"mym11qGHsvNt3esNGnPZ8xTuQDDdvzVLP4\",\n \"n3H19KHvnn5N6PKbVhZk4PM7kZYWbUW1jG\",\n \"mt1jLmH7uq5x4vnMd2Zqnpm4w7ckkdgDSr\",\n \"muiGAtEmv3D3AvhKxp6pxaiaYstNgkYBeS\"\n ]\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n \"mwpbuD2xLqHN352Ag1ntMRDpu6bV9PxyLb\",\n \"mrWGKtehqRNHX1qo9DiQbTu8vUVmTx3AJE\",\n \"mmPUWDor4sLvbGctcUjFjRsj7o94YQmVkC\",\n \"n3vDyZVf6EuxN2r6BqLpMgS67f4epzdqZT\",\n \"n1SHWyZqJiWMNrdCxmQx9V3xQ83hWJnJUM\",\n \"mweqDPRKNNkSLpGP2Kr651TEtQijM4NEVm\",\n \"n3hzACYXp2epupNQSa5QFDDUcgprVt5rV1\",\n \"mzVz9QnHzyJ15wCFAYRt7bzLoeoBK83N8J\",\n \"n3dnMbCeTpMMqzuJxbJB32qoa1CC5CMfRA\",\n \"miuZSzrr2MH8qvf3rwoRnkaNH5enZfSH1q\",\n \"mq6YGvAQ9Edj2mManWjbufSvPBqUrrzjgJ\",\n \"mzsUgb5dCMh2iFp14dvqZWkLKwt4sfCcmU\",\n \"ms5gJaXcsiHP64SHxRspxU6ZdxaCn7kS9E\",\n \"mvETNRY6cV97UJLKq9oD1YFQMzRi7ws3x3\",\n \"mioLjPKzYbc12oQN5T7wNtpPRqgPe8Mgnd\",\n \"n2cykwbGgwagYFnVFgAL95H8Sa2ciygBeB\",\n \"n3yrPmbxnkTHpvJENs6YWfGnJo6ZxBtdrd\",\n \"mgCTRnGJU922PVkiQLtDbAv7ZTZKfnTRGj\",\n \"mh3A5mCcB1BWRk2qP3dwzEToC58fNymxQq\",\n \"n1EbYvEqsT264RpNwxJErxNZSr73YLK5Gi\",\n \"miquu4BM3HbL4TdkZYvbLjxPum75xA8rS5\",\n \"miXywcRRg3vVT5wst6pwxXhagJ6UKvG1Uz\",\n \"mstsodJ1hWJd1So6fFnCNwXnD2ovm6SscX\",\n \"mfcRDTDcY638nZYaejiRLozZLTdaYHktvo\",\n \"mvqVYgqco4W6n5nYmiGMRZHmc6MiGhwZUp\",\n \"mt37V8PpEqfQwg9AYDMVxD1VbHatnYSuyd\",\n \"n2rpLpSwWHuz61oDkHJ7samRaX2CrShddX\"\n ]\n}"
},
{
"title": "List addresses in specified account",
"curl": "curl -d'{\"method\": \"address_list\", \"params\": {\"account_id\": \"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\"}}' http://localhost:5279/",
"lbrynet": "lbrynet address list --account_id=\"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_list\", \"params\": {\"account_id\": \"mmiprM3BwUmzyB7ebMmL6GCE1YFw3TGk5W\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n \"mtptR4d9LBAgrra7xcsYHCRbi2cAn2MZLf\",\n \"mrfzBjhGDZoCmVeyQ32ryiQ6XbsoaH58uA\",\n \"mpZqBj8pttN7xXQP9FkVfKRSAkGvDd16XD\",\n \"mhtxFybjayPc8V4W1AopRw4MiphNA94pHf\",\n \"mp4wnohKv6rBWD4aL8rMEmBDmVgGZRQnc8\",\n \"mn5TqvgEQdHbg2KhxQZ7bHNMZtYVLkVBSV\",\n \"mwF8k177yZy1nms1AP3r3g5WtK5p7XhpRo\",\n \"mkhUFcKjiKhEid5QS573QwL38RAQjCrwY2\",\n \"mwabsSQcxdRxw8QYBWaL81tmu6WSQniAVu\",\n \"mkUfoXesw8P3CuDo4UHBcAAtDTjgUyMXnU\",\n \"mkSkAys8sHRZjRpzYXT9yk7KnwgvagDSRE\",\n \"mskWQ4fPukRpC5fVdqEvaiHtBgujJdRsR8\",\n \"n3d5BjF1h8wGnkBahYrHZoVhb1qg51SB3D\",\n \"n4jzZeestt64jghEGrV4Ad5rUBnVLJhE3U\",\n \"mmWUHYyddFXus5yYJf4Rtpkdv8GpgK9hYT\",\n \"mjv7LQMFR8tGWcTwH5JzWsCUXwRAygbCLu\",\n \"mrSPmWUdBrRHx1nMAUN1J3PnqcRELgga4U\",\n \"mfhy3VFVwCTPshEp7QnUUrhYvh9uBpHhzF\",\n \"mvwGdyxVbSeNvrcdbws42Wuob2ix2FYYq3\",\n \"mwHJKytimnJUQn3R4z3oMvtxFe7bWR8Lhn\",\n \"mnSwZR1JqNNcmaQyvapZwbqLcD8iyTZ279\",\n \"muiVnmmz5DWGtSHyuHcgcM6f7Ho38utTu2\",\n \"n21oZjxk8F4VtaSjQPxzdD9iFj9cNFpjn4\",\n \"n1CPPg4ypsEJtYHnMi3HKEJoLNPkMVgTe9\",\n \"mzFAivojDpyFhZCMRadw6AcJZXUxBbVW8A\",\n \"mxs9r97CSAGCkzCVMcMk3ijT9uaGXQWxDY\"\n ]\n}"
"curl": "curl -d'{\"method\": \"address_list\", \"params\": {\"account_id\": \"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\"}}' http://localhost:5279/",
"lbrynet": "lbrynet address list --account_id=\"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_list\", \"params\": {\"account_id\": \"mrgGy6tfn3BBLrR56aJrdRCayqwxofDfXH\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n \"mvWcQmp1Z9ryTe9KXuEFCbpKTdnDs3aXFV\",\n \"mzyVviBL61iCAJGgj4UGV89FD29sDCFSPH\",\n \"mok13BFBoydmH5jgW72GcCmsBFdj6FHvuM\",\n \"n27LP5ChLA1dggFVSVvZUoQSzuzjU4qGaz\",\n \"mv2WkbBYY24ezE3Tj78eJ9NA7TTZNaFSoD\",\n \"n4rGHx8SE1HXD7TjLjTavN7Qxzu2s6PHFL\",\n \"mqmdBcPHgipgLERdWnnrVkAaDuKTG8vn7r\",\n \"mhCLZXu3nxv6UG1BQ2dEXjsWoNwEQWboDo\",\n \"mjotbnaJ5hEuC4njSAyULMPUgL6aiVtund\",\n \"n1mjsaUdjkfEvvv5XwgwKuXVHboWk6krtv\",\n \"mjxa6Ab4fzfFUezniWtiMcudRRXKUXBkhX\",\n \"n2CD7uc8oWKkckThQ6vMK8PWnSRTwnZNW9\",\n \"miP2ZuLcrXVzpQdS7D8eFyBwoMREPY5d85\",\n \"n36VqScWuYZq2RQDXgsmaBzrUWBizVssia\",\n \"ms29KPAjP3YgyHaYgH8swJntmRzZEEfUF1\",\n \"morJAncdHuypAa9Z8XKHcncuUxRHuGucFM\",\n \"moD6rKnqi8z241dTr5af7VgzNKzfzPbawT\",\n \"mgJB5ij3PLNgNRCvfvyup1CsZSxSmvkNns\",\n \"n2WPRvMr2jAsh8JVafa6W5gdM6v56tRkYg\",\n \"mqU13a6mhhv6ij8GT2PmpBRJqSrJiZunY8\",\n \"mjgjVMFcHsav4eWqUJZXFpyNAn4VPjxGZh\",\n \"n1L2tmc6CEq6gBvxUW4ukg5URyD2eWdqfV\",\n \"mskTkRhwhWepPcnEcmqKreADoG5ZVXniPP\",\n \"myDoCnTUAeYhjV5eSXy6CYhwoSj5NpisWe\",\n \"n1UqhucGjj97H4FL87JnFL8Aatk1bAmGHV\",\n \"mjZ8HCbb1sgYm7bvc18y8xz8h89FLuoe6T\"\n ]\n}"
}
]
},
@@ -774,7 +774,7 @@
"curl": "curl -d'{\"method\": \"address_unused\", \"params\": {}}' http://localhost:5279/",
"lbrynet": "lbrynet address unused",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_unused\", \"params\": {}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": \"mztwZDgaFUnDFbtkxN2VLszuoojQMc6tLQ\"\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": \"mzsUgb5dCMh2iFp14dvqZWkLKwt4sfCcmU\"\n}"
}
]
}
@@ -824,10 +824,10 @@
"examples": [
{
"title": "Delete a blob",
"curl": "curl -d'{\"method\": \"blob_delete\", \"params\": {\"blob_hash\": \"d087dd83169ac7553c3026d4f47e42a3f673aa6e0220eef7d6867f8d94460080f020e470b8b4d7df4a9d8e6981b0784c\"}}' http://localhost:5279/",
"lbrynet": "lbrynet blob delete d087dd83169ac7553c3026d4f47e42a3f673aa6e0220eef7d6867f8d94460080f020e470b8b4d7df4a9d8e6981b0784c",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"blob_delete\", \"params\": {\"blob_hash\": \"d087dd83169ac7553c3026d4f47e42a3f673aa6e0220eef7d6867f8d94460080f020e470b8b4d7df4a9d8e6981b0784c\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": \"Deleted d087dd83169ac7553c3026d4f47e42a3f673aa6e0220eef7d6867f8d94460080f020e470b8b4d7df4a9d8e6981b0784c\"\n}"
"curl": "curl -d'{\"method\": \"blob_delete\", \"params\": {\"blob_hash\": \"fb5be9ad617fd756b29c835efb11e6fa44a301b7a506bb72d58108a0f276a6bf86591e0bce04525d098440fb9f5b286a\"}}' http://localhost:5279/",
"lbrynet": "lbrynet blob delete fb5be9ad617fd756b29c835efb11e6fa44a301b7a506bb72d58108a0f276a6bf86591e0bce04525d098440fb9f5b286a",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"blob_delete\", \"params\": {\"blob_hash\": \"fb5be9ad617fd756b29c835efb11e6fa44a301b7a506bb72d58108a0f276a6bf86591e0bce04525d098440fb9f5b286a\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": \"Deleted fb5be9ad617fd756b29c835efb11e6fa44a301b7a506bb72d58108a0f276a6bf86591e0bce04525d098440fb9f5b286a\"\n}"
}
]
},
@@ -905,7 +905,7 @@
"curl": "curl -d'{\"method\": \"blob_list\", \"params\": {\"needed\": false, \"finished\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet blob list",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"blob_list\", \"params\": {\"needed\": false, \"finished\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n \"d087dd83169ac7553c3026d4f47e42a3f673aa6e0220eef7d6867f8d94460080f020e470b8b4d7df4a9d8e6981b0784c\",\n \"32340dbf239be75d656c8cc72165bc97b33c7897bcad3e32eda18beae71e63f3be034ed64f2091e46fea657917aa24d8\",\n \"e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"a76d75a13ff15d946f929115e248dd411996abea4e1f37f73a72ba82fcd39a0dbbb3a3777e767984cd30e9eef2b68312\"\n ]\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n \"fb5be9ad617fd756b29c835efb11e6fa44a301b7a506bb72d58108a0f276a6bf86591e0bce04525d098440fb9f5b286a\",\n \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"2bd76e60458f62cfd36bc2f8304dcc96359f388476ad79ca220b302a5dd7345da6037c027f823e17b2f251203192afb3\",\n \"98dfa858507f8c3b68aad063a88a6424b1989db4b55fdab9195ae3ba80866ac98700cbea771cc0ea0065fc4fcdac1cbe\"\n ]\n}"
}
]
},
@@ -980,10 +980,10 @@
"examples": [
{
"title": "Abandon a channel claim",
"curl": "curl -d'{\"method\": \"channel_abandon\", \"params\": {\"claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\", \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet channel abandon 682bdf7e3ea6564bcf8aebe3cf227544189d1a6d",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_abandon\", \"params\": {\"claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\", \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000164ddfed624b05a77a72a6f56208a73d73483cd303a81753c9cb1cba30c5f663f000000006b483045022100b8d3305e1e4f4dbf8b6f1627f1d2612f0afb41f91365b1ae11c298c52ae8be0a02202f7a2e45342607900e1a2d46e7b7d54f7cab9cbc85a399a19fa65c1f59b02c450121022f03def56e0d77c0f19e1c8ae315abccbf761e76343f19324fc8d5e4e521716bffffffff0134b7f505000000001976a9143a3d7976ad928fc8579eac779c0cbc7e49a2958d88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"muK7TZrirA8yHzxFcXa51W7CjxbAho2Zua\",\n \"amount\": \"1.0\",\n \"claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"claim_op\": \"update\",\n \"confirmations\": 8,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"timestamp\": 1559011813,\n \"txid\": \"3f665f0ca3cbb19c3c75813a30cd8334d7738a20566f2aa7775ab024d6fedd64\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004eeccdcff00c8336c5d616fee009894e5cbbc2bbf9497021aabbde81beaf8e6edf423de4ff094a8d4e7ea87d9469fd7d3b834b80d9b330d2f7a887108c5ea9268\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mkpu8W1mArAiBb6aV5MfGd9Uo9wnhHFSBa\",\n \"amount\": \"0.999893\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"8bba7bc7a0d69d1a786de725c54a6ee8ce66b445a06d22345064b6558acec5de\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000107\",\n \"total_input\": \"1.0\",\n \"total_output\": \"0.999893\",\n \"txid\": \"8bba7bc7a0d69d1a786de725c54a6ee8ce66b445a06d22345064b6558acec5de\"\n }\n}"
"curl": "curl -d'{\"method\": \"channel_abandon\", \"params\": {\"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\", \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet channel abandon 67193e65e8c0363f26aff251435cf1795e47e2f8",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_abandon\", \"params\": {\"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\", \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000187fc493ce9081f842874b079131513508679e7f01d6058dfb1dbad7fce2ab8be000000006b483045022100b03e72becb27277ac183222249b3fb694b3f435ef21f7e4dcfe677e9129f13bf0220699a4e65156bbbafd967df6340732fbd51d8e1a20b71f3501f4548de6b3840810121031e8fea600c38afe3fa4d56a76c5a14da1c63735e97a0f4897f0148c0448c01cdffffffff0134b7f505000000001976a914ae6714999a339aef99dd18b56d49e87d1b5084a388ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mvETNRY6cV97UJLKq9oD1YFQMzRi7ws3x3\",\n \"amount\": \"1.0\",\n \"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"claim_op\": \"update\",\n \"confirmations\": 8,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"timestamp\": 1558113063,\n \"txid\": \"beb82ace7faddbb1df58601df0e779865013151379b07428841f08e93c49fc87\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mwR7Mb7ofen5fzCnowjDC2GG8wwQ5Mic9P\",\n \"amount\": \"0.999893\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"f2557c72be663ec6d8e01cabb4d599957b17ed34b0844daf3c2a7493fee2cd2a\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000107\",\n \"total_input\": \"1.0\",\n \"total_output\": \"0.999893\",\n \"txid\": \"f2557c72be663ec6d8e01cabb4d599957b17ed34b0844daf3c2a7493fee2cd2a\"\n }\n}"
}
]
},
@@ -1095,14 +1095,14 @@
"curl": "curl -d'{\"method\": \"channel_create\", \"params\": {\"name\": \"@channel\", \"bid\": \"1.0\", \"featured\": [], \"tags\": [], \"languages\": [], \"locations\": [], \"preview\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet channel create @channel 1.0",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_create\", \"params\": {\"name\": \"@channel\", \"bid\": \"1.0\", \"featured\": [], \"tags\": [], \"languages\": [], \"locations\": [], \"preview\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000015b1437e0a48d9f617d74d0526130b55142b9809cfc4768fc524176dd0532f83e010000006b483045022100a3a998eda6a968a75a230ceb7712d745273e41c20b0573873ca75973048b37b9022039055db9b97a2517f4a81142a7be9fead9e2866c5946f8fdeeb7cbea93fee634012103382e6fef405ac1e202d4edea0888abfc8a9ec4e2ec499681a78b940d23a4cbaaffffffff0200e1f5050000000084b508406368616e6e656c4c5d00125a0a583056301006072a8648ce3d020106052b8104000a03420004eeccdcff00c8336c5d616fee009894e5cbbc2bbf9497021aabbde81beaf8e6edf423de4ff094a8d4e7ea87d9469fd7d3b834b80d9b330d2f7a887108c5ea92686d7576a91497546b4edcb94a6b0fcd8593ed3a942c92ca8d9988acc462a029000000001976a914681c30baec28e2aa8d45a228f2a6af2e0a4fcec188ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mhkrXjG9n4C7EJyH4ooDVVTYm2cjzGZcxS\",\n \"amount\": \"7.999876\",\n \"confirmations\": 2,\n \"height\": 207,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1559011813,\n \"txid\": \"3ef83205dd764152fc6847fc9c80b94251b5306152d0747d619f8da4e037145b\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"muK7TZrirA8yHzxFcXa51W7CjxbAho2Zua\",\n \"amount\": \"1.0\",\n \"claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"timestamp\": null,\n \"txid\": \"1e6a8336442131461b92bdf3098baa01790df5a0d7d75bd1ab703744bc2ace9a\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004eeccdcff00c8336c5d616fee009894e5cbbc2bbf9497021aabbde81beaf8e6edf423de4ff094a8d4e7ea87d9469fd7d3b834b80d9b330d2f7a887108c5ea9268\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mq1SLhoqW2g3qY1eGpcp2r5Xw1Vf19ocP8\",\n \"amount\": \"6.983769\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"1e6a8336442131461b92bdf3098baa01790df5a0d7d75bd1ab703744bc2ace9a\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.016107\",\n \"total_input\": \"7.999876\",\n \"total_output\": \"7.983769\",\n \"txid\": \"1e6a8336442131461b92bdf3098baa01790df5a0d7d75bd1ab703744bc2ace9a\"\n }\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001db75946a6e5c3ae4fba9643571cb397b944abe0f5447896d8fa4eb211203da5f010000006a473044022060f5f4558bf31494b793af0c0edfebe5d3325538ecababe967caed5b62f78f9e02205801be9412b4bada94fb1ed038bf53830c6b8dc9804ddf4ad71b5c0c431f0f350121024d0d34f9a054ed1888b0138c9169ae91085393aa874b52066d6dc1bc3cfe1857ffffffff0200e1f5050000000084b508406368616e6e656c4c5d00125a0a583056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c56d7576a914a16b1616689b84e9c75e8859854d20052afb93bf88acc462a029000000001976a9147888050e199716fc5ac0fafa910af696715e411488ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mwpbuD2xLqHN352Ag1ntMRDpu6bV9PxyLb\",\n \"amount\": \"7.999876\",\n \"confirmations\": 2,\n \"height\": 207,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1558113063,\n \"txid\": \"5fda031221eba48f6d8947540fbe4a947b39cb713564a9fbe43a5c6e6a9475db\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mvETNRY6cV97UJLKq9oD1YFQMzRi7ws3x3\",\n \"amount\": \"1.0\",\n \"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"timestamp\": null,\n \"txid\": \"e940ff7cd92fd38324b61e87df8171f8f96e1d4931ab4d2af0ae768855cad150\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c5\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mrWGKtehqRNHX1qo9DiQbTu8vUVmTx3AJE\",\n \"amount\": \"6.983769\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"e940ff7cd92fd38324b61e87df8171f8f96e1d4931ab4d2af0ae768855cad150\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.016107\",\n \"total_input\": \"7.999876\",\n \"total_output\": \"7.983769\",\n \"txid\": \"e940ff7cd92fd38324b61e87df8171f8f96e1d4931ab4d2af0ae768855cad150\"\n }\n}"
},
{
"title": "Create a channel claim with all metadata",
"curl": "curl -d'{\"method\": \"channel_create\", \"params\": {\"name\": \"@bigchannel\", \"bid\": \"1.0\", \"title\": \"Big Channel\", \"description\": \"A channel with lots of videos.\", \"email\": \"creator@smallmedia.com\", \"website_url\": \"http://smallmedia.com\", \"featured\": [], \"tags\": [\"music\", \"art\"], \"languages\": [\"pt-BR\", \"uk\"], \"locations\": [\"BR\", \"UA::Kiyv\"], \"thumbnail_url\": \"http://smallmedia.com/logo.jpg\", \"cover_url\": \"http://smallmedia.com/logo.jpg\", \"preview\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet channel create @bigchannel 1.0 --title=\"Big Channel\" --description=\"A channel with lots of videos.\" --email=\"creator@smallmedia.com\" --tags=music --tags=art --languages=pt-BR --languages=uk --locations=BR --locations=UA::Kiyv --website_url=\"http://smallmedia.com\" --thumbnail_url=\"http://smallmedia.com/logo.jpg\" --cover_url=\"http://smallmedia.com/logo.jpg\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_create\", \"params\": {\"name\": \"@bigchannel\", \"bid\": \"1.0\", \"title\": \"Big Channel\", \"description\": \"A channel with lots of videos.\", \"email\": \"creator@smallmedia.com\", \"website_url\": \"http://smallmedia.com\", \"featured\": [], \"tags\": [\"music\", \"art\"], \"languages\": [\"pt-BR\", \"uk\"], \"locations\": [\"BR\", \"UA::Kiyv\"], \"thumbnail_url\": \"http://smallmedia.com/logo.jpg\", \"cover_url\": \"http://smallmedia.com/logo.jpg\", \"preview\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000164ddfed624b05a77a72a6f56208a73d73483cd303a81753c9cb1cba30c5f663f010000006a47304402207c048cfb78f8e2bca9395448ea87ae4d932e9f30fbeef88950490700e22867b7022055d06a29ed14fe51ac059bfb1c87e7e8dda755a8c772cd82d3dd0bb03a7c0d980121023029cb2848043d7fdbbfee2e289e7138e1fda02f479f4fc7c70f6057b4749b15ffffffff0200e1f50500000000fd5001b50b406269676368616e6e656c4d25010012ab010a583056301006072a8648ce3d020106052b8104000a03420004816277e675319fe21d8a1605d7ab8840d0d4c7972252914c58b4883d22501c5185c450737232112d3c1d011d258ea7dbcb8430461d1bd24c28bd92b1882eca41121663726561746f7240736d616c6c6d656469612e636f6d1a15687474703a2f2f736d616c6c6d656469612e636f6d22202a1e687474703a2f2f736d616c6c6d656469612e636f6d2f6c6f676f2e6a7067420b426967204368616e6e656c4a1e41206368616e6e656c2077697468206c6f7473206f6620766964656f732e52202a1e687474703a2f2f736d616c6c6d656469612e636f6d2f6c6f676f2e6a70675a056d757369635a0361727462050883011820620308ab016a0208206a0908e9011a044b6979766d7576a9146edf701f9576ecc9350a237341c557039e4fe91988ace221d305000000001976a9144cfde5a37df242b0d4d9d975bc1c6d11243b511b88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mi8yHTnrdinYn2JFHXBsSK4CBex6CtaRFK\",\n \"amount\": \"1.9993355\",\n \"confirmations\": 1,\n \"height\": 210,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1559011813,\n \"txid\": \"3f665f0ca3cbb19c3c75813a30cd8334d7738a20566f2aa7775ab024d6fedd64\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mqdCHu4sTh3bZoSTyMwR62i5w3e6U9aBCA\",\n \"amount\": \"1.0\",\n \"claim_id\": \"9c594079a7dd41fbc8d68011bec5bcdfb0f8dddb\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"@bigchannel\",\n \"normalized_name\": \"@bigchannel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@bigchannel#9c594079a7dd41fbc8d68011bec5bcdfb0f8dddb\",\n \"timestamp\": null,\n \"txid\": \"60b2c4430178f48b1b4bdda0aaacd66fe1512d0c0e4f16e646a6d178a6a112c9\",\n \"type\": \"claim\",\n \"value\": {\n \"cover\": {\n \"url\": \"http://smallmedia.com/logo.jpg\"\n },\n \"description\": \"A channel with lots of videos.\",\n \"email\": \"creator@smallmedia.com\",\n \"languages\": [\n \"pt-BR\",\n \"uk\"\n ],\n \"locations\": [\n {\n \"country\": \"BR\"\n },\n {\n \"city\": \"Kiyv\",\n \"country\": \"UA\"\n }\n ],\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004816277e675319fe21d8a1605d7ab8840d0d4c7972252914c58b4883d22501c5185c450737232112d3c1d011d258ea7dbcb8430461d1bd24c28bd92b1882eca41\",\n \"tags\": [\n \"music\",\n \"art\"\n ],\n \"thumbnail\": {\n \"url\": \"http://smallmedia.com/logo.jpg\"\n },\n \"title\": \"Big Channel\",\n \"website_url\": \"http://smallmedia.com\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mnY3oi1Auwp7Cb4CQRGDLoKWwsARVzes45\",\n \"amount\": \"0.9772285\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"60b2c4430178f48b1b4bdda0aaacd66fe1512d0c0e4f16e646a6d178a6a112c9\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.022107\",\n \"total_input\": \"1.9993355\",\n \"total_output\": \"1.9772285\",\n \"txid\": \"60b2c4430178f48b1b4bdda0aaacd66fe1512d0c0e4f16e646a6d178a6a112c9\"\n }\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000187fc493ce9081f842874b079131513508679e7f01d6058dfb1dbad7fce2ab8be010000006b483045022100b3425a6d7f4fb1d7118799116c5166fdc53eb67ce7c73c4d93c53b9948a92a54022000acb4e1b812594405997ed1d67a66cbe7d7d8887d706ee77a7c6e36d21e95f7012102aafc9b133d073a6f6cc73be0bfc7ceb60ecae2cb5776d57843b9a8370f6772fdffffffff0200e1f50500000000fd5001b50b406269676368616e6e656c4d25010012ab010a583056301006072a8648ce3d020106052b8104000a034200049825bd3b56048f750b9691a0bb78f1f643f64cb45b93f69450eab0e19aa36b0215bec62b8207f2b3f9de91112a35ee142f50bf3ce86d3a4e2176d4037e0a1999121663726561746f7240736d616c6c6d656469612e636f6d1a15687474703a2f2f736d616c6c6d656469612e636f6d22202a1e687474703a2f2f736d616c6c6d656469612e636f6d2f6c6f676f2e6a7067420b426967204368616e6e656c4a1e41206368616e6e656c2077697468206c6f7473206f6620766964656f732e52202a1e687474703a2f2f736d616c6c6d656469612e636f6d2f6c6f676f2e6a70675a056d757369635a0361727462050883011820620308ab016a0208206a0908e9011a044b6979766d7576a914f29d61de0783dcf020ec617e8b2a4e86428206ab88ace221d305000000001976a914da807b748e40ea127ad78d2613cb638a997b160b88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mmPUWDor4sLvbGctcUjFjRsj7o94YQmVkC\",\n \"amount\": \"1.9993355\",\n \"confirmations\": 1,\n \"height\": 210,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1558113063,\n \"txid\": \"beb82ace7faddbb1df58601df0e779865013151379b07428841f08e93c49fc87\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"n3dnMbCeTpMMqzuJxbJB32qoa1CC5CMfRA\",\n \"amount\": \"1.0\",\n \"claim_id\": \"7b6b7fa23d531a3a220c864d494883314800b54d\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"name\": \"@bigchannel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@bigchannel#7b6b7fa23d531a3a220c864d494883314800b54d\",\n \"timestamp\": null,\n \"txid\": \"cc4167a5c14d4a19410a6dff9c1814869f7ac310cc792433e61cc355552d2c8c\",\n \"type\": \"claim\",\n \"value\": {\n \"cover\": {\n \"url\": \"http://smallmedia.com/logo.jpg\"\n },\n \"description\": \"A channel with lots of videos.\",\n \"email\": \"creator@smallmedia.com\",\n \"languages\": [\n \"pt-BR\",\n \"uk\"\n ],\n \"locations\": [\n {\n \"country\": \"BR\"\n },\n {\n \"city\": \"Kiyv\",\n \"country\": \"UA\"\n }\n ],\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200049825bd3b56048f750b9691a0bb78f1f643f64cb45b93f69450eab0e19aa36b0215bec62b8207f2b3f9de91112a35ee142f50bf3ce86d3a4e2176d4037e0a1999\",\n \"tags\": [\n \"music\",\n \"art\"\n ],\n \"thumbnail\": {\n \"url\": \"http://smallmedia.com/logo.jpg\"\n },\n \"title\": \"Big Channel\",\n \"website_url\": \"http://smallmedia.com\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"n1SHWyZqJiWMNrdCxmQx9V3xQ83hWJnJUM\",\n \"amount\": \"0.9772285\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"cc4167a5c14d4a19410a6dff9c1814869f7ac310cc792433e61cc355552d2c8c\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.022107\",\n \"total_input\": \"1.9993355\",\n \"total_output\": \"1.9772285\",\n \"txid\": \"cc4167a5c14d4a19410a6dff9c1814869f7ac310cc792433e61cc355552d2c8c\"\n }\n}"
}
]
},
@@ -1157,21 +1157,21 @@
"is_required": false
}
],
"returns": " {\n \"page\": \"Page number of the current items.\",\n \"page_size\": \"Number of items to show on a page.\",\n \"total_pages\": \"Total number of pages.\",\n \"total_items\": \"Total number of items.\",\n \"items\": [\n {\n \"txid\": \"hash of transaction in hex\",\n \"nout\": \"position in the transaction\",\n \"height\": \"block where transaction was recorded\",\n \"amount\": \"value of the txo as a decimal\",\n \"address\": \"address of who can spend the txo\",\n \"confirmations\": \"number of confirmed blocks\",\n \"is_change\": \"payment to change address, only available when it can be determined\",\n \"is_mine\": \"payment to one of your accounts, only available when it can be determined\",\n \"type\": \"one of 'claim', 'support' or 'payment'\",\n \"name\": \"when type is 'claim' or 'support', this is the claim name\",\n \"claim_id\": \"when type is 'claim' or 'support', this is the claim id\",\n \"claim_op\": \"when type is 'claim', this determines if it is 'create' or 'update'\",\n \"value\": \"when type is 'claim' or 'support' with payload, this is the decoded protobuf payload\",\n \"value_type\": \"determines the type of the 'value' field: 'channel', 'stream', etc\",\n \"protobuf\": \"hex encoded raw protobuf version of 'value' field\",\n \"permanent_url\": \"when type is 'claim' or 'support', this is the long permanent claim URL\",\n \"signing_channel\": \"for signed claims only, metadata of signing channel\",\n \"is_channel_signature_valid\": \"for signed claims only, whether signature is valid\"\n }\n ]\n }",
"returns": " {\n \"page\": \"Page number of the current items.\",\n \"page_size\": \"Number of items to show on a page.\",\n \"total_pages\": \"Total number of pages.\",\n \"items\": [\n {\n \"txid\": \"hash of transaction in hex\",\n \"nout\": \"position in the transaction\",\n \"height\": \"block where transaction was recorded\",\n \"amount\": \"value of the txo as a decimal\",\n \"address\": \"address of who can spend the txo\",\n \"confirmations\": \"number of confirmed blocks\",\n \"is_change\": \"payment to change address, only available when it can be determined\",\n \"is_mine\": \"payment to one of your accounts, only available when it can be determined\",\n \"type\": \"one of 'claim', 'support' or 'payment'\",\n \"name\": \"when type is 'claim' or 'support', this is the claim name\",\n \"claim_id\": \"when type is 'claim' or 'support', this is the claim id\",\n \"claim_op\": \"when type is 'claim', this determines if it is 'create' or 'update'\",\n \"value\": \"when type is 'claim' or 'support' with payload, this is the decoded protobuf payload\",\n \"value_type\": \"determines the type of the 'value' field: 'channel', 'stream', etc\",\n \"protobuf\": \"hex encoded raw protobuf version of 'value' field\",\n \"permanent_url\": \"when type is 'claim' or 'support', this is the long permanent claim URL\",\n \"signing_channel\": \"for signed claims only, metadata of signing channel\",\n \"is_channel_signature_valid\": \"for signed claims only, whether signature is valid\"\n }\n ]\n }",
"examples": [
{
"title": "List your channel claims",
"curl": "curl -d'{\"method\": \"channel_list\", \"params\": {}}' http://localhost:5279/",
"lbrynet": "lbrynet channel list",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_list\", \"params\": {}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"address\": \"muK7TZrirA8yHzxFcXa51W7CjxbAho2Zua\",\n \"amount\": \"1.0\",\n \"claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"height\": 209,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"timestamp\": 1559011813,\n \"txid\": \"1e6a8336442131461b92bdf3098baa01790df5a0d7d75bd1ab703744bc2ace9a\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004eeccdcff00c8336c5d616fee009894e5cbbc2bbf9497021aabbde81beaf8e6edf423de4ff094a8d4e7ea87d9469fd7d3b834b80d9b330d2f7a887108c5ea9268\"\n },\n \"value_type\": \"channel\"\n }\n ]\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"address\": \"mvETNRY6cV97UJLKq9oD1YFQMzRi7ws3x3\",\n \"amount\": \"1.0\",\n \"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"height\": 209,\n \"is_change\": false,\n \"is_mine\": true,\n \"name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"timestamp\": 1558113063,\n \"txid\": \"e940ff7cd92fd38324b61e87df8171f8f96e1d4931ab4d2af0ae768855cad150\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c5\"\n },\n \"value_type\": \"channel\"\n }\n ]\n}"
},
{
"title": "Paginate your channel claims",
"curl": "curl -d'{\"method\": \"channel_list\", \"params\": {\"page\": 1, \"page_size\": 20}}' http://localhost:5279/",
"lbrynet": "lbrynet channel list --page=1 --page_size=20",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_list\", \"params\": {\"page\": 1, \"page_size\": 20}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"muK7TZrirA8yHzxFcXa51W7CjxbAho2Zua\",\n \"amount\": \"1.0\",\n \"claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"height\": 209,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"timestamp\": 1559011813,\n \"txid\": \"1e6a8336442131461b92bdf3098baa01790df5a0d7d75bd1ab703744bc2ace9a\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004eeccdcff00c8336c5d616fee009894e5cbbc2bbf9497021aabbde81beaf8e6edf423de4ff094a8d4e7ea87d9469fd7d3b834b80d9b330d2f7a887108c5ea9268\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mvETNRY6cV97UJLKq9oD1YFQMzRi7ws3x3\",\n \"amount\": \"1.0\",\n \"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"height\": 209,\n \"is_change\": false,\n \"is_mine\": true,\n \"name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"timestamp\": 1558113063,\n \"txid\": \"e940ff7cd92fd38324b61e87df8171f8f96e1d4931ab4d2af0ae768855cad150\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c5\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_pages\": 1\n }\n}"
}
]
},
@@ -1310,10 +1310,10 @@
"examples": [
{
"title": "Update a channel claim",
"curl": "curl -d'{\"method\": \"channel_update\", \"params\": {\"claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\", \"title\": \"New Channel\", \"featured\": [], \"clear_featured\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"new_signing_key\": false, \"preview\": false, \"replace\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet channel update 682bdf7e3ea6564bcf8aebe3cf227544189d1a6d --title=\"New Channel\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_update\", \"params\": {\"claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\", \"title\": \"New Channel\", \"featured\": [], \"clear_featured\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"new_signing_key\": false, \"preview\": false, \"replace\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000029ace2abc443770abd15bd7d7a0f50d7901aa8b09f3bd921b4631214436836a1e000000006b483045022100ce01d888adf2a629f71342ddb1c127ddd04cea8bcf18c67ccc94a97b2e4798ae02202150f0091d71f69cf5656cd525b789ca5ef38a5416e6995c22a53748b653f0900121022f03def56e0d77c0f19e1c8ae315abccbf761e76343f19324fc8d5e4e521716bffffffffbaaf5b2ddeda8c5a6f931bb2a33b8f7bef07e0c2c1e4241ba40779857be0da92000000006b483045022100f3fdc34c545f2116042ccff330a3af3dc195329bb64e0a4a08dd75beed959b0602205680bab6e19b244670fdb86f86197b9d6028b11a67fcdfa6b91907634c7fe291012102500d97c6528fc25ed450b3ad8e62934e5400cc601941e5a4f8b250c8a88f7a3dffffffff0200e1f50500000000a6b708406368616e6e656c146d1a9d18447522cfe3eb8acf4b56a63e7edf2b684c6a00125a0a583056301006072a8648ce3d020106052b8104000a03420004eeccdcff00c8336c5d616fee009894e5cbbc2bbf9497021aabbde81beaf8e6edf423de4ff094a8d4e7ea87d9469fd7d3b834b80d9b330d2f7a887108c5ea9268420b4e6577204368616e6e656c6d6d76a91497546b4edcb94a6b0fcd8593ed3a942c92ca8d9988ac6ebeea0b000000001976a9141cc00d6cb1247dee818dda0fca641e7e016c98b888ac00000000\",\n \"inputs\": [\n {\n \"address\": \"muK7TZrirA8yHzxFcXa51W7CjxbAho2Zua\",\n \"amount\": \"1.0\",\n \"claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"height\": 209,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"timestamp\": 1559011813,\n \"txid\": \"1e6a8336442131461b92bdf3098baa01790df5a0d7d75bd1ab703744bc2ace9a\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004eeccdcff00c8336c5d616fee009894e5cbbc2bbf9497021aabbde81beaf8e6edf423de4ff094a8d4e7ea87d9469fd7d3b834b80d9b330d2f7a887108c5ea9268\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mq1SLhoqW2g3qY1eGpcp2r5Xw1Vf19ocP8\",\n \"amount\": \"1.999604\",\n \"confirmations\": 1,\n \"height\": 209,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 0,\n \"timestamp\": 1559011813,\n \"txid\": \"92dae07b857907a41b24e4c1c2e007ef7b8f3ba3b21b936f5a8cdade2d5bafba\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"muK7TZrirA8yHzxFcXa51W7CjxbAho2Zua\",\n \"amount\": \"1.0\",\n \"claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"claim_op\": \"update\",\n \"confirmations\": -2,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"timestamp\": null,\n \"txid\": \"3f665f0ca3cbb19c3c75813a30cd8334d7738a20566f2aa7775ab024d6fedd64\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004eeccdcff00c8336c5d616fee009894e5cbbc2bbf9497021aabbde81beaf8e6edf423de4ff094a8d4e7ea87d9469fd7d3b834b80d9b330d2f7a887108c5ea9268\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mi8yHTnrdinYn2JFHXBsSK4CBex6CtaRFK\",\n \"amount\": \"1.9993355\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"3f665f0ca3cbb19c3c75813a30cd8334d7738a20566f2aa7775ab024d6fedd64\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.0002685\",\n \"total_input\": \"2.999604\",\n \"total_output\": \"2.9993355\",\n \"txid\": \"3f665f0ca3cbb19c3c75813a30cd8334d7738a20566f2aa7775ab024d6fedd64\"\n }\n}"
"curl": "curl -d'{\"method\": \"channel_update\", \"params\": {\"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\", \"title\": \"New Channel\", \"featured\": [], \"clear_featured\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"new_signing_key\": false, \"preview\": false, \"replace\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet channel update 67193e65e8c0363f26aff251435cf1795e47e2f8 --title=\"New Channel\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_update\", \"params\": {\"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\", \"title\": \"New Channel\", \"featured\": [], \"clear_featured\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"new_signing_key\": false, \"preview\": false, \"replace\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000250d1ca558876aef02a4dab31491d6ef9f87181df871eb62483d32fd97cff40e9000000006b48304502210097ca8f97bd9236114aa4e0beff7d7c75c2f3ce9bf65390c0bc2d2478f5c09a6b0220039ca9d75e3147f08d4637b7c97b896bec7fa9bdc40329194b92ef0aaac58d600121031e8fea600c38afe3fa4d56a76c5a14da1c63735e97a0f4897f0148c0448c01cdffffffffc03f7730c1486c989dcc4338f058d2b7a67803826d1c4dd7ab81b40ed7bb821f000000006b483045022100bd72d137340083d0609627957de2243784d30f614922c1d56c3ffea89f6388a702206a8913c05984d97eab6e429d46e236361d5b3ca3ce017b27d481d28b23936c30012103ce2d7ffce7a840465e470da09b80334f7d145a0d3812d51e73c05c37ed639895ffffffff0200e1f50500000000a6b708406368616e6e656c14f8e2475e79f15c4351f2af263f36c0e8653e19674c6a00125a0a583056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c5420b4e6577204368616e6e656c6d6d76a914a16b1616689b84e9c75e8859854d20052afb93bf88ac6ebeea0b000000001976a9144066a516149b5efc22d609eff65d107b4672a83588ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mvETNRY6cV97UJLKq9oD1YFQMzRi7ws3x3\",\n \"amount\": \"1.0\",\n \"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"height\": 209,\n \"is_change\": false,\n \"is_mine\": true,\n \"name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"timestamp\": 1558113063,\n \"txid\": \"e940ff7cd92fd38324b61e87df8171f8f96e1d4931ab4d2af0ae768855cad150\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c5\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mweqDPRKNNkSLpGP2Kr651TEtQijM4NEVm\",\n \"amount\": \"1.999604\",\n \"confirmations\": 1,\n \"height\": 209,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 0,\n \"timestamp\": 1558113063,\n \"txid\": \"1f82bbd70eb481abd74d1c6d820378a6b7d258f03843cc9d986c48c130773fc0\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mvETNRY6cV97UJLKq9oD1YFQMzRi7ws3x3\",\n \"amount\": \"1.0\",\n \"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"claim_op\": \"update\",\n \"confirmations\": -2,\n \"height\": -2,\n \"name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"timestamp\": null,\n \"txid\": \"beb82ace7faddbb1df58601df0e779865013151379b07428841f08e93c49fc87\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mmPUWDor4sLvbGctcUjFjRsj7o94YQmVkC\",\n \"amount\": \"1.9993355\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"beb82ace7faddbb1df58601df0e779865013151379b07428841f08e93c49fc87\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.0002685\",\n \"total_input\": \"2.999604\",\n \"total_output\": \"2.9993355\",\n \"txid\": \"beb82ace7faddbb1df58601df0e779865013151379b07428841f08e93c49fc87\"\n }\n}"
}
]
}
@@ -1345,212 +1345,68 @@
"is_required": false
}
],
"returns": " {\n \"page\": \"Page number of the current items.\",\n \"page_size\": \"Number of items to show on a page.\",\n \"total_pages\": \"Total number of pages.\",\n \"total_items\": \"Total number of items.\",\n \"items\": [\n {\n \"txid\": \"hash of transaction in hex\",\n \"nout\": \"position in the transaction\",\n \"height\": \"block where transaction was recorded\",\n \"amount\": \"value of the txo as a decimal\",\n \"address\": \"address of who can spend the txo\",\n \"confirmations\": \"number of confirmed blocks\",\n \"is_change\": \"payment to change address, only available when it can be determined\",\n \"is_mine\": \"payment to one of your accounts, only available when it can be determined\",\n \"type\": \"one of 'claim', 'support' or 'payment'\",\n \"name\": \"when type is 'claim' or 'support', this is the claim name\",\n \"claim_id\": \"when type is 'claim' or 'support', this is the claim id\",\n \"claim_op\": \"when type is 'claim', this determines if it is 'create' or 'update'\",\n \"value\": \"when type is 'claim' or 'support' with payload, this is the decoded protobuf payload\",\n \"value_type\": \"determines the type of the 'value' field: 'channel', 'stream', etc\",\n \"protobuf\": \"hex encoded raw protobuf version of 'value' field\",\n \"permanent_url\": \"when type is 'claim' or 'support', this is the long permanent claim URL\",\n \"signing_channel\": \"for signed claims only, metadata of signing channel\",\n \"is_channel_signature_valid\": \"for signed claims only, whether signature is valid\"\n }\n ]\n }",
"returns": " {\n \"page\": \"Page number of the current items.\",\n \"page_size\": \"Number of items to show on a page.\",\n \"total_pages\": \"Total number of pages.\",\n \"items\": [\n {\n \"txid\": \"hash of transaction in hex\",\n \"nout\": \"position in the transaction\",\n \"height\": \"block where transaction was recorded\",\n \"amount\": \"value of the txo as a decimal\",\n \"address\": \"address of who can spend the txo\",\n \"confirmations\": \"number of confirmed blocks\",\n \"is_change\": \"payment to change address, only available when it can be determined\",\n \"is_mine\": \"payment to one of your accounts, only available when it can be determined\",\n \"type\": \"one of 'claim', 'support' or 'payment'\",\n \"name\": \"when type is 'claim' or 'support', this is the claim name\",\n \"claim_id\": \"when type is 'claim' or 'support', this is the claim id\",\n \"claim_op\": \"when type is 'claim', this determines if it is 'create' or 'update'\",\n \"value\": \"when type is 'claim' or 'support' with payload, this is the decoded protobuf payload\",\n \"value_type\": \"determines the type of the 'value' field: 'channel', 'stream', etc\",\n \"protobuf\": \"hex encoded raw protobuf version of 'value' field\",\n \"permanent_url\": \"when type is 'claim' or 'support', this is the long permanent claim URL\",\n \"signing_channel\": \"for signed claims only, metadata of signing channel\",\n \"is_channel_signature_valid\": \"for signed claims only, whether signature is valid\"\n }\n ]\n }",
"examples": [
{
"title": "List all your claims",
"curl": "curl -d'{\"method\": \"claim_list\", \"params\": {}}' http://localhost:5279/",
"lbrynet": "lbrynet claim list",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_list\", \"params\": {}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"address\": \"mg5Gn2NmJFVpZUU1ScVKf34KXVmJsrxXeu\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_change\": false,\n \"is_channel_signature_valid\": true,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"signing_channel\": {\n \"address\": \"muK7TZrirA8yHzxFcXa51W7CjxbAho2Zua\",\n \"amount\": \"1.0\",\n \"claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"timestamp\": 1559011813,\n \"txid\": \"3f665f0ca3cbb19c3c75813a30cd8334d7738a20566f2aa7775ab024d6fedd64\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004eeccdcff00c8336c5d616fee009894e5cbbc2bbf9497021aabbde81beaf8e6edf423de4ff094a8d4e7ea87d9469fd7d3b834b80d9b330d2f7a887108c5ea9268\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1559011814,\n \"txid\": \"fa78db71b5e4205ec33a69106f9c9528ed9289fa3f8efc51baebe6e514247287\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp6h32p99s\",\n \"sd_hash\": \"e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"size\": \"11\"\n }\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"muK7TZrirA8yHzxFcXa51W7CjxbAho2Zua\",\n \"amount\": \"1.0\",\n \"claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"timestamp\": 1559011813,\n \"txid\": \"3f665f0ca3cbb19c3c75813a30cd8334d7738a20566f2aa7775ab024d6fedd64\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004eeccdcff00c8336c5d616fee009894e5cbbc2bbf9497021aabbde81beaf8e6edf423de4ff094a8d4e7ea87d9469fd7d3b834b80d9b330d2f7a887108c5ea9268\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n }\n ]\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"address\": \"mzVz9QnHzyJ15wCFAYRt7bzLoeoBK83N8J\",\n \"amount\": \"1.0\",\n \"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_change\": false,\n \"is_channel_signature_valid\": true,\n \"is_mine\": true,\n \"name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"signing_channel\": {\n \"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"name\": \"@channel\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c5\",\n \"title\": \"New Channel\"\n }\n },\n \"timestamp\": 1558113064,\n \"txid\": \"b66c49273cb5f48f73f8e626523233da52aa1a64e7a3f90a0f053e7c96e2b5b7\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpip8uriwe\",\n \"sd_hash\": \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"size\": \"11\"\n }\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mvETNRY6cV97UJLKq9oD1YFQMzRi7ws3x3\",\n \"amount\": \"1.0\",\n \"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"timestamp\": 1558113063,\n \"txid\": \"beb82ace7faddbb1df58601df0e779865013151379b07428841f08e93c49fc87\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n }\n ]\n}"
},
{
"title": "Paginate your claims",
"curl": "curl -d'{\"method\": \"claim_list\", \"params\": {\"page\": 1, \"page_size\": 20}}' http://localhost:5279/",
"lbrynet": "lbrynet claim list --page=1 --page_size=20",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_list\", \"params\": {\"page\": 1, \"page_size\": 20}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mg5Gn2NmJFVpZUU1ScVKf34KXVmJsrxXeu\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_change\": false,\n \"is_channel_signature_valid\": true,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"signing_channel\": {\n \"address\": \"muK7TZrirA8yHzxFcXa51W7CjxbAho2Zua\",\n \"amount\": \"1.0\",\n \"claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"timestamp\": 1559011813,\n \"txid\": \"3f665f0ca3cbb19c3c75813a30cd8334d7738a20566f2aa7775ab024d6fedd64\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004eeccdcff00c8336c5d616fee009894e5cbbc2bbf9497021aabbde81beaf8e6edf423de4ff094a8d4e7ea87d9469fd7d3b834b80d9b330d2f7a887108c5ea9268\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1559011814,\n \"txid\": \"fa78db71b5e4205ec33a69106f9c9528ed9289fa3f8efc51baebe6e514247287\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp6h32p99s\",\n \"sd_hash\": \"e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"size\": \"11\"\n }\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"muK7TZrirA8yHzxFcXa51W7CjxbAho2Zua\",\n \"amount\": \"1.0\",\n \"claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"timestamp\": 1559011813,\n \"txid\": \"3f665f0ca3cbb19c3c75813a30cd8334d7738a20566f2aa7775ab024d6fedd64\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004eeccdcff00c8336c5d616fee009894e5cbbc2bbf9497021aabbde81beaf8e6edf423de4ff094a8d4e7ea87d9469fd7d3b834b80d9b330d2f7a887108c5ea9268\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 2,\n \"total_pages\": 1\n }\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mzVz9QnHzyJ15wCFAYRt7bzLoeoBK83N8J\",\n \"amount\": \"1.0\",\n \"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_change\": false,\n \"is_channel_signature_valid\": true,\n \"is_mine\": true,\n \"name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"signing_channel\": {\n \"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"name\": \"@channel\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c5\",\n \"title\": \"New Channel\"\n }\n },\n \"timestamp\": 1558113064,\n \"txid\": \"b66c49273cb5f48f73f8e626523233da52aa1a64e7a3f90a0f053e7c96e2b5b7\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpip8uriwe\",\n \"sd_hash\": \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"size\": \"11\"\n }\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mvETNRY6cV97UJLKq9oD1YFQMzRi7ws3x3\",\n \"amount\": \"1.0\",\n \"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"timestamp\": 1558113063,\n \"txid\": \"beb82ace7faddbb1df58601df0e779865013151379b07428841f08e93c49fc87\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_pages\": 1\n }\n}"
}
]
},
{
"name": "claim_search",
"description": "Search for stream and channel claims on the blockchain.\n\nArguments marked with \"supports equality constraints\" allow prepending the\nvalue with an equality constraint such as '>', '>=', '<' and '<='\neg. --height=\">400000\" would limit results to only claims above 400k block height.",
"description": "Search for stream and channel claims on the blockchain.\n\nUse --channel_id=<channel_id> or --channel_name=<channel_name> to list all stream claims in a channel.",
"arguments": [
{
"name": "name",
"type": "str",
"description": "claim name (normalized)",
"description": "find claims with this name",
"is_required": false
},
{
"name": "claim_id",
"type": "str",
"description": "full or partial claim id",
"description": "find a claim with this claim_id",
"is_required": false
},
{
"name": "txid",
"type": "str",
"description": "transaction id",
"description": "find a claim with this txid:nout",
"is_required": false
},
{
"name": "nout",
"type": "str",
"description": "position in the transaction",
"description": "find a claim with this txid:nout",
"is_required": false
},
{
"name": "channel",
"name": "channel_id",
"type": "str",
"description": "claims signed by this channel (argument is a URL which automatically gets resolved), see --channel_ids if you need to filter by multiple channels at the same time, includes claims with invalid signatures, use in conjunction with --is_channel_signature_valid",
"description": "limit search to specific channel claim id (returns stream claims)",
"is_required": false
},
{
"name": "channel_ids",
"name": "channel_name",
"type": "str",
"description": "claims signed by any of these channels (arguments must be claim ids of the channels), includes claims with invalid signatures, use in conjunction with --is_channel_signature_valid",
"description": "limit search to specific channel name (returns stream claims)",
"is_required": false
},
{
"name": "is_channel_signature_valid",
"name": "winning",
"type": "bool",
"description": "only return claims with valid channel signatures",
"is_required": false
},
{
"name": "is_controlling",
"type": "bool",
"description": "only return winning claims of their respective name",
"is_required": false
},
{
"name": "height",
"type": "int",
"description": "last updated block height (supports equality constraints)",
"is_required": false
},
{
"name": "timestamp",
"type": "int",
"description": "last updated timestamp (supports equality constraints)",
"is_required": false
},
{
"name": "creation_height",
"type": "int",
"description": "created at block height (supports equality constraints)",
"is_required": false
},
{
"name": "creation_timestamp",
"type": "int",
"description": "created at timestamp (supports equality constraints)",
"is_required": false
},
{
"name": "activation_height",
"type": "int",
"description": "height at which claim starts competing for name (supports equality constraints)",
"is_required": false
},
{
"name": "expiration_height",
"type": "int",
"description": "height at which claim will expire (supports equality constraints)",
"is_required": false
},
{
"name": "release_time",
"type": "int",
"description": "limit to claims self-described as having been released to the public on or after this UTC timestamp, when claim does not provide a release time the publish time is used instead (supports equality constraints)",
"is_required": false
},
{
"name": "amount",
"type": "int",
"description": "limit by claim value (supports equality constraints)",
"is_required": false
},
{
"name": "support_amount",
"type": "int",
"description": "limit by supports and tips recieved (supports equality constraints)",
"is_required": false
},
{
"name": "effective_amount",
"type": "int",
"description": "limit by total value (initial claim value plus all tips and supports received), this amount is blank until claim has reached activation height (supports equality constraints)",
"is_required": false
},
{
"name": "trending_group",
"type": "int",
"description": "group numbers 1 through 4 representing the trending groups of the content: 4 means content is trending globally and independently, 3 means content is not trending globally but is trending independently (locally), 2 means it is trending globally but not independently and 1 means it's not trending globally or locally (supports equality constraints)",
"is_required": false
},
{
"name": "trending_mixed",
"type": "int",
"description": "trending amount taken from the global or local value depending on the trending group: 4 - global value, 3 - local value, 2 - global value, 1 - local value (supports equality constraints)",
"is_required": false
},
{
"name": "trending_local",
"type": "int",
"description": "trending value calculated relative only to the individual contents past history (supports equality constraints)",
"is_required": false
},
{
"name": "trending_global",
"type": "int",
"description": "trending value calculated relative to all trending content globally (supports equality constraints)",
"is_required": false
},
{
"name": "any_tags",
"type": "list",
"description": "find claims containing any of the tags",
"is_required": false
},
{
"name": "all_tags",
"type": "list",
"description": "find claims containing every tag",
"is_required": false
},
{
"name": "not_tags",
"type": "list",
"description": "find claims not containing any of these tags",
"is_required": false
},
{
"name": "any_languages",
"type": "list",
"description": "find claims containing any of the languages",
"is_required": false
},
{
"name": "all_languages",
"type": "list",
"description": "find claims containing every language",
"is_required": false
},
{
"name": "not_languages",
"type": "list",
"description": "find claims not containing any of these languages",
"is_required": false
},
{
"name": "any_locations",
"type": "list",
"description": "find claims containing any of the locations",
"is_required": false
},
{
"name": "all_locations",
"type": "list",
"description": "find claims containing every location",
"is_required": false
},
{
"name": "not_locations",
"type": "list",
"description": "find claims not containing any of these locations",
"description": "limit to winning claims",
"is_required": false
},
{
@@ -1564,29 +1420,23 @@
"type": "int",
"description": "number of items on page during pagination",
"is_required": false
},
{
"name": "order_by",
"type": "str",
"description": "field to order by, default is descending order, to do an ascending order prepend ^ to the field name, eg. '^amount' available fields: 'name', 'height', 'release_time', 'publish_time', 'amount', 'effective_amount', 'support_amount', 'trending_group', 'trending_mixed', 'trending_local', 'trending_global', 'activation_height'",
"is_required": false
}
],
"returns": " {\n \"page\": \"Page number of the current items.\",\n \"page_size\": \"Number of items to show on a page.\",\n \"total_pages\": \"Total number of pages.\",\n \"total_items\": \"Total number of items.\",\n \"items\": [\n {\n \"txid\": \"hash of transaction in hex\",\n \"nout\": \"position in the transaction\",\n \"height\": \"block where transaction was recorded\",\n \"amount\": \"value of the txo as a decimal\",\n \"address\": \"address of who can spend the txo\",\n \"confirmations\": \"number of confirmed blocks\",\n \"is_change\": \"payment to change address, only available when it can be determined\",\n \"is_mine\": \"payment to one of your accounts, only available when it can be determined\",\n \"type\": \"one of 'claim', 'support' or 'payment'\",\n \"name\": \"when type is 'claim' or 'support', this is the claim name\",\n \"claim_id\": \"when type is 'claim' or 'support', this is the claim id\",\n \"claim_op\": \"when type is 'claim', this determines if it is 'create' or 'update'\",\n \"value\": \"when type is 'claim' or 'support' with payload, this is the decoded protobuf payload\",\n \"value_type\": \"determines the type of the 'value' field: 'channel', 'stream', etc\",\n \"protobuf\": \"hex encoded raw protobuf version of 'value' field\",\n \"permanent_url\": \"when type is 'claim' or 'support', this is the long permanent claim URL\",\n \"signing_channel\": \"for signed claims only, metadata of signing channel\",\n \"is_channel_signature_valid\": \"for signed claims only, whether signature is valid\"\n }\n ]\n }",
"returns": " {\n \"page\": \"Page number of the current items.\",\n \"page_size\": \"Number of items to show on a page.\",\n \"total_pages\": \"Total number of pages.\",\n \"items\": [\n {\n \"txid\": \"hash of transaction in hex\",\n \"nout\": \"position in the transaction\",\n \"height\": \"block where transaction was recorded\",\n \"amount\": \"value of the txo as a decimal\",\n \"address\": \"address of who can spend the txo\",\n \"confirmations\": \"number of confirmed blocks\",\n \"is_change\": \"payment to change address, only available when it can be determined\",\n \"is_mine\": \"payment to one of your accounts, only available when it can be determined\",\n \"type\": \"one of 'claim', 'support' or 'payment'\",\n \"name\": \"when type is 'claim' or 'support', this is the claim name\",\n \"claim_id\": \"when type is 'claim' or 'support', this is the claim id\",\n \"claim_op\": \"when type is 'claim', this determines if it is 'create' or 'update'\",\n \"value\": \"when type is 'claim' or 'support' with payload, this is the decoded protobuf payload\",\n \"value_type\": \"determines the type of the 'value' field: 'channel', 'stream', etc\",\n \"protobuf\": \"hex encoded raw protobuf version of 'value' field\",\n \"permanent_url\": \"when type is 'claim' or 'support', this is the long permanent claim URL\",\n \"signing_channel\": \"for signed claims only, metadata of signing channel\",\n \"is_channel_signature_valid\": \"for signed claims only, whether signature is valid\"\n }\n ]\n }",
"examples": [
{
"title": "Search for all claims in channel",
"curl": "curl -d'{\"method\": \"claim_search\", \"params\": {\"channel\": \"@channel\", \"channel_ids\": [], \"is_channel_signature_valid\": false, \"is_controlling\": false, \"any_tags\": [], \"all_tags\": [], \"not_tags\": [], \"any_languages\": [], \"all_languages\": [], \"not_languages\": [], \"any_locations\": [], \"all_locations\": [], \"not_locations\": [], \"order_by\": []}}' http://localhost:5279/",
"lbrynet": "lbrynet claim search --channel=@channel",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_search\", \"params\": {\"channel\": \"@channel\", \"channel_ids\": [], \"is_channel_signature_valid\": false, \"is_controlling\": false, \"any_tags\": [], \"all_tags\": [], \"not_tags\": [], \"any_languages\": [], \"all_languages\": [], \"not_languages\": [], \"any_locations\": [], \"all_locations\": [], \"not_locations\": [], \"order_by\": []}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [],\n \"page\": 1,\n \"page_size\": 10,\n \"total_items\": 0,\n \"total_pages\": 0\n }\n}"
"curl": "curl -d'{\"method\": \"claim_search\", \"params\": {\"channel_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\", \"winning\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet claim search --channel_id=\"67193e65e8c0363f26aff251435cf1795e47e2f8\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_search\", \"params\": {\"channel_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\", \"winning\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"absolute_channel_position\": 0,\n \"address\": \"mzVz9QnHzyJ15wCFAYRt7bzLoeoBK83N8J\",\n \"amount\": \"1.0\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"claim_sequence\": -1,\n \"confirmations\": 1,\n \"decoded_claim\": true,\n \"effective_amount\": \"1.0\",\n \"has_signature\": true,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"protobuf\": \"01f8e2475e79f15c4351f2af263f36c0e8653e1967128556beabb3c0f3216a15825a50d9f22326fff3c4f8b53089ced7fed5b66aaf3eb00db47aba375985ea1440e0ddee48e5ef9e695688f8d31284f25ab37ebc5b0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706970387572697765180b22186170706c69636174696f6e2f6f637465742d73747265616d323006310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"signature_is_valid\": true,\n \"signing_channel\": {\n \"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"name\": \"@channel\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c5\",\n \"title\": \"New Channel\"\n }\n },\n \"supports\": [],\n \"timestamp\": 1558113064,\n \"txid\": \"b66c49273cb5f48f73f8e626523233da52aa1a64e7a3f90a0f053e7c96e2b5b7\",\n \"valid_at_height\": 214,\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpip8uriwe\",\n \"sd_hash\": \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"size\": \"11\"\n }\n }\n }\n ],\n \"page\": 1,\n \"page_size\": 10,\n \"total_pages\": 1\n }\n}"
},
{
"title": "Search for claims matching a name",
"curl": "curl -d'{\"method\": \"claim_search\", \"params\": {\"name\": \"astream\", \"channel_ids\": [], \"is_channel_signature_valid\": false, \"is_controlling\": false, \"any_tags\": [], \"all_tags\": [], \"not_tags\": [], \"any_languages\": [], \"all_languages\": [], \"not_languages\": [], \"any_locations\": [], \"all_locations\": [], \"not_locations\": [], \"order_by\": []}}' http://localhost:5279/",
"curl": "curl -d'{\"method\": \"claim_search\", \"params\": {\"name\": \"astream\", \"winning\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet claim search --name=\"astream\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_search\", \"params\": {\"name\": \"astream\", \"channel_ids\": [], \"is_channel_signature_valid\": false, \"is_controlling\": false, \"any_tags\": [], \"all_tags\": [], \"not_tags\": [], \"any_languages\": [], \"all_languages\": [], \"not_languages\": [], \"any_locations\": [], \"all_locations\": [], \"not_locations\": [], \"order_by\": []}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [],\n \"page\": 1,\n \"page_size\": 10,\n \"total_items\": 0,\n \"total_pages\": 0\n }\n}"
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_search\", \"params\": {\"name\": \"astream\", \"winning\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mzVz9QnHzyJ15wCFAYRt7bzLoeoBK83N8J\",\n \"amount\": \"1.0\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"claim_sequence\": -1,\n \"confirmations\": 1,\n \"decoded_claim\": true,\n \"effective_amount\": \"1.0\",\n \"has_signature\": true,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"protobuf\": \"01f8e2475e79f15c4351f2af263f36c0e8653e1967128556beabb3c0f3216a15825a50d9f22326fff3c4f8b53089ced7fed5b66aaf3eb00db47aba375985ea1440e0ddee48e5ef9e695688f8d31284f25ab37ebc5b0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706970387572697765180b22186170706c69636174696f6e2f6f637465742d73747265616d323006310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"signature_is_valid\": true,\n \"signing_channel\": {\n \"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"name\": \"@channel\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c5\",\n \"title\": \"New Channel\"\n }\n },\n \"supports\": [],\n \"timestamp\": 1558113064,\n \"txid\": \"b66c49273cb5f48f73f8e626523233da52aa1a64e7a3f90a0f053e7c96e2b5b7\",\n \"valid_at_height\": 214,\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpip8uriwe\",\n \"sd_hash\": \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"size\": \"11\"\n }\n }\n }\n ],\n \"page\": 1,\n \"page_size\": 1,\n \"total_pages\": 1\n }\n}"
}
]
}
@@ -1733,9 +1583,9 @@
"examples": [
{
"title": "Delete a file",
"curl": "curl -d'{\"method\": \"file_delete\", \"params\": {\"delete_from_download_dir\": false, \"delete_all\": false, \"claim_id\": \"ffdbe8f44f285fbc4a352763727abd86d17399c1\"}}' http://localhost:5279/",
"lbrynet": "lbrynet file delete --claim_id=\"ffdbe8f44f285fbc4a352763727abd86d17399c1\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_delete\", \"params\": {\"delete_from_download_dir\": false, \"delete_all\": false, \"claim_id\": \"ffdbe8f44f285fbc4a352763727abd86d17399c1\"}}).json()",
"curl": "curl -d'{\"method\": \"file_delete\", \"params\": {\"delete_from_download_dir\": false, \"delete_all\": false, \"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\"}}' http://localhost:5279/",
"lbrynet": "lbrynet file delete --claim_id=\"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_delete\", \"params\": {\"delete_from_download_dir\": false, \"delete_all\": false, \"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": true\n}"
}
]
@@ -1842,14 +1692,14 @@
"curl": "curl -d'{\"method\": \"file_list\", \"params\": {\"reverse\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet file list",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_list\", \"params\": {\"reverse\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": -1,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": -1,\n \"key\": \"1441a34034b2dbc19094f1c7b164680c\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp6h32p99s\",\n \"sd_hash\": \"e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"size\": \"11\"\n }\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"fa78db71b5e4205ec33a69106f9c9528ed9289fa3f8efc51baebe6e514247287:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"016d1a9d18447522cfe3eb8acf4b56a63e7edf2b68fdfdb7869eb7447ab2e61a2d5cdf8199867bda63dd1edc699b7dee31d618198502a11309baff2f6d52104f494ca48ff9e5961c5a00badba23fcfeb010f595fc10a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d703668333270393973180b22186170706c69636174696f6e2f6f637465742d73747265616d3230e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"sd_hash\": \"e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"e5189cf47e5bdecdef6ec77874410bf7d57ac71ccfb4e6588311a7375c890e513be365538d51068fe97a0c21a8e389e0\",\n \"stream_name\": \"tmp6h32p99s\",\n \"streaming_url\": \"http://localhost:5280/stream/e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"suggested_file_name\": \"tmp6h32p99s\",\n \"timestamp\": null,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"fa78db71b5e4205ec33a69106f9c9528ed9289fa3f8efc51baebe6e514247287\",\n \"written_bytes\": null\n },\n {\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"e90a079b038cabe2782bc6a5b4f55f4e5febc5a1\",\n \"claim_name\": \"blank-image\",\n \"completed\": true,\n \"confirmations\": -1,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": -1,\n \"key\": \"81146b05970a6504588868483783fb9d\",\n \"metadata\": {\n \"author\": \"Picaso\",\n \"description\": \"A blank PNG that is 5x7.\",\n \"fee\": {\n \"address\": \"mhgGjVVY6kjrAxf2cz1ALfbst6CQhZ72qg\",\n \"amount\": \"0.3\",\n \"currency\": \"LBC\"\n },\n \"image\": {\n \"height\": 7,\n \"width\": 5\n },\n \"languages\": [\n \"en\"\n ],\n \"license\": \"Public Domain\",\n \"license_url\": \"http://public-domain.org\",\n \"locations\": [\n {\n \"city\": \"Manchester\",\n \"country\": \"US\",\n \"state\": \"NH\"\n }\n ],\n \"release_time\": \"1559011789\",\n \"source\": {\n \"hash\": \"6c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545\",\n \"media_type\": \"image/png\",\n \"name\": \"tmpg0gz6g_3.png\",\n \"sd_hash\": \"a76d75a13ff15d946f929115e248dd411996abea4e1f37f73a72ba82fcd39a0dbbb3a3777e767984cd30e9eef2b68312\",\n \"size\": \"99\"\n },\n \"stream_type\": \"image\",\n \"tags\": [\n \"blank\",\n \"art\"\n ],\n \"thumbnail\": {\n \"url\": \"http://smallmedia.com/thumbnail.jpg\"\n },\n \"title\": \"Blank Image\"\n },\n \"mime_type\": \"image/png\",\n \"nout\": 0,\n \"outpoint\": \"5faad4dc0519a4861480b7386e58e0857801ec6d13ba2a308449546ce4d18928:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"016d1a9d18447522cfe3eb8acf4b56a63e7edf2b688f6d18586c20043e6f4852d49b4ade3732b787c4bf1335d57b0bbd87bdf4720f75eda1765146eb1bf653b82823ec8716d72920fcc8849d3ce0885ff89cb7f1ac0ae6010a82010a306c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545120Line truncated
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 3,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": 214,\n \"key\": \"44bb79917c27efbb9014f8bbc78e3eeb\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpip8uriwe\",\n \"sd_hash\": \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"size\": \"11\"\n }\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"b66c49273cb5f48f73f8e626523233da52aa1a64e7a3f90a0f053e7c96e2b5b7:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01f8e2475e79f15c4351f2af263f36c0e8653e1967128556beabb3c0f3216a15825a50d9f22326fff3c4f8b53089ced7fed5b66aaf3eb00db47aba375985ea1440e0ddee48e5ef9e695688f8d31284f25ab37ebc5b0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706970387572697765180b22186170706c69636174696f6e2f6f637465742d73747265616d323006310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"sd_hash\": \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"ef42dee59a9efc14a5611b1bb1a300b2fb5cfb92acf8e9a2034ddf341c42fc9293efef53761751fdcfec53ac74837b6a\",\n \"stream_name\": \"tmpip8uriwe\",\n \"streaming_url\": \"http://localhost:5280/stream/06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"suggested_file_name\": \"tmpip8uriwe\",\n \"timestamp\": 1558113064,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"b66c49273cb5f48f73f8e626523233da52aa1a64e7a3f90a0f053e7c96e2b5b7\",\n \"written_bytes\": null\n },\n {\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"20edd2806f871fd5137173e2c8500d3e40bbb28f\",\n \"claim_name\": \"blank-image\",\n \"completed\": true,\n \"confirmations\": -1,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": -1,\n \"key\": \"7d9e3e8063f9aefd46cfb9047130855a\",\n \"metadata\": {\n \"author\": \"Picaso\",\n \"description\": \"A blank PNG that is 5x7.\",\n \"fee\": {\n \"address\": \"mh3A5mCcB1BWRk2qP3dwzEToC58fNymxQq\",\n \"amount\": \"0.3\",\n \"currency\": \"LBC\"\n },\n \"image\": {\n \"height\": 7,\n \"width\": 5\n },\n \"languages\": [\n \"en\"\n ],\n \"license\": \"Public Domain\",\n \"license_url\": \"http://public-domain.org\",\n \"locations\": [\n {\n \"city\": \"Manchester\",\n \"country\": \"US\",\n \"state\": \"NH\"\n }\n ],\n \"release_time\": \"1558113038\",\n \"source\": {\n \"hash\": \"6c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545\",\n \"media_type\": \"image/png\",\n \"name\": \"tmph7izwd1p.png\",\n \"sd_hash\": \"fb5be9ad617fd756b29c835efb11e6fa44a301b7a506bb72d58108a0f276a6bf86591e0bce04525d098440fb9f5b286a\",\n \"size\": \"99\"\n },\n \"stream_type\": \"image\",\n \"tags\": [\n \"blank\",\n \"art\"\n ],\n \"thumbnail\": {\n \"url\": \"http://smallmedia.com/thumbnail.jpg\"\n },\n \"title\": \"Blank Image\"\n },\n \"mime_type\": \"image/png\",\n \"nout\": 0,\n \"outpoint\": \"6a2686e4b2887b4d14766e7d447c6b76d788152e12b705f13000adec63b7a611:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01f8e2475e79f15c4351f2af263f36c0e8653e1967e9c30300f2db8da744b33f3c1beb0f0d1f8b09607a591fd6eefdb99e487b303454a5b77b6a7d45afd612902f615de4084a65e6a104e7d0b938a94cf075aa9ce40ae6010a82010a306c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1Line truncated
},
{
"title": "List files matching a parameter",
"curl": "curl -d'{\"method\": \"file_list\", \"params\": {\"claim_id\": \"ffdbe8f44f285fbc4a352763727abd86d17399c1\", \"reverse\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet file list --claim_id=\"ffdbe8f44f285fbc4a352763727abd86d17399c1\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_list\", \"params\": {\"claim_id\": \"ffdbe8f44f285fbc4a352763727abd86d17399c1\", \"reverse\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 3,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": 214,\n \"key\": \"1441a34034b2dbc19094f1c7b164680c\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp6h32p99s\",\n \"sd_hash\": \"e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"size\": \"11\"\n }\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"fa78db71b5e4205ec33a69106f9c9528ed9289fa3f8efc51baebe6e514247287:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"016d1a9d18447522cfe3eb8acf4b56a63e7edf2b68fdfdb7869eb7447ab2e61a2d5cdf8199867bda63dd1edc699b7dee31d618198502a11309baff2f6d52104f494ca48ff9e5961c5a00badba23fcfeb010f595fc10a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d703668333270393973180b22186170706c69636174696f6e2f6f637465742d73747265616d3230e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"sd_hash\": \"e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"e5189cf47e5bdecdef6ec77874410bf7d57ac71ccfb4e6588311a7375c890e513be365538d51068fe97a0c21a8e389e0\",\n \"stream_name\": \"tmp6h32p99s\",\n \"streaming_url\": \"http://localhost:5280/stream/e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"suggested_file_name\": \"tmp6h32p99s\",\n \"timestamp\": 1559011814,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"fa78db71b5e4205ec33a69106f9c9528ed9289fa3f8efc51baebe6e514247287\",\n \"written_bytes\": null\n }\n ]\n}"
"curl": "curl -d'{\"method\": \"file_list\", \"params\": {\"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\", \"reverse\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet file list --claim_id=\"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_list\", \"params\": {\"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\", \"reverse\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 3,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": 214,\n \"key\": \"44bb79917c27efbb9014f8bbc78e3eeb\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpip8uriwe\",\n \"sd_hash\": \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"size\": \"11\"\n }\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"b66c49273cb5f48f73f8e626523233da52aa1a64e7a3f90a0f053e7c96e2b5b7:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01f8e2475e79f15c4351f2af263f36c0e8653e1967128556beabb3c0f3216a15825a50d9f22326fff3c4f8b53089ced7fed5b66aaf3eb00db47aba375985ea1440e0ddee48e5ef9e695688f8d31284f25ab37ebc5b0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706970387572697765180b22186170706c69636174696f6e2f6f637465742d73747265616d323006310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"sd_hash\": \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"ef42dee59a9efc14a5611b1bb1a300b2fb5cfb92acf8e9a2034ddf341c42fc9293efef53761751fdcfec53ac74837b6a\",\n \"stream_name\": \"tmpip8uriwe\",\n \"streaming_url\": \"http://localhost:5280/stream/06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"suggested_file_name\": \"tmpip8uriwe\",\n \"timestamp\": 1558113064,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"b66c49273cb5f48f73f8e626523233da52aa1a64e7a3f90a0f053e7c96e2b5b7\",\n \"written_bytes\": null\n }\n ]\n}"
}
]
},
@@ -1966,10 +1816,10 @@
"examples": [
{
"title": "Save a file to the downloads directory",
"curl": "curl -d'{\"method\": \"file_save\", \"params\": {\"sd_hash\": \"e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\"}}' http://localhost:5279/",
"lbrynet": "lbrynet file save --sd_hash=\"e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_save\", \"params\": {\"sd_hash\": \"e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 3,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": 214,\n \"key\": \"1441a34034b2dbc19094f1c7b164680c\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp6h32p99s\",\n \"sd_hash\": \"e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"size\": \"11\"\n }\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"fa78db71b5e4205ec33a69106f9c9528ed9289fa3f8efc51baebe6e514247287:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"016d1a9d18447522cfe3eb8acf4b56a63e7edf2b68fdfdb7869eb7447ab2e61a2d5cdf8199867bda63dd1edc699b7dee31d618198502a11309baff2f6d52104f494ca48ff9e5961c5a00badba23fcfeb010f595fc10a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d703668333270393973180b22186170706c69636174696f6e2f6f637465742d73747265616d3230e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"sd_hash\": \"e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"status\": \"running\",\n \"stopped\": false,\n \"stream_hash\": \"e5189cf47e5bdecdef6ec77874410bf7d57ac71ccfb4e6588311a7375c890e513be365538d51068fe97a0c21a8e389e0\",\n \"stream_name\": \"tmp6h32p99s\",\n \"streaming_url\": \"http://localhost:5280/stream/e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"suggested_file_name\": \"tmp6h32p99s\",\n \"timestamp\": 1559011814,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"fa78db71b5e4205ec33a69106f9c9528ed9289fa3f8efc51baebe6e514247287\",\n \"written_bytes\": null\n }\n}"
"curl": "curl -d'{\"method\": \"file_save\", \"params\": {\"sd_hash\": \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\"}}' http://localhost:5279/",
"lbrynet": "lbrynet file save --sd_hash=\"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_save\", \"params\": {\"sd_hash\": \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 3,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": 214,\n \"key\": \"44bb79917c27efbb9014f8bbc78e3eeb\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpip8uriwe\",\n \"sd_hash\": \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"size\": \"11\"\n }\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"b66c49273cb5f48f73f8e626523233da52aa1a64e7a3f90a0f053e7c96e2b5b7:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01f8e2475e79f15c4351f2af263f36c0e8653e1967128556beabb3c0f3216a15825a50d9f22326fff3c4f8b53089ced7fed5b66aaf3eb00db47aba375985ea1440e0ddee48e5ef9e695688f8d31284f25ab37ebc5b0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706970387572697765180b22186170706c69636174696f6e2f6f637465742d73747265616d323006310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"sd_hash\": \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"status\": \"running\",\n \"stopped\": false,\n \"stream_hash\": \"ef42dee59a9efc14a5611b1bb1a300b2fb5cfb92acf8e9a2034ddf341c42fc9293efef53761751fdcfec53ac74837b6a\",\n \"stream_name\": \"tmpip8uriwe\",\n \"streaming_url\": \"http://localhost:5280/stream/06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"suggested_file_name\": \"tmpip8uriwe\",\n \"timestamp\": 1558113064,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"b66c49273cb5f48f73f8e626523233da52aa1a64e7a3f90a0f053e7c96e2b5b7\",\n \"written_bytes\": null\n }\n}"
}
]
},
@@ -2059,7 +1909,7 @@
"curl": "curl -d'{\"method\": \"settings_get\", \"params\": {}}' http://localhost:5279/",
"lbrynet": "lbrynet settings get",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"settings_get\", \"params\": {}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"announce_head_and_sd_only\": true,\n \"api\": \"localhost:5279\",\n \"blob_download_timeout\": 30.0,\n \"blob_lru_cache_size\": 0,\n \"blockchain_name\": \"lbrycrd_regtest\",\n \"cache_time\": 150,\n \"comment_server\": \"http://comments.lbry.com:2903/api\",\n \"components_to_skip\": [\n \"dht\",\n \"upnp\",\n \"hash_announcer\",\n \"peer_protocol_server\"\n ],\n \"concurrent_blob_announcers\": 10,\n \"concurrent_reflector_uploads\": 10,\n \"config\": \"/home/lex/.local/share/lbry/lbrynet/daemon_settings.yml\",\n \"data_dir\": \"/tmp/tmpf06o5qj4\",\n \"download_dir\": \"/tmp/tmpf06o5qj4\",\n \"download_timeout\": 30.0,\n \"fixed_peer_delay\": 2.0,\n \"known_dht_nodes\": [],\n \"lbryum_servers\": [\n [\n \"127.0.0.1\",\n 50001\n ]\n ],\n \"max_connections_per_download\": 4,\n \"max_key_fee\": {\n \"amount\": 50.0,\n \"currency\": \"USD\"\n },\n \"network_interface\": \"0.0.0.0\",\n \"node_rpc_timeout\": 5.0,\n \"peer_connect_timeout\": 3.0,\n \"reflect_streams\": true,\n \"reflector_servers\": [\n [\n \"127.0.0.1\",\n 5566\n ]\n ],\n \"s3_headers_depth\": 960,\n \"save_blobs\": true,\n \"save_files\": true,\n \"share_usage_data\": false,\n \"split_buckets_under_index\": 1,\n \"streaming_get\": true,\n \"streaming_server\": \"localhost:5280\",\n \"tcp_port\": 3333,\n \"udp_port\": 4444,\n \"use_upnp\": false,\n \"wallet_dir\": \"/tmp/tmpf06o5qj4\"\n }\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"announce_head_and_sd_only\": true,\n \"api\": \"localhost:5279\",\n \"blob_download_timeout\": 30.0,\n \"blockchain_name\": \"lbrycrd_regtest\",\n \"cache_time\": 150,\n \"comment_server\": \"http://comments.lbry.com:2903/api\",\n \"components_to_skip\": [\n \"dht\",\n \"upnp\",\n \"hash_announcer\",\n \"peer_protocol_server\"\n ],\n \"concurrent_blob_announcers\": 10,\n \"concurrent_reflector_uploads\": 10,\n \"config\": \"/home/jack/.lbrynet/daemon_settings.yml\",\n \"data_dir\": \"/tmp/tmpnk2c4f2x\",\n \"download_dir\": \"/tmp/tmpnk2c4f2x\",\n \"download_timeout\": 30.0,\n \"fixed_peer_delay\": 2.0,\n \"known_dht_nodes\": [],\n \"lbryum_servers\": [\n [\n \"127.0.0.1\",\n 50001\n ]\n ],\n \"max_connections_per_download\": 4,\n \"max_key_fee\": {\n \"amount\": 50.0,\n \"currency\": \"USD\"\n },\n \"network_interface\": \"0.0.0.0\",\n \"node_rpc_timeout\": 5.0,\n \"peer_connect_timeout\": 3.0,\n \"reflect_streams\": true,\n \"reflector_servers\": [\n [\n \"127.0.0.1\",\n 5566\n ]\n ],\n \"s3_headers_depth\": 960,\n \"save_blobs\": true,\n \"save_files\": true,\n \"share_usage_data\": false,\n \"split_buckets_under_index\": 1,\n \"streaming_get\": true,\n \"streaming_server\": \"localhost:5280\",\n \"tcp_port\": 3333,\n \"udp_port\": 4444,\n \"use_upnp\": false,\n \"wallet_dir\": \"/tmp/tmpnk2c4f2x\"\n }\n}"
}
]
},
@@ -2120,10 +1970,10 @@
"examples": [
{
"title": "Abandon a stream claim",
"curl": "curl -d'{\"method\": \"stream_abandon\", \"params\": {\"claim_id\": \"ffdbe8f44f285fbc4a352763727abd86d17399c1\", \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream abandon ffdbe8f44f285fbc4a352763727abd86d17399c1",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_abandon\", \"params\": {\"claim_id\": \"ffdbe8f44f285fbc4a352763727abd86d17399c1\", \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000187722414e5e6ebba51fc8e3ffa8992ed28959c6f10693ac35e20e4b571db78fa000000006b483045022100a387d3d1bbd1d7473c3d0285344b4d4fef9cfd2ec54ad3f40b2edd6852068d4802206e81afbd2b2dc48bdf2b89227aaebcf2f2f8448530125beb8cd3ac861f0ee745012102700c310dacc983a7cfe3187c0913373c956fbb5f850a13043c2897f2da825120ffffffff0134b7f505000000001976a914b70f37bc1d9a6cef8d47db72a4267c957193fe7d88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mg5Gn2NmJFVpZUU1ScVKf34KXVmJsrxXeu\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"claim_op\": \"update\",\n \"confirmations\": 3,\n \"height\": 214,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"signing_channel\": {\n \"address\": \"muK7TZrirA8yHzxFcXa51W7CjxbAho2Zua\",\n \"amount\": \"1.0\",\n \"claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"claim_op\": \"update\",\n \"confirmations\": 7,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"timestamp\": 1559011813,\n \"txid\": \"3f665f0ca3cbb19c3c75813a30cd8334d7738a20566f2aa7775ab024d6fedd64\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004eeccdcff00c8336c5d616fee009894e5cbbc2bbf9497021aabbde81beaf8e6edf423de4ff094a8d4e7ea87d9469fd7d3b834b80d9b330d2f7a887108c5ea9268\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1559011814,\n \"txid\": \"fa78db71b5e4205ec33a69106f9c9528ed9289fa3f8efc51baebe6e514247287\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp6h32p99s\",\n \"sd_hash\": \"e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"size\": \"11\"\n }\n },\n \"value_type\": \"stream\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mxCtBWCjYjg56RoikBbn6GTFdBGBH89NdT\",\n \"amount\": \"0.999893\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"715f7493f78217a0a1f15094563adc0e09ea443b748713eea766f8d492f21815\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000107\",\n \"total_input\": \"1.0\",\n \"total_output\": \"0.999893\",\n \"txid\": \"715f7493f78217a0a1f15094563adc0e09ea443b748713eea766f8d492f21815\"\n }\n}"
"curl": "curl -d'{\"method\": \"stream_abandon\", \"params\": {\"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\", \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream abandon 2606a71cd812c77bc3dc76ecc3727e0368b1af6d",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_abandon\", \"params\": {\"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\", \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001b7b5e2967c3e050f0af9a3e7641aaa52da33325226e6f8738ff4b53c27496cb6000000006b483045022100d560713a5a8d9369754bbe3c861331642f0095a7e9c34560b2efe17c9adc1f07022076d2a9e52de7062a27e36c38c6da5239b31fa3531f0b04411fb22b6b6d8623fd01210248599b7ed9d22dc6e1569332c54749b5f9c02402a49a98da5c92ef3df448f113ffffffff0134b7f505000000001976a914ce70166483a78ef6018c6766c68c0b0442fc9e6e88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mzVz9QnHzyJ15wCFAYRt7bzLoeoBK83N8J\",\n \"amount\": \"1.0\",\n \"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"claim_op\": \"update\",\n \"confirmations\": 3,\n \"height\": 214,\n \"is_change\": false,\n \"is_mine\": true,\n \"name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"signing_channel\": {\n \"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"name\": \"@channel\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c5\",\n \"title\": \"New Channel\"\n }\n },\n \"timestamp\": 1558113064,\n \"txid\": \"b66c49273cb5f48f73f8e626523233da52aa1a64e7a3f90a0f053e7c96e2b5b7\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpip8uriwe\",\n \"sd_hash\": \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"size\": \"11\"\n }\n },\n \"value_type\": \"stream\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mzLVmYa3EbjZcnZJQ9g3LrEJ7Kj4HL1Wmi\",\n \"amount\": \"0.999893\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"b55ff6c7813dbc1759b701f6273811d9a386ce40b10ff5571aec661a7b880682\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000107\",\n \"total_input\": \"1.0\",\n \"total_output\": \"0.999893\",\n \"txid\": \"b55ff6c7813dbc1759b701f6273811d9a386ce40b10ff5571aec661a7b880682\"\n }\n}"
}
]
},
@@ -2306,17 +2156,17 @@
"examples": [
{
"title": "Create a stream claim without metadata",
"curl": "curl -d'{\"method\": \"stream_create\", \"params\": {\"name\": \"astream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmp6h32p99s\", \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"preview\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream create astream 1.0 /tmp/tmp6h32p99s",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_create\", \"params\": {\"name\": \"astream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmp6h32p99s\", \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"preview\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000019ace2abc443770abd15bd7d7a0f50d7901aa8b09f3bd921b4631214436836a1e010000006b483045022100bcb08cbd4591cafdbd6a45ad159d5d3a1d5b690a45afa00788044f04d8b2959b02202f746fe20222c7502bef41fe052abef118d97df7e0723e04afa13913abdec276012102500d97c6528fc25ed450b3ad8e62934e5400cc601941e5a4f8b250c8a88f7a3dffffffff0200e1f50500000000bab5076173747265616d4c94000a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d703668333270393973180b22186170706c69636174696f6e2f6f637465742d73747265616d3230e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e06d7576a914061cbd2df8421ab14497e62baf747461c7c9137b88ac38fb9423000000001976a914c1c932e896b2e8073e6da13a87111deba2b5f97588ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mq1SLhoqW2g3qY1eGpcp2r5Xw1Vf19ocP8\",\n \"amount\": \"6.983769\",\n \"confirmations\": 4,\n \"height\": 209,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1559011813,\n \"txid\": \"1e6a8336442131461b92bdf3098baa01790df5a0d7d75bd1ab703744bc2ace9a\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mg5Gn2NmJFVpZUU1ScVKf34KXVmJsrxXeu\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"timestamp\": null,\n \"txid\": \"ad2d9b984b2a9e923b12f7652dd9a945664f647e9ead8779fd9b240a68301442\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp6h32p99s\",\n \"sd_hash\": \"e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"size\": \"11\"\n }\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"myBbjcsUMBsTi5aA1Y3FQr3eXZHTkTKjGn\",\n \"amount\": \"5.969662\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"ad2d9b984b2a9e923b12f7652dd9a945664f647e9ead8779fd9b240a68301442\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.014107\",\n \"total_input\": \"6.983769\",\n \"total_output\": \"6.969662\",\n \"txid\": \"ad2d9b984b2a9e923b12f7652dd9a945664f647e9ead8779fd9b240a68301442\"\n }\n}"
"curl": "curl -d'{\"method\": \"stream_create\", \"params\": {\"name\": \"astream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpip8uriwe\", \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"preview\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream create astream 1.0 /tmp/tmpip8uriwe",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_create\", \"params\": {\"name\": \"astream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpip8uriwe\", \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"preview\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000150d1ca558876aef02a4dab31491d6ef9f87181df871eb62483d32fd97cff40e9010000006b483045022100ade1d56753cee6dd79ea183dd7389ecc051265361d6066b146406da91588cf9702204a57095efa8618089d8e3d1e8f3806df2e221a62c23e489c540747c12d4a4a1d012102e4f371b1ecf18107102c17cd564b9649f6c45ccb605691c5a80c7c94c54acd64ffffffff0200e1f50500000000bab5076173747265616d4c94000a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706970387572697765180b22186170706c69636174696f6e2f6f637465742d73747265616d323006310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a0424626d7576a914d03b84e073b9094b455ff6b00d33fa88d2810f2188ac38fb9423000000001976a9144205724c6bbfdfd050bf1d0866338b7d11207a8488ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mrWGKtehqRNHX1qo9DiQbTu8vUVmTx3AJE\",\n \"amount\": \"6.983769\",\n \"confirmations\": 4,\n \"height\": 209,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1558113063,\n \"txid\": \"e940ff7cd92fd38324b61e87df8171f8f96e1d4931ab4d2af0ae768855cad150\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mzVz9QnHzyJ15wCFAYRt7bzLoeoBK83N8J\",\n \"amount\": \"1.0\",\n \"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"timestamp\": null,\n \"txid\": \"5d885f1883b8119fe5ff86463198d275833fbd59fceda1d2c2a3e3a42e4554de\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpip8uriwe\",\n \"sd_hash\": \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"size\": \"11\"\n }\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mmY3R9EcmdQTb5p8hxGHSpD9rou8ki41yN\",\n \"amount\": \"5.969662\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"5d885f1883b8119fe5ff86463198d275833fbd59fceda1d2c2a3e3a42e4554de\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.014107\",\n \"total_input\": \"6.983769\",\n \"total_output\": \"6.969662\",\n \"txid\": \"5d885f1883b8119fe5ff86463198d275833fbd59fceda1d2c2a3e3a42e4554de\"\n }\n}"
},
{
"title": "Create an image stream claim with all metadata and fee",
"curl": "curl -d'{\"method\": \"stream_create\", \"params\": {\"name\": \"blank-image\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpg0gz6g_3.png\", \"fee_currency\": \"LBC\", \"fee_amount\": \"0.3\", \"title\": \"Blank Image\", \"description\": \"A blank PNG that is 5x7.\", \"author\": \"Picaso\", \"tags\": [\"blank\", \"art\"], \"languages\": [\"en\"], \"locations\": [\"US:NH:Manchester\"], \"license\": \"Public Domain\", \"license_url\": \"http://public-domain.org\", \"thumbnail_url\": \"http://smallmedia.com/thumbnail.jpg\", \"release_time\": 1559011789, \"channel_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\", \"channel_account_id\": [], \"preview\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream create blank-image 1.0 /tmp/tmpg0gz6g_3.png --tags=blank --tags=art --languages=en --locations=US:NH:Manchester --fee_currency=LBC --fee_amount=0.3 --title=\"Blank Image\" --description=\"A blank PNG that is 5x7.\" --author=Picaso --license=\"Public Domain\" --license_url=http://public-domain.org --thumbnail_url=\"http://smallmedia.com/thumbnail.jpg\" --release_time=1559011789 --channel_id=\"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_create\", \"params\": {\"name\": \"blank-image\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpg0gz6g_3.png\", \"fee_currency\": \"LBC\", \"fee_amount\": \"0.3\", \"title\": \"Blank Image\", \"description\": \"A blank PNG that is 5x7.\", \"author\": \"Picaso\", \"tags\": [\"blank\", \"art\"], \"languages\": [\"en\"], \"locations\": [\"US:NH:Manchester\"], \"license\": \"Public Domain\", \"license_url\": \"http://public-domain.org\", \"thumbnail_url\": \"http://smallmedia.com/thumbnail.jpg\", \"release_time\": 1559011789, \"channel_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\", \"channel_account_id\": [], \"preview\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001421430680a249bfd7987ad9e7e644f6645a9d92d65f7123b929e2a4b989b2dad010000006b483045022100f90b38c9fd9f7b6489a17ca1af70b04b10b544c72b571b85501d465807b8bcbf02205edbc843f9a033d49a95ad1f0846c122cc5858fa3da8feba6efe91c899899225012102b7475e6b3d7641d46a7c7de4e6ba758e1730873b8d3edc388f04ee63df093ac3ffffffff0200e1f50500000000fddc01b50b626c616e6b2d696d6167654db101016d1a9d18447522cfe3eb8acf4b56a63e7edf2b688f6d18586c20043e6f4852d49b4ade3732b787c4bf1335d57b0bbd87bdf4720f75eda1765146eb1bf653b82823ec8716d72920fcc8849d3ce0885ff89cb7f1ac0ae6010a82010a306c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545120f746d706730677a36675f332e706e6718632209696d6167652f706e673230a76d75a13ff15d946f929115e248dd411996abea4e1f37f73a72ba82fcd39a0dbbb3a3777e767984cd30e9eef2b68312120650696361736f1a0d5075626c696320446f6d61696e2218687474703a2f2f7075626c69632d646f6d61696e2e6f726728cdc3b2e7053222080112196f17b363112d0b4907e7bf652c16c5261696179baf4b16065b188087a70e520408051007420b426c616e6b20496d6167654a184120626c616e6b20504e472074686174206973203578372e52252a23687474703a2f2f736d616c6c6d656469612e636f6d2f7468756d626e61696c2e6a70675a05626c616e6b5a03617274620208016a1308ec0112024e481a0a4d616e636865737465726d7576a91417b363112d0b4907e7bf652c16c5261696179baf88acac5e7d1d000000001976a91488b3555c5e06d6049bbe5426b72512f6d568b9e388ac00000000\",\n \"inputs\": [\n {\n \"address\": \"myBbjcsUMBsTi5aA1Y3FQr3eXZHTkTKjGn\",\n \"amount\": \"5.969662\",\n \"confirmations\": 2,\n \"height\": 213,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1559011814,\n \"txid\": \"ad2d9b984b2a9e923b12f7652dd9a945664f647e9ead8779fd9b240a68301442\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mhgGjVVY6kjrAxf2cz1ALfbst6CQhZ72qg\",\n \"amount\": \"1.0\",\n \"claim_id\": \"e90a079b038cabe2782bc6a5b4f55f4e5febc5a1\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"is_channel_signature_valid\": true,\n \"meta\": {},\n \"name\": \"blank-image\",\n \"normalized_name\": \"blank-image\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://blank-image#e90a079b038cabe2782bc6a5b4f55f4e5febc5a1\",\n \"signing_channel\": {\n \"address\": \"muK7TZrirA8yHzxFcXa51W7CjxbAho2Zua\",\n \"amount\": \"1.0\",\n \"claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"timestamp\": 1559011813,\n \"txid\": \"3f665f0ca3cbb19c3c75813a30cd8334d7738a20566f2aa7775ab024d6fedd64\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004eeccdcff00c8336c5d616fee009894e5cbbc2bbf9497021aabbde81beaf8e6edf423de4ff094a8d4e7ea87d9469fd7d3b834b80d9b330d2f7a887108c5ea9268\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": null,\n \"txid\": \"5faad4dc0519a4861480b7386e58e0857801ec6d13ba2a308449546ce4d18928\",\n \"type\": \"claim\",\n \"value\": {\n \"author\": \"Picaso\",\n \"description\": \"A blank PNG that is 5x7.\",\n \"fee\": {\n \"address\": \"mhgGjVVY6kjrAxf2cz1ALfbst6CQhZ72qg\",\n \"amount\": \"0.3\",\n \"currency\": \"LBC\"\n },\n \"image\": {\n \"height\": 7,\n \"width\": 5\n },\n \"languages\": [\n \"en\"\n ],\n \"license\": \"Public Domain\",\n \"license_url\": \"http://public-domain.org\",\n \"locations\": [\n {\n \"city\": \"Manchester\",\n \"country\": \"US\",\n \"state\": \"NH\"\n }\n ],\n \"release_time\": \"1559011789\",\n \"source\": {\n \"hash\": \"6c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545\",\n \"media_type\": \"image/png\",\n \"name\": \"tmpg0gz6g_3.png\",\n \"sd_hash\": \"a76d75a13ff15d946f929115e248dd411996abea4e1f37f73a72ba82fcd39a0dbbb3a3777e767984cd30e9eef2b68312\",\n \"size\": \"99\"\n },\n \"stream_type\": \"image\",\n \"tags\": [\n \"blank\",\n \"art\"\n ],\n Line truncated
"curl": "curl -d'{\"method\": \"stream_create\", \"params\": {\"name\": \"blank-image\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmph7izwd1p.png\", \"fee_currency\": \"LBC\", \"fee_amount\": \"0.3\", \"title\": \"Blank Image\", \"description\": \"A blank PNG that is 5x7.\", \"author\": \"Picaso\", \"tags\": [\"blank\", \"art\"], \"languages\": [\"en\"], \"locations\": [\"US:NH:Manchester\"], \"license\": \"Public Domain\", \"license_url\": \"http://public-domain.org\", \"thumbnail_url\": \"http://smallmedia.com/thumbnail.jpg\", \"release_time\": 1558113038, \"channel_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\", \"channel_account_id\": [], \"preview\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream create blank-image 1.0 /tmp/tmph7izwd1p.png --tags=blank --tags=art --languages=en --locations=US:NH:Manchester --fee_currency=LBC --fee_amount=0.3 --title=\"Blank Image\" --description=\"A blank PNG that is 5x7.\" --author=Picaso --license=\"Public Domain\" --license_url=http://public-domain.org --thumbnail_url=\"http://smallmedia.com/thumbnail.jpg\" --release_time=1558113038 --channel_id=\"67193e65e8c0363f26aff251435cf1795e47e2f8\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_create\", \"params\": {\"name\": \"blank-image\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmph7izwd1p.png\", \"fee_currency\": \"LBC\", \"fee_amount\": \"0.3\", \"title\": \"Blank Image\", \"description\": \"A blank PNG that is 5x7.\", \"author\": \"Picaso\", \"tags\": [\"blank\", \"art\"], \"languages\": [\"en\"], \"locations\": [\"US:NH:Manchester\"], \"license\": \"Public Domain\", \"license_url\": \"http://public-domain.org\", \"thumbnail_url\": \"http://smallmedia.com/thumbnail.jpg\", \"release_time\": 1558113038, \"channel_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\", \"channel_account_id\": [], \"preview\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001de54452ea4e3a3c2d2a1edfc59bd3f8375d298314686ffe59f11b883185f885d010000006a4730440220415a6ce0db25a258338a055f68e6cc8e7bde6a19856f8e0d7de66d4e405f87e102206ac0121d9e1de2c45a8b452abd3c9577fa49903cc295cb2993f2f21e48ecc2a80121020bfcf9627405a59302cff34631349d05c4e0932539b49e9c3c1f42716c9fa93bffffffff0200e1f50500000000fddc01b50b626c616e6b2d696d6167654db10101f8e2475e79f15c4351f2af263f36c0e8653e1967e9c30300f2db8da744b33f3c1beb0f0d1f8b09607a591fd6eefdb99e487b303454a5b77b6a7d45afd612902f615de4084a65e6a104e7d0b938a94cf075aa9ce40ae6010a82010a306c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545120f746d706837697a776431702e706e6718632209696d6167652f706e673230fb5be9ad617fd756b29c835efb11e6fa44a301b7a506bb72d58108a0f276a6bf86591e0bce04525d098440fb9f5b286a120650696361736f1a0d5075626c696320446f6d61696e2218687474703a2f2f7075626c69632d646f6d61696e2e6f7267288ed6fbe6053222080112196f10ae71e0a9fd99f62361922757769d7613456d247a60a9a2188087a70e520408051007420b426c616e6b20496d6167654a184120626c616e6b20504e472074686174206973203578372e52252a23687474703a2f2f736d616c6c6d656469612e636f6d2f7468756d626e61696c2e6a70675a05626c616e6b5a03617274620208016a1308ec0112024e481a0a4d616e636865737465726d7576a91410ae71e0a9fd99f62361922757769d7613456d2488acac5e7d1d000000001976a914f5b96ca126423359a466456e164dc1edfcf9914288ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mmY3R9EcmdQTb5p8hxGHSpD9rou8ki41yN\",\n \"amount\": \"5.969662\",\n \"confirmations\": 2,\n \"height\": 213,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1558113064,\n \"txid\": \"5d885f1883b8119fe5ff86463198d275833fbd59fceda1d2c2a3e3a42e4554de\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mh3A5mCcB1BWRk2qP3dwzEToC58fNymxQq\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20edd2806f871fd5137173e2c8500d3e40bbb28f\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"is_channel_signature_valid\": true,\n \"name\": \"blank-image\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://blank-image#20edd2806f871fd5137173e2c8500d3e40bbb28f\",\n \"signing_channel\": {\n \"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"name\": \"@channel\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c5\",\n \"title\": \"New Channel\"\n }\n },\n \"timestamp\": null,\n \"txid\": \"6a2686e4b2887b4d14766e7d447c6b76d788152e12b705f13000adec63b7a611\",\n \"type\": \"claim\",\n \"value\": {\n \"author\": \"Picaso\",\n \"description\": \"A blank PNG that is 5x7.\",\n \"fee\": {\n \"address\": \"mh3A5mCcB1BWRk2qP3dwzEToC58fNymxQq\",\n \"amount\": \"0.3\",\n \"currency\": \"LBC\"\n },\n \"image\": {\n \"height\": 7,\n \"width\": 5\n },\n \"languages\": [\n \"en\"\n ],\n \"license\": \"Public Domain\",\n \"license_url\": \"http://public-domain.org\",\n \"locations\": [\n {\n \"city\": \"Manchester\",\n \"country\": \"US\",\n \"state\": \"NH\"\n }\n ],\n \"release_time\": \"1558113038\",\n \"source\": {\n \"hash\": \"6c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545\",\n \"media_type\": \"image/png\",\n \"name\": \"tmph7izwd1p.png\",\n \"sd_hash\": \"fb5be9ad617fd756b29c835efb11e6fa44a301b7a506bb72d58108a0f276a6bf86591e0bce04525d098440fb9f5b286a\",\n \"size\": \"99\"\n },\n \"stream_type\": \"image\",\n \"tags\": [\n \"blank\",\n \"art\"\n ],\n \"thumbnail\": {\n \"url\": \"http://smallmedia.com/thumbnail.jpg\"\n },\n \"title\": \"Blank Image\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"n3vDyZVf6EuxN2r6BqLpMgS67f4epzdqZT\",\n \"amount\": \"4.947555\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"6a2686e4b2887b4d14766e7d447c6b76d788152e12b705f13000adec63b7a611\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.022107\",\n \"total_input\": \"5.969662\",\n \"total_output\": \"5.947555\",\n \"txid\": \"6a2686e4b2887b4d14766e7d447c6b76d788152e12b705Line truncated
}
]
},
@@ -2343,21 +2193,21 @@
"is_required": false
}
],
"returns": " {\n \"page\": \"Page number of the current items.\",\n \"page_size\": \"Number of items to show on a page.\",\n \"total_pages\": \"Total number of pages.\",\n \"total_items\": \"Total number of items.\",\n \"items\": [\n {\n \"txid\": \"hash of transaction in hex\",\n \"nout\": \"position in the transaction\",\n \"height\": \"block where transaction was recorded\",\n \"amount\": \"value of the txo as a decimal\",\n \"address\": \"address of who can spend the txo\",\n \"confirmations\": \"number of confirmed blocks\",\n \"is_change\": \"payment to change address, only available when it can be determined\",\n \"is_mine\": \"payment to one of your accounts, only available when it can be determined\",\n \"type\": \"one of 'claim', 'support' or 'payment'\",\n \"name\": \"when type is 'claim' or 'support', this is the claim name\",\n \"claim_id\": \"when type is 'claim' or 'support', this is the claim id\",\n \"claim_op\": \"when type is 'claim', this determines if it is 'create' or 'update'\",\n \"value\": \"when type is 'claim' or 'support' with payload, this is the decoded protobuf payload\",\n \"value_type\": \"determines the type of the 'value' field: 'channel', 'stream', etc\",\n \"protobuf\": \"hex encoded raw protobuf version of 'value' field\",\n \"permanent_url\": \"when type is 'claim' or 'support', this is the long permanent claim URL\",\n \"signing_channel\": \"for signed claims only, metadata of signing channel\",\n \"is_channel_signature_valid\": \"for signed claims only, whether signature is valid\"\n }\n ]\n }",
"returns": " {\n \"page\": \"Page number of the current items.\",\n \"page_size\": \"Number of items to show on a page.\",\n \"total_pages\": \"Total number of pages.\",\n \"items\": [\n {\n \"txid\": \"hash of transaction in hex\",\n \"nout\": \"position in the transaction\",\n \"height\": \"block where transaction was recorded\",\n \"amount\": \"value of the txo as a decimal\",\n \"address\": \"address of who can spend the txo\",\n \"confirmations\": \"number of confirmed blocks\",\n \"is_change\": \"payment to change address, only available when it can be determined\",\n \"is_mine\": \"payment to one of your accounts, only available when it can be determined\",\n \"type\": \"one of 'claim', 'support' or 'payment'\",\n \"name\": \"when type is 'claim' or 'support', this is the claim name\",\n \"claim_id\": \"when type is 'claim' or 'support', this is the claim id\",\n \"claim_op\": \"when type is 'claim', this determines if it is 'create' or 'update'\",\n \"value\": \"when type is 'claim' or 'support' with payload, this is the decoded protobuf payload\",\n \"value_type\": \"determines the type of the 'value' field: 'channel', 'stream', etc\",\n \"protobuf\": \"hex encoded raw protobuf version of 'value' field\",\n \"permanent_url\": \"when type is 'claim' or 'support', this is the long permanent claim URL\",\n \"signing_channel\": \"for signed claims only, metadata of signing channel\",\n \"is_channel_signature_valid\": \"for signed claims only, whether signature is valid\"\n }\n ]\n }",
"examples": [
{
"title": "List all your stream claims",
"curl": "curl -d'{\"method\": \"stream_list\", \"params\": {}}' http://localhost:5279/",
"lbrynet": "lbrynet stream list",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_list\", \"params\": {}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"address\": \"mg5Gn2NmJFVpZUU1ScVKf34KXVmJsrxXeu\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_change\": false,\n \"is_channel_signature_valid\": true,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"signing_channel\": {\n \"address\": \"muK7TZrirA8yHzxFcXa51W7CjxbAho2Zua\",\n \"amount\": \"1.0\",\n \"claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"timestamp\": 1559011813,\n \"txid\": \"3f665f0ca3cbb19c3c75813a30cd8334d7738a20566f2aa7775ab024d6fedd64\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004eeccdcff00c8336c5d616fee009894e5cbbc2bbf9497021aabbde81beaf8e6edf423de4ff094a8d4e7ea87d9469fd7d3b834b80d9b330d2f7a887108c5ea9268\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1559011814,\n \"txid\": \"fa78db71b5e4205ec33a69106f9c9528ed9289fa3f8efc51baebe6e514247287\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp6h32p99s\",\n \"sd_hash\": \"e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"size\": \"11\"\n }\n },\n \"value_type\": \"stream\"\n }\n ]\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"address\": \"mzVz9QnHzyJ15wCFAYRt7bzLoeoBK83N8J\",\n \"amount\": \"1.0\",\n \"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_change\": false,\n \"is_channel_signature_valid\": true,\n \"is_mine\": true,\n \"name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"signing_channel\": {\n \"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"name\": \"@channel\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c5\",\n \"title\": \"New Channel\"\n }\n },\n \"timestamp\": 1558113064,\n \"txid\": \"b66c49273cb5f48f73f8e626523233da52aa1a64e7a3f90a0f053e7c96e2b5b7\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpip8uriwe\",\n \"sd_hash\": \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"size\": \"11\"\n }\n },\n \"value_type\": \"stream\"\n }\n ]\n}"
},
{
"title": "Paginate your stream claims",
"curl": "curl -d'{\"method\": \"stream_list\", \"params\": {\"page\": 1, \"page_size\": 20}}' http://localhost:5279/",
"lbrynet": "lbrynet stream list --page=1 --page_size=20",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_list\", \"params\": {\"page\": 1, \"page_size\": 20}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mg5Gn2NmJFVpZUU1ScVKf34KXVmJsrxXeu\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_change\": false,\n \"is_channel_signature_valid\": true,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"signing_channel\": {\n \"address\": \"muK7TZrirA8yHzxFcXa51W7CjxbAho2Zua\",\n \"amount\": \"1.0\",\n \"claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"timestamp\": 1559011813,\n \"txid\": \"3f665f0ca3cbb19c3c75813a30cd8334d7738a20566f2aa7775ab024d6fedd64\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004eeccdcff00c8336c5d616fee009894e5cbbc2bbf9497021aabbde81beaf8e6edf423de4ff094a8d4e7ea87d9469fd7d3b834b80d9b330d2f7a887108c5ea9268\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1559011814,\n \"txid\": \"fa78db71b5e4205ec33a69106f9c9528ed9289fa3f8efc51baebe6e514247287\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp6h32p99s\",\n \"sd_hash\": \"e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"size\": \"11\"\n }\n },\n \"value_type\": \"stream\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mzVz9QnHzyJ15wCFAYRt7bzLoeoBK83N8J\",\n \"amount\": \"1.0\",\n \"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_change\": false,\n \"is_channel_signature_valid\": true,\n \"is_mine\": true,\n \"name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"signing_channel\": {\n \"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"name\": \"@channel\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c5\",\n \"title\": \"New Channel\"\n }\n },\n \"timestamp\": 1558113064,\n \"txid\": \"b66c49273cb5f48f73f8e626523233da52aa1a64e7a3f90a0f053e7c96e2b5b7\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpip8uriwe\",\n \"sd_hash\": \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"size\": \"11\"\n }\n },\n \"value_type\": \"stream\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_pages\": 1\n }\n}"
}
]
},
@@ -2574,10 +2424,10 @@
"examples": [
{
"title": "Update a stream claim to add channel",
"curl": "curl -d'{\"method\": \"stream_update\", \"params\": {\"claim_id\": \"ffdbe8f44f285fbc4a352763727abd86d17399c1\", \"clear_fee\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"channel_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\", \"clear_channel\": false, \"channel_account_id\": [], \"preview\": false, \"replace\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream update ffdbe8f44f285fbc4a352763727abd86d17399c1 --channel_id=\"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_update\", \"params\": {\"claim_id\": \"ffdbe8f44f285fbc4a352763727abd86d17399c1\", \"clear_fee\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"channel_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\", \"clear_channel\": false, \"channel_account_id\": [], \"preview\": false, \"replace\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000002421430680a249bfd7987ad9e7e644f6645a9d92d65f7123b929e2a4b989b2dad000000006a4730440220328e1833cbc85f07bb2a3b485a178c8ef50e0e11de1e029a3392cfcf3bf1d27302206a588363e64cb0e361cd6a9fe6f37067611bbe5eb3ed2271a6bb7f24e3fb72b0012102700c310dacc983a7cfe3187c0913373c956fbb5f850a13043c2897f2da825120ffffffffc912a1a678d1a646e6164f0e0c2d51e16fd6acaaa0dd4b1b8bf4780143c4b260010000006b483045022100d31bbf4ac9628ea729d0b4252b36e120c7dafdad9ada4207112423ec7dc748690220153223d7fa389287b7baea11e8c301b8607a602805c9f97c399f2eaa0c54d9f6012103a0263f43ab4d778afd664d54704040b580185511e529011f713976e3f0032647ffffffff0200e1f50500000000fd2301b7076173747265616d14c19973d186bd7a726327354abc5f284ff4e8dbff4ce8016d1a9d18447522cfe3eb8acf4b56a63e7edf2b68fdfdb7869eb7447ab2e61a2d5cdf8199867bda63dd1edc699b7dee31d618198502a11309baff2f6d52104f494ca48ff9e5961c5a00badba23fcfeb010f595fc10a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d703668333270393973180b22186170706c69636174696f6e2f6f637465742d73747265616d3230e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e06d6d76a914061cbd2df8421ab14497e62baf747461c7c9137b88ac32a0d205000000001976a914f0d879252e7fcd69f489f40a6e7df12d95b9b5bc88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mg5Gn2NmJFVpZUU1ScVKf34KXVmJsrxXeu\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"height\": 213,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"timestamp\": 1559011814,\n \"txid\": \"ad2d9b984b2a9e923b12f7652dd9a945664f647e9ead8779fd9b240a68301442\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp6h32p99s\",\n \"sd_hash\": \"e38f25767c7619948832380b12def270aa244ee0b712020551198b2c587babb08583b7ad928ea08f71e1a6ced74836e0\",\n \"size\": \"11\"\n }\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mnY3oi1Auwp7Cb4CQRGDLoKWwsARVzes45\",\n \"amount\": \"0.9772285\",\n \"confirmations\": 3,\n \"height\": 211,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1559011813,\n \"txid\": \"60b2c4430178f48b1b4bdda0aaacd66fe1512d0c0e4f16e646a6d178a6a112c9\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mg5Gn2NmJFVpZUU1ScVKf34KXVmJsrxXeu\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"claim_op\": \"update\",\n \"confirmations\": -2,\n \"height\": -2,\n \"is_channel_signature_valid\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ffdbe8f44f285fbc4a352763727abd86d17399c1\",\n \"signing_channel\": {\n \"address\": \"muK7TZrirA8yHzxFcXa51W7CjxbAho2Zua\",\n \"amount\": \"1.0\",\n \"claim_id\": \"682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"claim_op\": \"update\",\n \"confirmations\": 4,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#682bdf7e3ea6564bcf8aebe3cf227544189d1a6d\",\n \"timestamp\": 1559011813,\n \"txid\": \"3f665f0ca3cbb19c3c75813a30cd8334d7738a20566f2aa7775ab024d6fedd64\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004eeccdcff00c8336c5d616fee009894e5cbbc2bbf9497021aabbde81beaf8e6edf423de4ff094a8d4e7ea87d9469fd7d3b834b80d9b330d2f7a887108c5ea9268\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": null,\n \"txid\": \"fa78db71b5e4205ec33a69106f9c9528ed9289fa3f8efc51baebe6e514247287\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"appLine truncated
"curl": "curl -d'{\"method\": \"stream_update\", \"params\": {\"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\", \"clear_fee\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"channel_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\", \"clear_channel\": false, \"channel_account_id\": [], \"preview\": false, \"replace\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream update 2606a71cd812c77bc3dc76ecc3727e0368b1af6d --channel_id=\"67193e65e8c0363f26aff251435cf1795e47e2f8\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_update\", \"params\": {\"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\", \"clear_fee\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"channel_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\", \"clear_channel\": false, \"channel_account_id\": [], \"preview\": false, \"replace\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000002de54452ea4e3a3c2d2a1edfc59bd3f8375d298314686ffe59f11b883185f885d000000006b4830450221009bf40501fd5dcff6a5712dbe3a4169c6704e20d51f7c9a1c709584ff7703c311022060127b652e57b1722ca32a1fabd1a57770524bce439b92c2c7898316d7842c5501210248599b7ed9d22dc6e1569332c54749b5f9c02402a49a98da5c92ef3df448f113ffffffff8c2c2d5555c31ce6332479cc10c37a9f8614189cff6d0a41194a4dc1a56741cc010000006a47304402207827109f24fae8c5198f46ce44ae0ce5751efc1613e4c02414a5ad0dc77cdb2f022024c29dbabbbb317980c8ea4f090ff68becd762dbf56f89d1a0be1aae5bc65a8d0121038cb31d7471b5442c0df144d16733fbe51334f1b5348ba0267d67309aefe3489bffffffff0200e1f50500000000fd2301b7076173747265616d146dafb168037e72c3ec76dcc37bc712d81ca706264ce801f8e2475e79f15c4351f2af263f36c0e8653e1967128556beabb3c0f3216a15825a50d9f22326fff3c4f8b53089ced7fed5b66aaf3eb00db47aba375985ea1440e0ddee48e5ef9e695688f8d31284f25ab37ebc5b0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706970387572697765180b22186170706c69636174696f6e2f6f637465742d73747265616d323006310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a0424626d6d76a914d03b84e073b9094b455ff6b00d33fa88d2810f2188ac32a0d205000000001976a91450ac4be0af83010408c157824719217c048bdac488ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mzVz9QnHzyJ15wCFAYRt7bzLoeoBK83N8J\",\n \"amount\": \"1.0\",\n \"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"height\": 213,\n \"is_change\": false,\n \"is_mine\": true,\n \"name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"timestamp\": 1558113064,\n \"txid\": \"5d885f1883b8119fe5ff86463198d275833fbd59fceda1d2c2a3e3a42e4554de\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpip8uriwe\",\n \"sd_hash\": \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"size\": \"11\"\n }\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"n1SHWyZqJiWMNrdCxmQx9V3xQ83hWJnJUM\",\n \"amount\": \"0.9772285\",\n \"confirmations\": 3,\n \"height\": 211,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1558113063,\n \"txid\": \"cc4167a5c14d4a19410a6dff9c1814869f7ac310cc792433e61cc355552d2c8c\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mzVz9QnHzyJ15wCFAYRt7bzLoeoBK83N8J\",\n \"amount\": \"1.0\",\n \"claim_id\": \"2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"claim_op\": \"update\",\n \"confirmations\": -2,\n \"height\": -2,\n \"is_channel_signature_valid\": true,\n \"name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#2606a71cd812c77bc3dc76ecc3727e0368b1af6d\",\n \"signing_channel\": {\n \"claim_id\": \"67193e65e8c0363f26aff251435cf1795e47e2f8\",\n \"name\": \"@channel\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000487b10920b14642f4e0bca8d5225def746ae52ad02277aacd22fd770d1c5fcf82979fc8b9047dfe901bb973c71511ce4bc09b92c6d2f2377f1673ff5a899e35c5\",\n \"title\": \"New Channel\"\n }\n },\n \"timestamp\": null,\n \"txid\": \"b66c49273cb5f48f73f8e626523233da52aa1a64e7a3f90a0f053e7c96e2b5b7\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpip8uriwe\",\n \"sd_hash\": \"06310334c23b0473ff2464d94717052a61da6ceeb7be591779ef68b3b1633db273586a22f6d29fcf95e1c1ed6a042462\",\n \"size\": \"11\"\n }\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mnsWkmGMmaPRXEfwAcM2Fwy8ULUXNxYeCd\",\n \"amount\": \"0.9768965\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"b66c49273cb5f48f73f8e626523233da52aa1a64e7a3f90a0f053e7c96e2b5b7\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000332\",\n \"total_input\": \"1.9772285\",\n \"total_output\": \"1.9768965\",\n \"txid\": \"b66cLine truncated
}
]
}
@@ -2697,7 +2547,7 @@
"is_required": false
}
],
"returns": " {\n \"page\": \"Page number of the current items.\",\n \"page_size\": \"Number of items to show on a page.\",\n \"total_pages\": \"Total number of pages.\",\n \"total_items\": \"Total number of items.\",\n \"items\": [\n {\n \"txid\": \"hash of transaction in hex\",\n \"nout\": \"position in the transaction\",\n \"height\": \"block where transaction was recorded\",\n \"amount\": \"value of the txo as a decimal\",\n \"address\": \"address of who can spend the txo\",\n \"confirmations\": \"number of confirmed blocks\",\n \"is_change\": \"payment to change address, only available when it can be determined\",\n \"is_mine\": \"payment to one of your accounts, only available when it can be determined\",\n \"type\": \"one of 'claim', 'support' or 'payment'\",\n \"name\": \"when type is 'claim' or 'support', this is the claim name\",\n \"claim_id\": \"when type is 'claim' or 'support', this is the claim id\",\n \"claim_op\": \"when type is 'claim', this determines if it is 'create' or 'update'\",\n \"value\": \"when type is 'claim' or 'support' with payload, this is the decoded protobuf payload\",\n \"value_type\": \"determines the type of the 'value' field: 'channel', 'stream', etc\",\n \"protobuf\": \"hex encoded raw protobuf version of 'value' field\",\n \"permanent_url\": \"when type is 'claim' or 'support', this is the long permanent claim URL\",\n \"signing_channel\": \"for signed claims only, metadata of signing channel\",\n \"is_channel_signature_valid\": \"for signed claims only, whether signature is valid\"\n }\n ]\n }",
"returns": " {\n \"page\": \"Page number of the current items.\",\n \"page_size\": \"Number of items to show on a page.\",\n \"total_pages\": \"Total number of pages.\",\n \"items\": [\n {\n \"txid\": \"hash of transaction in hex\",\n \"nout\": \"position in the transaction\",\n \"height\": \"block where transaction was recorded\",\n \"amount\": \"value of the txo as a decimal\",\n \"address\": \"address of who can spend the txo\",\n \"confirmations\": \"number of confirmed blocks\",\n \"is_change\": \"payment to change address, only available when it can be determined\",\n \"is_mine\": \"payment to one of your accounts, only available when it can be determined\",\n \"type\": \"one of 'claim', 'support' or 'payment'\",\n \"name\": \"when type is 'claim' or 'support', this is the claim name\",\n \"claim_id\": \"when type is 'claim' or 'support', this is the claim id\",\n \"claim_op\": \"when type is 'claim', this determines if it is 'create' or 'update'\",\n \"value\": \"when type is 'claim' or 'support' with payload, this is the decoded protobuf payload\",\n \"value_type\": \"determines the type of the 'value' field: 'channel', 'stream', etc\",\n \"protobuf\": \"hex encoded raw protobuf version of 'value' field\",\n \"permanent_url\": \"when type is 'claim' or 'support', this is the long permanent claim URL\",\n \"signing_channel\": \"for signed claims only, metadata of signing channel\",\n \"is_channel_signature_valid\": \"for signed claims only, whether signature is valid\"\n }\n ]\n }",
"examples": []
}
]
@@ -2773,7 +2623,7 @@
"curl": "curl -d'{\"method\": \"transaction_list\", \"params\": {}}' http://localhost:5279/",
"lbrynet": "lbrynet transaction list",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"transaction_list\", \"params\": {}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"abandon_info\": [],\n \"claim_info\": [],\n \"confirmations\": 1,\n \"date\": \"2019-05-27 22:50\",\n \"fee\": \"-0.000124\",\n \"support_info\": [],\n \"timestamp\": 1559011813,\n \"txid\": \"3ef83205dd764152fc6847fc9c80b94251b5306152d0747d619f8da4e037145b\",\n \"update_info\": [],\n \"value\": \"-2.0\"\n },\n {\n \"abandon_info\": [],\n \"claim_info\": [],\n \"confirmations\": 7,\n \"date\": \"2019-05-27 22:50\",\n \"fee\": \"0.0\",\n \"support_info\": [],\n \"timestamp\": 1559011812,\n \"txid\": \"4717af0744c6d4f85cf43cc371161d8f8857e5fd1e4c1040deb1c07cb9efa0ff\",\n \"update_info\": [],\n \"value\": \"10.0\"\n }\n ]\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"abandon_info\": [],\n \"claim_info\": [],\n \"confirmations\": 1,\n \"date\": \"2019-05-17 13:11\",\n \"fee\": \"-0.000124\",\n \"support_info\": [],\n \"timestamp\": 1558113063,\n \"txid\": \"5fda031221eba48f6d8947540fbe4a947b39cb713564a9fbe43a5c6e6a9475db\",\n \"update_info\": [],\n \"value\": \"-2.0\"\n },\n {\n \"abandon_info\": [],\n \"claim_info\": [],\n \"confirmations\": 7,\n \"date\": \"2019-05-17 13:11\",\n \"fee\": \"0.0\",\n \"support_info\": [],\n \"timestamp\": 1558113062,\n \"txid\": \"468367c951e1a96f9456b61ca218374058fc0351f4b48520276950c44460435f\",\n \"update_info\": [],\n \"value\": \"10.0\"\n }\n ]\n}"
}
]
},
@@ -2819,7 +2669,7 @@
"is_required": false
}
],
"returns": " {\n \"page\": \"Page number of the current items.\",\n \"page_size\": \"Number of items to show on a page.\",\n \"total_pages\": \"Total number of pages.\",\n \"total_items\": \"Total number of items.\",\n \"items\": [\n {\n \"txid\": \"hash of transaction in hex\",\n \"nout\": \"position in the transaction\",\n \"height\": \"block where transaction was recorded\",\n \"amount\": \"value of the txo as a decimal\",\n \"address\": \"address of who can spend the txo\",\n \"confirmations\": \"number of confirmed blocks\",\n \"is_change\": \"payment to change address, only available when it can be determined\",\n \"is_mine\": \"payment to one of your accounts, only available when it can be determined\",\n \"type\": \"one of 'claim', 'support' or 'payment'\",\n \"name\": \"when type is 'claim' or 'support', this is the claim name\",\n \"claim_id\": \"when type is 'claim' or 'support', this is the claim id\",\n \"claim_op\": \"when type is 'claim', this determines if it is 'create' or 'update'\",\n \"value\": \"when type is 'claim' or 'support' with payload, this is the decoded protobuf payload\",\n \"value_type\": \"determines the type of the 'value' field: 'channel', 'stream', etc\",\n \"protobuf\": \"hex encoded raw protobuf version of 'value' field\",\n \"permanent_url\": \"when type is 'claim' or 'support', this is the long permanent claim URL\",\n \"signing_channel\": \"for signed claims only, metadata of signing channel\",\n \"is_channel_signature_valid\": \"for signed claims only, whether signature is valid\"\n }\n ]\n }",
"returns": " {\n \"page\": \"Page number of the current items.\",\n \"page_size\": \"Number of items to show on a page.\",\n \"total_pages\": \"Total number of pages.\",\n \"items\": [\n {\n \"txid\": \"hash of transaction in hex\",\n \"nout\": \"position in the transaction\",\n \"height\": \"block where transaction was recorded\",\n \"amount\": \"value of the txo as a decimal\",\n \"address\": \"address of who can spend the txo\",\n \"confirmations\": \"number of confirmed blocks\",\n \"is_change\": \"payment to change address, only available when it can be determined\",\n \"is_mine\": \"payment to one of your accounts, only available when it can be determined\",\n \"type\": \"one of 'claim', 'support' or 'payment'\",\n \"name\": \"when type is 'claim' or 'support', this is the claim name\",\n \"claim_id\": \"when type is 'claim' or 'support', this is the claim id\",\n \"claim_op\": \"when type is 'claim', this determines if it is 'create' or 'update'\",\n \"value\": \"when type is 'claim' or 'support' with payload, this is the decoded protobuf payload\",\n \"value_type\": \"determines the type of the 'value' field: 'channel', 'stream', etc\",\n \"protobuf\": \"hex encoded raw protobuf version of 'value' field\",\n \"permanent_url\": \"when type is 'claim' or 'support', this is the long permanent claim URL\",\n \"signing_channel\": \"for signed claims only, metadata of signing channel\",\n \"is_channel_signature_valid\": \"for signed claims only, whether signature is valid\"\n }\n ]\n }",
"examples": []
},
{
+1 -1
View File
@@ -1,4 +1,4 @@
__name__ = "lbrynet"
__version__ = "0.38.0rc6"
__version__ = "0.37.3rc1"
version = tuple(__version__.split('.'))
+15 -20
View File
@@ -121,7 +121,7 @@ class Toggle(Setting[bool]):
)
parser.add_argument(
self.no_cli_name,
help=f"Opposite of {self.cli_name}",
help=f"Opposite of --{self.cli_name}",
dest=self.name,
action="store_false",
default=NOT_SET
@@ -192,21 +192,7 @@ class MaxKeyFee(Setting[dict]):
)
class ListSetting(Setting[list]):
def validate(self, val):
assert isinstance(val, (tuple, list)), \
f"Setting '{self.name}' must be a tuple or list."
def contribute_to_argparse(self, parser: ArgumentParser):
parser.add_argument(
self.cli_name,
help=self.doc,
action='append'
)
class Servers(ListSetting):
class Servers(Setting[list]):
def validate(self, val):
assert isinstance(val, (tuple, list)), \
@@ -239,8 +225,16 @@ class Servers(ListSetting):
return [f"{host}:{port}" for host, port in value]
return value
def contribute_to_argparse(self, parser: ArgumentParser):
parser.add_argument(
self.cli_name,
nargs="*",
help=self.doc,
default=NOT_SET
)
class Strings(ListSetting):
class Strings(Setting[list]):
def validate(self, val):
assert isinstance(val, (tuple, list)), \
@@ -275,7 +269,7 @@ class ArgumentAccess:
def load(self, args):
for setting in self.configuration.get_settings():
value = getattr(args, setting.name, NOT_SET)
if value != NOT_SET and not (isinstance(setting, ListSetting) and value is None):
if value != NOT_SET:
self.args[setting.name] = setting.deserialize(value)
def __contains__(self, item: str):
@@ -526,7 +520,7 @@ class Config(CLIConfig):
# servers
reflector_servers = Servers("Reflector re-hosting servers", [
('reflector.lbry.com', 5566)
('reflector.lbry.io', 5566)
])
lbryum_servers = Servers("SPV wallet servers", [
('lbryumx1.lbry.com', 50001), # US EAST
@@ -540,7 +534,8 @@ class Config(CLIConfig):
('lbrynet4.lbry.com', 4444) # ASIA
])
comment_server = String("Comment server API URL", "https://comments.lbry.com/api")
# comment server uses a single string because requests are made to the /api resource
comment_server = String("Server to store user-generated metadata.", "http://comments.lbry.com:2903/api")
# blockchain
blockchain_name = String("Blockchain name - lbrycrd_main, lbrycrd_regtest, or lbrycrd_testnet", 'lbrycrd_main')
+6 -7
View File
@@ -52,9 +52,8 @@ class ConnectionManager:
self._status = {
'incoming_bps': {},
'outgoing_bps': {},
'total_incoming_mbs': 0.0,
'total_outgoing_mbs': 0.0,
'time': self.loop.time()
'total_incoming_mbps': 0.0,
'total_outgoing_mbps': 0.0,
}
while True:
@@ -69,10 +68,10 @@ class ConnectionManager:
k, v = self.incoming.popitem()
self._status['incoming_bps'][k] = v
now = self.loop.time()
self._status['total_outgoing_mbs'] = int(sum(list(self._status['outgoing_bps'].values())
) / (now - last)) / 1000000.0
self._status['total_incoming_mbs'] = int(sum(list(self._status['incoming_bps'].values())
) / (now - last)) / 1000000.0
self._status['total_outgoing_mbps'] = int(sum(list(self._status['outgoing_bps'].values()))
/ (now - last)) / 1000000.0
self._status['total_incoming_mbps'] = int(sum(list(self._status['incoming_bps'].values()))
/ (now - last)) / 1000000.0
self._status['time'] = now
def stop(self):
+2 -4
View File
@@ -169,7 +169,7 @@ def add_command_parser(parent, command):
def get_argument_parser():
main = ArgumentParser(
'lbrynet', description='An interface to the LBRY Network.', allow_abbrev=False,
'lbrynet', description='An interface to the LBRY Network.'
)
main.add_argument(
'-v', '--version', dest='cli_version', action="store_true",
@@ -192,8 +192,8 @@ def get_argument_parser():
help=('Enable debug output. Optionally specify loggers for which debug output '
'should selectively be applied.')
)
start.set_defaults(command='start', start_parser=start)
Config.contribute_to_argparse(start)
start.set_defaults(command='start', start_parser=start, doc=start.format_help())
api = Daemon.get_api_definitions()
groups = {}
@@ -239,7 +239,6 @@ def main(argv=None):
if args.help:
args.start_parser.print_help()
return 0
default_formatter = logging.Formatter("%(asctime)s %(levelname)-8s %(name)s:%(lineno)d: %(message)s")
file_handler = logging.handlers.RotatingFileHandler(
conf.log_file_path, maxBytes=2097152, backupCount=5
@@ -265,7 +264,6 @@ def main(argv=None):
loop.set_debug(True)
else:
log.setLevel(logging.INFO)
if conf.share_usage_data:
loggly_handler = get_loggly_handler()
loggly_handler.setLevel(logging.ERROR)
+3 -5
View File
@@ -244,14 +244,13 @@ class WalletComponent(Component):
def __init__(self, component_manager):
super().__init__(component_manager)
self.wallet_manager = None
self._started = False
@property
def component(self):
return self.wallet_manager
async def get_status(self):
if self.wallet_manager and self._started:
if self.wallet_manager and self.running:
local_height = self.wallet_manager.ledger.headers.height
remote_height = await self.wallet_manager.ledger.network.get_server_height()
best_hash = self.wallet_manager.get_best_blockhash()
@@ -266,7 +265,6 @@ class WalletComponent(Component):
async def start(self):
log.info("Starting torba wallet")
self.wallet_manager = await LbryWalletManager.from_lbrynet_config(self.conf)
self._started = True
await self.wallet_manager.start()
async def stop(self):
@@ -308,7 +306,7 @@ class BlobComponent(Component):
count = len(self.blob_manager.completed_blob_hashes)
return {
'finished_blobs': count,
'connections': {} if not self.blob_manager else self.blob_manager.connection_manager.status
'connections': self.blob_manager.connection_manager.status
}
@@ -515,7 +513,7 @@ class UPnPComponent(Component):
pass
if external_ip == "0.0.0.0" or not external_ip:
log.warning("unable to get external ip from UPnP, checking lbry.com fallback")
log.warning("unable to get external ip from UPnP, checking lbry.io fallback")
external_ip = await utils.get_external_ip()
if self.external_ip and self.external_ip != external_ip:
log.info("external ip changed from %s to %s", self.external_ip, external_ip)
+255 -289
View File
@@ -7,15 +7,12 @@ import inspect
import typing
import base58
import random
import ecdsa
import hashlib
from urllib.parse import urlencode, quote
from typing import Callable, Optional, List
from binascii import hexlify, unhexlify
from traceback import format_exc
from aiohttp import web
from functools import wraps
from google.protobuf.message import DecodeError
from torba.client.wallet import Wallet
from torba.client.baseaccount import SingleKey, HierarchicalDeterministic
@@ -33,13 +30,13 @@ from lbrynet.extras.daemon.Components import EXCHANGE_RATE_MANAGER_COMPONENT, UP
from lbrynet.extras.daemon.ComponentManager import RequiredCondition
from lbrynet.extras.daemon.ComponentManager import ComponentManager
from lbrynet.extras.daemon.json_response_encoder import JSONResponseEncoder
from lbrynet.extras.daemon.comment_client import jsonrpc_post, sign_comment
from lbrynet.extras.daemon.undecorated import undecorated
from lbrynet.wallet.transaction import Transaction, Output, Input
from lbrynet.wallet.account import Account as LBCAccount
from lbrynet.wallet.dewies import dewies_to_lbc, lbc_to_dewies
from lbrynet.schema.claim import Claim
from lbrynet.schema.url import URL
from lbrynet.schema.uri import parse_lbry_uri, URIParseError
from lbrynet.extras.daemon.comment_client import jsonrpc_batch, jsonrpc_post, rpc_body
if typing.TYPE_CHECKING:
@@ -51,6 +48,7 @@ if typing.TYPE_CHECKING:
from lbrynet.wallet.manager import LbryWalletManager
from lbrynet.wallet.ledger import MainNetLedger
from lbrynet.stream.stream_manager import StreamManager
from lbrynet.stream.managed_stream import ManagedStream
log = logging.getLogger(__name__)
@@ -115,7 +113,6 @@ def encode_pagination_doc(items):
"page": "Page number of the current items.",
"page_size": "Number of items to show on a page.",
"total_pages": "Total number of pages.",
"total_items": "Total number of items.",
"items": [items],
}
@@ -127,11 +124,9 @@ async def maybe_paginate(get_records: Callable, get_record_count: Callable,
"offset": page_size * (page-1),
"limit": page_size
})
total_items = await get_record_count(**constraints)
return {
"items": await get_records(**constraints),
"total_pages": int((total_items + (page_size-1)) / page_size),
"total_items": total_items,
"total_pages": int(((await get_record_count(**constraints)) + (page_size-1)) / page_size),
"page": page, "page_size": page_size
}
return await get_records(**constraints)
@@ -752,9 +747,8 @@ class Daemon(metaclass=JSONRPCServerType):
'outgoing_bps': {
<destination ip and tcp port>: (int) bytes per second sent,
},
'total_outgoing_mps': (float) megabytes per second sent,
'total_incoming_mps': (float) megabytes per second received,
'time': (float) timestamp
'total_outgoing_mbps': (float) megabytes per second sent,
'total_incoming_mbps': (float) megabytes per second received
}
},
'hash_announcer': {
@@ -807,14 +801,16 @@ class Daemon(metaclass=JSONRPCServerType):
Returns:
(dict) Dictionary of lbry version information
{
'build': (str) build type (e.g. "dev", "rc", "release"),
'ip': (str) remote ip, if available,
'lbrynet_version': (str) lbrynet_version,
'lbryum_version': (str) lbryum_version,
'lbryschema_version': (str) lbryschema_version,
'os_release': (str) os release string
'os_system': (str) os name
'platform': (str) platform string
'processor': (str) processor type,
'python_version': (str) python version,
'platform': (str) platform string,
'os_release': (str) os release string,
'os_system': (str) os name,
'lbrynet_version': (str) lbrynet version,
'torba_version': (str) torba version,
'build': (str) "dev" | "qa" | "rc" | "release",
}
"""
platform_info = system_info.get_platform()
@@ -897,16 +893,15 @@ class Daemon(metaclass=JSONRPCServerType):
valid_urls = set()
for u in urls:
try:
URL.parse(u)
parse_lbry_uri(u)
valid_urls.add(u)
except ValueError:
results[u] = {"error": f"{u} is not a valid url"}
except URIParseError:
results[u] = {"error": "%s is not a valid url" % u}
resolved = await self.resolve(list(valid_urls))
resolved = await self.resolve(*tuple(valid_urls))
for resolved_uri in resolved:
results[resolved_uri] = resolved[resolved_uri] if resolved[resolved_uri] is not None else \
{"error": f"{resolved_uri} did not resolve to a claim"}
results[resolved_uri] = resolved[resolved_uri]
return results
@@ -1693,129 +1688,65 @@ class Daemon(metaclass=JSONRPCServerType):
)
@requires(WALLET_COMPONENT)
async def jsonrpc_claim_search(self, **kwargs):
async def jsonrpc_claim_search(
self, name=None, claim_id=None, txid=None, nout=None,
channel_id=None, channel_name=None, winning=False, page=1, page_size=10):
"""
Search for stream and channel claims on the blockchain.
Arguments marked with "supports equality constraints" allow prepending the
value with an equality constraint such as '>', '>=', '<' and '<='
eg. --height=">400000" would limit results to only claims above 400k block height.
Use --channel_id=<channel_id> or --channel_name=<channel_name> to list all stream claims in a channel.
Usage:
claim_search [<name> | --name=<name>] [--claim_id=<claim_id>] [--txid=<txid>] [--nout=<nout>]
[--channel=<channel> | --channel_ids=<channel_ids>...]
[--valid_channel_signatures] [--invalid_channel_signatures]
[--is_controlling] [--release_time=<release_time>] [--public_key_id=<public_key_id>]
[--timestamp=<timestamp>] [--creation_timestamp=<creation_timestamp>]
[--height=<height>] [--creation_height=<creation_height>]
[--activation_height=<activation_height>] [--expiration_height=<expiration_height>]
[--amount=<amount>] [--effective_amount=<effective_amount>]
[--support_amount=<support_amount>] [--trending_group=<trending_group>]
[--trending_mixed=<trending_mixed>] [--trending_local=<trending_local>]
[--trending_global=<trending_global]
[--claim_type=<claim_type>] [--stream_types=<stream_types>...] [--media_types=<media_types>...]
[--any_tags=<any_tags>...] [--all_tags=<all_tags>...] [--not_tags=<not_tags>...]
[--any_languages=<any_languages>...] [--all_languages=<all_languages>...]
[--not_languages=<not_languages>...]
[--any_locations=<any_locations>...] [--all_locations=<all_locations>...]
[--not_locations=<not_locations>...]
[--order_by=<order_by>...] [--page=<page>] [--page_size=<page_size>]
claim_search [<name> | --name=<name>] [--claim_id=<claim_id>] [--txid=<txid> --nout=<nout>]
[--channel_id=<channel_id>] [--channel_name=<channel_name>] [--winning] [--page=<page>]
[--page_size=<page_size>]
Options:
--name=<name> : (str) claim name (normalized)
--claim_id=<claim_id> : (str) full or partial claim id
--txid=<txid> : (str) transaction id
--nout=<nout> : (str) position in the transaction
--channel=<channel> : (str) claims signed by this channel (argument is
a URL which automatically gets resolved),
see --channel_ids if you need to filter by
multiple channels at the same time,
includes claims with invalid signatures,
use in conjunction with --valid_channel_signatures
--channel_ids=<channel_ids> : (str) claims signed by any of these channels
(arguments must be claim ids of the channels),
includes claims with invalid signatures,
use in conjunction with --valid_channel_signatures
--valid_channel_signatures : (bool) only return claims with valid channel signatures
--invalid_channel_signatures : (bool) only return claims with invalid channel signatures
--is_controlling : (bool) only return winning claims of their respective name
--public_key_id=<public_key_id> : (str) only return channels having this public key id, this is
the same key as used in the wallet file to map
channel certificate private keys: {'public_key_id': 'private key'}
--height=<height> : (int) last updated block height (supports equality constraints)
--timestamp=<timestamp> : (int) last updated timestamp (supports equality constraints)
--creation_height=<creation_height> : (int) created at block height (supports equality constraints)
--creation_timestamp=<creation_timestamp>: (int) created at timestamp (supports equality constraints)
--activation_height=<activation_height> : (int) height at which claim starts competing for name
(supports equality constraints)
--expiration_height=<expiration_height> : (int) height at which claim will expire
(supports equality constraints)
--release_time=<release_time> : (int) limit to claims self-described as having been
released to the public on or after this UTC
timestamp, when claim does not provide
a release time the publish time is used instead
(supports equality constraints)
--amount=<amount> : (int) limit by claim value (supports equality constraints)
--support_amount=<support_amount>: (int) limit by supports and tips recieved (supports
equality constraints)
--effective_amount=<effective_amount>: (int) limit by total value (initial claim value plus
all tips and supports received), this amount is
blank until claim has reached activation height
(supports equality constraints)
--trending_group=<trending_group>: (int) group numbers 1 through 4 representing the
trending groups of the content: 4 means
content is trending globally and independently,
3 means content is not trending globally but is
trending independently (locally), 2 means it is
trending globally but not independently and 1
means it's not trending globally or locally
(supports equality constraints)
--trending_mixed=<trending_mixed>: (int) trending amount taken from the global or local
value depending on the trending group:
4 - global value, 3 - local value, 2 - global
value, 1 - local value (supports equality
constraints)
--trending_local=<trending_local>: (int) trending value calculated relative only to
the individual contents past history (supports
equality constraints)
--trending_global=<trending_global>: (int) trending value calculated relative to all
trending content globally (supports
equality constraints)
--claim_type=<claim_type> : (str) filter by 'channel', 'stream' or 'unknown'
--stream_types=<stream_types> : (list) filter by 'video', 'image', 'document', etc
--media_types=<media_types> : (list) filter by 'video/mp4', 'image/png', etc
--any_tags=<any_tags> : (list) find claims containing any of the tags
--all_tags=<all_tags> : (list) find claims containing every tag
--not_tags=<not_tags> : (list) find claims not containing any of these tags
--any_languages=<any_languages> : (list) find claims containing any of the languages
--all_languages=<all_languages> : (list) find claims containing every language
--not_languages=<not_languages> : (list) find claims not containing any of these languages
--any_locations=<any_locations> : (list) find claims containing any of the locations
--all_locations=<all_locations> : (list) find claims containing every location
--not_locations=<not_locations> : (list) find claims not containing any of these locations
--page=<page> : (int) page to return during paginating
--page_size=<page_size> : (int) number of items on page during pagination
--order_by=<order_by> : (str) field to order by, default is descending order, to do an
ascending order prepend ^ to the field name, eg. '^amount'
available fields: 'name', 'height', 'release_time',
'publish_time', 'amount', 'effective_amount',
'support_amount', 'trending_group', 'trending_mixed',
'trending_local', 'trending_global', 'activation_height'
--name=<name> : (str) find claims with this name
--claim_id=<claim_id> : (str) find a claim with this claim_id
--txid=<txid> : (str) find a claim with this txid:nout
--nout=<nout> : (str) find a claim with this txid:nout
--channel_id=<channel_id> : (str) limit search to specific channel claim id (returns stream claims)
--channel_name=<channel_name> : (str) limit search to specific channel name (returns stream claims)
--winning : (bool) limit to winning claims
--page=<page> : (int) page to return during paginating
--page_size=<page_size> : (int) number of items on page during pagination
Returns: {Paginated[Output]}
"""
if kwargs.pop('valid_channel_signatures', False):
kwargs['signature_valid'] = 1
if kwargs.pop('invalid_channel_signatures', False):
kwargs['signature_valid'] = 0
page_num, page_size = abs(kwargs.pop('page', 1)), min(abs(kwargs.pop('page_size', 10)), 50)
kwargs.update({'offset': page_size * (page_num-1), 'limit': page_size})
txos, offset, total = await self.ledger.claim_search(**kwargs)
return {
"items": txos, "page": page_num, "page_size": page_size,
"total_pages": int((total + (page_size-1)) / page_size),
"total_items": total
}
claims = []
if name is not None:
claims = await self.ledger.network.get_claims_for_name(name)
elif claim_id is not None:
claim = await self.wallet_manager.get_claim_by_claim_id(claim_id)
if claim and claim != 'claim not found':
claims = {'claims': [claim]}
elif txid is not None and nout is not None:
claim = await self.wallet_manager.get_claim_by_outpoint(txid, int(nout))
if claim and claim != 'claim not found':
claims = {'claims': [claim]}
elif channel_id is not None or channel_name is not None:
channel_url = f"{channel_name}{('#' + str(channel_id)) if channel_id else ''}" if channel_name else None
if channel_id and not channel_name:
claim = await self.wallet_manager.get_claim_by_claim_id(channel_id)
if claim and claim != 'claim not found':
channel_url = f"{claim['name']}#{claim['claim_id']}"
if channel_url:
resolve = await self.resolve(channel_url, page=page, page_size=page_size)
resolve = resolve.get(channel_url, {})
claims = resolve.get('claims_in_channel', []) or []
total_pages = 0
if claims:
total_pages = int((resolve['total_claims'] + (page_size-1)) / page_size)
#sort_claim_results(claims)
return {"items": claims, "total_pages": total_pages, "page": page, "page_size": page_size}
else:
raise Exception("Must specify either name, claim_id, or txid:nout.")
if claims:
resolutions = await self.resolve(*(f"{claim['name']}#{claim['claim_id']}" for claim in claims['claims']))
claims = [value.get('claim', value.get('certificate')) for value in resolutions.values()]
sort_claim_results(claims)
return {"items": claims, "total_pages": 1, "page": 1, "page_size": len(claims)}
CHANNEL_DOC = """
Create, update, abandon and list your channel claims.
@@ -1923,7 +1854,7 @@ class Daemon(metaclass=JSONRPCServerType):
if not preview:
await tx.sign([account])
await account.ledger.broadcast(tx)
account.add_channel_private_key(txo.private_key)
account.add_channel_private_key(txo.ref, txo.private_key)
self.default_wallet.save()
await self.storage.save_claims([self._old_get_temp_claim_info(
tx, txo, claim_address, claim, name, dewies_to_lbc(amount)
@@ -2061,7 +1992,7 @@ class Daemon(metaclass=JSONRPCServerType):
if not preview:
await tx.sign([account])
await account.ledger.broadcast(tx)
account.add_channel_private_key(new_txo.private_key)
account.add_channel_private_key(new_txo.ref, new_txo.private_key)
self.default_wallet.save()
await self.storage.save_claims([self._old_get_temp_claim_info(
tx, new_txo, claim_address, new_txo.claim, new_txo.claim_name, dewies_to_lbc(amount)
@@ -2145,69 +2076,38 @@ class Daemon(metaclass=JSONRPCServerType):
)
@requires(WALLET_COMPONENT)
async def jsonrpc_channel_export(self, channel_id=None, channel_name=None, account_id=None):
async def jsonrpc_channel_export(self, claim_id):
"""
Export channel private key.
Export serialized channel signing information for a given certificate claim id
Usage:
channel_export (<channel_id> | --channel_id=<channel_id> | --channel_name=<channel_name>)
[--account_id=<account_id>...]
channel_export (<claim_id> | --claim_id=<claim_id>)
Options:
--channel_id=<channel_id> : (str) claim id of channel to export
--channel_name=<channel_name> : (str) name of channel to export
--account_id=<account_id> : (str) one or more account ids for accounts
to look in for channels, defaults to
all accounts.
--claim_id=<claim_id> : (str) Claim ID to export information about
Returns:
(str) serialized channel private key
(str) Serialized certificate information
"""
channel = await self.get_channel_or_error(account_id, channel_id, channel_name, for_signing=True)
address = channel.get_address(self.ledger)
public_key = await self.ledger.get_public_key_for_address(channel.get_address(self.ledger))
if not public_key:
raise Exception("Can't find public key for address holding the channel.")
export = {
'name': channel.claim_name,
'channel_id': channel.claim_id,
'holding_address': address,
'holding_public_key': public_key.extended_key_string(),
'signing_private_key': channel.private_key.to_pem().decode()
}
return base58.b58encode(json.dumps(export, separators=(',', ':')))
return await self.wallet_manager.export_certificate_info(claim_id)
@requires(WALLET_COMPONENT)
async def jsonrpc_channel_import(self, channel_data):
async def jsonrpc_channel_import(self, serialized_certificate_info):
"""
Import serialized channel private key (to allow signing new streams to the channel)
Import serialized channel signing information (to allow signing new claims to the channel)
Usage:
channel_import (<channel_data> | --channel_data=<channel_data>)
channel_import (<serialized_certificate_info> | --serialized_certificate_info=<serialized_certificate_info>)
Options:
--channel_data=<channel_data> : (str) serialized channel, as exported by channel export
--serialized_certificate_info=<serialized_certificate_info> : (str) certificate info
Returns:
(dict) Result dictionary
"""
decoded = base58.b58decode(channel_data)
data = json.loads(decoded)
channel_private_key = ecdsa.SigningKey.from_pem(
data['signing_private_key'], hashfunc=hashlib.sha256
)
account: LBCAccount = await self.ledger.get_account_for_address(data['holding_address'])
if not account:
account = LBCAccount.from_dict(self.ledger, self.default_wallet, {
'name': f"Holding Account For Channel {data['name']}",
'public_key': data['holding_public_key'],
'address_generator': {'name': 'single-address'}
})
if self.ledger.network.is_connected:
await self.ledger.subscribe_account(account)
account.add_channel_private_key(channel_private_key)
self.default_wallet.save()
return f"Added channel signing key for {data['name']}."
return await self.wallet_manager.import_certificate_info(serialized_certificate_info)
STREAM_DOC = """
Create, update, abandon, list and inspect your stream claims.
@@ -2293,7 +2193,7 @@ class Daemon(metaclass=JSONRPCServerType):
--duration=<duration> : (int) audio/video duration in seconds, automatically calculated
--channel_id=<channel_id> : (str) claim id of the publisher channel
--channel_name=<channel_name> : (str) name of publisher channel
--channel_account_id=<channel_account_id>: (str) one or more account ids for accounts to look in
--channel_account_id=<channel_id>: (str) one or more account ids for accounts to look in
for channel certificates, defaults to all accounts.
--account_id=<account_id> : (str) account to use for funding the transaction
--claim_address=<claim_address>: (str) address where the claim is sent to, if not specified
@@ -2406,7 +2306,7 @@ class Daemon(metaclass=JSONRPCServerType):
--duration=<duration> : (int) audio/video duration in seconds, automatically calculated
--channel_id=<channel_id> : (str) claim id of the publisher channel
--channel_name=<channel_name> : (str) name of the publisher channel
--channel_account_id=<channel_account_id>: (str) one or more account ids for accounts to look in
--channel_account_id=<channel_id>: (str) one or more account ids for accounts to look in
for channel certificates, defaults to all accounts.
--account_id=<account_id> : (str) account to use for funding the transaction
--claim_address=<claim_address>: (str) address where the claim is sent to, if not specified
@@ -2556,7 +2456,7 @@ class Daemon(metaclass=JSONRPCServerType):
--channel_id=<channel_id> : (str) claim id of the publisher channel
--channel_name=<channel_name> : (str) name of the publisher channel
--clear_channel : (bool) remove channel signature
--channel_account_id=<channel_account_id>: (str) one or more account ids for accounts to look in
--channel_account_id=<channel_id>: (str) one or more account ids for accounts to look in
for channel certificates, defaults to all accounts.
--account_id=<account_id> : (str) account to use for funding the transaction
--claim_address=<claim_address>: (str) address where the claim is sent to, if not specified
@@ -2766,13 +2666,14 @@ class Daemon(metaclass=JSONRPCServerType):
"""
account = self.get_account_or_default(account_id)
amount = self.get_dewies_or_error("amount", amount)
claim = await self.ledger.get_claim_by_claim_id(claim_id)
claim_address = claim.get_address(self.ledger)
claim = await account.ledger.get_claim_by_claim_id(claim_id)
claim_name = claim['name']
claim_address = claim['address']
if not tip:
claim_address = await account.receiving.get_or_create_usable_address()
tx = await Transaction.support(
claim.claim_name, claim_id, amount, claim_address, [account], account
claim_name, claim_id, amount, claim_address, [account], account
)
if not preview:
@@ -3343,113 +3244,173 @@ class Daemon(metaclass=JSONRPCServerType):
Create and list comments.
"""
async def jsonrpc_comment_list(self, claim_id: str, parent_id: str = None,
page=1, page_size=50, include_replies=True):
@requires(WALLET_COMPONENT)
async def jsonrpc_comment_list(self, claim_id, parent_comment_id=None, flat=False,
page=1, page_size=None, max_replies_shown=5):
"""
List comments associated with a claim.
Usage:
comment_list (<claim_id> | --claim_id=<claim_id>)
[(--page=<page> --page_size=<page_size>)]
[--parent_id=<parent_id>] [--include_replies]
comment_list <claim_id> [--flat] [(--page=<page> --page_size=<page_size>)]
[--parent_comment_id=<parent_comment_id>]
[--max_replies_shown=<max_replies_shown>]
Options:
--claim_id=<claim_id> : (str) The claim on which the comment will be made on
--include_replies : (bool) Flag to indicate whether or not you want the
replies to be included with the response or not
--parent_id=<parent_id> : (int)
--flat : (bool) Flag to indicate whether or not you want the
replies to be flattened along with the rest of
the comments attached to the claim. Off by default
--parent_comment_id=<parent_comment_id> : (int) The ID of an existing
comment to list replies from
--max_replies_shown=<max_replies_shown> : (int) For every comment that we pull replies from,
only retrieve up to this amount.
Note: This is not the same as page size.
--page=<page> : (int) The page you'd like to see in the comment list.
The first page is 1, second page is 2, and so on.
--page_size=<page_size> : (int) The amount of comments that you'd like to
retrieve in one request
Returns:
(dict) Containing the list, and information about the paginated content:
(dict) Dict containing the following schema:
{
"page": "Page number of the current items.",
"page_size": "Number of items to show on a page.",
"total_pages": "Total number of pages.",
"total_items": "Total number of items.",
"items": "A List of dict objects representing comments."
[
{
"comment": (str) The actual string as inputted by the user,
"comment_id": (str) The Comment's unique identifier,
"channel_name": (str) Name of the channel this was posted under, prepended with a '@',
"channel_id": (str) The Channel Claim ID that this comment was posted under,
"signature": (str) The signature of the comment,
"channel_url": (str) Channel's URI in the ClaimTrie,
"parent_id": (str) Comment this is replying to, (None) if this is the root,
"timestamp": (int) The time at which comment was entered into the server at, in nanoseconds.
},
...
]
"page": (int) The page of comments as provided when limiting response to page_size.
"page_size": (int) Number of comments in the given page. -1 if page_size wasn't used
"comments": (list) Contains all the comments (as dicts) as provided by the specified parameters
}
"""
return await jsonrpc_post(
self.conf.comment_server,
"get_claim_comments",
claim_id=claim_id,
parent_id=parent_id,
page=page,
page_size=page_size,
top_level=not include_replies
)
# Should be like this:
# comment list [claim_id] [parent_comment_id] --flat --page=1 --page-size=10
url = self.conf.comment_server
# The server uses permanent URIs for keys; not claims.
# This is temporary until we can get that functionality removed
claim_info = (await self.jsonrpc_claim_search(claim_id=claim_id))
if 'error' in claim_info:
raise Exception(claim_info['error'])
if claim_info["page"] == 0:
return {'page': 1, 'page_size': 0, 'comments': []}
claim_uri = claim_info["items"][0]['permanent_url']
# These two cases need separation since getting replies requires a bit of magic
# to reduce request count from O(n^2) to O(1)
if parent_comment_id:
# Since we don't directly get all the comment data at once,
# we have to do a bit more work to get them
comment_ids = await jsonrpc_post(url, 'get_comment_replies',
comm_index=parent_comment_id, clean=False)
comment_ids = comment_ids['result']
if page_size is not None:
comment_ids = comment_ids[page_size * (page - 1): page_size * page]
# now we have to just batch request the reply comments
comments_batch = [
rpc_body('get_comment_data', index, comm_index=comment_id, better_keys=True)
for index, comment_id in enumerate(comment_ids)
]
del comment_ids
comments = await jsonrpc_batch(url, comments_batch, clean=True)
else:
# Get the content of the top level comments
comments = await jsonrpc_post(url, 'get_claim_comments', uri=claim_uri, better_keys=True)
if page_size is not None:
comments = comments[page_size * (page - 1): page_size * page]
# By now comments should be a list containing comment dicts that are supposed to be
# at the given height that was requested. The parent_id may or may not be present
# in the dicts, as they may or may not be replies to comments at a higher level
# However this is dependent purely on whether or not parent_comment_id is None or not
reply_lists = await jsonrpc_batch(url, [
rpc_body('get_comment_replies', index, comm_index=comment['comment_id'])
for index, comment in enumerate(comments)
])
response = {
'page': page,
'page_size': -1 if page_size is None else page_size,
'comments': []
}
if flat:
# If it's flat then we'll need to get the comments into an order such that
# If an element e in the list has a non-null parent id, the element before it
# is either also a reply with the same parent id, or has an id that equals e's parent id,
# in which case it's the comment that is being replied to.
# Otherwise, if it has a null parent id, then it is a top level comment.
async def jsonrpc_comment_create(
self, claim_id: str, comment: str, parent_id: str = None,
channel_account_id=None, channel_name: str = None, channel_id: str = None) -> dict:
# To do this, we create a dict that maps the index of the comment in the array
# to a list containing the comment IDs of the replies
comment_replies = {resp['id']: resp['result'] for resp in reply_lists if 'result' in resp}
# Next, we create a batch request for the actual data of all of the replies
# the id in this batch request is going to be in the form 'X:Y'
# where X is the index of the parent comment in `comments,
# and Y is index of the reply's ID within the list X maps to in `comment_replies`
full_replies_batch = [
rpc_body('get_comment_data', f'{parent_idx}:{idx}', comm_index=reply_id, better_keys=True)
for parent_idx, id_list in comment_replies.items()
for idx, reply_id in enumerate(id_list[0:max_replies_shown])
]
reply_dump = await jsonrpc_batch(url, full_replies_batch)
del full_replies_batch
# This neatly orders the response into a dict to aggregate the
# full comments by the parent comment they're replying to
#
# WARNING: The following block is going to be saving the comment dict
# objects TO `comment_replies`. This means that the lists
# stored in `comments_replies` may not hold just comments, but
# the ids of the comments who weren't requested due to the
# maximum reply limit. They need to be either cleaned out or stored
# somewhere else
for comment in reply_dump:
parent_index, reply_index = comment['id'].split(':')
parent_index, reply_index = int(parent_index), int(reply_index)
comment_replies[parent_index][reply_index] = comment['result']
for idx, parent_comment in enumerate(comments):
if 'parent_id' not in parent_comment:
parent_comment['parent_id'] = None
parent_comment['reply_count'] = len(comment_replies[idx])
parent_comment['omitted'] = 0
if len(comment_replies[idx]) > max_replies_shown:
parent_comment['omitted'] = len(comment_replies[idx]) - max_replies_shown
response['comments'].append(parent_comment)
response['comments'] += comment_replies[idx][0:max_replies_shown]
response['page_size'] = page_size if page_size is not None else -1
return response
else:
for id_list in reply_lists:
comments[id_list['id']]['reply_count'] = len(id_list['result'])
comments[id_list['id']]['omitted'] = len(id_list['result'])
response['comments'] = comments
del reply_lists
return response
@requires(WALLET_COMPONENT)
async def jsonrpc_comment_create(self, claim_id: str, channel_id: str,
message: str, parent_comment_id: int = None) -> dict:
"""
Create and associate a comment with a claim using your channel identity.
Usage:
comment_create (<comment> | --comment=<comment>)
(<claim_id> | --claim_id=<claim_id>)
[--parent_id=<parent_id>]
[--channel_id=<channel_id>] [--channel_name=<channel_name>]
[--channel_account_id=<channel_account_id>...]
comment_create <claim_id> <channel_id> <message> [--parent_comment_id=<parent_comment_id>]
Options:
--comment=<comment> : (str) Comment to be made, should be at most 2000 characters.
--claim_id=<claim_id> : (str) The ID of the claim on which the comment should be made on
--parent_id=<parent_id> : (str) The ID of a comment to make a response to
--channel_id=<channel_id> : (str) The ID of the channel you want to post under
--channel_name=<channel_name>: (str) The channel you want to post as, prepend with a '@'
--channel_account_id=<channel_account_id>: (str) one or more account ids for accounts to look in
for channel certificates, defaults to all accounts.
--parent_comment_id=<parent_comment_id> : (int) The ID of a comment to make a response to
Returns:
(dict) Comment object if successfully made, (None) otherwise
{
"comment": (str) The actual string as inputted by the user,
"comment_id": (str) The Comment's unique identifier,
"channel_name": (str) Name of the channel this was posted under, prepended with a '@',
"channel_id": (str) The Channel Claim ID that this comeent was posted under,
"signature": (str) The signature of the comment,
"channel_url": (str) Channel's URI in the ClaimTrie,
"parent_id": (str) Comment this is replying to, (None) if this is the root,
"timestamp": (int) The time at which comment was entered into the server at, in nanoseconds.
}
(dict) Comment object if successfully made
"""
comment = {
'comment': comment,
'claim_id': claim_id,
'parent_id': parent_id,
}
channel = await self.get_channel_or_none(channel_account_id, channel_id, channel_name, for_signing=True)
if channel:
comment.update({
'channel_id': channel.claim_id,
'channel_name': channel.claim_name,
'signature': sign_comment(
channel_name=channel_name,
channel_id=channel_id,
comment=comment,
salt=time.time_ns()
)
})
return await jsonrpc_post(self.conf.comment_server, 'create_comment', **comment)
if not 1 < len(message) <= 2000:
raise Exception(f'Message length ({len(message)}) needs to be between 2 and 2000 chars')
url = self.conf.comment_server
if parent_comment_id is not None:
comment_id = await jsonrpc_post(url, 'reply', parent_id=parent_comment_id,
poster=channel_id, message=message)
else:
claim_data = await self.jsonrpc_claim_search(claim_id=claim_id)
if 'error' not in claim_data and claim_data['total_pages'] == 1:
uri = claim_data['items'][0]['permanent_url']
comment_id = await jsonrpc_post(url, 'comment', uri=uri,
poster=channel_id, message=message)
else:
raise Exception(f"permanent_url is not in the claim_data {claim_data}\n"
f"The given claim_id ({claim_id}) may be invalid")
return await jsonrpc_post(url, 'get_comment_data', comm_index=comment_id, better_keys=True)
def valid_address_or_error(self, address):
try:
@@ -3464,16 +3425,16 @@ class Daemon(metaclass=JSONRPCServerType):
raise Exception(
"Stream name cannot be blank."
)
parsed = URL.parse(name)
if parsed.has_channel:
parsed = parse_lbry_uri(name)
if parsed.is_channel:
raise Exception(
"Stream names cannot start with '@' symbol. This is reserved for channels claims."
)
if not parsed.has_stream or parsed.stream.name != name:
if parsed.name != name:
raise Exception(
"Stream name has invalid characters."
)
except (TypeError, ValueError):
except (TypeError, URIParseError):
raise Exception("Invalid stream name.")
@staticmethod
@@ -3483,12 +3444,12 @@ class Daemon(metaclass=JSONRPCServerType):
raise Exception(
"Channel name cannot be blank."
)
parsed = URL.parse(name)
if not parsed.has_channel:
parsed = parse_lbry_uri(name)
if not parsed.is_channel:
raise Exception("Channel names must start with '@' symbol.")
if parsed.channel.name != name:
if parsed.name != name:
raise Exception("Channel name has invalid character")
except (TypeError, ValueError):
except (TypeError, URIParseError):
raise Exception("Invalid channel name.")
def get_fee_address(self, kwargs: dict, claim_address: str) -> str:
@@ -3564,18 +3525,23 @@ class Daemon(metaclass=JSONRPCServerType):
except ValueError as e:
raise ValueError(f"Invalid value for '{argument}': {e.args[0]}")
async def resolve(self, urls):
results = await self.ledger.resolve(urls)
if results:
try:
claims = self.stream_manager._convert_to_old_resolve_output(results)
await self.storage.save_claims_for_resolve([
value for value in claims.values() if 'error' not in value
])
except DecodeError:
pass
async def resolve(self, *uris, **kwargs):
page = kwargs.get('page', 0)
page_size = kwargs.get('page_size', 10)
ledger: MainNetLedger = self.default_account.ledger
results = await ledger.resolve(page, page_size, *uris)
if 'error' not in results:
await self.storage.save_claims_for_resolve([
value for value in results.values() if 'error' not in value
])
return results
async def get_claims_for_name(self, name: str):
response = await self.ledger.network.get_claims_for_name(name)
resolutions = await self.resolve(*(f"{claim['name']}#{claim['claim_id']}" for claim in response['claims']))
response['claims'] = [value.get('claim', value.get('certificate')) for value in resolutions.values()]
return response
def _old_get_temp_claim_info(self, tx, txo, address, claim_dict, name, bid):
return {
"claim_id": txo.claim_id,
+19 -39
View File
@@ -1,51 +1,31 @@
import logging
import aiohttp
import hashlib
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives.asymmetric import utils
from cryptography.hazmat.primitives.asymmetric.rsa import generate_private_key
log = logging.getLogger(__name__)
def sign_comment(**kwargs):
private_key = generate_private_key(
public_exponent=65537,
key_size=4096,
backend=default_backend()
)
chosen_hash = hashes.SHA256()
hasher = hashes.Hash(chosen_hash, default_backend())
value_to_hash = b':'.join(bytes(v, 'utf-8') for v in kwargs.values() if type(v) is str)
hasher.update(value_to_hash)
digest = hasher.finalize()
signature = private_key.sign(
digest,
padding.PSS(
mgf=padding.MGF1(hashes.SHA256()),
salt_length=padding.PSS.MAX_LENGTH
),
utils.Prehashed(chosen_hash)
)
m = hashlib.sha3_256()
m.update(signature)
return m.hexdigest()
def rpc_body(method: str, rpc_id: any, **params) -> dict:
return {'jsonrpc': '2.0', 'id': rpc_id, 'method': method, 'params': {**params}}
async def jsonrpc_post(url: str, method: str, **params) -> any:
json_body = {'jsonrpc': '2.0', 'id': None, 'method': method, 'params': params}
clean = params.pop('clean', True)
response = (await jsonrpc_batch(url, [rpc_body(method, 1, **params)]))[0]
if clean:
if 'error' in response:
return response['error']
return response['result']
else:
return response
async def jsonrpc_batch(url: str, calls: list, batch_size: int = 50, clean: bool = False) -> list:
headers = {'Content-Type': 'application/json'}
async with aiohttp.request('POST', url, json=json_body, headers=headers) as response:
try:
result = await response.json()
return result['result'] if 'result' in result else result
except aiohttp.client.ContentTypeError as cte:
log.exception('Unable to decode respose from server: %s', cte)
return await response.text()
complete = []
batch_size = max(batch_size, 50)
for i in range(0, len(calls), batch_size):
async with aiohttp.request('POST', url, headers=headers, json=calls[i:i+batch_size]) as response:
complete += await response.json()
if clean:
complete = [body['result'] if 'result' in body else None for body in complete]
return complete
@@ -123,8 +123,8 @@ class LBRYioFeed(MarketFeed):
def __init__(self):
super().__init__(
"BTCLBC",
"lbry.com",
"https://api.lbry.com/lbc/exchange_rate",
"lbry.io",
"https://api.lbry.io/lbc/exchange_rate",
{},
0.0,
)
@@ -140,8 +140,8 @@ class LBRYioBTCFeed(MarketFeed):
def __init__(self):
super().__init__(
"USDBTC",
"lbry.com",
"https://api.lbry.com/lbc/exchange_rate",
"lbry.io",
"https://api.lbry.io/lbc/exchange_rate",
{},
0.0,
)
+24 -38
View File
@@ -1,11 +1,9 @@
import logging
from decimal import Decimal
from binascii import hexlify, unhexlify
from binascii import hexlify
from datetime import datetime
from json import JSONEncoder
from google.protobuf.message import DecodeError
from ecdsa import BadSignatureError
from lbrynet.schema.claim import Claim
from lbrynet.wallet.ledger import MainNetLedger, Account
from lbrynet.wallet.transaction import Transaction, Output
@@ -169,41 +167,33 @@ class JSONResponseEncoder(JSONEncoder):
if txo.script.is_claim_involved:
output.update({
'name': txo.claim_name,
'normalized_name': txo.normalized_name,
'claim_id': txo.claim_id,
'permanent_url': txo.permanent_url,
'meta': self.encode_claim_meta(txo.meta)
})
if 'short_url' in output['meta']:
output['short_url'] = output['meta'].pop('short_url')
if 'canonical_url' in output['meta']:
output['canonical_url'] = output['meta'].pop('canonical_url')
if txo.script.is_claim_name or txo.script.is_update_claim:
try:
output['value'] = txo.claim
output['value_type'] = txo.claim.claim_type
if self.include_protobuf:
output['protobuf'] = hexlify(txo.claim.to_bytes())
output['value'] = txo.claim
output['value_type'] = txo.claim.claim_type
if self.include_protobuf:
output['protobuf'] = hexlify(txo.claim.to_bytes())
if txo.channel is not None:
output['signing_channel'] = {
'name': txo.channel.claim_name,
'claim_id': txo.channel.claim_id,
'value': txo.channel.claim
}
if check_signature and txo.claim.is_signed:
if txo.channel is not None:
output['signing_channel'] = self.encode_output(txo.channel)
output['is_channel_signature_valid'] = False
try:
output['is_channel_signature_valid'] = txo.is_signed_by(txo.channel, self.ledger)
else:
output['signing_channel'] = {'channel_id': txo.claim.signing_channel_id}
output['is_channel_signature_valid'] = False
except DecodeError:
pass
except BadSignatureError:
pass
except ValueError:
log.exception(
'txo.id: %s, txo.channel.id:%s, output: %s',
txo.id, txo.channel.id, output
)
return output
def encode_claim_meta(self, meta):
for key, value in meta.items():
if key.endswith('_amount'):
if isinstance(value, int):
meta[key] = dewies_to_lbc(value)
if meta.get('creation_height', 0) > 0:
meta['creation_timestamp'] = self.ledger.headers[meta['creation_height']]['timestamp']
return meta
def encode_input(self, txi):
return self.encode_output(txi.txo_ref.txo, False) if txi.txo_ref.txo is not None else {
'txid': txi.txo_ref.tx_ref.id,
@@ -228,10 +218,6 @@ class JSONResponseEncoder(JSONEncoder):
})
return file
def encode_claim(self, claim):
encoded = getattr(claim, claim.claim_type).to_dict()
if 'public_key' in encoded:
encoded['public_key_id'] = self.ledger.public_key_to_address(
unhexlify(encoded['public_key'])
)
return encoded
@staticmethod
def encode_claim(claim):
return getattr(claim, claim.claim_type).to_dict()
-2
View File
@@ -3,7 +3,6 @@ import os
import logging.handlers
from lbrynet import build_type, __version__ as lbrynet_version
from torba import __version__ as torba_version
log = logging.getLogger(__name__)
@@ -19,7 +18,6 @@ def get_platform() -> dict:
"os_release": platform.release(),
"os_system": os_system,
"lbrynet_version": lbrynet_version,
"torba_version": torba_version,
"build": build_type.BUILD, # CI server sets this during build step
}
if p["os_system"] == "Linux":
+3 -2
View File
@@ -195,13 +195,14 @@ class Stream(BaseClaim):
claim['source']['hash'] = self.source.file_hash
if 'sd_hash' in claim['source']:
claim['source']['sd_hash'] = self.source.sd_hash
if 'media_type' in claim['source']:
claim['stream_type'] = guess_stream_type(claim['source']['media_type'])
fee = claim.get('fee', {})
if 'address' in fee:
fee['address'] = self.fee.address
if 'amount' in fee:
fee['amount'] = str(self.fee.amount)
stream_type = self.message.WhichOneof('type')
if stream_type:
claim['stream_type'] = stream_type
return claim
def update(self, file_path=None, height=None, width=None, duration=None, **kwargs):
+2 -4
View File
@@ -15,10 +15,8 @@ def from_old_json_schema(claim, payload: bytes):
raise DecodeError('Could not parse JSON.')
stream = claim.stream
stream.source.sd_hash = value['sources']['lbry_sd_hash']
stream.source.media_type = (
value.get('content_type', value.get('content-type')) or
'application/octet-stream'
)
stream.source.media_type = value.get(
'content_type', value.get('content-type', 'application/octet-stream'))
stream.title = value.get('title', '')
stream.description = value.get('description', '')
if value.get('thumbnail', ''):
-117
View File
@@ -1,117 +0,0 @@
import base64
import struct
from typing import List
from binascii import hexlify
from itertools import chain
from lbrynet.schema.types.v2.result_pb2 import Outputs as OutputsMessage
class Outputs:
__slots__ = 'txos', 'extra_txos', 'txs', 'offset', 'total'
def __init__(self, txos: List, extra_txos: List, txs: set, offset: int, total: int):
self.txos = txos
self.txs = txs
self.extra_txos = extra_txos
self.offset = offset
self.total = total
def inflate(self, txs):
tx_map = {tx.hash: tx for tx in txs}
for txo_message in self.extra_txos:
self.message_to_txo(txo_message, tx_map)
return [self.message_to_txo(txo_message, tx_map) for txo_message in self.txos]
def message_to_txo(self, txo_message, tx_map):
if txo_message.WhichOneof('meta') == 'error':
return None
txo = tx_map[txo_message.tx_hash].outputs[txo_message.nout]
if txo_message.WhichOneof('meta') == 'claim':
claim = txo_message.claim
txo.meta = {
'short_url': f'lbry://{claim.short_url}',
'canonical_url': f'lbry://{claim.canonical_url or claim.short_url}',
'is_controlling': claim.is_controlling,
'creation_height': claim.creation_height,
'activation_height': claim.activation_height,
'expiration_height': claim.expiration_height,
'effective_amount': claim.effective_amount,
'support_amount': claim.support_amount,
'trending_group': claim.trending_group,
'trending_mixed': claim.trending_mixed,
'trending_local': claim.trending_local,
'trending_global': claim.trending_global,
}
if claim.HasField('channel'):
txo.channel = tx_map[claim.channel.tx_hash].outputs[claim.channel.nout]
try:
if txo.claim.is_channel:
txo.meta['claims_in_channel'] = claim.claims_in_channel
except:
pass
return txo
@classmethod
def from_base64(cls, data: str) -> 'Outputs':
return cls.from_bytes(base64.b64decode(data))
@classmethod
def from_bytes(cls, data: bytes) -> 'Outputs':
outputs = OutputsMessage()
outputs.ParseFromString(data)
txs = set()
for txo_message in chain(outputs.txos, outputs.extra_txos):
if txo_message.WhichOneof('meta') == 'error':
continue
txs.add((hexlify(txo_message.tx_hash[::-1]).decode(), txo_message.height))
return cls(outputs.txos, outputs.extra_txos, txs, outputs.offset, outputs.total)
@classmethod
def to_base64(cls, txo_rows, extra_txo_rows, offset=0, total=None) -> str:
return base64.b64encode(cls.to_bytes(txo_rows, extra_txo_rows, offset, total)).decode()
@classmethod
def to_bytes(cls, txo_rows, extra_txo_rows, offset=0, total=None) -> bytes:
page = OutputsMessage()
page.offset = offset
page.total = total or len(txo_rows)
for row in txo_rows:
cls.row_to_message(row, page.txos.add())
for row in extra_txo_rows:
cls.row_to_message(row, page.extra_txos.add())
return page.SerializeToString()
@classmethod
def row_to_message(cls, txo, txo_message):
if isinstance(txo, Exception):
txo_message.error.text = txo.args[0]
if isinstance(txo, ValueError):
txo_message.error.code = txo_message.error.INVALID
elif isinstance(txo, LookupError):
txo_message.error.code = txo_message.error.NOT_FOUND
return
txo_message.tx_hash = txo['txo_hash'][:32]
txo_message.nout, = struct.unpack('<I', txo['txo_hash'][32:])
txo_message.height = txo['height']
txo_message.claim.short_url = txo['short_url']
if txo['canonical_url'] is not None:
txo_message.claim.canonical_url = txo['canonical_url']
txo_message.claim.is_controlling = bool(txo['is_controlling'])
txo_message.claim.creation_height = txo['creation_height']
txo_message.claim.activation_height = txo['activation_height']
txo_message.claim.expiration_height = txo['expiration_height']
if txo['claims_in_channel'] is not None:
txo_message.claim.claims_in_channel = txo['claims_in_channel']
txo_message.claim.effective_amount = txo['effective_amount']
txo_message.claim.support_amount = txo['support_amount']
txo_message.claim.trending_group = txo['trending_group']
txo_message.claim.trending_mixed = txo['trending_mixed']
txo_message.claim.trending_local = txo['trending_local']
txo_message.claim.trending_global = txo['trending_global']
if txo['channel_txo_hash']:
channel = txo_message.claim.channel
channel.tx_hash = txo['channel_txo_hash'][:32]
channel.nout, = struct.unpack('<I', txo['channel_txo_hash'][32:])
channel.height = txo['channel_height']
-376
View File
@@ -1,376 +0,0 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: result.proto
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor.FileDescriptor(
name='result.proto',
package='pb',
syntax='proto3',
serialized_options=None,
serialized_pb=_b('\n\x0cresult.proto\x12\x02pb\"b\n\x07Outputs\x12\x18\n\x04txos\x18\x01 \x03(\x0b\x32\n.pb.Output\x12\x1e\n\nextra_txos\x18\x02 \x03(\x0b\x32\n.pb.Output\x12\r\n\x05total\x18\x03 \x01(\r\x12\x0e\n\x06offset\x18\x04 \x01(\r\"{\n\x06Output\x12\x0f\n\x07tx_hash\x18\x01 \x01(\x0c\x12\x0c\n\x04nout\x18\x02 \x01(\r\x12\x0e\n\x06height\x18\x03 \x01(\r\x12\x1e\n\x05\x63laim\x18\x07 \x01(\x0b\x32\r.pb.ClaimMetaH\x00\x12\x1a\n\x05\x65rror\x18\x0f \x01(\x0b\x32\t.pb.ErrorH\x00\x42\x06\n\x04meta\"\xe7\x02\n\tClaimMeta\x12\x1b\n\x07\x63hannel\x18\x01 \x01(\x0b\x32\n.pb.Output\x12\x11\n\tshort_url\x18\x02 \x01(\t\x12\x15\n\rcanonical_url\x18\x03 \x01(\t\x12\x16\n\x0eis_controlling\x18\x04 \x01(\x08\x12\x17\n\x0f\x63reation_height\x18\x05 \x01(\r\x12\x19\n\x11\x61\x63tivation_height\x18\x06 \x01(\r\x12\x19\n\x11\x65xpiration_height\x18\x07 \x01(\r\x12\x19\n\x11\x63laims_in_channel\x18\x08 \x01(\r\x12\x18\n\x10\x65\x66\x66\x65\x63tive_amount\x18\n \x01(\x04\x12\x16\n\x0esupport_amount\x18\x0b \x01(\x04\x12\x16\n\x0etrending_group\x18\x0c \x01(\r\x12\x16\n\x0etrending_mixed\x18\r \x01(\x02\x12\x16\n\x0etrending_local\x18\x0e \x01(\x02\x12\x17\n\x0ftrending_global\x18\x0f \x01(\x02\"i\n\x05\x45rror\x12\x1c\n\x04\x63ode\x18\x01 \x01(\x0e\x32\x0e.pb.Error.Code\x12\x0c\n\x04text\x18\x02 \x01(\t\"4\n\x04\x43ode\x12\x10\n\x0cUNKNOWN_CODE\x10\x00\x12\r\n\tNOT_FOUND\x10\x01\x12\x0b\n\x07INVALID\x10\x02\x62\x06proto3')
)
_ERROR_CODE = _descriptor.EnumDescriptor(
name='Code',
full_name='pb.Error.Code',
filename=None,
file=DESCRIPTOR,
values=[
_descriptor.EnumValueDescriptor(
name='UNKNOWN_CODE', index=0, number=0,
serialized_options=None,
type=None),
_descriptor.EnumValueDescriptor(
name='NOT_FOUND', index=1, number=1,
serialized_options=None,
type=None),
_descriptor.EnumValueDescriptor(
name='INVALID', index=2, number=2,
serialized_options=None,
type=None),
],
containing_type=None,
serialized_options=None,
serialized_start=660,
serialized_end=712,
)
_sym_db.RegisterEnumDescriptor(_ERROR_CODE)
_OUTPUTS = _descriptor.Descriptor(
name='Outputs',
full_name='pb.Outputs',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='txos', full_name='pb.Outputs.txos', index=0,
number=1, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='extra_txos', full_name='pb.Outputs.extra_txos', index=1,
number=2, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='total', full_name='pb.Outputs.total', index=2,
number=3, type=13, cpp_type=3, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='offset', full_name='pb.Outputs.offset', index=3,
number=4, type=13, cpp_type=3, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=20,
serialized_end=118,
)
_OUTPUT = _descriptor.Descriptor(
name='Output',
full_name='pb.Output',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='tx_hash', full_name='pb.Output.tx_hash', index=0,
number=1, type=12, cpp_type=9, label=1,
has_default_value=False, default_value=_b(""),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='nout', full_name='pb.Output.nout', index=1,
number=2, type=13, cpp_type=3, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='height', full_name='pb.Output.height', index=2,
number=3, type=13, cpp_type=3, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='claim', full_name='pb.Output.claim', index=3,
number=7, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='error', full_name='pb.Output.error', index=4,
number=15, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
_descriptor.OneofDescriptor(
name='meta', full_name='pb.Output.meta',
index=0, containing_type=None, fields=[]),
],
serialized_start=120,
serialized_end=243,
)
_CLAIMMETA = _descriptor.Descriptor(
name='ClaimMeta',
full_name='pb.ClaimMeta',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='channel', full_name='pb.ClaimMeta.channel', index=0,
number=1, type=11, cpp_type=10, label=1,
has_default_value=False, default_value=None,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='short_url', full_name='pb.ClaimMeta.short_url', index=1,
number=2, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='canonical_url', full_name='pb.ClaimMeta.canonical_url', index=2,
number=3, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='is_controlling', full_name='pb.ClaimMeta.is_controlling', index=3,
number=4, type=8, cpp_type=7, label=1,
has_default_value=False, default_value=False,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='creation_height', full_name='pb.ClaimMeta.creation_height', index=4,
number=5, type=13, cpp_type=3, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='activation_height', full_name='pb.ClaimMeta.activation_height', index=5,
number=6, type=13, cpp_type=3, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='expiration_height', full_name='pb.ClaimMeta.expiration_height', index=6,
number=7, type=13, cpp_type=3, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='claims_in_channel', full_name='pb.ClaimMeta.claims_in_channel', index=7,
number=8, type=13, cpp_type=3, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='effective_amount', full_name='pb.ClaimMeta.effective_amount', index=8,
number=10, type=4, cpp_type=4, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='support_amount', full_name='pb.ClaimMeta.support_amount', index=9,
number=11, type=4, cpp_type=4, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='trending_group', full_name='pb.ClaimMeta.trending_group', index=10,
number=12, type=13, cpp_type=3, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='trending_mixed', full_name='pb.ClaimMeta.trending_mixed', index=11,
number=13, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='trending_local', full_name='pb.ClaimMeta.trending_local', index=12,
number=14, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='trending_global', full_name='pb.ClaimMeta.trending_global', index=13,
number=15, type=2, cpp_type=6, label=1,
has_default_value=False, default_value=float(0),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=246,
serialized_end=605,
)
_ERROR = _descriptor.Descriptor(
name='Error',
full_name='pb.Error',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='code', full_name='pb.Error.code', index=0,
number=1, type=14, cpp_type=8, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
_descriptor.FieldDescriptor(
name='text', full_name='pb.Error.text', index=1,
number=2, type=9, cpp_type=9, label=1,
has_default_value=False, default_value=_b("").decode('utf-8'),
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR),
],
extensions=[
],
nested_types=[],
enum_types=[
_ERROR_CODE,
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=607,
serialized_end=712,
)
_OUTPUTS.fields_by_name['txos'].message_type = _OUTPUT
_OUTPUTS.fields_by_name['extra_txos'].message_type = _OUTPUT
_OUTPUT.fields_by_name['claim'].message_type = _CLAIMMETA
_OUTPUT.fields_by_name['error'].message_type = _ERROR
_OUTPUT.oneofs_by_name['meta'].fields.append(
_OUTPUT.fields_by_name['claim'])
_OUTPUT.fields_by_name['claim'].containing_oneof = _OUTPUT.oneofs_by_name['meta']
_OUTPUT.oneofs_by_name['meta'].fields.append(
_OUTPUT.fields_by_name['error'])
_OUTPUT.fields_by_name['error'].containing_oneof = _OUTPUT.oneofs_by_name['meta']
_CLAIMMETA.fields_by_name['channel'].message_type = _OUTPUT
_ERROR.fields_by_name['code'].enum_type = _ERROR_CODE
_ERROR_CODE.containing_type = _ERROR
DESCRIPTOR.message_types_by_name['Outputs'] = _OUTPUTS
DESCRIPTOR.message_types_by_name['Output'] = _OUTPUT
DESCRIPTOR.message_types_by_name['ClaimMeta'] = _CLAIMMETA
DESCRIPTOR.message_types_by_name['Error'] = _ERROR
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
Outputs = _reflection.GeneratedProtocolMessageType('Outputs', (_message.Message,), dict(
DESCRIPTOR = _OUTPUTS,
__module__ = 'result_pb2'
# @@protoc_insertion_point(class_scope:pb.Outputs)
))
_sym_db.RegisterMessage(Outputs)
Output = _reflection.GeneratedProtocolMessageType('Output', (_message.Message,), dict(
DESCRIPTOR = _OUTPUT,
__module__ = 'result_pb2'
# @@protoc_insertion_point(class_scope:pb.Output)
))
_sym_db.RegisterMessage(Output)
ClaimMeta = _reflection.GeneratedProtocolMessageType('ClaimMeta', (_message.Message,), dict(
DESCRIPTOR = _CLAIMMETA,
__module__ = 'result_pb2'
# @@protoc_insertion_point(class_scope:pb.ClaimMeta)
))
_sym_db.RegisterMessage(ClaimMeta)
Error = _reflection.GeneratedProtocolMessageType('Error', (_message.Message,), dict(
DESCRIPTOR = _ERROR,
__module__ = 'result_pb2'
# @@protoc_insertion_point(class_scope:pb.Error)
))
_sym_db.RegisterMessage(Error)
# @@protoc_insertion_point(module_scope)
+185
View File
@@ -0,0 +1,185 @@
import re
PROTOCOL = 'lbry://'
CHANNEL_CHAR = '@'
CLAIM_ID_CHAR = '#'
CLAIM_SEQUENCE_CHAR = ':'
BID_POSITION_CHAR = '$'
PATH_CHAR = '/'
QUERY_CHAR = '?'
CLAIM_ID_MAX_LENGTH = 40
CHANNEL_NAME_MIN_LENGTH = 1
class URIParseError(Exception):
pass
class URI(object):
__slots__ = ['name', 'claim_sequence', 'bid_position', 'claim_id', 'path']
def __init__(self, name, claim_sequence=None, bid_position=None, claim_id=None, path=None):
if len([v for v in [claim_sequence, bid_position, claim_id] if v is not None]) > 1:
raise ValueError(
"Only one of these may be present at a time: claim_sequence, bid_position, claim_id"
)
self.name = name
self.claim_sequence = claim_sequence
self.bid_position = bid_position
self.claim_id = claim_id
self.path = path
if self.path is not None and not self.contains_channel:
raise ValueError("Content claims cannot have paths")
def __str__(self):
return self.to_uri_string()
def __eq__(self, other):
for prop in self.__slots__:
if not hasattr(other, prop) or getattr(self, prop) != getattr(other, prop):
return False
return self.__class__ == other.__class__
@property
def channel_name(self):
return self.name if self.contains_channel else None
@property
def claim_name(self):
return self.name if not self.contains_channel else self.path
@property
def contains_channel(self):
return self.name.startswith(CHANNEL_CHAR)
@property
def is_channel(self):
return self.contains_channel and not self.path
def to_uri_string(self):
uri_string = PROTOCOL + "%s" % self.name
if self.claim_sequence is not None:
uri_string += CLAIM_SEQUENCE_CHAR + "%i" % self.claim_sequence
elif self.bid_position is not None:
uri_string += BID_POSITION_CHAR + "%i" % self.bid_position
elif self.claim_id is not None:
uri_string += CLAIM_ID_CHAR + "%s" % self.claim_id
if self.path is not None:
uri_string += PATH_CHAR + "%s" % self.path
return uri_string
def to_dict(self):
return {
"name": self.name,
'claim_sequence': self.claim_sequence,
'bid_position': self.bid_position,
'claim_id': self.claim_id,
'path': self.path,
}
@classmethod
def from_uri_string(cls, uri_string):
"""
Parses LBRY uri into its components
:param uri_string: format - lbry://name:n$rank#id/path
optional modifiers:
claim_sequence (int): the nth claim to the name
bid_position (int): the bid queue position of the claim for the name
claim_id (str): the claim id for the claim
path (str): claim within a channel
:return: URI
"""
match = re.match(get_schema_regex(), uri_string)
if match is None:
raise URIParseError('Invalid URI')
if match.group('content_name') and match.group('path'):
raise URIParseError('Only channels may have paths')
return cls(
name=match.group("content_or_channel_name"),
claim_sequence=int(match.group("claim_sequence")) if match.group(
"claim_sequence") is not None else None,
bid_position=int(match.group("bid_position")) if match.group(
"bid_position") is not None else None,
claim_id=match.group("claim_id"),
path=match.group("path")
)
@classmethod
def from_dict(cls, uri_dict):
"""
Creates URI from dict
:return: URI
"""
return cls(**uri_dict)
def get_schema_regex():
def _named(name, regex):
return "(?P<" + name + ">" + regex + ")"
def _group(regex):
return "(?:" + regex + ")"
# TODO: regex should include the fact that content names cannot have paths
# right now this is only enforced in code, not in the regex
# Escape constants
claim_id_char = re.escape(CLAIM_ID_CHAR)
claim_sequence_char = re.escape(CLAIM_SEQUENCE_CHAR)
bid_position_char = re.escape(BID_POSITION_CHAR)
channel_char = re.escape(CHANNEL_CHAR)
path_char = re.escape(PATH_CHAR)
protocol = _named("protocol", re.escape(PROTOCOL))
# Define basic building blocks
valid_name_char = "[^=&#:$@%?/]" # from the grammar section of https://spec.lbry.io/
name_content = valid_name_char + '+'
name_min_channel_length = valid_name_char + '{' + str(CHANNEL_NAME_MIN_LENGTH) + ',}'
positive_number = "[1-9][0-9]*"
number = '\-?' + positive_number
# Define URI components
content_name = _named("content_name", name_content)
channel_name = _named("channel_name", channel_char + name_min_channel_length)
content_or_channel_name = _named("content_or_channel_name", content_name + "|" + channel_name)
claim_id_piece = _named("claim_id", "[0-9a-f]{1," + str(CLAIM_ID_MAX_LENGTH) + "}")
claim_id = _group(claim_id_char + claim_id_piece)
bid_position_piece = _named("bid_position", number)
bid_position = _group(bid_position_char + bid_position_piece)
claim_sequence_piece = _named("claim_sequence", number)
claim_sequence = _group(claim_sequence_char + claim_sequence_piece)
modifier = _named("modifier", claim_id + "|" + bid_position + "|" + claim_sequence)
path_piece = _named("path", name_content)
path = _group(path_char + path_piece)
# Combine components
uri = _named("uri", (
'^' +
protocol + '?' +
content_or_channel_name +
modifier + '?' +
path + '?' +
'$'
))
return uri
def parse_lbry_uri(lbry_uri):
return URI.from_uri_string(lbry_uri)
-126
View File
@@ -1,126 +0,0 @@
import re
import unicodedata
from typing import NamedTuple, Tuple
def _create_url_regex():
# see https://spec.lbry.com/
def _named(name, regex):
return "(?P<" + name + ">" + regex + ")"
def _group(regex):
return "(?:" + regex + ")"
def _oneof(*choices):
return _group('|'.join(choices))
def _claim(name, prefix=""):
return _group(
_named(name+"_name", prefix + "[^=&#:$@%?/]+") +
_oneof(
_group('#' + _named(name+"_claim_id", "[0-9a-f]{1,40}")),
_group(':' + _named(name+"_sequence", '[1-9][0-9]*')),
_group(r'\$' + _named(name+"_amount_order", '[1-9][0-9]*'))
) + '?'
)
return (
'^' +
_named("scheme", "lbry://") + '?' +
_oneof(
_group(_claim("channel_with_stream", "@") + "/" + _claim("stream_in_channel")),
_claim("channel", "@"),
_claim("stream")
) +
'$'
)
URL_REGEX = _create_url_regex()
def normalize_name(name):
return unicodedata.normalize('NFD', name).casefold()
class PathSegment(NamedTuple):
name: str
claim_id: str = None
sequence: int = None
amount_order: int = None
@property
def normalized(self):
return normalize_name(self.name)
def to_dict(self):
q = {'name': self.name}
if self.claim_id is not None:
q['claim_id'] = self.claim_id
if self.sequence is not None:
q['sequence'] = self.sequence
if self.amount_order is not None:
q['amount_order'] = self.amount_order
return q
def __str__(self):
if self.claim_id is not None:
return f"{self.name}#{self.claim_id}"
elif self.sequence is not None:
return f"{self.name}:{self.sequence}"
elif self.amount_order is not None:
return f"{self.name}${self.amount_order}"
return self.name
class URL(NamedTuple):
stream: PathSegment
channel: PathSegment
@property
def has_channel(self):
return self.channel is not None
@property
def has_stream(self):
return self.stream is not None
@property
def has_stream_in_channel(self):
return self.has_channel and self.has_stream
@property
def parts(self) -> Tuple:
if self.has_stream_in_channel:
return self.channel, self.stream
if self.has_channel:
return self.channel,
return self.stream,
def __str__(self):
return f"lbry://{'/'.join(str(p) for p in self.parts)}"
@classmethod
def parse(cls, url):
match = re.match(URL_REGEX, url)
if match is None:
raise ValueError('Invalid LBRY URL')
segments = {}
parts = match.groupdict()
for segment in ('channel', 'stream', 'channel_with_stream', 'stream_in_channel'):
if parts[f'{segment}_name'] is not None:
segments[segment] = PathSegment(
parts[f'{segment}_name'],
parts[f'{segment}_claim_id'],
parts[f'{segment}_sequence'],
parts[f'{segment}_amount_order']
)
if 'channel_with_stream' in segments:
segments['channel'] = segments['channel_with_stream']
segments['stream'] = segments['stream_in_channel']
return cls(segments.get('stream', None), segments.get('channel', None))
+5 -34
View File
@@ -12,9 +12,8 @@ from lbrynet.utils import cache_concurrent
from lbrynet.stream.descriptor import StreamDescriptor
from lbrynet.stream.managed_stream import ManagedStream
from lbrynet.schema.claim import Claim
from lbrynet.schema.url import URL
from lbrynet.extras.daemon.storage import lbc_to_dewies, dewies_to_lbc
from lbrynet.wallet.transaction import Output
from lbrynet.schema.uri import parse_lbry_uri
from lbrynet.extras.daemon.storage import lbc_to_dewies
if typing.TYPE_CHECKING:
from lbrynet.conf import Config
from lbrynet.blob.blob_manager import BlobManager
@@ -301,33 +300,6 @@ class StreamManager:
return None, existing_for_claim_id[0]
return None, None
def _convert_to_old_resolve_output(self, resolves):
result = {}
for url, txo in resolves.items():
if isinstance(txo, Output):
tx_height = txo.tx_ref.height
best_height = self.wallet.ledger.headers.height
result[url] = {
'name': txo.claim_name,
'value': txo.claim,
'protobuf': binascii.hexlify(txo.claim.to_bytes()),
'claim_id': txo.claim_id,
'txid': txo.tx_ref.id,
'nout': txo.position,
'amount': dewies_to_lbc(txo.amount),
'effective_amount': txo.meta.get('effective_amount', 0),
'height': tx_height,
'confirmations': (best_height+1) - tx_height if tx_height > 0 else tx_height,
'claim_sequence': -1,
'address': txo.get_address(self.wallet.ledger),
'valid_at_height': txo.meta.get('activation_height', None),
'timestamp': self.wallet.ledger.headers[tx_height]['timestamp'],
'supports': []
}
else:
result[url] = txo
return result
@cache_concurrent
async def download_stream_from_uri(self, uri, exchange_rate_manager: 'ExchangeRateManager',
timeout: typing.Optional[float] = None,
@@ -352,12 +324,11 @@ class StreamManager:
try:
# resolve the claim
if not URL.parse(uri).has_stream:
parsed_uri = parse_lbry_uri(uri)
if parsed_uri.is_channel:
raise ResolveError("cannot download a channel claim, specify a /path")
try:
resolved_result = self._convert_to_old_resolve_output(
await asyncio.wait_for(self.wallet.ledger.resolve([uri]), resolve_timeout)
)
resolved_result = await asyncio.wait_for(self.wallet.ledger.resolve(0, 1, uri), resolve_timeout)
except asyncio.TimeoutError:
raise ResolveTimeout(uri)
await self.storage.save_claims_for_resolve([
+35 -63
View File
@@ -4,7 +4,7 @@ import tempfile
import logging
from binascii import unhexlify
from torba.testcase import IntegrationTestCase, WalletNode
from torba.testcase import IntegrationTestCase
import lbrynet.wallet
@@ -58,6 +58,7 @@ class ExchangeRateManagerComponent(Component):
class CommandTestCase(IntegrationTestCase):
timeout = 180
LEDGER = lbrynet.wallet
MANAGER = LbryWalletManager
VERBOSITY = logging.WARN
@@ -70,10 +71,18 @@ class CommandTestCase(IntegrationTestCase):
logging.getLogger('lbrynet.daemon').setLevel(self.VERBOSITY)
logging.getLogger('lbrynet.stream').setLevel(self.VERBOSITY)
self.daemons = []
self.extra_wallet_nodes = []
self.extra_wallet_node_port = 5280
self.daemon = await self.add_daemon(self.wallet_node)
conf = Config()
conf.data_dir = self.wallet_node.data_path
conf.wallet_dir = self.wallet_node.data_path
conf.download_dir = self.wallet_node.data_path
conf.share_usage_data = False
conf.use_upnp = False
conf.reflect_streams = True
conf.blockchain_name = 'lbrycrd_regtest'
conf.lbryum_servers = [('127.0.0.1', 50001)]
conf.reflector_servers = [('127.0.0.1', 5566)]
conf.known_dht_nodes = []
conf.blob_lru_cache_size = self.blob_lru_cache_size
await self.account.ensure_address_gap()
address = (await self.account.receiving.get_addresses(limit=1, only_usable=True))[0]
@@ -81,6 +90,23 @@ class CommandTestCase(IntegrationTestCase):
await self.confirm_tx(sendtxid)
await self.generate(5)
def wallet_maker(component_manager):
self.wallet_component = WalletComponent(component_manager)
self.wallet_component.wallet_manager = self.manager
self.wallet_component._running = True
return self.wallet_component
conf.components_to_skip = [
DHT_COMPONENT, UPNP_COMPONENT, HASH_ANNOUNCER_COMPONENT,
PEER_PROTOCOL_SERVER_COMPONENT
]
self.daemon = Daemon(conf, ComponentManager(
conf, skip_components=conf.components_to_skip, wallet=wallet_maker,
exchange_rate_manager=ExchangeRateManagerComponent
))
await self.daemon.initialize()
self.manager.old_db = self.daemon.storage
server_tmp_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, server_tmp_dir)
self.server_config = Config()
@@ -99,54 +125,8 @@ class CommandTestCase(IntegrationTestCase):
async def asyncTearDown(self):
await super().asyncTearDown()
for wallet_node in self.extra_wallet_nodes:
await wallet_node.stop(cleanup=True)
for daemon in self.daemons:
daemon.component_manager.get_component('wallet')._running = False
await daemon.stop(shutdown_runner=False)
async def add_daemon(self, wallet_node=None, seed=None):
if wallet_node is None:
wallet_node = WalletNode(
self.wallet_node.manager_class,
self.wallet_node.ledger_class,
port=self.extra_wallet_node_port
)
self.extra_wallet_node_port += 1
await wallet_node.start(self.conductor.spv_node, seed=seed)
self.extra_wallet_nodes.append(wallet_node)
conf = Config()
conf.data_dir = wallet_node.data_path
conf.wallet_dir = wallet_node.data_path
conf.download_dir = wallet_node.data_path
conf.share_usage_data = False
conf.use_upnp = False
conf.reflect_streams = True
conf.blockchain_name = 'lbrycrd_regtest'
conf.lbryum_servers = [('127.0.0.1', 50001)]
conf.reflector_servers = [('127.0.0.1', 5566)]
conf.known_dht_nodes = []
conf.blob_lru_cache_size = self.blob_lru_cache_size
conf.components_to_skip = [
DHT_COMPONENT, UPNP_COMPONENT, HASH_ANNOUNCER_COMPONENT,
PEER_PROTOCOL_SERVER_COMPONENT
]
def wallet_maker(component_manager):
wallet_component = WalletComponent(component_manager)
wallet_component.wallet_manager = wallet_node.manager
wallet_component._running = True
return wallet_component
daemon = Daemon(conf, ComponentManager(
conf, skip_components=conf.components_to_skip, wallet=wallet_maker,
exchange_rate_manager=ExchangeRateManagerComponent
))
await daemon.initialize()
self.daemons.append(daemon)
wallet_node.manager.old_db = daemon.storage
return daemon
self.wallet_component._running = False
await self.daemon.stop(shutdown_runner=False)
async def confirm_tx(self, txid):
""" Wait for tx to be in mempool, then generate a block, wait for tx to be in a block. """
@@ -287,16 +267,8 @@ class CommandTestCase(IntegrationTestCase):
await self.on_transaction_dict(tx)
return tx
async def support_create(self, claim_id, bid='1.0', confirm=True, **kwargs):
tx = await self.out(self.daemon.jsonrpc_support_create(claim_id, bid, **kwargs))
if confirm:
await self.on_transaction_dict(tx)
await self.generate(1)
await self.on_transaction_dict(tx)
return tx
async def resolve(self, uri):
return await self.out(self.daemon.jsonrpc_resolve(uri))
async def claim_search(self, **kwargs):
return (await self.out(self.daemon.jsonrpc_claim_search(**kwargs)))['items']
async def claim_search(self, *args, **kwargs):
return (await self.out(self.daemon.jsonrpc_claim_search(*args, **kwargs)))['items']
+3 -3
View File
@@ -75,7 +75,7 @@ def obfuscate(plain):
return rot13(base64.b64encode(plain).decode())
def check_connection(server="lbry.com", port=80, timeout=5) -> bool:
def check_connection(server="lbry.io", port=80, timeout=5) -> bool:
"""Attempts to open a socket to server:port and returns True if successful."""
log.debug('Checking connection to %s:%s', server, port)
try:
@@ -102,7 +102,7 @@ def check_connection(server="lbry.com", port=80, timeout=5) -> bool:
return False
async def async_check_connection(server="lbry.com", port=80, timeout=5) -> bool:
async def async_check_connection(server="lbry.io", port=80, timeout=5) -> bool:
return await asyncio.get_event_loop().run_in_executor(None, check_connection, server, port, timeout)
@@ -271,7 +271,7 @@ async def aiohttp_request(method, url, **kwargs) -> typing.AsyncContextManager[a
async def get_external_ip() -> typing.Optional[str]: # used if upnp is disabled or non-functioning
try:
async with aiohttp_request("get", "https://api.lbry.com/ip") as resp:
async with aiohttp_request("get", "https://api.lbry.io/ip") as resp:
response = await resp.json()
if response['success']:
return response['data']['ip']
+124 -17
View File
@@ -1,11 +1,11 @@
import json
import logging
import binascii
from hashlib import sha256
from string import hexdigits
import ecdsa
from torba.client.baseaccount import BaseAccount, HierarchicalDeterministic
from torba.client.basetransaction import TXORef
log = logging.getLogger(__name__)
@@ -37,27 +37,134 @@ class Account(BaseAccount):
super().apply(d)
self.channel_keys.update(d.get('certificates', {}))
def add_channel_private_key(self, private_key):
public_key_bytes = private_key.get_verifying_key().to_der()
channel_pubkey_hash = self.ledger.public_key_to_address(public_key_bytes)
self.channel_keys[channel_pubkey_hash] = private_key.to_pem().decode()
def add_channel_private_key(self, ref: TXORef, private_key):
assert ref.id not in self.channel_keys, 'Trying to add a duplicate channel private key.'
self.channel_keys[ref.id] = private_key
def get_channel_private_key(self, public_key_bytes):
channel_pubkey_hash = self.ledger.public_key_to_address(public_key_bytes)
private_key_pem = self.channel_keys.get(channel_pubkey_hash)
if private_key_pem:
return ecdsa.SigningKey.from_pem(private_key_pem, hashfunc=sha256)
def get_channel_private_key(self, ref: TXORef):
return self.channel_keys.get(ref.id)
async def maybe_migrate_certificates(self):
if not self.channel_keys:
return
channel_keys = {}
for private_key_pem in self.channel_keys.values():
private_key = ecdsa.SigningKey.from_pem(private_key_pem, hashfunc=sha256)
public_key_der = private_key.get_verifying_key().to_der()
channel_keys[self.ledger.public_key_to_address(public_key_der)] = private_key_pem
self.channel_keys = channel_keys
addresses = {}
results = {
'total': 0,
'not-a-claim-tx': 0,
'migrate-success': 0,
'migrate-failed': 0,
'previous-success': 0,
'previous-corrupted': 0
}
double_hex_encoded_to_pop = []
for maybe_claim_id in list(self.channel_keys):
if ':' not in maybe_claim_id:
try:
validate_claim_id(maybe_claim_id)
continue
except Exception:
try:
maybe_claim_id_bytes = maybe_claim_id
if isinstance(maybe_claim_id_bytes, str):
maybe_claim_id_bytes = maybe_claim_id_bytes.encode()
decoded_double_hex = binascii.unhexlify(maybe_claim_id_bytes).decode()
validate_claim_id(decoded_double_hex)
if decoded_double_hex in self.channel_keys:
log.warning("don't know how to migrate certificate %s", decoded_double_hex)
else:
log.info("claim id was double hex encoded, fixing it")
double_hex_encoded_to_pop.append((maybe_claim_id, decoded_double_hex))
except Exception:
continue
for double_encoded_claim_id, correct_claim_id in double_hex_encoded_to_pop:
self.channel_keys[correct_claim_id] = self.channel_keys.pop(double_encoded_claim_id)
for maybe_claim_id in list(self.channel_keys):
results['total'] += 1
if ':' not in maybe_claim_id:
try:
validate_claim_id(maybe_claim_id)
except Exception as e:
log.warning(
"Failed to migrate claim '%s': %s",
maybe_claim_id, str(e)
)
results['migrate-failed'] += 1
continue
claims = await self.ledger.network.get_claims_by_ids(maybe_claim_id)
if maybe_claim_id not in claims:
log.warning(
"Failed to migrate claim '%s', server did not return any claim information.",
maybe_claim_id
)
results['migrate-failed'] += 1
continue
claim = claims[maybe_claim_id]
tx = None
if claim:
tx = await self.ledger.db.get_transaction(txid=claim['txid'])
else:
log.warning(maybe_claim_id)
if tx is not None:
txo = tx.outputs[claim['nout']]
if not txo.script.is_claim_involved:
results['not-a-claim-tx'] += 1
raise ValueError(
"Certificate with claim_id {} doesn't point to a valid transaction."
.format(maybe_claim_id)
)
tx_nout = '{txid}:{nout}'.format(**claim)
self.channel_keys[tx_nout] = self.channel_keys[maybe_claim_id]
del self.channel_keys[maybe_claim_id]
log.info(
"Migrated certificate with claim_id '%s' ('%s') to a new look up key %s.",
maybe_claim_id, txo.script.values['claim_name'], tx_nout
)
results['migrate-success'] += 1
else:
if claim:
addresses.setdefault(claim['address'], 0)
addresses[claim['address']] += 1
log.warning(
"Failed to migrate claim '%s', it's not associated with any of your addresses.",
maybe_claim_id
)
else:
log.warning(
"Failed to migrate claim '%s', it appears abandoned.",
maybe_claim_id
)
results['migrate-failed'] += 1
else:
try:
txid, nout = maybe_claim_id.split(':')
tx = await self.ledger.db.get_transaction(txid=txid)
if not tx:
log.warning(
"Claim migration failed to find a transaction for outpoint %s", maybe_claim_id
)
results['previous-corrupted'] += 1
continue
if tx.outputs[int(nout)].script.is_claim_involved:
results['previous-success'] += 1
else:
results['previous-corrupted'] += 1
except Exception:
log.exception("Couldn't verify certificate with look up key: %s", maybe_claim_id)
results['previous-corrupted'] += 1
self.wallet.save()
log.info('verifying and possibly migrating certificates:')
log.info(json.dumps(results, indent=2))
if addresses:
log.warning('failed for addresses:')
log.warning(json.dumps(
[{'address': a, 'number of certificates': c} for a, c in addresses.items()],
indent=2
))
async def save_max_gap(self):
if issubclass(self.address_generator, HierarchicalDeterministic):
+2 -4
View File
@@ -59,13 +59,11 @@ class WalletDatabase(BaseDatabase):
channel_ids = set()
for txo in txos:
if txo.is_claim and txo.can_decode_claim:
if txo.script.is_claim_name or txo.script.is_update_claim:
if txo.claim.is_signed:
channel_ids.add(txo.claim.signing_channel_id)
if txo.claim.is_channel and my_account is not None:
txo.private_key = my_account.get_channel_private_key(
txo.claim.channel.public_key_bytes
)
txo.private_key = my_account.get_channel_private_key(txo.ref)
if channel_ids:
channels = {
+22 -50
View File
@@ -1,18 +1,14 @@
import asyncio
import logging
from binascii import unhexlify
from typing import Tuple, List, Dict
from torba.client.baseledger import BaseLedger
from torba.client.baseaccount import SingleKey
from lbrynet.schema.result import Outputs
from lbrynet.schema.url import URL
from lbrynet.wallet.dewies import dewies_to_lbc
from lbrynet.wallet.resolve import Resolver
from lbrynet.wallet.account import Account
from lbrynet.wallet.network import Network
from lbrynet.wallet.database import WalletDatabase
from lbrynet.wallet.transaction import Transaction, Output
from lbrynet.wallet.transaction import Transaction
from lbrynet.wallet.header import Headers, UnvalidatedHeaders
@@ -53,33 +49,19 @@ class MainNetLedger(BaseLedger):
self.fee_per_name_char = self.config.get('fee_per_name_char', self.default_fee_per_name_char)
self.resolver = Resolver(self)
async def _inflate_outputs(self, query):
outputs = Outputs.from_base64(await query)
txs = []
if len(outputs.txs) > 0:
txs = await asyncio.gather(*(self.cache_transaction(*tx) for tx in outputs.txs))
return outputs.inflate(txs), outputs.offset, outputs.total
def resolve(self, page, page_size, *uris):
return self.resolver.resolve(page, page_size, *uris)
async def resolve(self, urls):
txos = (await self._inflate_outputs(self.network.resolve(urls)))[0]
assert len(urls) == len(txos), "Mismatch between urls requested for resolve and responses received."
result = {}
for url, txo in zip(urls, txos):
if txo and URL.parse(url).has_stream_in_channel:
if not txo.channel or not txo.is_signed_by(txo.channel, self):
txo = None
if txo:
result[url] = txo
else:
result[url] = {'error': f'{url} did not resolve to a claim'}
return result
async def get_claim_by_claim_id(self, claim_id):
result = (await self.network.get_claims_by_ids(claim_id)).pop(claim_id, {})
return await self.resolver.parse_and_validate_claim_result(result)
async def claim_search(self, **kwargs) -> Tuple[List, int, int]:
return await self._inflate_outputs(self.network.claim_search(**kwargs))
async def get_claim_by_claim_id(self, claim_id) -> Dict[str, Output]:
for claim in (await self.claim_search(claim_id=claim_id))[0]:
return claim
async def get_claim_by_outpoint(self, txid, nout):
claims = (await self.network.get_claims_in_tx(txid)) or []
for claim in claims:
if claim['nout'] == nout:
return await self.resolver.parse_and_validate_claim_result(claim)
return 'claim not found'
async def start(self):
await super().start()
@@ -88,26 +70,16 @@ class MainNetLedger(BaseLedger):
await self._report_state()
async def _report_state(self):
try:
for account in self.accounts:
balance = dewies_to_lbc(await account.get_balance())
channel_count = await account.get_channel_count()
claim_count = await account.get_claim_count()
if isinstance(account.receiving, SingleKey):
log.info("Loaded single key account %s with %s LBC. "
"%d channels, %d certificates and %d claims",
account.id, balance, channel_count, len(account.channel_keys), claim_count)
else:
total_receiving = len((await account.receiving.get_addresses()))
total_change = len((await account.change.get_addresses()))
log.info("Loaded account %s with %s LBC, %d receiving addresses (gap: %d), "
"%d change addresses (gap: %d), %d channels, %d certificates and %d claims. ",
account.id, balance, total_receiving, account.receiving.gap, total_change,
account.change.gap, channel_count, len(account.channel_keys), claim_count)
except:
log.exception(
'Failed to display wallet state, please file issue '
'for this bug along with the traceback you see below:')
for account in self.accounts:
total_receiving = len((await account.receiving.get_addresses()))
total_change = len((await account.change.get_addresses()))
channel_count = await account.get_channel_count()
claim_count = await account.get_claim_count()
balance = dewies_to_lbc(await account.get_balance())
log.info("Loaded account %s with %s LBC, %d receiving addresses (gap: %d), "
"%d change addresses (gap: %d), %d channels, %d certificates and %d claims. ",
account.id, balance, total_receiving, account.receiving.gap, total_change, account.change.gap,
channel_count, len(account.channel_keys), claim_count)
class TestNetLedger(MainNetLedger):
+13 -4
View File
@@ -197,12 +197,15 @@ class LbryWalletManager(BaseWalletManager):
tx = await self.db.get_transaction(txid=txid)
if not tx:
try:
raw = await self.ledger.network.get_transaction(txid)
height = await self.ledger.network.get_transaction_height(txid)
_raw = await self.ledger.network.get_transaction(txid)
except CodeMessageError as e:
return {'success': False, 'code': e.code, 'message': e.message}
tx = self.ledger.transaction_class(unhexlify(raw))
await self.ledger.maybe_verify_transaction(tx, height)
# this is a workaround for the current protocol. Should be fixed when lbryum support is over and we
# are able to use the modern get_transaction call, which accepts verbose to show height and other fields
height = await self.ledger.network.get_transaction_height(txid)
tx = self.ledger.transaction_class(unhexlify(_raw))
if tx and height > 0:
await self.ledger.maybe_verify_transaction(tx, height + 1) # off by one from server side, yes...
return tx
@staticmethod
@@ -304,3 +307,9 @@ class LbryWalletManager(BaseWalletManager):
def save(self):
for wallet in self.wallets:
wallet.save()
def get_claim_by_claim_id(self, claim_id):
return self.ledger.get_claim_by_claim_id(claim_id)
def get_claim_by_outpoint(self, txid, nout):
return self.ledger.get_claim_by_outpoint(txid, nout)
+14 -7
View File
@@ -4,13 +4,20 @@ from torba.client.basenetwork import BaseNetwork
class Network(BaseNetwork):
def get_server_height(self):
return self.rpc('blockchain.block.get_server_height', [])
return self.rpc('blockchain.block.get_server_height')
def get_claims_by_ids(self, claim_ids):
return self.rpc('blockchain.claimtrie.getclaimsbyids', claim_ids)
def get_values_for_uris(self, block_hash, *uris):
return self.rpc('blockchain.claimtrie.getvaluesforuris', block_hash, *uris)
def resolve(self, urls):
return self.rpc('blockchain.claimtrie.resolve', urls)
def get_claims_by_ids(self, *claim_ids):
return self.rpc('blockchain.claimtrie.getclaimsbyids', *claim_ids)
def claim_search(self, **kwargs):
return self.rpc('blockchain.claimtrie.search', kwargs)
def get_claims_in_tx(self, txid):
return self.rpc('blockchain.claimtrie.getclaimsintx', txid)
def get_claims_for_name(self, name):
return self.rpc('blockchain.claimtrie.getclaimsforname', name)
def get_transaction_height(self, txid):
# 1.0 protocol specific workaround. Newer protocol should use get_transaction with verbose True
return self.rpc('blockchain.transaction.get_height', txid)
+18 -14
View File
@@ -2,6 +2,7 @@ import logging
import asyncio
from cryptography.exceptions import InvalidSignature
from binascii import unhexlify, hexlify
from lbrynet.utils import lru_cache_concurrent
from lbrynet.wallet.account import validate_claim_id
@@ -9,7 +10,7 @@ from lbrynet.wallet.dewies import dewies_to_lbc
from lbrynet.error import UnknownNameError, UnknownClaimID, UnknownURI, UnknownOutpoint
from lbrynet.schema.claim import Claim
from google.protobuf.message import DecodeError
from lbrynet.schema.url import URL
from lbrynet.schema.uri import parse_lbry_uri, URIParseError
from lbrynet.wallet.claim_proofs import verify_proof, InvalidProofError
log = logging.getLogger(__name__)
@@ -26,15 +27,15 @@ class Resolver:
uris = set(uris)
try:
for uri in uris:
for part in URL.parse(uri).parts:
if part.claim_id:
validate_claim_id(part.claim_id)
parsed_uri = parse_lbry_uri(uri)
if parsed_uri.claim_id:
validate_claim_id(parsed_uri.claim_id)
claim_trie_root = self.ledger.headers.claim_trie_root
resolutions = await self.network.get_values_for_uris(self.ledger.headers.hash().decode(), *uris)
if len(uris) > 1:
return await self._batch_handle(resolutions, uris, page, page_size, claim_trie_root)
return await self._handle_resolutions(resolutions, uris, page, page_size, claim_trie_root)
except ValueError as err:
except URIParseError as err:
return {'error': err.args[0]}
except Exception as e:
log.exception(e)
@@ -72,7 +73,7 @@ class Resolver:
async def _handle_resolve_uri_response(self, uri, resolution, claim_trie_root, page=0, page_size=10):
result = {}
parsed_uri = URL.parse(uri)
parsed_uri = parse_lbry_uri(uri)
certificate_response = None
# parse an included certificate
if 'certificate' in resolution:
@@ -80,7 +81,7 @@ class Resolver:
certificate_resolution_type = resolution['certificate']['resolution_type']
if certificate_resolution_type == "winning" and certificate_response:
if 'height' in certificate_response:
certificate_response = _verify_proof(parsed_uri.stream.name,
certificate_response = _verify_proof(parsed_uri.name,
claim_trie_root,
certificate_response,
ledger=self.ledger)
@@ -95,7 +96,7 @@ class Resolver:
claim_resolution_type = resolution['claim']['resolution_type']
if claim_resolution_type == "winning" and claim_response:
if 'height' in claim_response:
claim_response = _verify_proof(parsed_uri.stream.name,
claim_response = _verify_proof(parsed_uri.name,
claim_trie_root,
claim_response,
ledger=self.ledger)
@@ -140,7 +141,7 @@ class Resolver:
# invalid signatures can only return outside a channel
if result.get('claim', {}).get('has_signature', False):
if parsed_uri.has_stream and not result['claim']['signature_is_valid']:
if parsed_uri.path and not result['claim']['signature_is_valid']:
return {'error': 'claim not found', 'success': False, 'uri': str(parsed_uri)}
return result
@@ -161,7 +162,7 @@ class Resolver:
if certificate is None:
log.info("fetching certificate to check claim signature")
channel_id = claim_result['value'].signing_channel_id
certificate = (await self.network.get_claims_by_ids([channel_id])).get(channel_id)
certificate = (await self.network.get_claims_by_ids(channel_id)).get(channel_id)
if not certificate:
log.warning('Certificate %s not found', channel_id)
claim_result['channel_name'] = certificate['name'] if certificate else None
@@ -237,7 +238,7 @@ class Resolver:
async def iter_validate_channel_claims():
formatted_claims = []
for claim_ids in queries:
batch_result = await self.network.get_claims_by_ids(claim_ids)
batch_result = await self.network.get_claims_by_ids(*claim_ids)
for claim_id in claim_ids:
claim = batch_result[claim_id]
if claim['name'] == claim_names[claim_id]:
@@ -339,9 +340,12 @@ def validate_claim_signature_and_get_channel_name(claim_result, certificate_clai
claim_tx=None, cert_tx=None):
valid_signature = False
if cert_tx and certificate_claim and claim_tx and claim_result:
valid_signature = claim_tx.outputs[claim_result['nout']].is_signed_by(
cert_tx.outputs[certificate_claim['nout']], ledger
)
try:
valid_signature = claim_tx.outputs[claim_result['nout']].is_signed_by(
cert_tx.outputs[certificate_claim['nout']], ledger
)
except InvalidSignature:
pass
if not valid_signature:
log.warning("lbry://%s#%s has an invalid signature",
claim_result['name'], claim_result['claim_id'])
+123 -72
View File
@@ -1,61 +1,14 @@
import time
import struct
import msgpack
from lbrynet.wallet.transaction import Transaction, Output
from torba.server.hash import hash_to_hex_str
from torba.server.block_processor import BlockProcessor
from lbrynet.schema.claim import Claim
from lbrynet.wallet.server.db import SQLDB
class Timer:
def __init__(self, name):
self.name = name
self.total = 0
self.count = 0
self.sub_timers = {}
self._last_start = None
def add_timer(self, name):
if name not in self.sub_timers:
self.sub_timers[name] = Timer(name)
return self.sub_timers[name]
def run(self, func, *args, forward_timer=False, timer_name=None, **kwargs):
t = self.add_timer(timer_name or func.__name__)
t.start()
try:
if forward_timer:
return func(*args, **kwargs, timer=t)
else:
return func(*args, **kwargs)
finally:
t.stop()
def start(self):
self._last_start = time.time()
return self
def stop(self):
self.total += (time.time() - self._last_start)
self.count += 1
self._last_start = None
return self
def show(self, depth=0, height=None):
if depth == 0:
print('='*100)
if height is not None:
print(f'STATISTICS AT HEIGHT {height}')
print('='*100)
else:
print(
f"{' '*depth} {self.total/60:4.2f}mins {self.name}"
# f"{self.total/self.count:.5f}sec/call, "
)
for sub_timer in self.sub_timers.values():
sub_timer.show(depth+1)
if depth == 0:
print('='*100)
from lbrynet.wallet.server.model import ClaimInfo
class LBRYBlockProcessor(BlockProcessor):
@@ -64,28 +17,126 @@ class LBRYBlockProcessor(BlockProcessor):
super().__init__(*args, **kwargs)
if self.env.coin.NET == "regtest":
self.prefetcher.polling_delay = 0.5
self.should_validate_signatures = self.env.boolean('VALIDATE_CLAIM_SIGNATURES', False)
self.logger.info(f"LbryumX Block Processor - Validating signatures: {self.should_validate_signatures}")
self.sql: SQLDB = self.db.sql
self.timer = Timer('BlockProcessor')
self.logger.info("LbryumX Block Processor - Validating signatures: {}".format(self.should_validate_signatures))
def advance_blocks(self, blocks):
self.sql.begin()
try:
self.timer.run(super().advance_blocks, blocks)
except:
self.logger.exception(f'Error while advancing transaction in new block.')
raise
finally:
self.sql.commit()
# save height, advance blocks as usual, then hook our claim tx processing
height = self.height + 1
super().advance_blocks(blocks)
pending_undo = []
for index, block in enumerate(blocks):
undo = self.advance_claim_txs(block.transactions, height + index)
pending_undo.append((height+index, undo,))
self.db.write_undo(pending_undo)
def advance_txs(self, height, txs, header):
timer = self.timer.sub_timers['advance_blocks']
undo = timer.run(super().advance_txs, height, txs, header, timer_name='super().advance_txs')
timer.run(self.sql.advance_txs, height, txs, header, self.daemon.cached_height(), forward_timer=True)
if (height % 10000 == 0 or not self.db.first_sync) and self.logger.isEnabledFor(20):
self.timer.show(height=height)
return undo
def advance_claim_txs(self, txs, height):
# TODO: generate claim undo info!
undo_info = []
add_undo = undo_info.append
update_inputs = set()
for etx, txid in txs:
update_inputs.clear()
tx = Transaction(etx.serialize())
for index, output in enumerate(tx.outputs):
if not output.is_claim:
continue
if output.script.is_claim_name:
add_undo(self.advance_claim_name_transaction(output, height, txid, index))
elif output.script.is_update_claim:
update_input = self.db.get_update_input(output.claim_hash, tx.inputs)
if update_input:
update_inputs.add(update_input)
add_undo(self.advance_update_claim(output, height, txid, index))
else:
info = (hash_to_hex_str(txid), output.claim_id,)
self.logger.error("REJECTED: {} updating {}".format(*info))
for txin in tx.inputs:
if txin not in update_inputs:
abandoned_claim_id = self.db.abandon_spent(txin.txo_ref.tx_ref.hash, txin.txo_ref.position)
if abandoned_claim_id:
add_undo((abandoned_claim_id, self.db.get_claim_info(abandoned_claim_id)))
return undo_info
def advance_update_claim(self, output: Output, height, txid, nout):
claim_id = output.claim_hash
claim_info = self.claim_info_from_output(output, txid, nout, height)
old_claim_info = self.db.get_claim_info(claim_id)
self.db.put_claim_id_for_outpoint(old_claim_info.txid, old_claim_info.nout, None)
if old_claim_info.cert_id:
self.db.remove_claim_from_certificate_claims(old_claim_info.cert_id, claim_id)
if claim_info.cert_id:
self.db.put_claim_id_signed_by_cert_id(claim_info.cert_id, claim_id)
self.db.put_claim_info(claim_id, claim_info)
self.db.put_claim_id_for_outpoint(txid, nout, claim_id)
return claim_id, old_claim_info
def advance_claim_name_transaction(self, output: Output, height, txid, nout):
claim_id = output.claim_hash
claim_info = self.claim_info_from_output(output, txid, nout, height)
if claim_info.cert_id:
self.db.put_claim_id_signed_by_cert_id(claim_info.cert_id, claim_id)
self.db.put_claim_info(claim_id, claim_info)
self.db.put_claim_id_for_outpoint(txid, nout, claim_id)
return claim_id, None
def backup_from_undo_info(self, claim_id, undo_claim_info):
"""
Undo information holds a claim state **before** a transaction changes it
There are 4 possibilities when processing it, of which only 3 are valid ones:
1. the claim is known and the undo info has info, it was an update
2. the claim is known and the undo info doesn't hold any info, it was claimed
3. the claim in unknown and the undo info has info, it was abandoned
4. the claim is unknown and the undo info does't hold info, error!
"""
undo_claim_info = ClaimInfo(*undo_claim_info) if undo_claim_info else None
current_claim_info = self.db.get_claim_info(claim_id)
if current_claim_info and undo_claim_info:
# update, remove current claim
self.db.remove_claim_id_for_outpoint(current_claim_info.txid, current_claim_info.nout)
if current_claim_info.cert_id:
self.db.remove_claim_from_certificate_claims(current_claim_info.cert_id, claim_id)
elif current_claim_info and not undo_claim_info:
# claim, abandon it
self.db.abandon_spent(current_claim_info.txid, current_claim_info.nout)
elif not current_claim_info and undo_claim_info:
# abandon, reclaim it (happens below)
pass
else:
# should never happen, unless the database got into an inconsistent state
raise Exception("Unexpected situation occurred on backup, this means the database is inconsistent. "
"Please report. Resetting the data folder (reindex) solves it for now.")
if undo_claim_info:
self.db.put_claim_info(claim_id, undo_claim_info)
if undo_claim_info.cert_id:
cert_id = self._checksig(undo_claim_info.value, undo_claim_info.address)
self.db.put_claim_id_signed_by_cert_id(cert_id, claim_id)
self.db.put_claim_id_for_outpoint(undo_claim_info.txid, undo_claim_info.nout, claim_id)
def backup_txs(self, txs):
self.logger.info("Reorg at height {} with {} transactions.".format(self.height, len(txs)))
undo_info = msgpack.loads(self.db.claim_undo_db.get(struct.pack(">I", self.height)), use_list=False)
for claim_id, undo_claim_info in reversed(undo_info):
self.backup_from_undo_info(claim_id, undo_claim_info)
return super().backup_txs(txs)
def backup_blocks(self, raw_blocks):
self.db.batched_flush_claims()
super().backup_blocks(raw_blocks=raw_blocks)
self.db.batched_flush_claims()
async def flush(self, flush_utxos):
self.db.batched_flush_claims()
return await super().flush(flush_utxos)
def claim_info_from_output(self, output: Output, txid, nout, height):
address = self.coin.address_from_script(output.script.source)
name, value, cert_id = output.script.values['claim_name'], output.script.values['claim'], None
assert txid and address
cert_id = self._checksig(value, address)
return ClaimInfo(name, value, txid, nout, output.amount, address, height, cert_id)
def _checksig(self, value, address):
try:
-21
View File
@@ -1,21 +0,0 @@
class FindShortestID:
__slots__ = 'short_id', 'new_id'
def __init__(self):
self.short_id = ''
self.new_id = None
def step(self, other_id, new_id):
self.new_id = new_id
for i in range(len(self.new_id)):
if other_id[i] != self.new_id[i]:
if i > len(self.short_id)-1:
self.short_id = self.new_id[:i+1]
break
def finalize(self):
return '#'+self.short_id
def register_canonical_functions(connection):
connection.create_aggregate("shortest_id", 2, FindShortestID)
+5
View File
@@ -53,3 +53,8 @@ class LBCDaemon(Daemon):
async def claimname(self, name, hexvalue, amount):
'''Claim a name, used for functional tests only.'''
return await self._send_single('claimname', (name, hexvalue, float(amount)))
@handles_errors
async def generate(self, number_of_blocks):
'''Generates regtest blocks, used for functional tests only.'''
return await self._send_single('generate', (int(number_of_blocks),))
File diff suppressed because it is too large. Load diff
+15
View File
@@ -0,0 +1,15 @@
from collections import namedtuple
import msgpack
# Classes representing data and their serializers, if any.
class ClaimInfo(namedtuple("NameClaim", "name value txid nout amount address height cert_id")):
'''Claim information as its stored on database'''
@classmethod
def from_serialized(cls, serialized):
return cls(*msgpack.loads(serialized))
@property
def serialized(self):
return msgpack.dumps(self)
+76 -23
View File
@@ -7,8 +7,7 @@ from torba.server.hash import hash_to_hex_str
from torba.server.session import ElectrumX
from torba.server import util
from lbrynet.schema.result import Outputs
from lbrynet.schema.url import URL
from lbrynet.schema.uri import parse_lbry_uri, CLAIM_ID_MAX_LENGTH, URIParseError
from lbrynet.wallet.server.block_processor import LBRYBlockProcessor
from lbrynet.wallet.server.db import LBRYDB
@@ -23,13 +22,13 @@ class LBRYElectrumX(ElectrumX):
self.daemon = self.session_mgr.daemon
self.bp: LBRYBlockProcessor = self.session_mgr.bp
self.db: LBRYDB = self.bp.db
# fixme: lbryum specific subscribe
self.subscribe_height = False
def set_request_handlers(self, ptuple):
super().set_request_handlers(ptuple)
handlers = {
'blockchain.transaction.get_height': self.transaction_get_height,
'blockchain.claimtrie.search': self.claimtrie_search,
'blockchain.claimtrie.resolve': self.claimtrie_resolve,
'blockchain.claimtrie.getclaimbyid': self.claimtrie_getclaimbyid,
'blockchain.claimtrie.getclaimsforname': self.claimtrie_getclaimsforname,
'blockchain.claimtrie.getclaimsbyids': self.claimtrie_getclaimsbyids,
@@ -43,15 +42,66 @@ class LBRYElectrumX(ElectrumX):
'blockchain.claimtrie.getclaimssignedbyid': self.claimtrie_getclaimssignedbyid,
'blockchain.block.get_server_height': self.get_server_height,
}
# fixme: methods we use but shouldnt be using anymore. To be removed when torba goes out
handlers.update({
'blockchain.numblocks.subscribe': self.numblocks_subscribe,
'blockchain.utxo.get_address': self.utxo_get_address,
'blockchain.transaction.broadcast':
self.transaction_broadcast_1_0,
'blockchain.transaction.get': self.transaction_get,
})
self.request_handlers.update(handlers)
async def claimtrie_search(self, **kwargs):
if 'claim_id' in kwargs:
self.assert_claim_id(kwargs['claim_id'])
return Outputs.to_base64(*self.db.sql.search(kwargs))
async def utxo_get_address(self, tx_hash, index):
# fixme: lbryum
# Used only for electrum client command-line requests. We no
# longer index by address, so need to request the raw
# transaction. So it works for any TXO not just UTXOs.
self.assert_tx_hash(tx_hash)
try:
index = int(index)
if index < 0:
raise ValueError
except ValueError:
raise RPCError(1, "index has to be >= 0 and integer")
raw_tx = await self.daemon_request('getrawtransaction', tx_hash)
if not raw_tx:
return None
raw_tx = util.hex_to_bytes(raw_tx)
tx = self.coin.DESERIALIZER(raw_tx).read_tx()
if index >= len(tx.outputs):
return None
return self.coin.address_from_script(tx.outputs[index].pk_script)
async def claimtrie_resolve(self, *urls):
return Outputs.to_base64(*self.db.sql.resolve(urls))
async def transaction_broadcast_1_0(self, raw_tx):
# fixme: lbryum
# An ugly API: current Electrum clients only pass the raw
# transaction in hex and expect error messages to be returned in
# the result field. And the server shouldn't be doing the client's
# user interface job here.
try:
return await self.transaction_broadcast(raw_tx)
except RPCError as e:
return e.message
async def numblocks_subscribe(self):
# fixme workaround for lbryum
'''Subscribe to get height of new blocks.'''
self.subscribe_height = True
return self.bp.height
async def notify(self, height, touched):
# fixme workaround for lbryum
await super().notify(height, touched)
if self.subscribe_height and height != self.notified_height:
self.send_notification('blockchain.numblocks.subscribe', (height,))
async def transaction_get(self, tx_hash, verbose=False):
# fixme: workaround for lbryum sending the height instead of True/False.
# fixme: lbryum_server ignored that and always used False, but this is out of spec
if verbose not in (True, False):
verbose = False
return await self.daemon_request('getrawtransaction', tx_hash, verbose)
async def get_server_height(self):
return self.bp.height
@@ -61,7 +111,9 @@ class LBRYElectrumX(ElectrumX):
transaction_info = await self.daemon.getrawtransaction(tx_hash, True)
if transaction_info and 'hex' in transaction_info and 'confirmations' in transaction_info:
# an unconfirmed transaction from lbrycrdd will not have a 'confirmations' field
return (self.db.db_height - transaction_info['confirmations']) + 1
height = self.db.db_height
height = height - transaction_info['confirmations']
return height
elif transaction_info and 'hex' in transaction_info:
return -1
return None
@@ -165,7 +217,9 @@ class LBRYElectrumX(ElectrumX):
if 'name' in claim:
name = claim['name'].encode('ISO-8859-1').decode()
info = self.db.sql.get_claims(claim_id=claim['claimId'])
claim_id = claim['claimId']
raw_claim_id = unhexlify(claim_id)[::-1]
info = self.db.get_claim_info(raw_claim_id)
if not info:
# raise RPCError("Lbrycrd has {} but not lbryumx, please submit a bug report.".format(claim_id))
return {}
@@ -254,22 +308,21 @@ class LBRYElectrumX(ElectrumX):
uri = uri
block_hash = block_hash
try:
parsed_uri = URL.parse(uri)
except ValueError as err:
return {'error': err.args[0]}
parsed_uri = parse_lbry_uri(uri)
except URIParseError as err:
return {'error': err.message}
result = {}
if parsed_uri.has_channel:
if parsed_uri.contains_channel:
certificate = None
# TODO: this is also done on the else, refactor
if parsed_uri.channel.claim_id:
if len(parsed_uri.channel.claim_id) < 40:
certificate_info = self.claimtrie_getpartialmatch(
parsed_uri.channel.name, parsed_uri.channel.claim_id)
if parsed_uri.claim_id:
if len(parsed_uri.claim_id) < CLAIM_ID_MAX_LENGTH:
certificate_info = self.claimtrie_getpartialmatch(parsed_uri.name, parsed_uri.claim_id)
else:
certificate_info = await self.claimtrie_getclaimbyid(parsed_uri.channel.claim_id)
if certificate_info and self.claim_matches_name(certificate_info, parsed_uri.channel.name):
certificate_info = await self.claimtrie_getclaimbyid(parsed_uri.claim_id)
if certificate_info and self.claim_matches_name(certificate_info, parsed_uri.name):
certificate = {'resolution_type': CLAIM_ID, 'result': certificate_info}
elif parsed_uri.claim_sequence:
certificate_info = await self.claimtrie_getnthclaimforname(parsed_uri.name, parsed_uri.claim_sequence)
@@ -300,7 +353,7 @@ class LBRYElectrumX(ElectrumX):
else:
claim = None
if parsed_uri.claim_id:
if len(parsed_uri.claim_id) < 40:
if len(parsed_uri.claim_id) < CLAIM_ID_MAX_LENGTH:
claim_info = self.claimtrie_getpartialmatch(parsed_uri.name, parsed_uri.claim_id)
else:
claim_info = await self.claimtrie_getclaimbyid(parsed_uri.claim_id)
-113
View File
@@ -1,113 +0,0 @@
from math import sqrt
TRENDING_WINDOW = 650 # number of blocks, ~24hr period
TRENDING_DATA_POINTS = 7 # WINDOW * DATA_POINTS = ~1 week worth of trending data
CREATE_TREND_TABLE = """
create table if not exists trend (
claim_hash bytes not null,
height integer not null,
amount integer not null,
primary key (claim_hash, height)
) without rowid;
"""
class ZScore:
__slots__ = 'count', 'total', 'power', 'last'
def __init__(self):
self.count = 0
self.total = 0
self.power = 0
self.last = None
def step(self, value):
if self.last is not None:
self.count += 1
self.total += self.last
self.power += self.last**2
self.last = value
@property
def mean(self):
return self.total / self.count
@property
def standard_deviation(self):
return sqrt((self.power / self.count) - self.mean**2)
def finalize(self):
if self.count == 0:
return self.last
return (self.last - self.mean) / (self.standard_deviation or 1)
def register_trending_functions(connection):
connection.create_aggregate("zscore", 1, ZScore)
def calculate_trending(db, height, is_first_sync, final_height):
# don't start tracking until we're at the end of initial sync
if is_first_sync and height < (final_height - (TRENDING_WINDOW*TRENDING_DATA_POINTS)):
return
if height % TRENDING_WINDOW != 0:
return
db.execute(f"""
DELETE FROM trend WHERE height < {height-(TRENDING_WINDOW*TRENDING_DATA_POINTS)}
""")
start = (height-TRENDING_WINDOW)+1
db.execute(f"""
INSERT INTO trend (claim_hash, height, amount)
SELECT claim_hash, {start}, COALESCE(
(SELECT SUM(amount) FROM support WHERE claim_hash=claim.claim_hash
AND height >= {start}), 0
) AS support_sum
FROM claim WHERE support_sum > 0
""")
zscore = ZScore()
for (global_sum,) in db.execute("SELECT AVG(amount) FROM trend GROUP BY height"):
zscore.step(global_sum)
global_mean, global_deviation = 0, 1
if zscore.count > 0:
global_mean = zscore.mean
global_deviation = zscore.standard_deviation
db.execute(f"""
UPDATE claim SET
trending_local = COALESCE((
SELECT zscore(amount) FROM trend
WHERE claim_hash=claim.claim_hash ORDER BY height DESC
), 0),
trending_global = COALESCE((
SELECT (amount - {global_mean}) / {global_deviation} FROM trend
WHERE claim_hash=claim.claim_hash AND height = {start}
), 0),
trending_group = 0,
trending_mixed = 0
""")
# trending_group and trending_mixed determine how trending will show in query results
# normally the SQL will be: "ORDER BY trending_group, trending_mixed"
# changing the trending_group will have significant impact on trending results
# changing the value used for trending_mixed will only impact trending within a trending_group
db.execute(f"""
UPDATE claim SET
trending_group = CASE
WHEN trending_local > 0 AND trending_global > 0 THEN 4
WHEN trending_local <= 0 AND trending_global > 0 THEN 3
WHEN trending_local > 0 AND trending_global <= 0 THEN 2
WHEN trending_local <= 0 AND trending_global <= 0 THEN 1
END,
trending_mixed = CASE
WHEN trending_local > 0 AND trending_global > 0 THEN trending_global
WHEN trending_local <= 0 AND trending_global > 0 THEN trending_local
WHEN trending_local > 0 AND trending_global <= 0 THEN trending_local
WHEN trending_local <= 0 AND trending_global <= 0 THEN trending_global
END
WHERE trending_local <> 0 OR trending_global <> 0
""")
+16 -45
View File
@@ -9,12 +9,11 @@ from cryptography.hazmat.primitives.serialization import load_der_public_key
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives.asymmetric.utils import Prehashed
from cryptography.exceptions import InvalidSignature
from ecdsa.util import sigencode_der
from torba.client.basetransaction import BaseTransaction, BaseInput, BaseOutput, ReadOnlyList
from torba.client.hash import hash160, sha256, Base58
from lbrynet.schema.claim import Claim
from lbrynet.schema.url import normalize_name
from lbrynet.wallet.account import Account
from lbrynet.wallet.script import InputScript, OutputScript
@@ -28,14 +27,13 @@ class Output(BaseOutput):
script: OutputScript
script_class = OutputScript
__slots__ = 'channel', 'private_key', 'meta'
__slots__ = 'channel', 'private_key'
def __init__(self, *args, channel: Optional['Output'] = None,
private_key: Optional[str] = None, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.channel = channel
self.private_key = private_key
self.meta = {}
def update_annotations(self, annotated):
super().update_annotations(annotated)
@@ -52,10 +50,6 @@ class Output(BaseOutput):
def is_claim(self) -> bool:
return self.script.is_claim_name or self.script.is_update_claim
@property
def is_support(self) -> bool:
return self.script.is_support_claim
@property
def claim_hash(self) -> bytes:
if self.script.is_claim_name:
@@ -75,10 +69,6 @@ class Output(BaseOutput):
return self.script.values['claim_name'].decode()
raise ValueError('No claim_name associated.')
@property
def normalized_name(self) -> str:
return normalize_name(self.claim_name)
@property
def claim(self) -> Claim:
if self.is_claim:
@@ -87,13 +77,6 @@ class Output(BaseOutput):
return self.script.values['claim']
raise ValueError('Only claim name and claim update have the claim payload.')
@property
def can_decode_claim(self):
try:
return self.claim
except:
return False
@property
def permanent_url(self) -> str:
if self.script.is_claim_involved:
@@ -104,7 +87,7 @@ class Output(BaseOutput):
def has_private_key(self):
return self.private_key is not None
def get_signature_digest(self, ledger):
def is_signed_by(self, channel: 'Output', ledger=None):
if self.claim.unsigned_payload:
pieces = [
Base58.decode(self.get_address(ledger)),
@@ -117,30 +100,15 @@ class Output(BaseOutput):
self.claim.signing_channel_hash,
self.claim.to_message_bytes()
]
return sha256(b''.join(pieces))
def get_encoded_signature(self):
digest = sha256(b''.join(pieces))
public_key = load_der_public_key(channel.claim.channel.public_key_bytes, default_backend())
hash = hashes.SHA256()
signature = hexlify(self.claim.signature)
r = int(signature[:int(len(signature)/2)], 16)
s = int(signature[int(len(signature)/2):], 16)
return ecdsa.util.sigencode_der(r, s, len(signature)*4)
@staticmethod
def is_signature_valid(encoded_signature, signature_digest, public_key_bytes):
try:
public_key = load_der_public_key(public_key_bytes, default_backend())
public_key.verify(encoded_signature, signature_digest, ec.ECDSA(Prehashed(hashes.SHA256())))
return True
except (ValueError, InvalidSignature):
pass
return False
def is_signed_by(self, channel: 'Output', ledger=None):
return self.is_signature_valid(
self.get_encoded_signature(),
self.get_signature_digest(ledger),
channel.claim.channel.public_key_bytes
)
encoded_sig = sigencode_der(r, s, len(signature)*4)
public_key.verify(encoded_sig, digest, ec.ECDSA(Prehashed(hash)))
return True
def sign(self, channel: 'Output', first_input_id=None):
self.channel = channel
@@ -150,7 +118,8 @@ class Output(BaseOutput):
self.claim.signing_channel_hash,
self.claim.to_message_bytes()
]))
self.claim.signature = channel.private_key.sign_digest_deterministic(digest, hashfunc=hashlib.sha256)
private_key = ecdsa.SigningKey.from_pem(channel.private_key, hashfunc=hashlib.sha256)
self.claim.signature = private_key.sign_digest_deterministic(digest, hashfunc=hashlib.sha256)
self.script.generate()
def clear_signature(self):
@@ -158,12 +127,14 @@ class Output(BaseOutput):
self.claim.clear_signature()
def generate_channel_private_key(self):
self.private_key = ecdsa.SigningKey.generate(curve=ecdsa.SECP256k1, hashfunc=hashlib.sha256)
self.claim.channel.public_key_bytes = self.private_key.get_verifying_key().to_der()
private_key = ecdsa.SigningKey.generate(curve=ecdsa.SECP256k1, hashfunc=hashlib.sha256)
self.private_key = private_key.to_pem().decode()
self.claim.channel.public_key_bytes = private_key.get_verifying_key().to_der()
self.script.generate()
return self.private_key
def is_channel_private_key(self, private_key):
def is_channel_private_key(self, private_key_pem):
private_key = ecdsa.SigningKey.from_pem(private_key_pem, hashfunc=hashlib.sha256)
return self.claim.channel.public_key_bytes == private_key.get_verifying_key().to_der()
@classmethod
+1 -1
View File
@@ -24,6 +24,6 @@ theme:
- type: 'telegram'
link: 'https://t.me/lbryofficial'
- type: 'discord'
link: 'https://chat.lbry.com'
link: 'https://chat.lbry.io'
- type: 'reddit'
link: 'https://reddit.com/r/lbry'
+1 -3
View File
@@ -1,7 +1,5 @@
FROM debian:buster-slim
ARG TORBA_VERSION=master
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
@@ -17,7 +15,7 @@ RUN python3.7 -m pip install --upgrade pip setuptools wheel
COPY . /app
WORKDIR /app
RUN python3.7 -m pip install --user git+https://github.com/lbryio/torba.git@${TORBA_VERSION}#egg=torba
RUN python3.7 -m pip install git+https://github.com/lbryio/torba.git#egg=torba
RUN python3.7 -m pip install -e .
# Orchstr8 API
+1 -2
View File
@@ -1,7 +1,6 @@
FROM debian:buster-slim
ARG user=lbry
ARG TORBA_VERSION=master
# create an unprivileged user
RUN groupadd -g 999 $user && useradd -r -u 999 -g $user $user
@@ -24,7 +23,7 @@ WORKDIR /home/$user
RUN python3.7 -m pip install --upgrade pip setuptools
# get torba
RUN python3.7 -m pip install --user git+https://github.com/lbryio/torba.git@${TORBA_VERSION}#egg=torba
RUN python3.7 -m pip install --user git+https://github.com/lbryio/torba.git#egg=torba
# get uvloop
RUN python3.7 -m pip install --user uvloop
-75
View File
@@ -1,75 +0,0 @@
import sys
import asyncio
from binascii import hexlify
from lbrynet.wallet.server.db import SQLDB
from lbrynet.wallet.server.coin import LBC
from lbrynet.wallet.server.daemon import Daemon
def hex_reverted(value: bytes) -> str:
return hexlify(value[::-1]).decode()
def match(name, what, value, expected):
if value != expected:
print(f'{name}: {what} mismatch, {value} is not {expected}')
return value == expected
def checkrecord(record, expected_winner, expected_claim):
assert record['is_controlling'] == record['claim_hash'], dict(record)
name = record['normalized']
claim_id = hex_reverted(record['claim_hash'])
takover = record['activation_height']
if not expected_winner:
print(f"{name} not on lbrycrd. We have {claim_id} at {takover} takeover height.")
return
if not match(name, 'claim id', claim_id, expected_winner['claimId']):
print(f"-- {name} has the wrong winner")
if not expected_claim:
print(f'{name}: {claim_id} not found, we possibly have an abandoned claim as winner')
return
match(name, 'height', record['height'], expected_claim['height'])
match(name, 'activation height', takover, expected_claim['valid at height'])
match(name, 'name', record['normalized'], expected_claim['normalized_name'])
match(name, 'amount', record['amount'], expected_claim['amount'])
match(name, 'effective amount', record['effective_amount'], expected_claim['effective amount'])
match(name, 'txid', hex_reverted(record['txo_hash'][:-4]), expected_claim['txid'])
match(name, 'nout', int.from_bytes(record['txo_hash'][-4:], 'little', signed=False), expected_claim['n'])
async def checkcontrolling(daemon: Daemon, db: SQLDB):
records, claim_ids, names, futs = [], [], [], []
for record in db.get_claims('claimtrie.claim_hash as is_controlling, claim.*', is_controlling=True):
records.append(record)
claim_id = hex_reverted(record['claim_hash'])
claim_ids.append((claim_id,))
names.append((record['normalized'],))
if len(names) > 50000:
futs.append(daemon._send_vector('getvalueforname', names[:]))
futs.append(daemon._send_vector('getclaimbyid', claim_ids[:]))
names.clear()
claim_ids.clear()
if names:
futs.append(daemon._send_vector('getvalueforname', names[:]))
futs.append(daemon._send_vector('getclaimbyid', claim_ids[:]))
names.clear()
claim_ids.clear()
while futs:
winners, claims = futs.pop(0), futs.pop(0)
for winner, claim in zip(await winners, await claims):
checkrecord(records.pop(0), winner, claim)
if __name__ == '__main__':
if not len(sys.argv) == 3:
print("usage: <db_file_path> <lbrycrd_url>")
sys.exit(1)
db_path, lbrycrd_url = sys.argv[1:] # pylint: disable=W0632
daemon = Daemon(LBC(), url=lbrycrd_url)
db = SQLDB(None, db_path)
db.open()
asyncio.get_event_loop().run_until_complete(checkcontrolling(daemon, db))
+1 -1
View File
@@ -47,7 +47,7 @@ async def main(blob_hash: str, url: str):
if __name__ == "__main__": # usage: python download_blob_from_peer.py <blob_hash> [host url:port]
url = 'reflector.lbry.com:5567'
url = 'reflector.lbry.io:5567'
if len(sys.argv) > 2:
url = sys.argv[2]
asyncio.run(main(sys.argv[1], url))
+1 -1
View File
@@ -262,7 +262,7 @@ class Examples(CommandTestCase):
await r(
'Search for all claims in channel',
'claim', 'search', '--channel=@channel'
'claim', 'search', f'--channel_id="{channel_id}"'
)
await r(
+1 -1
View File
@@ -26,7 +26,7 @@ def extract_uris(response):
async def get_frontpage_uris():
session = aiohttp.ClientSession()
try:
response = await session.get("https://api.lbry.com/file/list_homepage", timeout=10.0)
response = await session.get("https://api.lbry.io/file/list_homepage", timeout=10.0)
if response.status != 200:
print("API returned non 200 code!!")
return
+2 -9
View File
@@ -1,11 +1,9 @@
set -x
# must also be updated in travis.yml
TORBA_VERSION=master
TORBA=$1
rm -rf /tmp/.wine-*
apt-get -qq update
apt-get -qq install -y git
pip install setuptools_scm
cd lbry
@@ -14,12 +12,7 @@ cd lbry
wget -Onetifaces-0.10.7-cp37-cp37m-win32.whl https://ci.appveyor.com/api/buildjobs/6hworunifsymrhp2/artifacts/dist%2Fnetifaces-0.10.7-cp37-cp37m-win32.whl
pip install netifaces-0.10.7-cp37-cp37m-win32.whl
git clone --depth=1 --single-branch --branch ${TORBA_VERSION} https://github.com/lbryio/torba.git
cd torba
pip install .
cd ..
rm -rf torba
pip install git+https://github.com/lbryio/torba.git@${TORBA}#egg=torba
pip show torba
pip install -e .
pip install pywin32
+5 -5
View File
@@ -9,23 +9,23 @@ setup(
name=__name__,
version=__version__,
author="LBRY Inc.",
author_email="hello@lbry.com",
url="https://lbry.com",
author_email="hello@lbry.io",
url="https://lbry.io",
description="A decentralized media library and marketplace",
long_description=open(README_PATH, encoding='utf-8').read(),
long_description_content_type="text/markdown",
keywords="lbry protocol media",
license='MIT',
python_requires='>=3.7',
python_requires='>=3.6',
packages=find_packages(exclude=('tests',)),
zip_safe=False,
entry_points={
'console_scripts': 'lbrynet=lbrynet.extras.cli:main'
},
install_requires=[
'torba==0.5.5',
'torba==0.5.4a0',
'aiohttp==3.5.4',
'aioupnp==0.0.12',
'aioupnp',
'appdirs==1.4.3',
'certifi>=2018.11.29',
'colorama==0.3.7',
+16 -17
View File
@@ -39,8 +39,9 @@ class EpicAdventuresOfChris45(CommandTestCase):
self.assertEqual(result, '8.989893')
# And is the channel resolvable and empty?
response = await self.resolve('lbry://@spam')
self.assertEqual(response['lbry://@spam']['value_type'], 'channel')
response = await self.out(self.daemon.jsonrpc_resolve('lbry://@spam'))
self.assertIn('lbry://@spam', response)
self.assertIn('certificate', response['lbry://@spam'])
# "What goes well with spam?" ponders Chris...
# "A hovercraft with eels!" he exclaims.
@@ -63,8 +64,9 @@ class EpicAdventuresOfChris45(CommandTestCase):
# Also checks that his new story can be found on the blockchain before
# giving the link to all his friends.
response = await self.resolve('lbry://@spam/hovercraft')
self.assertEqual(response['lbry://@spam/hovercraft']['value_type'], 'stream')
response = await self.out(self.daemon.jsonrpc_resolve('lbry://@spam/hovercraft'))
self.assertIn('lbry://@spam/hovercraft', response)
self.assertIn('claim', response['lbry://@spam/hovercraft'])
# He goes to tell everyone about it and in the meantime 5 blocks are confirmed.
await self.generate(5)
@@ -84,11 +86,8 @@ class EpicAdventuresOfChris45(CommandTestCase):
await self.confirm_tx(abandon['txid'])
# And now checks that the claim doesn't resolve anymore.
response = await self.resolve('lbry://@spam/hovercraft')
self.assertEqual(
response['lbry://@spam/hovercraft'],
{'error': 'lbry://@spam/hovercraft did not resolve to a claim'}
)
response = await self.out(self.daemon.jsonrpc_resolve('lbry://@spam/hovercraft'))
self.assertNotIn('claim', response['lbry://@spam/hovercraft'])
# After abandoning he just waits for his LBCs to be returned to his account
await self.generate(5)
@@ -135,10 +134,10 @@ class EpicAdventuresOfChris45(CommandTestCase):
await self.confirm_tx(tx['txid'])
# And check if his support showed up
resolve_result = await self.resolve(uri)
resolve_result = await self.out(self.daemon.jsonrpc_resolve(uri))
# It obviously did! Because, blockchain baby \O/
self.assertEqual(resolve_result[uri]['amount'], '1.0')
self.assertEqual(resolve_result[uri]['meta']['effective_amount'], '1.2')
self.assertEqual(resolve_result[uri]['claim']['amount'], '1.0')
self.assertEqual(resolve_result[uri]['claim']['effective_amount'], '1.2')
await self.generate(5)
# Now he also wanted to support the original creator of the Award Winning Novel
@@ -149,9 +148,9 @@ class EpicAdventuresOfChris45(CommandTestCase):
await self.confirm_tx(tx['txid'])
# And again checks if it went to the just right place
resolve_result = await self.resolve(uri)
resolve_result = await self.out(self.daemon.jsonrpc_resolve(uri))
# Which it obviously did. Because....?????
self.assertEqual(resolve_result[uri]['meta']['effective_amount'], '1.5')
self.assertEqual(resolve_result[uri]['claim']['effective_amount'], '1.5')
await self.generate(5)
# Seeing the ravishing success of his novel Chris adds support to his claim too
@@ -161,7 +160,7 @@ class EpicAdventuresOfChris45(CommandTestCase):
# And check if his support showed up
resolve_result = await self.out(self.daemon.jsonrpc_resolve(uri))
# It did!
self.assertEqual(resolve_result[uri]['meta']['effective_amount'], '1.9')
self.assertEqual(resolve_result[uri]['claim']['effective_amount'], '1.9')
await self.generate(5)
# Now Ramsey who is a singer by profession, is preparing for his new "gig". He has everything in place for that
@@ -185,5 +184,5 @@ class EpicAdventuresOfChris45(CommandTestCase):
await self.confirm_tx(abandon['txid'])
# He them checks that the claim doesn't resolve anymore.
response = await self.resolve(uri)
self.assertEqual(response[uri], {'error': f'{uri} did not resolve to a claim'})
response = await self.out(self.daemon.jsonrpc_resolve(uri))
self.assertNotIn('claim', response[uri])
+283 -342
View File
@@ -1,268 +1,23 @@
import os.path
import hashlib
import tempfile
import logging
from binascii import unhexlify
from urllib.request import urlopen
import ecdsa
from lbrynet.wallet.transaction import Transaction, Output
from torba.client.errors import InsufficientFundsError
from lbrynet.schema.compat import OldClaimMessage
from lbrynet.testcase import CommandTestCase
from lbrynet.wallet.transaction import Transaction
from torba.client.hash import sha256, Base58
log = logging.getLogger(__name__)
class ClaimTestCase(CommandTestCase):
files_directory = os.path.join(os.path.dirname(__file__), 'files')
video_file_url = 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerEscapes.mp4'
video_file_name = os.path.join(files_directory, 'ForBiggerEscapes.mp4')
def setUp(self):
if not os.path.exists(self.video_file_name):
if not os.path.exists(self.files_directory):
os.mkdir(self.files_directory)
log.info(f'downloading test video from {self.video_file_name}')
with urlopen(self.video_file_url) as response, \
open(self.video_file_name, 'wb') as video_file:
video_file.write(response.read())
async def image_stream_create(self, name='blank-image', bid='1.0', confirm=True):
with tempfile.NamedTemporaryFile(suffix='.png') as file:
file.write(unhexlify(
b'89504e470d0a1a0a0000000d49484452000000050000000708020000004fc'
b'510b9000000097048597300000b1300000b1301009a9c1800000015494441'
b'5408d763fcffff3f031260624005d4e603004c45030b5286e9ea000000004'
b'9454e44ae426082'
))
file.flush()
tx = await self.out(
self.daemon.jsonrpc_stream_create(
name, bid, file_path=file.name
)
)
if confirm:
await self.on_transaction_dict(tx)
await self.generate(1)
await self.on_transaction_dict(tx)
return tx
async def video_stream_create(self, name='chrome', bid='1.0', confirm=True):
tx = await self.out(
self.daemon.jsonrpc_stream_create(
name, bid, file_path=self.video_file_name
)
)
if confirm:
await self.on_transaction_dict(tx)
await self.generate(1)
await self.on_transaction_dict(tx)
return tx
class ClaimSearchCommand(ClaimTestCase):
async def create_channel(self):
self.channel = await self.channel_create('@abc', '1.0')
self.channel_id = self.channel['outputs'][0]['claim_id']
async def create_lots_of_streams(self):
tx = await self.daemon.jsonrpc_account_fund(None, None, '0.001', outputs=100, broadcast=True)
await self.confirm_tx(tx.id)
# 4 claims per block, 3 blocks. Sorted by height (descending) then claim name (ascending).
self.streams = []
for j in range(3):
same_height_claims = []
for k in range(3):
claim_tx = await self.stream_create(
f'c{j}-{k}', '0.000001', channel_id=self.channel_id, confirm=False)
same_height_claims.append(claim_tx['outputs'][0]['name'])
await self.on_transaction_dict(claim_tx)
claim_tx = await self.stream_create(
f'c{j}-4', '0.000001', channel_id=self.channel_id, confirm=True)
same_height_claims.append(claim_tx['outputs'][0]['name'])
self.streams = same_height_claims + self.streams
async def assertFindsClaim(self, claim, **kwargs):
await self.assertFindsClaims([claim], **kwargs)
async def assertFindsClaims(self, claims, **kwargs):
results = await self.claim_search(**kwargs)
self.assertEqual(len(claims), len(results))
for claim, result in zip(claims, results):
self.assertEqual(
(claim['txid'], claim['outputs'][0]['claim_id']),
(result['txid'], result['claim_id'])
)
async def test_basic_claim_search(self):
await self.create_channel()
channel_txo = self.channel['outputs'][0]
channel2 = await self.channel_create('@abc', '0.1', allow_duplicate_name=True)
channel_txo2 = channel2['outputs'][0]
channel_id2 = channel_txo2['claim_id']
# finding a channel
await self.assertFindsClaims([channel2, self.channel], name='@abc')
await self.assertFindsClaim(self.channel, name='@abc', is_controlling=True)
await self.assertFindsClaim(self.channel, claim_id=self.channel_id)
await self.assertFindsClaim(self.channel, txid=self.channel['txid'], nout=0)
await self.assertFindsClaim(channel2, claim_id=channel_id2)
await self.assertFindsClaim(channel2, txid=channel2['txid'], nout=0)
await self.assertFindsClaim(
channel2, public_key_id=channel_txo2['value']['public_key_id'])
await self.assertFindsClaim(
self.channel, public_key_id=channel_txo['value']['public_key_id'])
signed = await self.stream_create('on-channel-claim', '0.001', channel_id=self.channel_id)
signed2 = await self.stream_create('on-channel-claim', '0.0001', channel_id=channel_id2,
allow_duplicate_name=True)
unsigned = await self.stream_create('unsigned', '0.0001')
# finding claims with and without a channel
await self.assertFindsClaims([signed2, signed], name='on-channel-claim')
await self.assertFindsClaims([signed2, signed], channel_ids=[self.channel_id, channel_id2])
await self.assertFindsClaim(signed, name='on-channel-claim', channel_ids=[self.channel_id])
await self.assertFindsClaim(signed2, name='on-channel-claim', channel_ids=[channel_id2])
await self.assertFindsClaim(unsigned, name='unsigned')
await self.assertFindsClaim(unsigned, txid=unsigned['txid'], nout=0)
await self.assertFindsClaim(unsigned, claim_id=unsigned['outputs'][0]['claim_id'])
two = await self.stream_create('on-channel-claim-2', '0.0001', channel_id=self.channel_id)
three = await self.stream_create('on-channel-claim-3', '0.0001', channel_id=self.channel_id)
# three streams in channel, zero streams in abandoned channel
claims = [three, two, signed]
await self.assertFindsClaims(claims, channel_ids=[self.channel_id])
await self.assertFindsClaims(claims, channel=f"@abc#{self.channel_id}")
await self.assertFindsClaims([three, two, signed2, signed], channel_ids=[channel_id2, self.channel_id])
await self.channel_abandon(claim_id=self.channel_id)
await self.assertFindsClaims([], channel_ids=[self.channel_id], valid_channel_signatures=True)
await self.assertFindsClaims([signed2], channel_ids=[channel_id2], valid_channel_signatures=True)
# pass `invalid_channel_signatures=False` to catch a bug in argument processing
await self.assertFindsClaims([signed2], channel_ids=[channel_id2, self.channel_id],
valid_channel_signatures=True, invalid_channel_signatures=False)
# invalid signature still returns channel_id
self.ledger._tx_cache.clear()
invalid_claims = await self.claim_search(invalid_channel_signatures=True)
self.assertEqual(3, len(invalid_claims))
self.assertTrue(all([not c['is_channel_signature_valid'] for c in invalid_claims]))
self.assertEqual({'channel_id': self.channel_id}, invalid_claims[0]['signing_channel'])
valid_claims = await self.claim_search(valid_channel_signatures=True)
self.assertEqual(1, len(valid_claims))
self.assertTrue(all([c['is_channel_signature_valid'] for c in valid_claims]))
self.assertEqual('@abc', valid_claims[0]['signing_channel']['name'])
# abandoned stream won't show up for streams in channel search
await self.stream_abandon(txid=signed2['txid'], nout=0)
await self.assertFindsClaims([], channel_ids=[channel_id2])
async def test_pagination(self):
await self.create_channel()
await self.create_lots_of_streams()
page = await self.claim_search(page_size=20, channel='@abc')
page_claim_ids = [item['name'] for item in page]
self.assertEqual(page_claim_ids, self.streams)
page = await self.claim_search(page_size=6, channel='@abc')
page_claim_ids = [item['name'] for item in page]
self.assertEqual(page_claim_ids, self.streams[:6])
page = await self.claim_search(page=2, page_size=6, channel='@abc')
page_claim_ids = [item['name'] for item in page]
self.assertEqual(page_claim_ids, self.streams[6:])
out_of_bounds = await self.claim_search(page=2, page_size=20, channel='@abc')
self.assertEqual(out_of_bounds, [])
async def test_tag_search(self):
claim1 = await self.stream_create('claim1', tags=['abc'])
claim2 = await self.stream_create('claim2', tags=['abc', 'def'])
claim3 = await self.stream_create('claim3', tags=['abc', 'ghi', 'jkl'])
claim4 = await self.stream_create('claim4', tags=['abc', 'ghi', 'mno'])
claim5 = await self.stream_create('claim5', tags=['pqr'])
# any_tags
await self.assertFindsClaims([claim5, claim4, claim3, claim2, claim1], any_tags=['abc', 'pqr'])
await self.assertFindsClaims([claim4, claim3, claim2, claim1], any_tags=['abc'])
await self.assertFindsClaims([claim4, claim3, claim2, claim1], any_tags=['abc', 'ghi'])
await self.assertFindsClaims([claim4, claim3], any_tags=['ghi'])
await self.assertFindsClaims([claim4, claim3], any_tags=['ghi', 'xyz'])
await self.assertFindsClaims([], any_tags=['xyz'])
# all_tags
await self.assertFindsClaims([], all_tags=['abc', 'pqr'])
await self.assertFindsClaims([claim4, claim3, claim2, claim1], all_tags=['abc'])
await self.assertFindsClaims([claim4, claim3], all_tags=['abc', 'ghi'])
await self.assertFindsClaims([claim4, claim3], all_tags=['ghi'])
await self.assertFindsClaims([], all_tags=['ghi', 'xyz'])
await self.assertFindsClaims([], all_tags=['xyz'])
# not_tags
await self.assertFindsClaims([], not_tags=['abc', 'pqr'])
await self.assertFindsClaims([claim5], not_tags=['abc'])
await self.assertFindsClaims([claim5], not_tags=['abc', 'ghi'])
await self.assertFindsClaims([claim5, claim2, claim1], not_tags=['ghi'])
await self.assertFindsClaims([claim5, claim2, claim1], not_tags=['ghi', 'xyz'])
await self.assertFindsClaims([claim5, claim4, claim3, claim2, claim1], not_tags=['xyz'])
# combinations
await self.assertFindsClaims([claim3], all_tags=['abc', 'ghi'], not_tags=['mno'])
await self.assertFindsClaims([claim3], all_tags=['abc', 'ghi'], any_tags=['jkl'], not_tags=['mno'])
await self.assertFindsClaims([claim4, claim3, claim2], all_tags=['abc'], any_tags=['def', 'ghi'])
async def test_order_by(self):
height = await self.ledger.network.get_server_height()
claims = [await self.stream_create(f'claim{i}') for i in range(5)]
await self.assertFindsClaims(claims, order_by=["^height"])
await self.assertFindsClaims(list(reversed(claims)), order_by=["height"])
await self.assertFindsClaims([claims[0]], height=height+1)
await self.assertFindsClaims([claims[4]], height=height+5)
await self.assertFindsClaims(claims[:1], height=f'<{height+2}', order_by=["^height"])
await self.assertFindsClaims(claims[:2], height=f'<={height+2}', order_by=["^height"])
await self.assertFindsClaims(claims[2:], height=f'>{height+2}', order_by=["^height"])
await self.assertFindsClaims(claims[1:], height=f'>={height+2}', order_by=["^height"])
await self.assertFindsClaims(claims, order_by=["^name"])
async def test_claim_type_and_media_type_search(self):
# create an invalid/unknown claim
address = await self.account.receiving.get_or_create_usable_address()
tx = await Transaction.claim_create(
'unknown', b'{"sources":{"lbry_sd_hash":""}}', 1, address, [self.account], self.account)
await tx.sign([self.account])
await self.broadcast(tx)
await self.confirm_tx(tx.id)
octet = await self.stream_create()
video = await self.video_stream_create()
image = await self.image_stream_create()
channel = await self.channel_create()
unknown = self.sout(tx)
# claim_type
await self.assertFindsClaims([image, video, octet, unknown], claim_type='stream')
await self.assertFindsClaims([channel], claim_type='channel')
# stream_type
await self.assertFindsClaims([octet, unknown], stream_types=['binary'])
await self.assertFindsClaims([video], stream_types=['video'])
await self.assertFindsClaims([image], stream_types=['image'])
await self.assertFindsClaims([image, video], stream_types=['video', 'image'])
# stream_type
await self.assertFindsClaims([octet, unknown], media_types=['application/octet-stream'])
await self.assertFindsClaims([video], media_types=['video/mp4'])
await self.assertFindsClaims([image], media_types=['image/png'])
await self.assertFindsClaims([image, video], media_types=['video/mp4', 'image/png'])
class ChannelCommands(CommandTestCase):
async def test_create_channel_names(self):
@@ -339,31 +94,21 @@ class ChannelCommands(CommandTestCase):
# create new channel with all fields set
tx = await self.out(self.channel_create('@bigchannel', **values))
channel = tx['outputs'][0]['value']
self.assertEqual(channel, {
'public_key': channel['public_key'],
'public_key_id': channel['public_key_id'],
**fixed_values
})
self.assertEqual(channel, {'public_key': channel['public_key'], **fixed_values})
# create channel with nothing set
tx = await self.out(self.channel_create('@lightchannel'))
channel = tx['outputs'][0]['value']
self.assertEqual(
channel, {'public_key': channel['public_key'], 'public_key_id': channel['public_key_id']})
self.assertEqual(channel, {'public_key': channel['public_key']})
# create channel with just a featured claim
tx = await self.out(self.channel_create('@featurechannel', featured='beef'))
txo = tx['outputs'][0]
claim_id, channel = txo['claim_id'], txo['value']
fixed_values['public_key'] = channel['public_key']
fixed_values['public_key_id'] = channel['public_key_id']
self.assertEqual(channel, {
'public_key': fixed_values['public_key'],
'public_key_id': fixed_values['public_key_id'],
'featured': ['beef']
})
self.assertEqual(channel, {'public_key': fixed_values['public_key'], 'featured': ['beef']})
# update channel "@featurechannel" setting all fields
# update channel setting all fields
tx = await self.out(self.channel_update(claim_id, **values))
channel = tx['outputs'][0]['value']
fixed_values['featured'].insert(0, 'beef') # existing featured claim
@@ -382,10 +127,9 @@ class ChannelCommands(CommandTestCase):
# replace mode (clears everything except public_key)
tx = await self.out(self.channel_update(claim_id, replace=True, title='foo', email='new@email.com'))
self.assertEqual(tx['outputs'][0]['value'], {
'public_key': channel['public_key'],
'public_key_id': channel['public_key_id'],
'title': 'foo', 'email': 'new@email.com'}
self.assertEqual(
tx['outputs'][0]['value'],
{'public_key': channel['public_key'], 'title': 'foo', 'email': 'new@email.com'}
)
# send channel to someone else
@@ -408,61 +152,28 @@ class ChannelCommands(CommandTestCase):
self.assertIsNone(txo.private_key)
# send the private key too
private_key = self.account.get_channel_private_key(unhexlify(channel['public_key']))
account2.add_channel_private_key(private_key)
txoid = f"{tx['outputs'][0]['txid']}:{tx['outputs'][0]['nout']}"
account2.channel_keys[txoid] = self.account.channel_keys[txoid]
# now should have private key
txo = (await account2.get_channels())[0]
self.assertIsNotNone(txo.private_key)
async def test_channel_export_import_into_new_account(self):
tx = await self.channel_create('@foo', '1.0')
claim_id = tx['outputs'][0]['claim_id']
channel_private_key = (await self.account.get_channels())[0].private_key
exported_data = await self.out(self.daemon.jsonrpc_channel_export(claim_id))
daemon2 = await self.add_daemon()
class StreamCommands(CommandTestCase):
# before importing channel
self.assertEqual(1, len(daemon2.default_wallet.accounts))
files_directory = os.path.join(os.path.dirname(__file__), 'files')
video_file_url = 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerEscapes.mp4'
video_file_name = os.path.join(files_directory, 'ForBiggerEscapes.mp4')
# importing channel which will create a new single key account
await daemon2.jsonrpc_channel_import(exported_data)
# after import
self.assertEqual(2, len(daemon2.default_wallet.accounts))
new_account = daemon2.default_wallet.accounts[1]
await daemon2.ledger._update_tasks.done.wait()
channels = await new_account.get_channels()
self.assertEqual(1, len(channels))
self.assertEqual(channel_private_key.to_string(), channels[0].private_key.to_string())
async def test_channel_export_import_into_existing_account(self):
tx = await self.channel_create('@foo', '1.0')
claim_id = tx['outputs'][0]['claim_id']
channel_private_key = (await self.account.get_channels())[0].private_key
exported_data = await self.out(self.daemon.jsonrpc_channel_export(claim_id))
daemon2 = await self.add_daemon(seed=self.account.seed)
await daemon2.ledger._update_tasks.done.wait() # will sync channel previously created
# before importing channel key, has channel without key
self.assertEqual(1, len(daemon2.default_wallet.accounts))
channels = await daemon2.default_account.get_channels()
self.assertEqual(1, len(channels))
self.assertIsNone(channels[0].private_key)
# importing channel will add it to existing account
await daemon2.jsonrpc_channel_import(exported_data)
# after import, still just one account but with private key now
self.assertEqual(1, len(daemon2.default_wallet.accounts))
channels = await daemon2.default_account.get_channels()
self.assertEqual(1, len(channels))
self.assertEqual(channel_private_key.to_string(), channels[0].private_key.to_string())
class StreamCommands(ClaimTestCase):
def setUp(self):
if not os.path.exists(self.video_file_name):
if not os.path.exists(self.files_directory):
os.mkdir(self.files_directory)
log.info(f'downloading test video from {self.video_file_name}')
with urlopen(self.video_file_url) as response,\
open(self.video_file_name, 'wb') as video_file:
video_file.write(response.read())
async def test_create_stream_names(self):
# claim new name
@@ -548,16 +259,16 @@ class StreamCommands(ClaimTestCase):
# defaults to using all accounts to lookup channel
await self.stream_create('hovercraft1', '0.1', channel_id=baz_id)
self.assertEqual((await self.claim_search(name='hovercraft1'))[0]['signing_channel']['name'], '@baz')
self.assertEqual((await self.claim_search('hovercraft1'))[0]['channel_name'], '@baz')
# lookup by channel_name in all accounts
await self.stream_create('hovercraft2', '0.1', channel_name='@baz')
self.assertEqual((await self.claim_search(name='hovercraft2'))[0]['signing_channel']['name'], '@baz')
self.assertEqual((await self.claim_search('hovercraft2'))[0]['channel_name'], '@baz')
# uses only the specific accounts which contains the channel
await self.stream_create('hovercraft3', '0.1', channel_id=baz_id, channel_account_id=[account2_id])
self.assertEqual((await self.claim_search(name='hovercraft3'))[0]['signing_channel']['name'], '@baz')
self.assertEqual((await self.claim_search('hovercraft3'))[0]['channel_name'], '@baz')
# lookup by channel_name in specific account
await self.stream_create('hovercraft4', '0.1', channel_name='@baz', channel_account_id=[account2_id])
self.assertEqual((await self.claim_search(name='hovercraft4'))[0]['signing_channel']['name'], '@baz')
self.assertEqual((await self.claim_search('hovercraft4'))[0]['channel_name'], '@baz')
# fails when specifying account which does not contain channel
with self.assertRaisesRegex(ValueError, "Couldn't find channel with channel_id"):
await self.stream_create(
@@ -628,7 +339,6 @@ class StreamCommands(ClaimTestCase):
}]
fixed_values['thumbnail'] = {'url': fixed_values.pop('thumbnail_url')}
fixed_values['release_time'] = str(values['release_time'])
fixed_values['stream_type'] = 'binary'
fixed_values['source'] = {
'hash': '56bf5dbae43f77a63d075b0f2ae9c7c3e3098db93779c7f9840da0f4db9c2f8c8454f4edd1373e2b64ee2e68350d916e',
'media_type': 'application/octet-stream',
@@ -652,7 +362,6 @@ class StreamCommands(ClaimTestCase):
stream = tx['outputs'][0]['value']
self.assertEqual(
stream, {
'stream_type': 'binary',
'source': {
'size': '3',
'media_type': 'application/octet-stream',
@@ -671,7 +380,6 @@ class StreamCommands(ClaimTestCase):
fixed_values['source']['sd_hash'] = stream['source']['sd_hash']
self.assertEqual(
stream, {
'stream_type': 'binary',
'source': {
'size': '3',
'media_type': 'application/octet-stream',
@@ -744,26 +452,44 @@ class StreamCommands(ClaimTestCase):
self.assertEqual(len(await self.daemon.jsonrpc_claim_list(account_id=account2_id)), 1)
async def test_automatic_type_and_metadata_detection_for_image(self):
txo = (await self.image_stream_create())['outputs'][0]
self.assertEqual(
txo['value'], {
'source': {
'size': '99',
'name': txo['value']['source']['name'],
'media_type': 'image/png',
'hash': '6c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545',
'sd_hash': txo['value']['source']['sd_hash'],
},
'stream_type': 'image',
'image': {
'width': 5,
'height': 7
with tempfile.NamedTemporaryFile(suffix='.png') as file:
file.write(unhexlify(
b'89504e470d0a1a0a0000000d49484452000000050000000708020000004fc'
b'510b9000000097048597300000b1300000b1301009a9c1800000015494441'
b'5408d763fcffff3f031260624005d4e603004c45030b5286e9ea000000004'
b'9454e44ae426082'
))
file.flush()
tx = await self.out(
self.daemon.jsonrpc_stream_create(
'blank-image', '1.0', file_path=file.name
)
)
txo = tx['outputs'][0]
self.assertEqual(
txo['value'], {
'source': {
'size': '99',
'name': os.path.basename(file.name),
'media_type': 'image/png',
'hash': '6c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545',
'sd_hash': txo['value']['source']['sd_hash'],
},
'stream_type': 'image',
'image': {
'width': 5,
'height': 7
}
}
}
)
)
async def test_automatic_type_and_metadata_detection_for_video(self):
txo = (await self.video_stream_create())['outputs'][0]
tx = await self.out(
self.daemon.jsonrpc_stream_create(
'chrome', '1.0', file_path=self.video_file_name
)
)
txo = tx['outputs'][0]
self.assertEqual(
txo['value'], {
'source': {
@@ -931,7 +657,7 @@ class StreamCommands(ClaimTestCase):
self.assertEqual(2, len(self.daemon.jsonrpc_file_list()))
r = await self.resolve('lbry://@abc/foo')
self.assertEqual(
r['lbry://@abc/foo']['claim_id'],
r['lbry://@abc/foo']['claim']['claim_id'],
tx3['outputs'][0]['claim_id']
)
@@ -939,11 +665,224 @@ class StreamCommands(ClaimTestCase):
tx4 = await self.publish('foo', languages='uk-UA')
self.assertEqual(2, len(self.daemon.jsonrpc_file_list()))
r = await self.resolve('lbry://foo')
claim = r['lbry://foo']
claim = r['lbry://foo']['claim']
self.assertEqual(claim['txid'], tx4['outputs'][0]['txid'])
self.assertNotIn('signing_channel', claim)
self.assertNotIn('channel_name', claim)
self.assertEqual(claim['value']['languages'], ['uk-UA'])
async def test_claim_search(self):
# search for channel claim
channel = await self.channel_create('@abc', '1.0')
channel_id, txid = channel['outputs'][0]['claim_id'], channel['txid']
value = channel['outputs'][0]['value']
claims = await self.claim_search('@abc')
self.assertEqual(claims[0]['value'], value)
claims = await self.claim_search(txid=txid, nout=0)
self.assertEqual(claims[0]['value'], value)
claims = await self.claim_search(claim_id=channel_id)
self.assertEqual(claims[0]['value'], value)
await self.channel_abandon(txid=txid, nout=0)
self.assertEqual(len(await self.claim_search(txid=txid, nout=0)), 0)
# search stream claims
channel = await self.channel_create('@abc', '1.0')
channel_id, txid = channel['outputs'][0]['claim_id'], channel['txid']
signed = await self.stream_create('on-channel-claim', '0.0001', channel_id=channel_id)
unsigned = await self.stream_create('unsigned', '0.0001')
claims = await self.claim_search('on-channel-claim')
self.assertEqual(claims[0]['value'], signed['outputs'][0]['value'])
claims = await self.claim_search('unsigned')
self.assertEqual(claims[0]['value'], unsigned['outputs'][0]['value'])
# list streams in a channel
await self.stream_create('on-channel-claim-2', '0.0001', channel_id=channel_id)
await self.stream_create('on-channel-claim-3', '0.0001', channel_id=channel_id)
claims = await self.claim_search(channel_id=channel_id)
self.assertEqual(len(claims), 3)
# same is expected using name or name#claim_id urls
claims = await self.claim_search(channel_name="@abc")
self.assertEqual(len(claims), 3)
claims = await self.claim_search(channel_name="@abc", channel_id=channel_id)
self.assertEqual(len(claims), 3)
claims = await self.claim_search(channel_name=f"@abc#{channel_id}")
self.assertEqual(len(claims), 3)
await self.stream_abandon(claim_id=claims[0]['claim_id'])
await self.stream_abandon(claim_id=claims[1]['claim_id'])
await self.stream_abandon(claim_id=claims[2]['claim_id'])
claims = await self.claim_search(channel_id=channel_id)
self.assertEqual(len(claims), 0)
tx = await self.daemon.jsonrpc_account_fund(None, None, '0.001', outputs=100, broadcast=True)
await self.confirm_tx(tx.id)
# 4 claims per block, 3 blocks. Sorted by height (descending) then claim_id (ascending).
claims = []
for j in range(3):
same_height_claims = []
for k in range(3):
claim_tx = await self.stream_create(f'c{j}-{k}', '0.000001', channel_id=channel_id, confirm=False)
same_height_claims.append(claim_tx['outputs'][0]['claim_id'])
await self.on_transaction_dict(claim_tx)
claim_tx = await self.stream_create(f'c{j}-4', '0.000001', channel_id=channel_id, confirm=True)
same_height_claims.append(claim_tx['outputs'][0]['claim_id'])
same_height_claims.sort(key=lambda x: int(x, 16))
claims = same_height_claims + claims
page = await self.claim_search(page_size=20, channel_id=channel_id)
page_claim_ids = [item['claim_id'] for item in page]
self.assertEqual(page_claim_ids, claims)
page = await self.claim_search(page_size=6, channel_id=channel_id)
page_claim_ids = [item['claim_id'] for item in page]
self.assertEqual(page_claim_ids, claims[:6])
out_of_bounds = await self.claim_search(page=2, page_size=20, channel_id=channel_id)
self.assertEqual(out_of_bounds, [])
async def test_abandoned_channel_with_signed_claims(self):
channel = (await self.channel_create('@abc', '1.0'))['outputs'][0]
orphan_claim = await self.stream_create('on-channel-claim', '0.0001', channel_id=channel['claim_id'])
await self.channel_abandon(txid=channel['txid'], nout=0)
channel = (await self.channel_create('@abc', '1.0'))['outputs'][0]
orphan_claim_id = orphan_claim['outputs'][0]['claim_id']
# Original channel doesnt exists anymore, so the signature is invalid. For invalid signatures, resolution is
# only possible outside a channel
response = await self.resolve('lbry://@abc/on-channel-claim')
self.assertNotIn('claim', response['lbry://@abc/on-channel-claim'])
response = await self.resolve('lbry://on-channel-claim')
self.assertIs(False, response['lbry://on-channel-claim']['claim']['signature_is_valid'])
direct_uri = 'lbry://on-channel-claim#' + orphan_claim_id
response = await self.resolve(direct_uri)
self.assertIs(False, response[direct_uri]['claim']['signature_is_valid'])
await self.stream_abandon(claim_id=orphan_claim_id)
uri = 'lbry://@abc/on-channel-claim'
# now, claim something on this channel (it will update the invalid claim, but we save and forcefully restore)
valid_claim = await self.stream_create('on-channel-claim', '0.00000001', channel_id=channel['claim_id'])
# resolves normally
response = await self.resolve(uri)
self.assertTrue(response[uri]['claim']['signature_is_valid'])
# ooops! claimed a valid conflict! (this happens on the wild, mostly by accident or race condition)
await self.stream_create(
'on-channel-claim', '0.00000001', channel_id=channel['claim_id'], allow_duplicate_name=True
)
# it still resolves! but to the older claim
response = await self.resolve(uri)
self.assertTrue(response[uri]['claim']['signature_is_valid'])
self.assertEqual(response[uri]['claim']['txid'], valid_claim['txid'])
claims = (await self.daemon.jsonrpc_claim_search('on-channel-claim'))['items']
self.assertEqual(2, len(claims))
signer_ids = set([claim['value'].signing_channel_id for claim in claims])
self.assertEqual({channel['claim_id']}, signer_ids)
async def test_normalization_resolution(self):
# this test assumes that the lbrycrd forks normalization at height == 250 on regtest
c1 = await self.stream_create('ΣίσυφοςfiÆ', '0.1')
c2 = await self.stream_create('ΣΊΣΥΦΟσFIæ', '0.2')
r1 = await self.daemon.jsonrpc_resolve(urls='lbry://ΣίσυφοςfiÆ')
r2 = await self.daemon.jsonrpc_resolve(urls='lbry://ΣΊΣΥΦΟσFIæ')
r1c = list(r1.values())[0]['claim']['claim_id']
r2c = list(r2.values())[0]['claim']['claim_id']
self.assertEqual(c1['outputs'][0]['claim_id'], r1c)
self.assertEqual(c2['outputs'][0]['claim_id'], r2c)
self.assertNotEqual(r1c, r2c)
await self.generate(50)
self.assertTrue(self.ledger.headers.height > 250)
r3 = await self.daemon.jsonrpc_resolve(urls='lbry://ΣίσυφοςfiÆ')
r4 = await self.daemon.jsonrpc_resolve(urls='lbry://ΣΊΣΥΦΟσFIæ')
r3c = list(r3.values())[0]['claim']['claim_id']
r4c = list(r4.values())[0]['claim']['claim_id']
r3n = list(r3.values())[0]['claim']['name']
r4n = list(r4.values())[0]['claim']['name']
self.assertEqual(c2['outputs'][0]['claim_id'], r3c)
self.assertEqual(c2['outputs'][0]['claim_id'], r4c)
self.assertEqual(r3c, r4c)
self.assertEqual(r3n, r4n)
async def test_resolve_old_claim(self):
channel = await self.daemon.jsonrpc_channel_create('@olds', '1.0')
await self.confirm_tx(channel.id)
address = channel.outputs[0].get_address(self.account.ledger)
claim = generate_signed_legacy(address, channel.outputs[0])
tx = await Transaction.claim_create('example', claim.SerializeToString(), 1, address, [self.account], self.account)
await tx.sign([self.account])
await self.broadcast(tx)
await self.confirm_tx(tx.id)
response = await self.daemon.jsonrpc_resolve(urls='@olds/example')
self.assertTrue(response['@olds/example']['claim']['signature_is_valid'])
claim.publisherSignature.signature = bytes(reversed(claim.publisherSignature.signature))
tx = await Transaction.claim_create(
'bad_example', claim.SerializeToString(), 1, address, [self.account], self.account
)
await tx.sign([self.account])
await self.broadcast(tx)
await self.confirm_tx(tx.id)
response = await self.daemon.jsonrpc_resolve(urls='bad_example')
self.assertIs(False, response['bad_example']['claim']['signature_is_valid'], response)
response = await self.daemon.jsonrpc_resolve(urls='@olds/bad_example')
self.assertEqual('URI lbry://@olds/bad_example cannot be resolved', response['@olds/bad_example']['error'])
def generate_signed_legacy(address: bytes, output: Output):
decoded_address = Base58.decode(address)
claim = OldClaimMessage()
claim.ParseFromString(unhexlify(
'080110011aee04080112a604080410011a2b4865726520617265203520526561736f6e73204920e29da4e'
'fb88f204e657874636c6f7564207c20544c4722920346696e64206f7574206d6f72652061626f7574204e'
'657874636c6f75643a2068747470733a2f2f6e657874636c6f75642e636f6d2f0a0a596f752063616e206'
'6696e64206d65206f6e20746865736520736f6369616c733a0a202a20466f72756d733a2068747470733a'
'2f2f666f72756d2e6865617679656c656d656e742e696f2f0a202a20506f64636173743a2068747470733'
'a2f2f6f6666746f706963616c2e6e65740a202a2050617472656f6e3a2068747470733a2f2f7061747265'
'6f6e2e636f6d2f7468656c696e757867616d65720a202a204d657263683a2068747470733a2f2f7465657'
'37072696e672e636f6d2f73746f7265732f6f6666696369616c2d6c696e75782d67616d65720a202a2054'
'77697463683a2068747470733a2f2f7477697463682e74762f786f6e64616b0a202a20547769747465723'
'a2068747470733a2f2f747769747465722e636f6d2f7468656c696e757867616d65720a0a2e2e2e0a6874'
'7470733a2f2f7777772e796f75747562652e636f6d2f77617463683f763d4672546442434f535f66632a0'
'f546865204c696e75782047616d6572321c436f7079726967687465642028636f6e746163742061757468'
'6f722938004a2968747470733a2f2f6265726b2e6e696e6a612f7468756d626e61696c732f46725464424'
'34f535f666352005a001a41080110011a30040e8ac6e89c061f982528c23ad33829fd7146435bf7a4cc22'
'f0bff70c4fe0b91fd36da9a375e3e1c171db825bf5d1f32209766964656f2f6d70342a5c080110031a406'
'2b2dd4c45e364030fbfad1a6fefff695ebf20ea33a5381b947753e2a0ca359989a5cc7d15e5392a0d354c'
'0b68498382b2701b22c03beb8dcb91089031b871e72214feb61536c007cdf4faeeaab4876cb397feaf6b51'
))
claim.ClearField("publisherSignature")
digest = sha256(b''.join([
decoded_address,
claim.SerializeToString(),
output.claim_hash[::-1]
]))
private_key = ecdsa.SigningKey.from_pem(output.private_key, hashfunc=hashlib.sha256)
signature = private_key.sign_digest_deterministic(digest, hashfunc=hashlib.sha256)
claim.publisherSignature.version = 1
claim.publisherSignature.signatureType = 1
claim.publisherSignature.signature = signature
claim.publisherSignature.certificateId = output.claim_hash[::-1]
return claim
class SupportCommands(CommandTestCase):
@@ -1022,3 +961,5 @@ class SupportCommands(CommandTestCase):
self.assertEqual(txs2[0]['support_info'][0]['is_tip'], False)
self.assertEqual(txs2[0]['value'], '0.0')
self.assertEqual(txs2[0]['fee'], '-0.0001415')
+140 -42
View File
@@ -1,16 +1,22 @@
import logging
import typing
import random
import asyncio
from aiohttp import web
from lbrynet.testcase import CommandTestCase
import lbrynet.schema
lbrynet.schema.BLOCKCHAIN_NAME = 'lbrycrd_regtest'
class FakedCommentServer:
ERRORS = {
'INVALID_URI': {'code': 1, 'message': 'Invalid claim URI'},
'INVALID_PARAMS': {'code': -32602, 'message': 'Invalid parameters'},
'INTERNAL': {'code': -32603, 'message': 'An internal error'},
'UNKNOWN': {'code': -1, 'message': 'An unknown or very miscellaneous error'},
'INVALID_METHOD': {'code': -32604, 'message': 'The Requested method does not exist'}
}
def __init__(self, port=2903):
@@ -19,21 +25,45 @@ class FakedCommentServer:
self.app.add_routes([web.post('/api', self.api)])
self.runner = None
self.server = None
self.comments = []
self.comment_id = 0
def create_comment(self, **comment):
self.comment_id += 1
comment['comment_id'] = self.comment_id
self.comments.append(comment)
return comment
def get_claim_comments(self, uri: str, better_keys: bool) -> typing.Union[dict, list, None]:
if not uri.startswith('lbry://'): # Very basic error case
return {'error': self.ERRORS['INVALID_URI']}
return [self.get_comment(i) for i in range(75)]
def get_claim_comments(self, page=1, page_size=50, **kwargs):
return self.comments[:page_size]
def get_comment(self, comment_id: int, parent_id: int = None) -> dict:
return {
'comment_id': comment_id,
'parent_id': parent_id,
'author': f'Person{comment_id}',
'message': f'comment {comment_id}',
'claim_id': random.randint(1, 2**16),
'time_posted': random.randint(2**16, 2**32 - 1),
'upvotes': random.randint(0, 9999), 'downvotes': random.randint(0, 9999)
}
def comment(self, uri: str, poster: str, message: str) -> typing.Union[int, dict, None]:
if not uri.startswith('lbry://'):
return {'error': self.ERRORS['INVALID_URI']}
return random.randint(1, 9999)
def reply(self, parent_id: int, poster: str, message: str) -> dict:
if 2 <= len(message) <= 2000 and 2 <= len(poster) <= 127 and parent_id > 0:
return random.randint(parent_id + 1, 2**32 - 1)
return {'error': self.ERRORS['INVALID_PARAMS']}
def get_comment_data(self, comm_index: int, better_keys: bool = False) -> typing.Union[dict, None]:
return self.get_comment(comm_index)
def get_comment_replies(self, comm_index: int) -> typing.Union[list, None]:
return [random.randint(comm_index, comm_index+250) for _ in range(75)]
methods = {
'get_claim_comments': get_claim_comments,
'create_comment': create_comment,
'get_comment_data': get_comment_data,
'get_comment_replies': get_comment_replies,
'comment': comment,
'reply': reply
}
def process_json(self, body) -> dict:
@@ -41,21 +71,32 @@ class FakedCommentServer:
if body['method'] in self.methods:
params = body.get('params', {})
result = self.methods[body['method']](self, **params)
response['result'] = result
if type(result) is dict and 'error' in result:
response['error'] = result['error']
else:
response['result'] = result
else:
response['error'] = self.ERRORS['INVALID_METHOD']
response['error'] = self.ERRORS['UNKNOWN']
return response
async def start(self):
async def _start(self):
self.runner = web.AppRunner(self.app)
await self.runner.setup()
self.server = web.TCPSite(self.runner, 'localhost', self.port)
await self.server.start()
async def stop(self):
await self.runner.shutdown()
async def _stop(self):
await self.runner.cleanup()
async def run(self, max_timeout=3600):
try:
await self._start()
await asyncio.sleep(max_timeout)
except asyncio.CancelledError:
pass
finally:
await self._stop()
async def api(self, request):
body = await request.json()
if type(body) is list or type(body) is dict:
@@ -65,41 +106,98 @@ class FakedCommentServer:
response = self.process_json(body)
return web.json_response(response)
else:
raise TypeError('invalid type passed')
return web.json_response({'error': self.ERRORS['UNKNOWN']})
class CommentCommands(CommandTestCase):
VERBOSITY = logging.WARN
async def asyncSetUp(self):
await super().asyncSetUp()
self.daemon.conf.comment_server = 'http://localhost:2903/api'
self.comment_server = FakedCommentServer(2903)
await self.comment_server.start()
self.addCleanup(self.comment_server.stop)
self.server = FakedCommentServer(2903)
self.server_task = asyncio.create_task(self.server.run(self.timeout))
async def asyncTearDown(self):
await super().asyncTearDown()
self.server_task.cancel()
if not self.server_task.cancelled():
await self.server_task
async def test_comment_create(self):
channel = (await self.channel_create('@JimmyBuffett'))['outputs'][0]
stream = (await self.stream_create())['outputs'][0]
self.assertEqual(0, len(await self.daemon.jsonrpc_comment_list(stream['claim_id'])))
claim = await self.stream_create(name='doge', bid='0.001', data=b'loool')
self.assertIn('outputs', claim)
comment = await self.daemon.jsonrpc_comment_create(
claim_id=stream['claim_id'],
channel_id=channel['claim_id'],
comment="It's 5 O'Clock Somewhere"
claim_id=claim['outputs'][0]['claim_id'],
channel_id='Jimmy Buffett',
message="It's 5 O'Clock Somewhere"
)
comments = await self.daemon.jsonrpc_comment_list(stream['claim_id'])
self.assertEqual(1, len(comments))
self.assertEqual(comment['comment_id'], comments[0]['comment_id'])
self.assertEqual(stream['claim_id'], comments[0]['claim_id'])
self.assertIs(type(comment), dict, msg=f"Response type ({type(comment)})is not dict: {comment}")
self.assertIn('message', comment, msg=f"Response {comment} doesn't contain message")
self.assertIn('author', comment)
channel2 = (await self.channel_create('@BuffettJimmy'))['outputs'][0]
await self.daemon.jsonrpc_comment_create(
claim_id=stream['claim_id'],
channel_name=channel2['name'],
comment='Let\'s all go to Margaritaville',
parent_id=comments[0]['comment_id']
async def test_comment_create_reply(self):
claim = await self.stream_create(name='doge', bid='0.001')
self.assertIn('outputs', claim)
reply = await self.daemon.jsonrpc_comment_create(
claim_id=claim['outputs'][0]['claim_id'],
channel_id='Jimmy Buffett',
message='Let\'s all go to Margaritaville',
parent_comment_id=42
)
comments = await self.daemon.jsonrpc_comment_list(stream['claim_id'])
self.assertEqual(2, len(comments))
self.assertEqual(comments[1]['channel_id'], channel2['claim_id'])
self.assertEqual(comments[0]['comment_id'], comments[1]['parent_id'])
self.assertIs(type(reply), dict, msg=f'Response {type(reply)} is not dict\nResponse: {reply}')
self.assertIn('author', reply)
async def test_comment_list_root_level(self):
claim = await self.stream_create(name='doge', bid='0.001')
self.assertIn('outputs', claim)
claim_id = claim['outputs'][0]['claim_id']
comments = await self.daemon.jsonrpc_comment_list(claim_id)
self.assertIsNotNone(type(comments))
self.assertIs(type(comments), dict)
self.assertIn('comments', comments, f"'comments' field was not found in returned dict: {comments}")
self.assertIs(type(comments['comments']), list, msg=f'comment_list: {comments}')
comments = await self.daemon.jsonrpc_comment_list(claim_id, page_size=50)
self.assertIsNotNone(comments)
self.assertIs(type(comments), dict)
self.assertIn('comments', comments, f"'comments' field was not found in returned dict: {comments}")
comment_list = comments['comments']
self.assertEqual(len(comment_list), 50, msg=f'comment_list incorrect size {len(comment_list)}: {comment_list}')
comments = await self.daemon.jsonrpc_comment_list(claim_id, page_size=50, page=2)
self.assertEqual(len(comments['comments']), 25, msg=f'comment list page 2: {comments["comments"]}')
comments = await self.daemon.jsonrpc_comment_list(claim_id, page_size=50, page=3)
self.assertEqual(len(comments['comments']), 0, msg=f'comment list is non-zero: {comments["comments"]}')
async def test_comment_list_replies(self):
claim = await self.stream_create(name='doge', bid='0.001')
self.assertIn('outputs', claim)
claim_id = claim['outputs'][0]['claim_id']
replies = await self.daemon.jsonrpc_comment_list(claim_id, parent_comment_id=23)
self.assertIsInstance(replies['comments'], list, msg=f'Invalid type: {replies["comments"]} should be list')
self.assertGreater(len(replies['comments']), 0, msg='Returned replies are empty')
replies = (await self.daemon.jsonrpc_comment_list(claim_id, parent_comment_id=25, page_size=50))['comments']
self.assertEqual(len(replies), 50, f'Replies invalid length ({len(replies)})')
replies = (await self.daemon.jsonrpc_comment_list(claim_id, parent_comment_id=67,
page_size=23, page=5))['comments']
self.assertEqual(len(replies), 0, f'replies {replies} not 23: {len(replies)}')
replies = (await self.daemon.jsonrpc_comment_list(claim_id, parent_comment_id=79,
page_size=60, page=2))['comments']
self.assertEqual(len(replies), 15, f'Size of replies is incorrect, should be 15: {replies}')
async def test_comment_list_flatness_flatness_LA(self):
claim = await self.stream_create(name='doge', bid='0.001')
self.assertIn('outputs', claim)
claim_id = claim['outputs'][0]['claim_id']
replies = await self.daemon.jsonrpc_comment_list(claim_id, parent_comment_id=23, flat=True)
self.assertIsInstance(replies['comments'], list, msg=f'Invalid type: {replies["comments"]} should be list')
self.assertGreater(len(replies['comments']), 0, msg='Returned replies are empty')
replies = (await self.daemon.jsonrpc_comment_list(claim_id, parent_comment_id=25, flat=True,
max_replies_shown=0, page_size=50))['comments']
self.assertEqual(len(replies), 50, f'Replies invalid length ({len(replies)})')
replies = (await self.daemon.jsonrpc_comment_list(claim_id, parent_comment_id=67,
flat=True, page_size=23, page=5))['comments']
self.assertEqual(len(replies), 0, f'replies {replies} not 23: {len(replies)}')
replies = (await self.daemon.jsonrpc_comment_list(claim_id, parent_comment_id=79,
page_size=60, page=2))['comments']
self.assertGreaterEqual(len(replies), 15, f'Size of replies is incorrect, should be 15: {replies}')
+4 -3
View File
@@ -77,11 +77,12 @@ class FileCommands(CommandTestCase):
async def test_file_list_updated_metadata_on_resolve(self):
await self.stream_create('foo', '0.01')
txo = (await self.daemon.resolve(['lbry://foo']))['lbry://foo']
claim = txo.claim
claim = await self.daemon.resolve('lbry://foo')
claim = claim['lbry://foo']['claim']['protobuf'].decode()
await self.daemon.jsonrpc_file_delete(claim_name='foo')
txid = await self.blockchain_claim_name('bar', hexlify(claim.to_bytes()).decode(), '0.01')
txid = await self.blockchain_claim_name('bar', claim, '0.01')
await self.daemon.jsonrpc_get('lbry://bar')
claim = Claim.from_bytes(unhexlify(claim))
claim.stream.description = "fix typos, fix the world"
await self.blockchain_update_name(txid, hexlify(claim.to_bytes()).decode(), '0.01')
await self.daemon.jsonrpc_resolve('lbry://bar')
@@ -59,8 +59,9 @@ class BasicTransactionTest(IntegrationTestCase):
self.assertEqual(d2l(await self.account.get_balance()), '7.985786')
self.assertEqual(d2l(await self.account.get_balance(include_claims=True)), '9.985786')
response = await self.ledger.resolve(['lbry://@bar/foo'])
self.assertEqual(response['lbry://@bar/foo'].claim.claim_type, 'stream')
response = await self.ledger.resolve(0, 10, 'lbry://@bar/foo')
self.assertIn('lbry://@bar/foo', response)
self.assertIn('claim', response['lbry://@bar/foo'])
abandon_tx = await Transaction.create([Input.spend(stream_tx.outputs[0])], [], [self.account], self.account)
await self.broadcast(abandon_tx)
@@ -68,10 +69,10 @@ class BasicTransactionTest(IntegrationTestCase):
await self.blockchain.generate(1)
await self.ledger.wait(abandon_tx)
response = await self.ledger.resolve(['lbry://@bar/foo'])
self.assertIn('error', response['lbry://@bar/foo'])
response = await self.ledger.resolve(0, 10, 'lbry://@bar/foo')
self.assertNotIn('claim', response['lbry://@bar/foo'])
# checks for expected format in inexistent URIs
response = await self.ledger.resolve(['lbry://404', 'lbry://@404'])
self.assertEqual('lbry://404 did not resolve to a claim', response['lbry://404']['error'])
self.assertEqual('lbry://@404 did not resolve to a claim', response['lbry://@404']['error'])
response = await self.ledger.resolve(0, 10, 'lbry://404', 'lbry://@404')
self.assertEqual('URI lbry://404 cannot be resolved', response['lbry://404']['error'])
self.assertEqual('URI lbry://@404 cannot be resolved', response['lbry://@404']['error'])
+61 -259
View File
@@ -1,275 +1,113 @@
import asyncio
import json
import hashlib
from unittest import skip
from binascii import hexlify, unhexlify
from binascii import hexlify
from lbrynet.testcase import CommandTestCase
from lbrynet.wallet.transaction import Transaction, Output
from lbrynet.schema.compat import OldClaimMessage
from torba.client.hash import sha256, Base58
class ResolveCommand(CommandTestCase):
def get_claim_id(self, tx):
return tx['outputs'][0]['claim_id']
async def assertResolvesToClaimId(self, name, claim_id):
other = (await self.resolve(name))[name]
if claim_id is None:
self.assertIn('error', other)
else:
self.assertEqual(claim_id, other['claim_id'])
async def test_resolve_response(self):
channel_id = self.get_claim_id(
await self.channel_create('@abc', '0.01')
)
async def test_resolve(self):
tx = await self.channel_create('@abc', '0.01')
channel_id = tx['outputs'][0]['claim_id']
# resolving a channel @abc
response = await self.resolve('lbry://@abc')
self.assertSetEqual({'lbry://@abc'}, set(response))
self.assertEqual(response['lbry://@abc']['name'], '@abc')
self.assertEqual(response['lbry://@abc']['value_type'], 'channel')
self.assertEqual(response['lbry://@abc']['meta']['claims_in_channel'], 0)
self.assertIn('certificate', response['lbry://@abc'])
self.assertNotIn('claim', response['lbry://@abc'])
self.assertEqual(response['lbry://@abc']['certificate']['name'], '@abc')
self.assertEqual(response['lbry://@abc']['claims_in_channel'], 0)
await self.stream_create('foo', '0.01', channel_id=channel_id)
await self.stream_create('foo2', '0.01', channel_id=channel_id)
# resolving a channel @abc with some claims in it
response['lbry://@abc']['confirmations'] += 2
response['lbry://@abc']['meta']['claims_in_channel'] = 2
self.assertEqual(response, await self.resolve('lbry://@abc'))
response = await self.resolve('lbry://@abc')
self.assertSetEqual({'lbry://@abc'}, set(response))
self.assertIn('certificate', response['lbry://@abc'])
self.assertNotIn('claim', response['lbry://@abc'])
self.assertEqual(response['lbry://@abc']['certificate']['name'], '@abc')
self.assertEqual(response['lbry://@abc']['claims_in_channel'], 2)
# resolving claim foo within channel @abc
response = await self.resolve('lbry://@abc/foo')
self.assertSetEqual({'lbry://@abc/foo'}, set(response))
claim = response['lbry://@abc/foo']
self.assertEqual(claim['name'], 'foo')
self.assertEqual(claim['value_type'], 'stream')
self.assertEqual(claim['signing_channel']['name'], '@abc')
self.assertTrue(claim['is_channel_signature_valid'])
self.assertIn('certificate', claim)
self.assertIn('claim', claim)
self.assertEqual(claim['claim']['name'], 'foo')
self.assertEqual(claim['claim']['channel_name'], '@abc')
self.assertEqual(claim['certificate']['name'], '@abc')
self.assertEqual(claim['claims_in_channel'], 0)
self.assertEqual(
claim['timestamp'],
self.ledger.headers[claim['height']]['timestamp']
claim['claim']['timestamp'],
self.ledger.headers[claim['claim']['height']]['timestamp']
)
self.assertEqual(
claim['signing_channel']['timestamp'],
self.ledger.headers[claim['signing_channel']['height']]['timestamp']
claim['certificate']['timestamp'],
self.ledger.headers[claim['certificate']['height']]['timestamp']
)
# resolving claim foo by itself
self.assertEqual(claim, (await self.resolve('lbry://foo'))['lbry://foo'])
response = await self.resolve('lbry://foo')
self.assertSetEqual({'lbry://foo'}, set(response))
claim = response['lbry://foo']
self.assertIn('certificate', claim)
self.assertIn('claim', claim)
self.assertEqual(claim['claim']['name'], 'foo')
self.assertEqual(claim['claim']['channel_name'], '@abc')
self.assertEqual(claim['certificate']['name'], '@abc')
self.assertEqual(claim['claims_in_channel'], 0)
# resolving from the given permanent url
permanent_url = response['lbry://@abc/foo']['permanent_url']
self.assertEqual(claim, (await self.resolve(permanent_url))[permanent_url])
new_response = await self.resolve(claim['claim']['permanent_url'])
self.assertEqual(new_response[claim['claim']['permanent_url']], claim)
# resolving multiple at once
response = await self.resolve(['lbry://foo', 'lbry://foo2'])
self.assertSetEqual({'lbry://foo', 'lbry://foo2'}, set(response))
claim = response['lbry://foo2']
self.assertEqual(claim['name'], 'foo2')
self.assertEqual(claim['value_type'], 'stream')
self.assertEqual(claim['signing_channel']['name'], '@abc')
self.assertTrue(claim['is_channel_signature_valid'])
self.assertIn('certificate', claim)
self.assertIn('claim', claim)
self.assertEqual(claim['claim']['name'], 'foo2')
self.assertEqual(claim['claim']['channel_name'], '@abc')
self.assertEqual(claim['certificate']['name'], '@abc')
self.assertEqual(claim['claims_in_channel'], 0)
# resolve has correct confirmations
tx_details = await self.blockchain.get_raw_transaction(claim['txid'])
self.assertEqual(claim['confirmations'], json.loads(tx_details)['confirmations'])
tx_details = await self.blockchain.get_raw_transaction(claim['claim']['txid'])
self.assertEqual(claim['claim']['confirmations'], json.loads(tx_details)['confirmations'])
# resolve handles invalid data
await self.blockchain_claim_name("gibberish", hexlify(b"{'invalid':'json'}").decode(), "0.1")
await self.generate(1)
txid = await self.blockchain_claim_name(
"gibberish", hexlify(b"{'invalid':'json'}").decode(), "0.1")
response = await self.resolve("lbry://gibberish")
self.assertSetEqual({'lbry://gibberish'}, set(response))
claim = response['lbry://gibberish']
claim = response['lbry://gibberish']['claim']
self.assertEqual(claim['name'], 'gibberish')
self.assertNotIn('value', claim)
async def test_winning_by_effective_amount(self):
# first one remains winner unless something else changes
claim_id1 = self.get_claim_id(
await self.channel_create('@foo', allow_duplicate_name=True))
await self.assertResolvesToClaimId('@foo', claim_id1)
claim_id2 = self.get_claim_id(
await self.channel_create('@foo', allow_duplicate_name=True))
await self.assertResolvesToClaimId('@foo', claim_id1)
claim_id3 = self.get_claim_id(
await self.channel_create('@foo', allow_duplicate_name=True))
await self.assertResolvesToClaimId('@foo', claim_id1)
# supports change the winner
await self.support_create(claim_id3, '0.09')
await self.assertResolvesToClaimId('@foo', claim_id3)
await self.support_create(claim_id2, '0.19')
await self.assertResolvesToClaimId('@foo', claim_id2)
await self.support_create(claim_id1, '0.29')
await self.assertResolvesToClaimId('@foo', claim_id1)
async def test_advanced_resolve(self):
claim_id1 = self.get_claim_id(
await self.stream_create('foo', '0.7', allow_duplicate_name=True))
claim_id2 = self.get_claim_id(
await self.stream_create('foo', '0.8', allow_duplicate_name=True))
claim_id3 = self.get_claim_id(
await self.stream_create('foo', '0.9', allow_duplicate_name=True))
# plain winning claim
await self.assertResolvesToClaimId('foo', claim_id3)
# sequence resolution
await self.assertResolvesToClaimId('foo:1', claim_id1)
await self.assertResolvesToClaimId('foo:2', claim_id2)
await self.assertResolvesToClaimId('foo:3', claim_id3)
await self.assertResolvesToClaimId('foo:4', None)
# amount order resolution
await self.assertResolvesToClaimId('foo$1', claim_id3)
await self.assertResolvesToClaimId('foo$2', claim_id2)
await self.assertResolvesToClaimId('foo$3', claim_id1)
await self.assertResolvesToClaimId('foo$4', None)
async def test_partial_claim_id_resolve(self):
# add some noise
await self.channel_create('@abc', '0.1', allow_duplicate_name=True)
await self.channel_create('@abc', '0.2', allow_duplicate_name=True)
await self.channel_create('@abc', '1.0', allow_duplicate_name=True)
channel_id = self.get_claim_id(
await self.channel_create('@abc', '1.1', allow_duplicate_name=True))
await self.assertResolvesToClaimId(f'@abc', channel_id)
await self.assertResolvesToClaimId(f'@abc#{channel_id[:10]}', channel_id)
await self.assertResolvesToClaimId(f'@abc#{channel_id}', channel_id)
channel = (await self.claim_search(claim_id=channel_id))[0]
await self.assertResolvesToClaimId(channel['short_url'], channel_id)
await self.assertResolvesToClaimId(channel['canonical_url'], channel_id)
await self.assertResolvesToClaimId(channel['permanent_url'], channel_id)
# add some noise
await self.stream_create('foo', '0.1', allow_duplicate_name=True, channel_id=channel['claim_id'])
await self.stream_create('foo', '0.2', allow_duplicate_name=True, channel_id=channel['claim_id'])
await self.stream_create('foo', '0.3', allow_duplicate_name=True, channel_id=channel['claim_id'])
claim_id1 = self.get_claim_id(
await self.stream_create('foo', '0.7', allow_duplicate_name=True, channel_id=channel['claim_id']))
claim1 = (await self.claim_search(claim_id=claim_id1))[0]
await self.assertResolvesToClaimId('foo', claim_id1)
await self.assertResolvesToClaimId('@abc/foo', claim_id1)
await self.assertResolvesToClaimId(claim1['short_url'], claim_id1)
await self.assertResolvesToClaimId(claim1['canonical_url'], claim_id1)
await self.assertResolvesToClaimId(claim1['permanent_url'], claim_id1)
claim_id2 = self.get_claim_id(
await self.stream_create('foo', '0.8', allow_duplicate_name=True, channel_id=channel['claim_id']))
claim2 = (await self.claim_search(claim_id=claim_id2))[0]
await self.assertResolvesToClaimId('foo', claim_id2)
await self.assertResolvesToClaimId('@abc/foo', claim_id2)
await self.assertResolvesToClaimId(claim2['short_url'], claim_id2)
await self.assertResolvesToClaimId(claim2['canonical_url'], claim_id2)
await self.assertResolvesToClaimId(claim2['permanent_url'], claim_id2)
async def test_abandoned_channel_with_signed_claims(self):
channel = (await self.channel_create('@abc', '1.0'))['outputs'][0]
orphan_claim = await self.stream_create('on-channel-claim', '0.0001', channel_id=channel['claim_id'])
abandoned_channel_id = channel['claim_id']
await self.channel_abandon(txid=channel['txid'], nout=0)
channel = (await self.channel_create('@abc', '1.0'))['outputs'][0]
orphan_claim_id = orphan_claim['outputs'][0]['claim_id']
# Original channel doesnt exists anymore, so the signature is invalid. For invalid signatures, resolution is
# only possible outside a channel
response = await self.resolve('lbry://@abc/on-channel-claim')
self.assertEqual(response, {
'lbry://@abc/on-channel-claim': {'error': 'lbry://@abc/on-channel-claim did not resolve to a claim'}
})
response = (await self.resolve('lbry://on-channel-claim'))['lbry://on-channel-claim']
self.assertFalse(response['is_channel_signature_valid'])
self.assertEqual({'channel_id': abandoned_channel_id}, response['signing_channel'])
direct_uri = 'lbry://on-channel-claim#' + orphan_claim_id
response = (await self.resolve(direct_uri))[direct_uri]
self.assertFalse(response['is_channel_signature_valid'])
self.assertEqual({'channel_id': abandoned_channel_id}, response['signing_channel'])
await self.stream_abandon(claim_id=orphan_claim_id)
uri = 'lbry://@abc/on-channel-claim'
# now, claim something on this channel (it will update the invalid claim, but we save and forcefully restore)
valid_claim = await self.stream_create('on-channel-claim', '0.00000001', channel_id=channel['claim_id'])
# resolves normally
response = await self.resolve(uri)
self.assertTrue(response[uri]['is_channel_signature_valid'])
# ooops! claimed a valid conflict! (this happens on the wild, mostly by accident or race condition)
await self.stream_create(
'on-channel-claim', '0.00000001', channel_id=channel['claim_id'], allow_duplicate_name=True
)
# it still resolves! but to the older claim
response = await self.resolve(uri)
self.assertTrue(response[uri]['is_channel_signature_valid'])
self.assertEqual(response[uri]['txid'], valid_claim['txid'])
claims = await self.claim_search(name='on-channel-claim')
self.assertEqual(2, len(claims))
self.assertEqual(
{channel['claim_id']}, {claim['signing_channel']['claim_id'] for claim in claims}
)
async def test_normalization_resolution(self):
one = 'ΣίσυφοςfiÆ'
two = 'ΣΊΣΥΦΟσFIæ'
_ = await self.stream_create(one, '0.1')
c = await self.stream_create(two, '0.2')
winner_id = c['outputs'][0]['claim_id']
r1 = await self.resolve(f'lbry://{one}')
r2 = await self.resolve(f'lbry://{two}')
self.assertEqual(winner_id, r1[f'lbry://{one}']['claim_id'])
self.assertEqual(winner_id, r2[f'lbry://{two}']['claim_id'])
async def test_resolve_old_claim(self):
channel = await self.daemon.jsonrpc_channel_create('@olds', '1.0')
await self.confirm_tx(channel.id)
address = channel.outputs[0].get_address(self.account.ledger)
claim = generate_signed_legacy(address, channel.outputs[0])
tx = await Transaction.claim_create('example', claim.SerializeToString(), 1, address, [self.account], self.account)
await tx.sign([self.account])
await self.broadcast(tx)
await self.confirm_tx(tx.id)
response = await self.resolve('@olds/example')
self.assertTrue(response['@olds/example']['is_channel_signature_valid'])
claim.publisherSignature.signature = bytes(reversed(claim.publisherSignature.signature))
tx = await Transaction.claim_create(
'bad_example', claim.SerializeToString(), 1, address, [self.account], self.account
)
await tx.sign([self.account])
await self.broadcast(tx)
await self.confirm_tx(tx.id)
response = await self.resolve('bad_example')
self.assertFalse(response['bad_example']['is_channel_signature_valid'])
response = await self.resolve('@olds/bad_example')
self.assertEqual(response, {
'@olds/bad_example': {'error': '@olds/bad_example did not resolve to a claim'}
})
self.assertEqual(claim['protobuf'], hexlify(b"{'invalid':'json'}").decode())
self.assertFalse(claim['decoded_claim'])
self.assertEqual(claim['txid'], txid)
self.assertEqual(claim['effective_amount'], "0.1")
async def _test_resolve_abc_foo(self):
response = await self.resolve('lbry://@abc/foo')
claim = response['lbry://@abc/foo']
self.assertIn('signing_channel', claim)
self.assertEqual(claim['name'], 'foo')
self.assertEqual(claim['signing_channel']['name'], '@abc')
self.assertEqual(claim['meta']['claims_in_channel'], 0)
self.assertIn('certificate', claim)
self.assertIn('claim', claim)
self.assertEqual(claim['claim']['name'], 'foo')
self.assertEqual(claim['claim']['channel_name'], '@abc')
self.assertEqual(claim['certificate']['name'], '@abc')
self.assertEqual(claim['claims_in_channel'], 0)
self.assertEqual(
claim['timestamp'],
self.ledger.headers[claim['height']]['timestamp']
claim['claim']['timestamp'],
self.ledger.headers[claim['claim']['height']]['timestamp']
)
self.assertEqual(
claim['signing_channel']['timestamp'],
self.ledger.headers[claim['signing_channel']['height']]['timestamp']
claim['certificate']['timestamp'],
self.ledger.headers[claim['certificate']['height']]['timestamp']
)
@skip('this test does not work with new resolve')
async def test_resolve_lru_cache_doesnt_persist_errors(self):
original_get_transaction = self.daemon.wallet_manager.ledger.network.get_transaction
@@ -304,39 +142,3 @@ class ResolveCommand(CommandTestCase):
self.daemon.wallet_manager.ledger.network.get_transaction = check_result_cached
await self._test_resolve_abc_foo()
self.assertFalse(called_again.is_set())
def generate_signed_legacy(address: bytes, output: Output):
decoded_address = Base58.decode(address)
claim = OldClaimMessage()
claim.ParseFromString(unhexlify(
'080110011aee04080112a604080410011a2b4865726520617265203520526561736f6e73204920e29da4e'
'fb88f204e657874636c6f7564207c20544c4722920346696e64206f7574206d6f72652061626f7574204e'
'657874636c6f75643a2068747470733a2f2f6e657874636c6f75642e636f6d2f0a0a596f752063616e206'
'6696e64206d65206f6e20746865736520736f6369616c733a0a202a20466f72756d733a2068747470733a'
'2f2f666f72756d2e6865617679656c656d656e742e696f2f0a202a20506f64636173743a2068747470733'
'a2f2f6f6666746f706963616c2e6e65740a202a2050617472656f6e3a2068747470733a2f2f7061747265'
'6f6e2e636f6d2f7468656c696e757867616d65720a202a204d657263683a2068747470733a2f2f7465657'
'37072696e672e636f6d2f73746f7265732f6f6666696369616c2d6c696e75782d67616d65720a202a2054'
'77697463683a2068747470733a2f2f7477697463682e74762f786f6e64616b0a202a20547769747465723'
'a2068747470733a2f2f747769747465722e636f6d2f7468656c696e757867616d65720a0a2e2e2e0a6874'
'7470733a2f2f7777772e796f75747562652e636f6d2f77617463683f763d4672546442434f535f66632a0'
'f546865204c696e75782047616d6572321c436f7079726967687465642028636f6e746163742061757468'
'6f722938004a2968747470733a2f2f6265726b2e6e696e6a612f7468756d626e61696c732f46725464424'
'34f535f666352005a001a41080110011a30040e8ac6e89c061f982528c23ad33829fd7146435bf7a4cc22'
'f0bff70c4fe0b91fd36da9a375e3e1c171db825bf5d1f32209766964656f2f6d70342a5c080110031a406'
'2b2dd4c45e364030fbfad1a6fefff695ebf20ea33a5381b947753e2a0ca359989a5cc7d15e5392a0d354c'
'0b68498382b2701b22c03beb8dcb91089031b871e72214feb61536c007cdf4faeeaab4876cb397feaf6b51'
))
claim.ClearField("publisherSignature")
digest = sha256(b''.join([
decoded_address,
claim.SerializeToString(),
output.claim_hash[::-1]
]))
signature = output.private_key.sign_digest_deterministic(digest, hashfunc=hashlib.sha256)
claim.publisherSignature.version = 1
claim.publisherSignature.signatureType = 1
claim.publisherSignature.signature = signature
claim.publisherSignature.certificateId = output.claim_hash[::-1]
return claim
@@ -17,7 +17,7 @@ class TransactionCommandsTestCase(CommandTestCase):
sendtxid = await self.blockchain.send_to_address(change_address, 10)
tx = await self.daemon.jsonrpc_transaction_show(sendtxid)
self.assertEqual(tx.id, sendtxid)
self.assertEqual(tx.height, -1)
self.assertEqual(tx.height, -2)
await self.generate(1)
tx = await self.daemon.jsonrpc_transaction_show(sendtxid)
self.assertEqual(tx.height, self.ledger.headers.height)
+113
View File
@@ -0,0 +1,113 @@
import unittest
from lbrynet.schema.uri import URI, URIParseError
claim_id_1 = "63f2da17b0d90042c559cc73b6b17f853945c43e"
parsed_uri_matches = [
("test", URI("test"), False, False, "test", None),
("test#%s" % claim_id_1, URI("test", claim_id=claim_id_1), False, False, "test", None),
("test:1", URI("test", claim_sequence=1), False, False, "test", None),
("test$1", URI("test", bid_position=1), False, False, "test", None),
("lbry://test", URI("test"), False, False, "test", None),
("lbry://test#%s" % claim_id_1, URI("test", claim_id=claim_id_1), False, False, "test", None),
("lbry://test:1", URI("test", claim_sequence=1), False, False, "test", None),
("lbry://test$1", URI("test", bid_position=1), False, False, "test", None),
("@test", URI("@test"), True, True, None, "@test"),
("@test#%s" % claim_id_1, URI("@test", claim_id=claim_id_1), True, True, None, "@test"),
("@test:1", URI("@test", claim_sequence=1), True, True, None, "@test"),
("@test$1", URI("@test", bid_position=1), True, True, None, "@test"),
("lbry://@test1:1/fakepath", URI("@test1", claim_sequence=1, path="fakepath"), True, False, "fakepath", "@test1"),
("lbry://@test1$1/fakepath", URI("@test1", bid_position=1, path="fakepath"), True, False, "fakepath", "@test1"),
("lbry://@test1#abcdef/fakepath", URI("@test1", claim_id="abcdef", path="fakepath"), True, False, "fakepath",
"@test1"),
("@z", URI("@z"), True, True, None, "@z"),
("@yx", URI("@yx"), True, True, None, "@yx"),
("@abc", URI("@abc"), True, True, None, "@abc")
]
parsed_uri_raises = [
("lbry://", URIParseError),
("lbry://test:3$1", URIParseError),
("lbry://test$1:1", URIParseError),
("lbry://test#x", URIParseError),
("lbry://test#x/page", URIParseError),
("lbry://test$", URIParseError),
("lbry://test#", URIParseError),
("lbry://test:", URIParseError),
("lbry://test$x", URIParseError),
("lbry://test:x", URIParseError),
("lbry://@test@", URIParseError),
("lbry://@test:", URIParseError),
("lbry://test@", URIParseError),
("lbry://tes@t", URIParseError),
("lbry://test:1#%s" % claim_id_1, URIParseError),
("lbry://test:0", URIParseError),
("lbry://test$0", URIParseError),
("lbry://test/path", URIParseError),
("lbry://@test1#abcdef/fakepath:1", URIParseError),
("lbry://@test1:1/fakepath:1", URIParseError),
("lbry://@test1:1ab/fakepath", URIParseError),
("lbry://test:1:1:1", URIParseError),
("whatever/lbry://test", URIParseError),
("lbry://lbry://test", URIParseError),
("lbry://@/what", URIParseError),
("lbry://abc:0x123", URIParseError),
("lbry://abc:0x123/page", URIParseError),
("lbry://@test1#ABCDEF/fakepath", URIParseError),
("test:0001", URIParseError),
("lbry://@test1$1/fakepath?arg1&arg2&arg3", URIParseError)
]
class TestURIParser(unittest.TestCase):
maxDiff = 4000
longMessage = True
def test_uri_parse(self):
for test_string, expected_uri_obj, contains_channel, is_channel, claim_name, channel_name in parsed_uri_matches:
try:
# string -> URI
self.assertEqual(URI.from_uri_string(test_string), expected_uri_obj, test_string)
# URI -> dict -> URI
self.assertEqual(URI.from_dict(expected_uri_obj.to_dict()), expected_uri_obj,
test_string)
# contains_channel
self.assertEqual(URI.from_uri_string(test_string).contains_channel, contains_channel,
test_string)
# is_channel
self.assertEqual(URI.from_uri_string(test_string).is_channel, is_channel,
test_string)
# claim_name
self.assertEqual(URI.from_uri_string(test_string).claim_name, claim_name,
test_string)
# channel_name
self.assertEqual(URI.from_uri_string(test_string).channel_name, channel_name,
test_string)
# convert-to-string test only works if protocol is present in test_string
if test_string.startswith('lbry://'):
# string -> URI -> string
self.assertEqual(URI.from_uri_string(test_string).to_uri_string(), test_string,
test_string)
# string -> URI -> dict -> URI -> string
uri_dict = URI.from_uri_string(test_string).to_dict()
self.assertEqual(URI.from_dict(uri_dict).to_uri_string(), test_string,
test_string)
# URI -> dict -> URI -> string
self.assertEqual(URI.from_dict(expected_uri_obj.to_dict()).to_uri_string(),
test_string, test_string)
except URIParseError as err:
print("ERROR: " + test_string)
raise
def test_uri_errors(self):
for test_str, err in parsed_uri_raises:
try:
URI.from_uri_string(test_str)
except URIParseError:
pass
else:
print("\nSuccessfully parsed invalid url: " + test_str)
self.assertRaises(err, URI.from_uri_string, test_str)
-88
View File
@@ -1,88 +0,0 @@
import unittest
from lbrynet.schema.url import URL
claim_id = "63f2da17b0d90042c559cc73b6b17f853945c43e"
class TestURLParsing(unittest.TestCase):
segments = 'stream', 'channel'
fields = 'name', 'claim_id', 'sequence', 'amount_order'
def _assert_url(self, url_string, **kwargs):
url = URL.parse(url_string)
if url_string.startswith('lbry://'):
self.assertEqual(url_string, str(url))
else:
self.assertEqual(f'lbry://{url_string}', str(url))
present = {}
for key in kwargs:
for segment_name in self.segments:
if key.startswith(segment_name):
present[segment_name] = True
break
for segment_name in self.segments:
segment = getattr(url, segment_name)
if segment_name not in present:
self.assertIsNone(segment)
else:
for field in self.fields:
self.assertEqual(
getattr(segment, field),
kwargs.get(f'{segment_name}_{field}', None)
)
def _fail_url(self, url):
with self.assertRaisesRegex(ValueError, 'Invalid LBRY URL'):
URL.parse(url)
def test_parser_valid_urls(self):
url = self._assert_url
# stream
url('test', stream_name='test')
url('test:1', stream_name='test', stream_sequence='1')
url('test$1', stream_name='test', stream_amount_order='1')
url(f'test#{claim_id}', stream_name='test', stream_claim_id=claim_id)
# channel
url('@test', channel_name='@test')
url('@test:1', channel_name='@test', channel_sequence='1')
url('@test$1', channel_name='@test', channel_amount_order='1')
url(f'@test#{claim_id}', channel_name='@test', channel_claim_id=claim_id)
# channel/stream
url('lbry://@test/stuff', channel_name='@test', stream_name='stuff')
url('lbry://@test:1/stuff', channel_name='@test', channel_sequence='1', stream_name='stuff')
url('lbry://@test$1/stuff', channel_name='@test', channel_amount_order='1', stream_name='stuff')
url(f'lbry://@test#{claim_id}/stuff', channel_name='@test', channel_claim_id=claim_id, stream_name='stuff')
def test_parser_invalid_urls(self):
fail = self._fail_url
fail("lbry://")
fail("lbry://test:3$1")
fail("lbry://test$1:1")
fail("lbry://test#x")
fail("lbry://test#x/page")
fail("lbry://test$")
fail("lbry://test#")
fail("lbry://test:")
fail("lbry://test$x")
fail("lbry://test:x")
fail("lbry://@test@")
fail("lbry://@test:")
fail("lbry://test@")
fail("lbry://tes@t")
fail(f"lbry://test:1#{claim_id}")
fail("lbry://test:0")
fail("lbry://test$0")
fail("lbry://test/path")
fail("lbry://@test1:1ab/fakepath")
fail("lbry://test:1:1:1")
fail("whatever/lbry://test")
fail("lbry://lbry://test")
fail("lbry://@/what")
fail("lbry://abc:0x123")
fail("lbry://abc:0x123/page")
fail("lbry://@test1#ABCDEF/fakepath")
fail("test:0001")
fail("lbry://@test1$1/fakepath?arg1&arg2&arg3")
+2 -8
View File
@@ -4,7 +4,7 @@ import types
import tempfile
import unittest
import argparse
from lbrynet.conf import Config, BaseConfig, String, Integer, Toggle, Servers, Strings, NOT_SET
from lbrynet.conf import Config, BaseConfig, String, Integer, Toggle, Servers, NOT_SET
from lbrynet.error import InvalidCurrencyError
@@ -14,7 +14,6 @@ class TestConfig(BaseConfig):
test_false_toggle = Toggle('toggle help', False)
test_true_toggle = Toggle('toggle help', True)
servers = Servers('servers help', [('localhost', 80)])
strings = Strings('cheese', ['string'])
class ConfigurationTests(unittest.TestCase):
@@ -55,7 +54,6 @@ class ConfigurationTests(unittest.TestCase):
self.assertTrue(c.test_true_toggle)
self.assertFalse(c.test_false_toggle)
self.assertEqual(c.servers, [('localhost', 80)])
self.assertEqual(c.strings, ['string'])
args = parser.parse_args(['--test-str', 'blah'])
c = TestConfig.create_from_arguments(args)
@@ -78,14 +76,10 @@ class ConfigurationTests(unittest.TestCase):
self.assertFalse(c.test_true_toggle)
self.assertFalse(c.test_false_toggle)
args = parser.parse_args(['--servers=localhost:1', '--servers=192.168.0.1:2'])
args = parser.parse_args(['--servers', 'localhost:1', '192.168.0.1:2'])
c = TestConfig.create_from_arguments(args)
self.assertEqual(c.servers, [('localhost', 1), ('192.168.0.1', 2)])
args = parser.parse_args(['--strings=cheddar', '--strings=mozzarella'])
c = TestConfig.create_from_arguments(args)
self.assertEqual(c.strings, ['cheddar', 'mozzarella'])
def test_environment(self):
c = TestConfig()
self.assertEqual(c.test_str, 'the default')
Whitespace-only changes.
-436
View File
@@ -1,436 +0,0 @@
import unittest
import ecdsa
import hashlib
from binascii import hexlify
from torba.client.constants import COIN, NULL_HASH32
from lbrynet.schema.claim import Claim
from lbrynet.wallet.server.db import SQLDB
from lbrynet.wallet.server.coin import LBCRegTest
from lbrynet.wallet.server.trending import TRENDING_WINDOW
from lbrynet.wallet.server.canonical import FindShortestID
from lbrynet.wallet.server.block_processor import Timer
from lbrynet.wallet.transaction import Transaction, Input, Output
def get_output(amount=COIN, pubkey_hash=NULL_HASH32):
return Transaction() \
.add_outputs([Output.pay_pubkey_hash(amount, pubkey_hash)]) \
.outputs[0]
def get_input():
return Input.spend(get_output())
def get_tx():
return Transaction().add_inputs([get_input()])
class OldWalletServerTransaction:
def __init__(self, tx):
self.tx = tx
def serialize(self):
return self.tx.raw
class TestSQLDB(unittest.TestCase):
def setUp(self):
self.first_sync = False
self.daemon_height = 1
self.coin = LBCRegTest()
self.sql = SQLDB(self, ':memory:')
self.timer = Timer('BlockProcessor')
self.sql.open()
self._current_height = 0
self._txos = {}
def _make_tx(self, output, txi=None):
tx = get_tx().add_outputs([output])
if txi is not None:
tx.add_inputs([txi])
self._txos[output.ref.hash] = output
return OldWalletServerTransaction(tx), tx.hash
def _set_channel_key(self, channel, key):
private_key = ecdsa.SigningKey.from_string(key*32, curve=ecdsa.SECP256k1, hashfunc=hashlib.sha256)
channel.private_key = private_key
channel.claim.channel.public_key_bytes = private_key.get_verifying_key().to_der()
channel.script.generate()
def get_channel(self, title, amount, name='@foo', key=b'a'):
claim = Claim()
claim.channel.title = title
channel = Output.pay_claim_name_pubkey_hash(amount, name, claim, b'abc')
self._set_channel_key(channel, key)
return self._make_tx(channel)
def get_channel_update(self, channel, amount, key=b'a'):
self._set_channel_key(channel, key)
return self._make_tx(
Output.pay_update_claim_pubkey_hash(
amount, channel.claim_name, channel.claim_id, channel.claim, b'abc'
),
Input.spend(channel)
)
def get_stream(self, title, amount, name='foo', channel=None):
claim = Claim()
claim.stream.title = title
result = self._make_tx(Output.pay_claim_name_pubkey_hash(amount, name, claim, b'abc'))
if channel:
result[0].tx.outputs[0].sign(channel)
result[0].tx._reset()
return result
def get_stream_update(self, tx, amount):
claim = Transaction(tx[0].serialize()).outputs[0]
return self._make_tx(
Output.pay_update_claim_pubkey_hash(
amount, claim.claim_name, claim.claim_id, claim.claim, b'abc'
),
Input.spend(claim)
)
def get_abandon(self, tx):
claim = Transaction(tx[0].serialize()).outputs[0]
return self._make_tx(
Output.pay_pubkey_hash(claim.amount, b'abc'),
Input.spend(claim)
)
def get_support(self, tx, amount):
claim = Transaction(tx[0].serialize()).outputs[0]
return self._make_tx(
Output.pay_support_pubkey_hash(
amount, claim.claim_name, claim.claim_id, b'abc'
)
)
def get_controlling(self):
for claim in self.sql.execute("select claim.* from claimtrie natural join claim"):
txo = self._txos[claim['txo_hash']]
controlling = txo.claim.stream.title, claim['amount'], claim['effective_amount'], claim['activation_height']
return controlling
def get_active(self):
controlling = self.get_controlling()
active = []
for claim in self.sql.execute(
f"select * from claim where activation_height <= {self._current_height}"):
txo = self._txos[claim['txo_hash']]
if controlling and controlling[0] == txo.claim.stream.title:
continue
active.append((txo.claim.stream.title, claim['amount'], claim['effective_amount'], claim['activation_height']))
return active
def get_accepted(self):
accepted = []
for claim in self.sql.execute(
f"select * from claim where activation_height > {self._current_height}"):
txo = self._txos[claim['txo_hash']]
accepted.append((txo.claim.stream.title, claim['amount'], claim['effective_amount'], claim['activation_height']))
return accepted
def advance(self, height, txs):
self._current_height = height
self.sql.advance_txs(height, txs, {'timestamp': 1}, self.daemon_height, self.timer)
return [otx[0].tx.outputs[0] for otx in txs]
def state(self, controlling=None, active=None, accepted=None):
self.assertEqual(controlling, self.get_controlling())
self.assertEqual(active or [], self.get_active())
self.assertEqual(accepted or [], self.get_accepted())
def test_example_from_spec(self):
# https://spec.lbry.com/#claim-activation-example
advance, state = self.advance, self.state
stream = self.get_stream('Claim A', 10*COIN)
advance(13, [stream])
state(
controlling=('Claim A', 10*COIN, 10*COIN, 13),
active=[],
accepted=[]
)
advance(1001, [self.get_stream('Claim B', 20*COIN)])
state(
controlling=('Claim A', 10*COIN, 10*COIN, 13),
active=[],
accepted=[('Claim B', 20*COIN, 0, 1031)]
)
advance(1010, [self.get_support(stream, 14*COIN)])
state(
controlling=('Claim A', 10*COIN, 24*COIN, 13),
active=[],
accepted=[('Claim B', 20*COIN, 0, 1031)]
)
advance(1020, [self.get_stream('Claim C', 50*COIN)])
state(
controlling=('Claim A', 10*COIN, 24*COIN, 13),
active=[],
accepted=[
('Claim B', 20*COIN, 0, 1031),
('Claim C', 50*COIN, 0, 1051)]
)
advance(1031, [])
state(
controlling=('Claim A', 10*COIN, 24*COIN, 13),
active=[('Claim B', 20*COIN, 20*COIN, 1031)],
accepted=[('Claim C', 50*COIN, 0, 1051)]
)
advance(1040, [self.get_stream('Claim D', 300*COIN)])
state(
controlling=('Claim A', 10*COIN, 24*COIN, 13),
active=[('Claim B', 20*COIN, 20*COIN, 1031)],
accepted=[
('Claim C', 50*COIN, 0, 1051),
('Claim D', 300*COIN, 0, 1072)]
)
advance(1051, [])
state(
controlling=('Claim D', 300*COIN, 300*COIN, 1051),
active=[
('Claim A', 10*COIN, 24*COIN, 13),
('Claim B', 20*COIN, 20*COIN, 1031),
('Claim C', 50*COIN, 50*COIN, 1051)],
accepted=[]
)
# beyond example
advance(1052, [self.get_stream_update(stream, 290*COIN)])
state(
controlling=('Claim A', 290*COIN, 304*COIN, 13),
active=[
('Claim B', 20*COIN, 20*COIN, 1031),
('Claim C', 50*COIN, 50*COIN, 1051),
('Claim D', 300*COIN, 300*COIN, 1051),
],
accepted=[]
)
def test_competing_claims_subsequent_blocks_height_wins(self):
advance, state = self.advance, self.state
advance(13, [self.get_stream('Claim A', 10*COIN)])
state(
controlling=('Claim A', 10*COIN, 10*COIN, 13),
active=[],
accepted=[]
)
advance(14, [self.get_stream('Claim B', 10*COIN)])
state(
controlling=('Claim A', 10*COIN, 10*COIN, 13),
active=[('Claim B', 10*COIN, 10*COIN, 14)],
accepted=[]
)
advance(15, [self.get_stream('Claim C', 10*COIN)])
state(
controlling=('Claim A', 10*COIN, 10*COIN, 13),
active=[
('Claim B', 10*COIN, 10*COIN, 14),
('Claim C', 10*COIN, 10*COIN, 15)],
accepted=[]
)
def test_competing_claims_in_single_block_position_wins(self):
advance, state = self.advance, self.state
stream = self.get_stream('Claim A', 10*COIN)
stream2 = self.get_stream('Claim B', 10*COIN)
advance(13, [stream, stream2])
state(
controlling=('Claim A', 10*COIN, 10*COIN, 13),
active=[('Claim B', 10*COIN, 10*COIN, 13)],
accepted=[]
)
def test_competing_claims_in_single_block_effective_amount_wins(self):
advance, state = self.advance, self.state
stream = self.get_stream('Claim A', 10*COIN)
stream2 = self.get_stream('Claim B', 11*COIN)
advance(13, [stream, stream2])
state(
controlling=('Claim B', 11*COIN, 11*COIN, 13),
active=[('Claim A', 10*COIN, 10*COIN, 13)],
accepted=[]
)
def test_winning_claim_deleted(self):
advance, state = self.advance, self.state
stream = self.get_stream('Claim A', 10*COIN)
stream2 = self.get_stream('Claim B', 11*COIN)
advance(13, [stream, stream2])
state(
controlling=('Claim B', 11*COIN, 11*COIN, 13),
active=[('Claim A', 10*COIN, 10*COIN, 13)],
accepted=[]
)
advance(14, [self.get_abandon(stream2)])
state(
controlling=('Claim A', 10*COIN, 10*COIN, 13),
active=[],
accepted=[]
)
def test_winning_claim_deleted_and_new_claim_becomes_winner(self):
advance, state = self.advance, self.state
stream = self.get_stream('Claim A', 10*COIN)
stream2 = self.get_stream('Claim B', 11*COIN)
advance(13, [stream, stream2])
state(
controlling=('Claim B', 11*COIN, 11*COIN, 13),
active=[('Claim A', 10*COIN, 10*COIN, 13)],
accepted=[]
)
advance(15, [self.get_abandon(stream2), self.get_stream('Claim C', 12*COIN)])
state(
controlling=('Claim C', 12*COIN, 12*COIN, 15),
active=[('Claim A', 10*COIN, 10*COIN, 13)],
accepted=[]
)
def test_winning_claim_expires_and_another_takes_over(self):
advance, state = self.advance, self.state
advance(10, [self.get_stream('Claim A', 11*COIN)])
advance(20, [self.get_stream('Claim B', 10*COIN)])
state(
controlling=('Claim A', 11*COIN, 11*COIN, 10),
active=[('Claim B', 10*COIN, 10*COIN, 20)],
accepted=[]
)
advance(262984, [])
state(
controlling=('Claim B', 10*COIN, 10*COIN, 20),
active=[],
accepted=[]
)
advance(262994, [])
state(
controlling=None,
active=[],
accepted=[]
)
def test_trending(self):
advance, state = self.advance, self.state
no_trend = self.get_stream('Claim A', COIN)
downwards = self.get_stream('Claim B', COIN)
up_small = self.get_stream('Claim C', COIN)
up_medium = self.get_stream('Claim D', COIN)
up_biggly = self.get_stream('Claim E', COIN)
claims = advance(1, [up_biggly, up_medium, up_small, no_trend, downwards])
for window in range(1, 8):
advance(TRENDING_WINDOW * window, [
self.get_support(downwards, (20-window)*COIN),
self.get_support(up_small, int(20+(window/10)*COIN)),
self.get_support(up_medium, (20+(window*(2 if window == 7 else 1)))*COIN),
self.get_support(up_biggly, (20+(window*(3 if window == 7 else 1)))*COIN),
])
results = self.sql._search(order_by=['trending_local'])
self.assertEqual([c.claim_id for c in claims], [hexlify(c['claim_hash'][::-1]).decode() for c in results])
self.assertEqual([10, 6, 2, 0, -2], [int(c['trending_local']) for c in results])
self.assertEqual([53, 38, -32, 0, -6], [int(c['trending_global']) for c in results])
self.assertEqual([4, 4, 2, 0, 1], [int(c['trending_group']) for c in results])
self.assertEqual([53, 38, 2, 0, -6], [int(c['trending_mixed']) for c in results])
@staticmethod
def _get_x_with_claim_id_prefix(getter, prefix, cached_iteration=None, **kwargs):
iterations = cached_iteration+1 if cached_iteration else 100
for i in range(cached_iteration or 1, iterations):
stream = getter(f'claim #{i}', COIN, **kwargs)
if stream[0].tx.outputs[0].claim_id.startswith(prefix):
cached_iteration is None and print(f'Found "{prefix}" in {i} iterations.')
return stream
if cached_iteration:
raise ValueError(f'Failed to find "{prefix}" at cached iteration, run with None to find iteration.')
raise ValueError(f'Failed to find "{prefix}" in {iterations} iterations, try different values.')
def get_channel_with_claim_id_prefix(self, prefix, cached_iteration=None, **kwargs):
return self._get_x_with_claim_id_prefix(self.get_channel, prefix, cached_iteration, **kwargs)
def get_stream_with_claim_id_prefix(self, prefix, cached_iteration=None, **kwargs):
return self._get_x_with_claim_id_prefix(self.get_stream, prefix, cached_iteration, **kwargs)
def test_canonical_url_and_channel_validation(self):
advance = self.advance
tx_chan_a = self.get_channel_with_claim_id_prefix('a', 1, key=b'c')
tx_chan_ab = self.get_channel_with_claim_id_prefix('ab', 72, key=b'c')
txo_chan_a = tx_chan_a[0].tx.outputs[0]
advance(1, [tx_chan_a])
advance(2, [tx_chan_ab])
r_ab, r_a = self.sql._search(order_by=['creation_height'], limit=2)
self.assertEqual("@foo#a", r_a['short_url'])
self.assertEqual("@foo#ab", r_ab['short_url'])
self.assertIsNone(r_a['canonical_url'])
self.assertIsNone(r_ab['canonical_url'])
self.assertEqual(0, r_a['claims_in_channel'])
self.assertEqual(0, r_ab['claims_in_channel'])
tx_a = self.get_stream_with_claim_id_prefix('a', 2)
tx_ab = self.get_stream_with_claim_id_prefix('ab', 42)
tx_abc = self.get_stream_with_claim_id_prefix('abc', 65)
advance(3, [tx_a])
advance(4, [tx_ab, tx_abc])
r_abc, r_ab, r_a = self.sql._search(order_by=['creation_height', 'tx_position'], limit=3)
self.assertEqual("foo#a", r_a['short_url'])
self.assertEqual("foo#ab", r_ab['short_url'])
self.assertEqual("foo#abc", r_abc['short_url'])
self.assertIsNone(r_a['canonical_url'])
self.assertIsNone(r_ab['canonical_url'])
self.assertIsNone(r_abc['canonical_url'])
tx_a2 = self.get_stream_with_claim_id_prefix('a', 7, channel=txo_chan_a)
tx_ab2 = self.get_stream_with_claim_id_prefix('ab', 23, channel=txo_chan_a)
a2_claim_id = tx_a2[0].tx.outputs[0].claim_id
ab2_claim_id = tx_ab2[0].tx.outputs[0].claim_id
advance(6, [tx_a2])
advance(7, [tx_ab2])
r_ab2, r_a2 = self.sql._search(order_by=['creation_height'], limit=2)
self.assertEqual(f"foo#{a2_claim_id[:2]}", r_a2['short_url'])
self.assertEqual(f"foo#{ab2_claim_id[:4]}", r_ab2['short_url'])
self.assertEqual("@foo#a/foo#a", r_a2['canonical_url'])
self.assertEqual("@foo#a/foo#ab", r_ab2['canonical_url'])
self.assertEqual(2, self.sql._search(claim_id=txo_chan_a.claim_id, limit=1)[0]['claims_in_channel'])
# change channel public key, invaliding stream claim signatures
advance(8, [self.get_channel_update(txo_chan_a, COIN, key=b'a')])
r_ab2, r_a2 = self.sql._search(order_by=['creation_height'], limit=2)
self.assertEqual(f"foo#{a2_claim_id[:2]}", r_a2['short_url'])
self.assertEqual(f"foo#{ab2_claim_id[:4]}", r_ab2['short_url'])
self.assertIsNone(r_a2['canonical_url'])
self.assertIsNone(r_ab2['canonical_url'])
self.assertEqual(0, self.sql._search(claim_id=txo_chan_a.claim_id, limit=1)[0]['claims_in_channel'])
# reinstate previous channel public key (previous stream claim signatures become valid again)
channel_update = self.get_channel_update(txo_chan_a, COIN, key=b'c')
advance(9, [channel_update])
r_ab2, r_a2 = self.sql._search(order_by=['creation_height'], limit=2)
self.assertEqual(f"foo#{a2_claim_id[:2]}", r_a2['short_url'])
self.assertEqual(f"foo#{ab2_claim_id[:4]}", r_ab2['short_url'])
self.assertEqual("@foo#a/foo#a", r_a2['canonical_url'])
self.assertEqual("@foo#a/foo#ab", r_ab2['canonical_url'])
self.assertEqual(2, self.sql._search(claim_id=txo_chan_a.claim_id, limit=1)[0]['claims_in_channel'])
# delete channel, invaliding stream claim signatures
advance(10, [self.get_abandon(channel_update)])
r_ab2, r_a2 = self.sql._search(order_by=['creation_height'], limit=2)
self.assertEqual(f"foo#{a2_claim_id[:2]}", r_a2['short_url'])
self.assertEqual(f"foo#{ab2_claim_id[:4]}", r_ab2['short_url'])
self.assertIsNone(r_a2['canonical_url'])
self.assertIsNone(r_ab2['canonical_url'])
def test_canonical_find_shortest_id(self):
new_hash = 'abcdef0123456789beef'
other0 = '1bcdef0123456789beef'
other1 = 'ab1def0123456789beef'
other2 = 'abc1ef0123456789beef'
other3 = 'abcdef0123456789bee1'
f = FindShortestID()
f.step(other0, new_hash)
self.assertEqual('#a', f.finalize())
f.step(other1, new_hash)
self.assertEqual('#abc', f.finalize())
f.step(other2, new_hash)
self.assertEqual('#abcd', f.finalize())
f.step(other3, new_hash)
self.assertEqual('#abcdef0123456789beef', f.finalize())
+4 -2
View File
@@ -49,7 +49,8 @@ class TestSigningAndValidatingClaim(AsyncioTestCase):
def test_fail_to_validate_on_wrong_channel(self):
stream = self.get_stream()
stream.sign(self.get_channel())
self.assertFalse(stream.is_signed_by(self.get_channel()))
with self.assertRaises(InvalidSignature):
self.assertTrue(stream.is_signed_by(self.get_channel()))
def test_fail_to_validate_altered_claim(self):
channel = self.get_channel()
@@ -57,7 +58,8 @@ class TestSigningAndValidatingClaim(AsyncioTestCase):
stream.sign(channel)
self.assertTrue(stream.is_signed_by(channel))
stream.claim.stream.title = 'hello'
self.assertFalse(stream.is_signed_by(channel))
with self.assertRaises(InvalidSignature):
self.assertTrue(stream.is_signed_by(channel))
def test_valid_private_key_for_cert(self):
channel = self.get_channel()