Compare commits

..
7 Commits
102 changed files with 2922 additions and 3966 deletions

No files matched your search

-67
View File
@@ -1,67 +0,0 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '21 0 * * 4'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
+3 -13
View File
@@ -22,9 +22,10 @@ jobs:
with:
python-version: '3.7'
- run: make install tools
- env:
- working-directory: lbry
env:
HOME: /tmp
run: make test-unit-coverage
run: coverage run -p --source=lbry -m unittest discover -vv tests.unit
tests-integration:
name: "tests / integration"
@@ -36,17 +37,6 @@ jobs:
- blockchain
- other
steps:
- name: Configure sysctl limits
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
- name: Runs Elasticsearch
uses: elastic/elastic-github-actions/elasticsearch@master
with:
stack-version: 7.6.0
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
-44
View File
@@ -1,44 +0,0 @@
# This workflow integrates a collection of open source static analysis tools
# with GitHub code scanning. For documentation, or to provide feedback, visit
# https://github.com/github/ossar-action
name: OSSAR
on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '28 17 * * 1'
jobs:
OSSAR-Scan:
# OSSAR runs on windows-latest.
# ubuntu-latest and macos-latest support coming soon
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Ensure a compatible version of dotnet is installed.
# The [Microsoft Security Code Analysis CLI](https://aka.ms/mscadocs) is built with dotnet v3.1.201.
# A version greater than or equal to v3.1.201 of dotnet must be installed on the agent in order to run this action.
# GitHub hosted runners already have a compatible version of dotnet installed and this step may be skipped.
# For self-hosted runners, ensure dotnet version 3.1.201 or later is installed by including this action:
# - name: Install .NET
# uses: actions/setup-dotnet@v1
# with:
# dotnet-version: '3.1.x'
# Run open source static analysis tools
- name: Run OSSAR
uses: github/ossar-action@v1
id: ossar
# Upload results to the Security tab
- name: Upload OSSAR results
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: ${{ steps.ossar.outputs.sarifFile }}
+8 -15
View File
@@ -1,11 +1,5 @@
default:
image: python:3.7
services:
- name: docker.elastic.co/elasticsearch/elasticsearch:7.11.2
alias: elasticsearch
command: [ "bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node" ]
variables:
ES_JAVA_OPTS: "-Xms512m -Xmx512m"
#cache:
@@ -47,14 +41,13 @@ test:datanetwork-integration:
stage: test
script:
- pip install tox-travis
- ELASTIC_HOST=elasticsearch tox -e datanetwork --recreate
- tox -e datanetwork --recreate
test:blockchain-integration:
stage: test
script:
- curl "http://elasticsearch:9200/_cat/health"
- pip install tox-travis
- ELASTIC_HOST=elasticsearch tox -e blockchain
- tox -e blockchain
test:other-integration:
stage: test
@@ -62,13 +55,13 @@ test:other-integration:
- apt-get update
- apt-get install -y --no-install-recommends ffmpeg
- pip install tox-travis
- ELASTIC_HOST=elasticsearch tox -e other
- tox -e other
test:json-api:
stage: test
script:
- make install tools
- ELASTIC_HOST=elasticsearch HOME=/tmp coverage run -p --source=lbry scripts/generate_json_api.py
#test:json-api:
# stage: test
# script:
# - make install tools
# - HOME=/tmp coverage run -p --source=lbry scripts/generate_json_api.py
+1 -13
View File
@@ -92,23 +92,11 @@ To install on Windows:
```
## Run the tests
### Elasticsearch
For running integration tests, Elasticsearch is required to be available at localhost:9200/
The easiest way to start it is using docker with:
```bash
make elastic-docker
```
Alternative installation methods are available [at Elasticsearch website](https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html).
To run the unit and integration tests from the repo directory:
To run the unit tests from the repo directory:
```
python -m unittest discover tests.unit
python -m unittest discover tests.integration
```
## Usage
+7 -14
View File
@@ -1,7 +1,11 @@
.PHONY: install tools lint test test-unit test-unit-coverage test-integration idea
.PHONY: install tools lint test idea
install:
pip install lbry-libtorrent
pip install https://s3.amazonaws.com/files.lbry.io/python_libtorrent-1.2.4-py3-none-any.whl
CFLAGS="-DSQLITE_MAX_VARIABLE_NUMBER=2500000" pip install -U https://github.com/rogerbinns/apsw/releases/download/3.30.1-r1/apsw-3.30.1-r1.zip \
--global-option=fetch \
--global-option=--version --global-option=3.30.1 --global-option=--all \
--global-option=build --global-option=--enable --global-option=fts5
pip install -e .
tools:
@@ -12,20 +16,9 @@ lint:
pylint --rcfile=setup.cfg lbry
#mypy --ignore-missing-imports lbry
test: test-unit test-integration
test-unit:
python -m unittest discover tests.unit
test-unit-coverage:
coverage run -p --source=lbry -m unittest discover -vv tests.unit
test-integration:
test:
tox
idea:
mkdir -p .idea
cp -r scripts/idea/* .idea
elastic-docker:
docker run -d -v lbryhub:/usr/share/elasticsearch/data -p 9200:9200 -p 9300:9300 -e"ES_JAVA_OPTS=-Xms512m -Xmx512m" -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.12.1
+2 -2
View File
@@ -4,7 +4,7 @@ LBRY is a decentralized peer-to-peer protocol for publishing and accessing digit
LBRY SDK for Python is currently the most fully featured implementation of the LBRY Network protocols and includes many useful components and tools for building decentralized applications. Primary features and components include:
* Built on Python 3.7 and `asyncio`.
* Built on Python 3.7+ and `asyncio`.
* Kademlia DHT (Distributed Hash Table) implementation for finding peers to download from and announcing to peers what we have to host ([lbry.dht](https://github.com/lbryio/lbry-sdk/tree/master/lbry/dht)).
* Blob exchange protocol for transferring encrypted blobs of content and negotiating payments ([lbry.blob_exchange](https://github.com/lbryio/lbry-sdk/tree/master/lbry/blob_exchange)).
* Protobuf schema for encoding and decoding metadata stored on the blockchain ([lbry.schema](https://github.com/lbryio/lbry-sdk/tree/master/lbry/schema)).
@@ -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 PGP key is here](https://lbry.com/faq/pgp-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.com/faq/gpg-key) if you need it.
## Contact
-9
View File
@@ -1,9 +0,0 @@
# Security Policy
## Supported Versions
While we are not at v1.0 yet, only the latest release will be supported.
## Reporting a Vulnerability
See https://lbry.com/faq/security
+2 -4
View File
@@ -1,4 +1,4 @@
FROM debian:10-slim
FROM ubuntu:19.10
ARG user=lbry
ARG db_dir=/database
@@ -13,9 +13,7 @@ RUN apt-get update && \
wget \
tar unzip \
build-essential \
pkg-config \
libleveldb-dev \
python3.7 \
python3 \
python3-dev \
python3-pip \
python3-wheel \
+22 -31
View File
@@ -1,45 +1,36 @@
version: "3"
volumes:
lbrycrd:
wallet_server:
es01:
services:
lbrycrd:
image: lbry/lbrycrd:${LBRYCRD_TAG:-latest-release}
restart: always
ports: # accessible from host
- "9246:9246" # rpc port
expose: # internal to docker network. also this doesn't do anything. its for documentation only.
- "9245" # node-to-node comms port
volumes:
- "lbrycrd:/data/.lbrycrd"
environment:
- RUN_MODE=default
# Curently not snapshot provided
#- SNAPSHOT_URL=${LBRYCRD_SNAPSHOT_URL-https://lbry.com/snapshot/blockchain}
- RPC_ALLOW_IP=0.0.0.0/0
wallet_server:
depends_on:
- es01
image: lbry/wallet-server:${WALLET_SERVER_TAG:-latest-release}
depends_on:
- lbrycrd
restart: always
network_mode: host
ports:
- "50001:50001" # rpc port
- "2112:2112" # uncomment to enable prometheus
- "50005:50005" # websocket port
#- "2112:2112" # uncomment to enable prometheus
volumes:
- "wallet_server:/database"
environment:
- DAEMON_URL=http://lbry:lbry@127.0.0.1:9245
- TCP_PORT=50001
- PROMETHEUS_PORT=2112
- QUERY_TIMEOUT_MS=3000 # how long search queries allowed to run before cancelling, in milliseconds
- TRENDING_ALGORITHMS=variable_decay
- MAX_SEND=10000000000000 # deprecated. leave it high until its removed
- MAX_SUBS=1000000000000 # deprecated. leave it high until its removed
- FILTERING_CHANNEL_IDS=770bd7ecba84fd2f7607fb15aedd2b172c2e153f 95e5db68a3101df19763f3a5182e4b12ba393ee8
- BLOCKING_CHANNEL_IDS=dd687b357950f6f271999971f43c785e8067c3a9 06871aa438032244202840ec59a469b303257cad b4a2528f436eca1bf3bf3e10ff3f98c57bd6c4c6 e4e230b131082f6b10c8f7994bbb83f29e8e6fb9
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.11.0
container_name: es01
environment:
- node.name=es01
- discovery.type=single-node
- indices.query.bool.max_clause_count=4096
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms8g -Xmx8g" # no more than 32, remember to disable swap
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- es01:/usr/share/elasticsearch/data
ports:
- 127.0.0.1:9200:9200
# Curently not snapshot provided
# - SNAPSHOT_URL=${WALLET_SERVER_SNAPSHOT_URL-https://lbry.com/snapshot/wallet}
- DAEMON_URL=http://lbry:lbry@lbrycrd:9245
+1 -3
View File
@@ -20,6 +20,4 @@ if [[ -n "$SNAPSHOT_URL" ]] && [[ ! -f /database/claims.db ]]; then
rm "$filename"
fi
/home/lbry/.local/bin/lbry-hub-elastic-sync /database/claims.db
echo 'starting server'
/home/lbry/.local/bin/lbry-hub "$@"
/home/lbry/.local/bin/torba-server "$@"
+153 -333
View File
@@ -46,7 +46,7 @@
{
"name": "wallet_id",
"type": "str",
"description": "wallet to check for claim purchase receipts",
"description": "wallet to check for claim purchase reciepts",
"is_required": false
}
],
@@ -54,10 +54,10 @@
"examples": [
{
"title": "Get a file",
"curl": "curl -d'{\"method\": \"get\", \"params\": {\"uri\": \"astream#ea41b9f807c6982cf97a1178838dfef64feaa014\"}}' http://localhost:5279/",
"lbrynet": "lbrynet get astream#ea41b9f807c6982cf97a1178838dfef64feaa014",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"get\", \"params\": {\"uri\": \"astream#ea41b9f807c6982cf97a1178838dfef64feaa014\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"added_on\": 1621405335,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 4,\n \"content_fee\": null,\n \"download_directory\": \"/tmp/tmp5s0wcgsl\",\n \"download_path\": \"/tmp/tmp5s0wcgsl/tmpvccpjv29\",\n \"file_name\": \"tmpvccpjv29\",\n \"height\": 214,\n \"is_fully_reflected\": false,\n \"key\": \"1331d793facb0a628aa3416c5f1b2c59\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01c23f90d26738136a2d4fd7016f9c3f6009c6cc2097c286c8bea94843a4f2796781afd1797a19737f2ae770022e06b623fedaea0a9654fc9e098271a9c186889d14e0bab2cc75cd36b1e67efe284d06467438d0ed0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d70766363706a763239180b22186170706c69636174696f6e2f6f637465742d73747265616d323054ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"purchase_receipt\": null,\n \"reflector_progress\": 0,\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"aacc5131b8a53b4254185d476dc6fcd254ab08945416c68bdfd09571c660e58862e813b90fe4f6cf1f6d85633268b385\",\n \"stream_name\": \"tmpvccpjv29\",\n \"streaming_url\": \"http://localhost:5280/stream/54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"suggested_file_name\": \"tmpvccpjv29\",\n \"timestamp\": 1621405356,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"uploading_to_reflector\": false,\n \"written_bytes\": 11\n }\n}"
"curl": "curl -d'{\"method\": \"get\", \"params\": {\"uri\": \"astream#fe7ee643b50b724f6029f6edfe90d67b5512b3ae\"}}' http://localhost:5279/",
"lbrynet": "lbrynet get astream#fe7ee643b50b724f6029f6edfe90d67b5512b3ae",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"get\", \"params\": {\"uri\": \"astream#fe7ee643b50b724f6029f6edfe90d67b5512b3ae\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"added_on\": 1602862436,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 3,\n \"content_fee\": null,\n \"download_directory\": \"/tmp/tmpzzr985r8\",\n \"download_path\": \"/tmp/tmpzzr985r8/tmpk0n0x2sb\",\n \"file_name\": \"tmpk0n0x2sb\",\n \"height\": 214,\n \"is_fully_reflected\": false,\n \"key\": \"7acc8b9eac8e533c57b933928ab6fad0\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpk0n0x2sb\",\n \"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"c620b71698533d88efa10c80d79a30b74464214cb0d893ec5ab4ec1c37d1676e:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01f2d6950adda2502b543f042e4e8496b63a2bc95d1391e6159e2874bf75624f77339a61abf38b4da3237a5a52ad92aece2cefae8742c427064051fadb0dcfcc8f957b190341110ce64b8fd3f5cc874e16db11cbdc0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706b306e3078327362180b22186170706c69636174696f6e2f6f637465742d73747265616d3230d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"purchase_receipt\": null,\n \"reflector_progress\": 0,\n \"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"6b8f6829a8820cd430d23b3de7dd67ad77a11d912b04ac5577014d51af877a0c3a094e8d3d9bc2ae6b2c13c2ea44e477\",\n \"stream_name\": \"tmpk0n0x2sb\",\n \"streaming_url\": \"http://localhost:5280/stream/d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"suggested_file_name\": \"tmpk0n0x2sb\",\n \"timestamp\": 1602862457,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"c620b71698533d88efa10c80d79a30b74464214cb0d893ec5ab4ec1c37d1676e\",\n \"uploading_to_reflector\": false,\n \"written_bytes\": 11\n }\n}"
}
]
},
@@ -83,18 +83,6 @@
"description": "path to file to be associated with name.",
"is_required": false
},
{
"name": "file_name",
"type": "str",
"description": "name of file to be associated with stream.",
"is_required": false
},
{
"name": "file_hash",
"type": "str",
"description": "hash of file to be associated with stream.",
"is_required": false
},
{
"name": "validate_file",
"type": "bool",
@@ -203,12 +191,6 @@
"description": "audio/video duration in seconds, automatically calculated",
"is_required": false
},
{
"name": "sd_hash",
"type": "str",
"description": "sd_hash of stream",
"is_required": false
},
{
"name": "channel_id",
"type": "str",
@@ -268,10 +250,10 @@
"examples": [
{
"title": "Publish a file",
"curl": "curl -d'{\"method\": \"publish\", \"params\": {\"name\": \"a-new-stream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmp71cpkkpk\", \"validate_file\": false, \"optimize_file\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet publish a-new-stream --bid=1.0 --file_path=/tmp/tmp71cpkkpk",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"publish\", \"params\": {\"name\": \"a-new-stream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmp71cpkkpk\", \"validate_file\": false, \"optimize_file\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000015f41ebc2b2af4adaafc3fe8631d6f56f9c2cd1d67c384fa8c10559354183f3ab010000006b483045022100c00b31d02741ecce403cce42c8ffb89a977ba9a769b11947b19727e1253670b302203ee3d3e40b7b81e4ae3b9d1260014089231309a6873ae8de061efd9e1dbc6514012103654434c522fa0681cb1131a62328a3c3c99f43242edf2d055dbefa69b3c9b5d3ffffffff0200e1f50500000000bfb50c612d6e65772d73747265616d4c94000a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d70373163706b6b706b180b22186170706c69636174696f6e2f6f637465742d73747265616d32303ba910e14fbcd8314f7de8e5e39b7442a2d257c3b975d0780131e7fe5978e17b5f59708abb7279597e71646d0970bf4e6d7576a9145199d244266b2168acfccfcf3c12f6b7b2f37fa088ac54826311000000001976a914b940ff67df6bd84a70a08f88ec01a4bfba20db5e88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mgyaP4FvA3DLPfatc7bfJS8a62c2AHQZH1\",\n \"amount\": \"3.941448\",\n \"confirmations\": 3,\n \"height\": 217,\n \"nout\": 1,\n \"timestamp\": 1621405356,\n \"txid\": \"abf38341355905c1a84f387cd6d12c9c6ff5d63186fec3afda4aafb2c2eb415f\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mnxRJHcT6tEndwbT2fS3bTjcyknA8x1MV3\",\n \"amount\": \"1.0\",\n \"claim_id\": \"26ed324fb68e5f0093d8bb16ee4b2f371004f456\",\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#26ed324fb68e5f0093d8bb16ee4b2f371004f456\",\n \"timestamp\": null,\n \"txid\": \"f5a1b7441bcb30df43696f135975e16c303c1ed8ab443353390de8bac25c3cad\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp71cpkkpk\",\n \"sd_hash\": \"3ba910e14fbcd8314f7de8e5e39b7442a2d257c3b975d0780131e7fe5978e17b5f59708abb7279597e71646d0970bf4e\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mxQVAfGJmsfYiH6JrM3uTxzHjNpBesAWFe\",\n \"amount\": \"2.917341\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"f5a1b7441bcb30df43696f135975e16c303c1ed8ab443353390de8bac25c3cad\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.024107\",\n \"total_input\": \"3.941448\",\n \"total_output\": \"3.917341\",\n \"txid\": \"f5a1b7441bcb30df43696f135975e16c303c1ed8ab443353390de8bac25c3cad\"\n }\n}"
"curl": "curl -d'{\"method\": \"publish\", \"params\": {\"name\": \"a-new-stream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpzg66qsrc\", \"validate_file\": false, \"optimize_file\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet publish a-new-stream --bid=1.0 --file_path=/tmp/tmpzg66qsrc",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"publish\", \"params\": {\"name\": \"a-new-stream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpzg66qsrc\", \"validate_file\": false, \"optimize_file\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001b5c2fa21042c9c7902e2210e72f6e732356ce3fa8284a6d62b2230ada4c68778010000006b483045022100e650ed64dda5492752201f302c36d49ba40a2650eaaf1b241a1afb4cf2712b3d022070e3e9d610155cf3a0e61f7d84d92989927b7f159b52ea67cb18899f642b0049012102980b4392de9b4cd0090d3e81f5f85ef2f08c6dc2280eeb2bcfb58c6ddbf75908ffffffff0200e1f50500000000bfb50c612d6e65772d73747265616d4c94000a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d707a67363671737263180b22186170706c69636174696f6e2f6f637465742d73747265616d32300a4cf1efdc3d85ef48863f9fafd675bb9cc4e83c7f4bbec17f99e4dd6004a21c3317d08107e3e00e8d205102e2490e646d7576a914f16d76520d9764aa8658b40a8d7fd0a6a73ef41a88ace0b46217000000001976a9143c9f3b8c3c8f0a63a43f32ef3c5615875db424b288ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mqeTenbgAseTRfcPJpmSXpUjRMNphrhjGu\",\n \"amount\": \"4.947555\",\n \"confirmations\": 4,\n \"height\": 215,\n \"nout\": 1,\n \"timestamp\": 1602862457,\n \"txid\": \"7887c6a4ad30222bd6a68482fae36c3532e7f6720e21e202799c2c0421fac2b5\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"n3XWGrLR13rLfqCpeJDGFkb3DmyDr8a2Ry\",\n \"amount\": \"1.0\",\n \"claim_id\": \"dc9071a98355d66734dd63cac49ddf4cc1d7f871\",\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#dc9071a98355d66734dd63cac49ddf4cc1d7f871\",\n \"timestamp\": null,\n \"txid\": \"7e9f8a03143f9697dbf796d74e163f8457c7aa8dfea7e9fb3ee078ad3d8defaa\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpzg66qsrc\",\n \"sd_hash\": \"0a4cf1efdc3d85ef48863f9fafd675bb9cc4e83c7f4bbec17f99e4dd6004a21c3317d08107e3e00e8d205102e2490e64\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mm3VbEqmHhZ1vu69EMJC467JiPQQgbApbW\",\n \"amount\": \"3.923448\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"7e9f8a03143f9697dbf796d74e163f8457c7aa8dfea7e9fb3ee078ad3d8defaa\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.024107\",\n \"total_input\": \"4.947555\",\n \"total_output\": \"4.923448\",\n \"txid\": \"7e9f8a03143f9697dbf796d74e163f8457c7aa8dfea7e9fb3ee078ad3d8defaa\"\n }\n}"
}
]
},
@@ -288,7 +270,7 @@
{
"name": "wallet_id",
"type": "str",
"description": "wallet to check for claim purchase receipts",
"description": "wallet to check for claim purchase reciepts",
"is_required": false
},
{
@@ -332,10 +314,10 @@
"examples": [
{
"title": "Resolve a claim",
"curl": "curl -d'{\"method\": \"resolve\", \"params\": {\"urls\": [\"astream#ea41b9f807c6982cf97a1178838dfef64feaa014\"], \"include_purchase_receipt\": false, \"include_is_my_output\": false, \"include_sent_supports\": false, \"include_sent_tips\": false, \"include_received_tips\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet resolve astream#ea41b9f807c6982cf97a1178838dfef64feaa014",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"resolve\", \"params\": {\"urls\": [\"astream#ea41b9f807c6982cf97a1178838dfef64feaa014\"], \"include_purchase_receipt\": false, \"include_is_my_output\": false, \"include_sent_supports\": false, \"include_sent_tips\": false, \"include_received_tips\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"astream#ea41b9f807c6982cf97a1178838dfef64feaa014\": {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#2/astream#e\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"update\",\n \"confirmations\": 4,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"meta\": {\n \"activation_height\": 213,\n \"creation_height\": 213,\n \"creation_timestamp\": 1621405356,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263187,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 213,\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#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"short_url\": \"lbry://astream#e\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#2\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 8,\n \"has_signing_key\": false,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 209,\n \"claims_in_channel\": 2,\n \"creation_height\": 209,\n \"creation_timestamp\": 1621405355,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263183,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 209,\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#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"short_url\": \"lbry://@channel#2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1621405356,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n }\n}"
"curl": "curl -d'{\"method\": \"resolve\", \"params\": {\"urls\": [\"astream#fe7ee643b50b724f6029f6edfe90d67b5512b3ae\"], \"include_purchase_receipt\": false, \"include_is_my_output\": false, \"include_sent_supports\": false, \"include_sent_tips\": false, \"include_received_tips\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet resolve astream#fe7ee643b50b724f6029f6edfe90d67b5512b3ae",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"resolve\", \"params\": {\"urls\": [\"astream#fe7ee643b50b724f6029f6edfe90d67b5512b3ae\"], \"include_purchase_receipt\": false, \"include_is_my_output\": false, \"include_sent_supports\": false, \"include_sent_tips\": false, \"include_received_tips\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"astream#fe7ee643b50b724f6029f6edfe90d67b5512b3ae\": {\n \"address\": \"mzNC6CMEetGVw6QDGChpUM3HfV7DpWGZ7R\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#5/astream#f\",\n \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\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\": 1602862457,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263187,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 213,\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#fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"short_url\": \"lbry://astream#f\",\n \"signing_channel\": {\n \"address\": \"mofqoKUmhmPTCoudQRXgjzGSDnCyJvZAZg\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#5\",\n \"claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"claim_op\": \"update\",\n \"confirmations\": 7,\n \"has_signing_key\": false,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 209,\n \"claims_in_channel\": 1,\n \"creation_height\": 209,\n \"creation_timestamp\": 1602862456,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263183,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 209,\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#5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"short_url\": \"lbry://@channel#5\",\n \"timestamp\": 1602862456,\n \"txid\": \"3ee8f25ad7bfef1d30e3fce0b212d77b74a495ef1d7635a8be77b96ffbe8e412\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200049b4cbe0f5275e7b1c170f458af09628ba75401fd95d0205ed9de9037b396f60936d555da2bc8dd09b1804b250f32d1bd07382bd3a4aaa2700b08b137b91f1159\",\n \"public_key_id\": \"mkVrRXQGgjhBaygCP3dNpbmtm5Yohno8q2\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1602862457,\n \"txid\": \"c620b71698533d88efa10c80d79a30b74464214cb0d893ec5ab4ec1c37d1676e\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpk0n0x2sb\",\n \"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n }\n}"
}
]
},
@@ -357,7 +339,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 \"connections\": {\n \"incoming_bps\": {},\n \"max_incoming_mbs\": 0.0,\n \"max_outgoing_mbs\": 0.0,\n \"outgoing_bps\": {},\n \"total_incoming_mbs\": 0.0,\n \"total_outgoing_mbs\": 0.0,\n \"total_received\": 0,\n \"total_sent\": 0\n },\n \"finished_blobs\": 0\n },\n \"ffmpeg_status\": {\n \"analyze_audio_volume\": true,\n \"available\": true,\n \"which\": \"/usr/bin/ffmpeg\"\n },\n \"file_manager\": {\n \"managed_files\": 0\n },\n \"installation_id\": \"5b3thUHqWPtw7tsqms7k6EhytxX6kg99EtrTSLjrZpPohJfgdtDFw9v3vHQkTLHjkJ\",\n \"is_running\": true,\n \"skipped_components\": [\n \"dht\",\n \"upnp\",\n \"hash_announcer\",\n \"peer_protocol_server\",\n \"libtorrent_component\"\n ],\n \"startup_status\": {\n \"blob_manager\": true,\n \"database\": true,\n \"exchange_rate_manager\": true,\n \"file_manager\": true,\n \"wallet\": true,\n \"wallet_server_payments\": true\n },\n \"wallet\": {\n \"available_servers\": 1,\n \"best_blockhash\": \"ec817b4f72ffdc8f2e1fef1eec569b4a96ab1b9a7a5421d6dea82c12ae817753\",\n \"blocks\": 206,\n \"blocks_behind\": 0,\n \"connected\": \"localhost:50002\",\n \"connected_features\": {\n \"daily_fee\": \"0\",\n \"description\": \"\",\n \"donation_address\": \"\",\n \"genesis_hash\": \"6e3fcf1299d4ec5d79c3a4c91d624a4acf9e2e173d95a1a0504f677669687556\",\n \"hash_function\": \"sha256\",\n \"hosts\": {},\n \"payment_address\": \"\",\n \"protocol_max\": \"0.99.0\",\n \"protocol_min\": \"0.54.0\",\n \"pruning\": null,\n \"server_version\": \"0.97.0\",\n \"trending_algorithm\": \"zscore\"\n },\n \"headers_synchronization_progress\": 100,\n \"known_servers\": 1,\n \"servers\": [\n {\n \"availability\": true,\n \"host\": \"localhost\",\n \"latency\": 0.004196007997961715,\n \"port\": 50002\n }\n ]\n },\n \"wallet_server_payments\": {\n \"max_fee\": \"0.0\",\n \"running\": false\n }\n }\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blob_manager\": {\n \"connections\": {\n \"incoming_bps\": {},\n \"max_incoming_mbs\": 0.0,\n \"max_outgoing_mbs\": 0.0,\n \"outgoing_bps\": {},\n \"total_incoming_mbs\": 0.0,\n \"total_outgoing_mbs\": 0.0,\n \"total_received\": 0,\n \"total_sent\": 0\n },\n \"finished_blobs\": 0\n },\n \"connection_status\": {\n \"code\": \"network_connection\",\n \"message\": \"Your internet connection appears to have been interrupted\"\n },\n \"ffmpeg_status\": {\n \"analyze_audio_volume\": true,\n \"available\": true,\n \"which\": \"/usr/bin/ffmpeg\"\n },\n \"file_manager\": {\n \"managed_files\": 0\n },\n \"installation_id\": \"V15UZPpbGpTXg7L4Z4e2PSwvkHpu9GfrP5kaev1rpg3CPeUt7HsbA6FwfVtHh8EAe\",\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 \"database\": true,\n \"exchange_rate_manager\": true,\n \"file_manager\": true,\n \"libtorrent_component\": true,\n \"wallet\": true,\n \"wallet_server_payments\": true\n },\n \"wallet\": {\n \"available_servers\": 1,\n \"best_blockhash\": \"6b8c8af9b97544b81320fc87bce1b342d4eae95e7bedfa0b68c2051cdbd51f28\",\n \"blocks\": 206,\n \"blocks_behind\": 0,\n \"connected\": \"127.0.0.1:50002\",\n \"connected_features\": {\n \"daily_fee\": \"0\",\n \"description\": \"\",\n \"donation_address\": \"\",\n \"genesis_hash\": \"6e3fcf1299d4ec5d79c3a4c91d624a4acf9e2e173d95a1a0504f677669687556\",\n \"hash_function\": \"sha256\",\n \"hosts\": {},\n \"payment_address\": \"\",\n \"protocol_max\": \"0.99.0\",\n \"protocol_min\": \"0.54.0\",\n \"pruning\": null,\n \"server_version\": \"0.83.0\",\n \"trending_algorithm\": \"zscore\"\n },\n \"headers_synchronization_progress\": 100,\n \"known_servers\": 1,\n \"servers\": [\n {\n \"availability\": true,\n \"host\": \"localhost\",\n \"latency\": 0.010411103023216128,\n \"port\": 50002\n }\n ]\n },\n \"wallet_server_payments\": {\n \"max_fee\": \"0.0\",\n \"running\": false\n }\n }\n}"
}
]
},
@@ -379,7 +361,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\": \"Unknown\",\n \"distro\": {\n \"codename\": \"buster\",\n \"id\": \"debian\",\n \"like\": \"\",\n \"version\": \"10\",\n \"version_parts\": {\n \"build_number\": \"\",\n \"major\": \"10\",\n \"minor\": \"\"\n }\n },\n \"lbrynet_version\": \"0.97.0\",\n \"os_release\": \"5.4.107-1.fc25.qubes.x86_64\",\n \"os_system\": \"Linux\",\n \"platform\": \"Linux-5.4.107-1.fc25.qubes.x86_64-x86_64-with-debian-10.9\",\n \"processor\": \"\",\n \"python_version\": \"3.7.3\",\n \"version\": \"0.97.0\"\n }\n}"
"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.83.0\",\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.5\",\n \"version\": \"0.83.0\"\n }\n}"
}
]
}
@@ -433,10 +415,10 @@
"examples": [
{
"title": "Add an account from seed",
"curl": "curl -d'{\"method\": \"account_add\", \"params\": {\"account_name\": \"new account\", \"seed\": \"remember bamboo bacon absurd copper easy hill wish soccer office lawn limb\", \"single_key\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet account add \"new account\" --seed=\"remember bamboo bacon absurd copper easy hill wish soccer office lawn limb\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_add\", \"params\": {\"account_name\": \"new account\", \"seed\": \"remember bamboo bacon absurd copper easy hill wish soccer office lawn limb\", \"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\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1621405324,\n \"name\": \"new account\",\n \"private_key\": \"tprv8ZgxMBicQKsPeotZxjhxcL98N5eitgmSNgPrxekYztXJ7brMFd9ARZVC43QpNgvrY2exF1KxJQ4A69X5WaaADjcScHdoGKfU2dACXhaBdE7\",\n \"public_key\": \"tpubD6NzVbkrYhZ4YGvMrPNZ1joEw7Af41xLwyzeFAnrRAKgx677t1xkc474E9dTquq7uzegJexpLhtvkyDDy8z63CEwyVr7jPix8DB3mq2Emey\",\n \"seed\": \"remember bamboo bacon absurd copper easy hill wish soccer office lawn limb\"\n }\n}"
"curl": "curl -d'{\"method\": \"account_add\", \"params\": {\"account_name\": \"new account\", \"seed\": \"canyon divert wave luxury danger furnace age music fetch circle ship penalty\", \"single_key\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet account add \"new account\" --seed=\"canyon divert wave luxury danger furnace age music fetch circle ship penalty\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_add\", \"params\": {\"account_name\": \"new account\", \"seed\": \"canyon divert wave luxury danger furnace age music fetch circle ship penalty\", \"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\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1602862425,\n \"name\": \"new account\",\n \"private_key\": \"tprv8ZgxMBicQKsPdKjSM3yfb29VuJBXyr9SJYQ7iAwXEsPA4NnGgDgFJu9KF3xDQJqEKPJLZbSd7EUAaYVqM9HMz92tG2BcDX2A1u59NVmBCM3\",\n \"public_key\": \"tpubD6NzVbkrYhZ4WnmEEheFzRocUKhU9BLLsqztzgypf9BYts33JcVqVPmBRBZkMfZCqjpgbRbmKwSisEW3w5Ex256TmeqXZfiMUEbRFn5TZPG\",\n \"seed\": \"canyon divert wave luxury danger furnace age music fetch circle ship penalty\"\n }\n}"
}
]
},
@@ -474,9 +456,9 @@
},
{
"title": "Get balance for specific account by id",
"curl": "curl -d'{\"method\": \"account_balance\", \"params\": {\"account_id\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\"}}' http://localhost:5279/",
"lbrynet": "lbrynet account balance \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_balance\", \"params\": {\"account_id\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\"}}).json()",
"curl": "curl -d'{\"method\": \"account_balance\", \"params\": {\"account_id\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\"}}' http://localhost:5279/",
"lbrynet": "lbrynet account balance \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_balance\", \"params\": {\"account_id\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"available\": \"2.0\",\n \"reserved\": \"0.0\",\n \"reserved_subtotals\": {\n \"claims\": \"0.0\",\n \"supports\": \"0.0\",\n \"tips\": \"0.0\"\n },\n \"total\": \"2.0\"\n }\n}"
}
]
@@ -511,7 +493,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\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1621405324,\n \"name\": \"generated account\",\n \"private_key\": \"tprv8ZgxMBicQKsPeotZxjhxcL98N5eitgmSNgPrxekYztXJ7brMFd9ARZVC43QpNgvrY2exF1KxJQ4A69X5WaaADjcScHdoGKfU2dACXhaBdE7\",\n \"public_key\": \"tpubD6NzVbkrYhZ4YGvMrPNZ1joEw7Af41xLwyzeFAnrRAKgx677t1xkc474E9dTquq7uzegJexpLhtvkyDDy8z63CEwyVr7jPix8DB3mq2Emey\",\n \"seed\": \"remember bamboo bacon absurd copper easy hill wish soccer office lawn limb\"\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\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1602862425,\n \"name\": \"generated account\",\n \"private_key\": \"tprv8ZgxMBicQKsPdKjSM3yfb29VuJBXyr9SJYQ7iAwXEsPA4NnGgDgFJu9KF3xDQJqEKPJLZbSd7EUAaYVqM9HMz92tG2BcDX2A1u59NVmBCM3\",\n \"public_key\": \"tpubD6NzVbkrYhZ4WnmEEheFzRocUKhU9BLLsqztzgypf9BYts33JcVqVPmBRBZkMfZCqjpgbRbmKwSisEW3w5Ex256TmeqXZfiMUEbRFn5TZPG\",\n \"seed\": \"canyon divert wave luxury danger furnace age music fetch circle ship penalty\"\n }\n}"
}
]
},
@@ -566,24 +548,24 @@
"examples": [
{
"title": "Transfer 2 LBC from default account to specific account",
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"to_account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\", \"amount\": \"2.0\", \"everything\": false, \"broadcast\": true}}' http://localhost:5279/",
"lbrynet": "lbrynet account fund --to_account=\"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\" --amount=2.0 --broadcast",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"to_account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\", \"amount\": \"2.0\", \"everything\": false, \"broadcast\": true}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000158b9aacf16272c014b4ea68547f99b83aac802ec1649da83922ecdc9273b727a010000006b483045022100daca5565f0ad55024830d3ea012285bfa572abda34d585b086899ae9959025db022025b134dcb5ce9d9eee109c649b5aaa1efb82bd782ec0bc7fc8982c563cb61470012103f2ee97726d5454ae20354313092052968f819e77b792e6fc52458fa4ddfe34e7ffffffff0200c2eb0b000000001976a914cdfc5605a8e5ea0e13e4be23811bba94622e161b88ac90d7ae2f000000001976a9142ad7e4109f922f32e09cb95ccd0d94150cc9e6fc88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mffPeSmHrFE3tg5J4zCQGP4muR6CcUV5wu\",\n \"amount\": \"10.0\",\n \"confirmations\": 6,\n \"height\": 201,\n \"nout\": 1,\n \"timestamp\": 1621405354,\n \"txid\": \"7a723b27c9cd2e9283da4916ec02c8aa839bf94785a64e4b012c2716cfaab958\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mzJ76zabb25ur5UEzCcPqDNcdnANJJktk1\",\n \"amount\": \"2.0\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"d0f0cc2d9bc25d86d629b61eb4cc9cdc981a96223879056c0a623521ed8aa0a2\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mjRVJULUCxB7s3guxUriGqN5C7RFj6Fsxh\",\n \"amount\": \"7.999876\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"d0f0cc2d9bc25d86d629b61eb4cc9cdc981a96223879056c0a623521ed8aa0a2\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000124\",\n \"total_input\": \"10.0\",\n \"total_output\": \"9.999876\",\n \"txid\": \"d0f0cc2d9bc25d86d629b61eb4cc9cdc981a96223879056c0a623521ed8aa0a2\"\n }\n}"
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"to_account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\", \"amount\": \"2.0\", \"everything\": false, \"broadcast\": true}}' http://localhost:5279/",
"lbrynet": "lbrynet account fund --to_account=\"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\" --amount=2.0 --broadcast",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"to_account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\", \"amount\": \"2.0\", \"everything\": false, \"broadcast\": true}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001593d803c01161d9d524478df75cef6c11da8d87614e5223d31d1f3ab4a754308000000006b483045022100d755e3d2cc4065107b641336906586a7b159842d903782e6b160c90c39aef6dc02204ad601b3c40820c9695890025fb16a9545b8fd333f0370631773d62b2148b6cc012102da03d047c77c88fc85700096abca5ab15ce21e95ad4ff1e71d908fa3cc190995ffffffff0200c2eb0b000000001976a914bbd66d8f43ae842b769d041309a95819cbde14e388ac90d7ae2f000000001976a914bb6805e32be149c2d7510ba04c327fd34288016c88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mx9RtSnJXpvcsMBshzEfvEmpsqtQJh9HTN\",\n \"amount\": \"10.0\",\n \"confirmations\": 6,\n \"height\": 201,\n \"nout\": 0,\n \"timestamp\": 1602862455,\n \"txid\": \"0843754aabf3d1313d22e51476d8a81dc1f6ce75df7844529d1d16013c803d59\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mxe9XeEC5YThvqweuLJywuccfe7FGTmD4c\",\n \"amount\": \"2.0\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"6947372f3637caa782cdb49daf4c9cb4f06a8479152eee6691912f042d3d5358\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mxbsGa4jf99tDFJtiFtxyVJ7N3xPUsD9qo\",\n \"amount\": \"7.999876\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"6947372f3637caa782cdb49daf4c9cb4f06a8479152eee6691912f042d3d5358\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000124\",\n \"total_input\": \"10.0\",\n \"total_output\": \"9.999876\",\n \"txid\": \"6947372f3637caa782cdb49daf4c9cb4f06a8479152eee6691912f042d3d5358\"\n }\n}"
},
{
"title": "Spread LBC between multiple addresses",
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"to_account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\", \"from_account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\", \"amount\": \"1.5\", \"everything\": false, \"outputs\": 2, \"broadcast\": true}}' http://localhost:5279/",
"lbrynet": "lbrynet account fund --to_account=\"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\" --from_account=\"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\" --amount=1.5 --outputs=2 --broadcast",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"to_account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\", \"from_account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\", \"amount\": \"1.5\", \"everything\": false, \"outputs\": 2, \"broadcast\": true}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001a2a08aed2135620a6c05793822961a98dc9cccb41eb629d6865dc29b2dccf0d0000000006a47304402205f3edef7ce0ca0c525806eeb3d6cbbc4435cd0e99af6b255b3adf850053597c4022007356877e70c4db839f3fe7c3895143482a84db7691f2efb7fbc1b15def1e2c501210374fa170082b9b46254f2887e0f938be9e9b2e2753f5966d03eca0b3c238ecc6affffffff03c0687804000000001976a914b49ada82e78a48e693c1cfe3c4472a0b994c4bce88acc0687804000000001976a914b49ada82e78a48e693c1cfe3c4472a0b994c4bce88ac6cb9fa02000000001976a91420f5af908fbb3a2dff2ad9c136cfc60c9b48170c88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mzJ76zabb25ur5UEzCcPqDNcdnANJJktk1\",\n \"amount\": \"2.0\",\n \"confirmations\": 1,\n \"height\": 207,\n \"nout\": 0,\n \"timestamp\": 1621405355,\n \"txid\": \"d0f0cc2d9bc25d86d629b61eb4cc9cdc981a96223879056c0a623521ed8aa0a2\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mwyuRzojNR4AcQ3Dzk8tTVsdYZnoMJYD6B\",\n \"amount\": \"0.75\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"ff2efa766fed54efaaf8bd95be4c61da6e4756d98939cdd23af0df64d9eb4577\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mwyuRzojNR4AcQ3Dzk8tTVsdYZnoMJYD6B\",\n \"amount\": \"0.75\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"ff2efa766fed54efaaf8bd95be4c61da6e4756d98939cdd23af0df64d9eb4577\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"miXEEjwhrMsbL91dccqwTJeTkRmgDGSYoP\",\n \"amount\": \"0.499859\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 2,\n \"timestamp\": null,\n \"txid\": \"ff2efa766fed54efaaf8bd95be4c61da6e4756d98939cdd23af0df64d9eb4577\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000141\",\n \"total_input\": \"2.0\",\n \"total_output\": \"1.999859\",\n \"txid\": \"ff2efa766fed54efaaf8bd95be4c61da6e4756d98939cdd23af0df64d9eb4577\"\n }\n}"
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"to_account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\", \"from_account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\", \"amount\": \"1.5\", \"everything\": false, \"outputs\": 2, \"broadcast\": true}}' http://localhost:5279/",
"lbrynet": "lbrynet account fund --to_account=\"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\" --from_account=\"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\" --amount=1.5 --outputs=2 --broadcast",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"to_account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\", \"from_account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\", \"amount\": \"1.5\", \"everything\": false, \"outputs\": 2, \"broadcast\": true}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000158533d2d042f919166ee2e1579846af0b49c4caf9db4cd82a7ca37362f374769000000006b483045022100c76e4f1ee55950017492b9bad6178e5f231e2b78b76b87cdb3b896e645525f3a02206c29691cfd6aa7dea5c8cefe77a019c056039b4ae69c794655116a6c583c6f070121021fa6ee5903084a3c68cf3219b09b83ffd1b25eae5d5ad66a708c1259e774c4cfffffffff03c0687804000000001976a9146a86d0525868bfe9f0287eb0792ac22dd73be8a488acc0687804000000001976a9146a86d0525868bfe9f0287eb0792ac22dd73be8a488ac6cb9fa02000000001976a914de0d514e0b0ec3cf293ec252dbbbad5842ac88cf88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mxe9XeEC5YThvqweuLJywuccfe7FGTmD4c\",\n \"amount\": \"2.0\",\n \"confirmations\": 1,\n \"height\": 207,\n \"nout\": 0,\n \"timestamp\": 1602862456,\n \"txid\": \"6947372f3637caa782cdb49daf4c9cb4f06a8479152eee6691912f042d3d5358\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mqEDRQrRnfFzaX6m2HSgdrCsCd7Vy6MDf2\",\n \"amount\": \"0.75\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"32b6cbd8343c4d508e333603db439e8a469bbe986f19d33a0ee7d44755f8b340\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mqEDRQrRnfFzaX6m2HSgdrCsCd7Vy6MDf2\",\n \"amount\": \"0.75\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"32b6cbd8343c4d508e333603db439e8a469bbe986f19d33a0ee7d44755f8b340\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"n1m4FxpboAMcDtbVjnFoiqYTnoTmbUPm9H\",\n \"amount\": \"0.499859\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 2,\n \"timestamp\": null,\n \"txid\": \"32b6cbd8343c4d508e333603db439e8a469bbe986f19d33a0ee7d44755f8b340\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000141\",\n \"total_input\": \"2.0\",\n \"total_output\": \"1.999859\",\n \"txid\": \"32b6cbd8343c4d508e333603db439e8a469bbe986f19d33a0ee7d44755f8b340\"\n }\n}"
},
{
"title": "Transfer all LBC to a specified account",
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"from_account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\", \"everything\": true, \"broadcast\": true}}' http://localhost:5279/",
"lbrynet": "lbrynet account fund --from_account=\"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\" --everything --broadcast",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"from_account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\", \"everything\": true, \"broadcast\": true}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000037745ebd964dff03ad2cd3989d956476eda614cbe95bdf8aaef54ed6f76fa2eff000000006b4830450221008f287b89057f784e197e2318f2be9f5ad53c3e19300ea61bbc6bc030cbb013c90220425cdeb4b5dd8207ec4c755a63cfdda9788a27598c24c0ada41fa7901cfbd82b012103c0330685b2f4734821f4f6b8116c9de7c5faa9d518da7275c823e1440864631bffffffff7745ebd964dff03ad2cd3989d956476eda614cbe95bdf8aaef54ed6f76fa2eff010000006a4730440220493dbb56e0750528e33a6313f1b5577e46b584cfbee44088717c1de513ffa50002207385d2a245325be823ffbc0a2445a02212d75c04a13140c4d885e05588021465012103c0330685b2f4734821f4f6b8116c9de7c5faa9d518da7275c823e1440864631bffffffff7745ebd964dff03ad2cd3989d956476eda614cbe95bdf8aaef54ed6f76fa2eff020000006b483045022100f1344b664449676fdd4b99e4c21e22e361ecd223fae1b05108d0d5e919350d9902203fef98f15717541f256841fb5964f1c22c2bd9281a32420aaf112cc9e79974850121025780217a60380b1410bd46a3c261ac0ae3d86b1dc4b8c45addb0525217ddd31dffffffff015027eb0b000000001976a9147ef48a8cc47e6fbce1d7bb3d909d5e5aa557bd3488ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mwyuRzojNR4AcQ3Dzk8tTVsdYZnoMJYD6B\",\n \"amount\": \"0.75\",\n \"confirmations\": 1,\n \"height\": 208,\n \"nout\": 0,\n \"timestamp\": 1621405355,\n \"txid\": \"ff2efa766fed54efaaf8bd95be4c61da6e4756d98939cdd23af0df64d9eb4577\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mwyuRzojNR4AcQ3Dzk8tTVsdYZnoMJYD6B\",\n \"amount\": \"0.75\",\n \"confirmations\": 1,\n \"height\": 208,\n \"nout\": 1,\n \"timestamp\": 1621405355,\n \"txid\": \"ff2efa766fed54efaaf8bd95be4c61da6e4756d98939cdd23af0df64d9eb4577\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"miXEEjwhrMsbL91dccqwTJeTkRmgDGSYoP\",\n \"amount\": \"0.499859\",\n \"confirmations\": 1,\n \"height\": 208,\n \"nout\": 2,\n \"timestamp\": 1621405355,\n \"txid\": \"ff2efa766fed54efaaf8bd95be4c61da6e4756d98939cdd23af0df64d9eb4577\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"ms6EPFDDfSb3gVMgyBZ5drGuYH9uqvvmPq\",\n \"amount\": \"1.999604\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"ac0d083d10fabb4abcd15d2a8c94868fd4a64de15f0d94d10eecc547155fb8f5\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000255\",\n \"total_input\": \"1.999859\",\n \"total_output\": \"1.999604\",\n \"txid\": \"ac0d083d10fabb4abcd15d2a8c94868fd4a64de15f0d94d10eecc547155fb8f5\"\n }\n}"
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"from_account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\", \"everything\": true, \"broadcast\": true}}' http://localhost:5279/",
"lbrynet": "lbrynet account fund --from_account=\"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\" --everything --broadcast",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"from_account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\", \"everything\": true, \"broadcast\": true}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000340b3f85547d4e70e3ad3196f98be9b468a9e43db0336338e504d3c34d8cbb632000000006b4830450221009286f4bb5c7772a63a8f112c778030299e5bd881eb438f7096c6fcfea2f298b20220610535e1cf672f1bae3769e68831ffd2548503d1b0c754408a4313562609266201210252ccb7fdb5a3df0ace8fec6ccfeafd779a3e7c8140e90837265284525e9220f6ffffffff40b3f85547d4e70e3ad3196f98be9b468a9e43db0336338e504d3c34d8cbb632010000006b483045022100c7f1430fda72968855d0023e05c664867290510b716dfaf248d9fee78af4e5b2022007ac25af1b07efb5fef962b8937d9164fea7739c50712538d26e44f67e3d317901210252ccb7fdb5a3df0ace8fec6ccfeafd779a3e7c8140e90837265284525e9220f6ffffffff40b3f85547d4e70e3ad3196f98be9b468a9e43db0336338e504d3c34d8cbb632020000006a47304402202e070692322d651350ad87d2a5a8af921a8b2b4c559247d07b9d74e64ce6bc41022034c4496122a92b2a22b7164d168e1b2746e80fe874dcb0f9dab5a16b1db0bb320121037074c41a3706b2b2694945c608d0b382ed414c60d5c3d2c688fe8f529a11952cffffffff015027eb0b000000001976a9143b6f1c1f03cf44fe2fb73c719d9360ce53426ce088ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mqEDRQrRnfFzaX6m2HSgdrCsCd7Vy6MDf2\",\n \"amount\": \"0.75\",\n \"confirmations\": 1,\n \"height\": 208,\n \"nout\": 0,\n \"timestamp\": 1602862456,\n \"txid\": \"32b6cbd8343c4d508e333603db439e8a469bbe986f19d33a0ee7d44755f8b340\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mqEDRQrRnfFzaX6m2HSgdrCsCd7Vy6MDf2\",\n \"amount\": \"0.75\",\n \"confirmations\": 1,\n \"height\": 208,\n \"nout\": 1,\n \"timestamp\": 1602862456,\n \"txid\": \"32b6cbd8343c4d508e333603db439e8a469bbe986f19d33a0ee7d44755f8b340\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"n1m4FxpboAMcDtbVjnFoiqYTnoTmbUPm9H\",\n \"amount\": \"0.499859\",\n \"confirmations\": 1,\n \"height\": 208,\n \"nout\": 2,\n \"timestamp\": 1602862456,\n \"txid\": \"32b6cbd8343c4d508e333603db439e8a469bbe986f19d33a0ee7d44755f8b340\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mkwDGRHqKvQXW9zwfumqrJUhiBDWbzPr1M\",\n \"amount\": \"1.999604\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"4b414b1e4adc47f05e343c46f0ad5193935628beb51056f6d26589bcba9b4916\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000255\",\n \"total_input\": \"1.999859\",\n \"total_output\": \"1.999604\",\n \"txid\": \"4b414b1e4adc47f05e343c46f0ad5193935628beb51056f6d26589bcba9b4916\"\n }\n}"
}
]
},
@@ -641,7 +623,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 \"items\": [\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\": \"n34d7tsf9D7HjzWr2LnE7c9x9rwtvGNNwG\",\n \"is_default\": true,\n \"ledger\": \"lbc_regtest\",\n \"name\": \"Account #n34d7tsf9D7HjzWr2LnE7c9x9rwtvGNNwG\",\n \"public_key\": \"tpubD6NzVbkrYhZ4Y47gVC3GHm5nxPbxoWF7fxq3L59VBTkw5X3iiyHrka3AD5M7YWvC8NvUngQwrm6wacpWxEeJMXNH3YvJBYAbtp2TVmsSyw4\",\n \"satoshis\": 1000000000\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_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\": \"myTjaQ7rr9opqoawJAkBwiAjVhTbgq8tXM\",\n \"is_default\": true,\n \"ledger\": \"lbc_regtest\",\n \"name\": \"Account #myTjaQ7rr9opqoawJAkBwiAjVhTbgq8tXM\",\n \"public_key\": \"tpubD6NzVbkrYhZ4Y8SWimAJbLYDuxaPvKDYMbSZQxqfHBRj11AbPTjykWJ87TReUKEeBqMMDYfwa7cPGKtWV22VXw6Y8gf13tXNt94cuyJ9Jzp\",\n \"satoshis\": 1000000000\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
}
]
},
@@ -686,10 +668,10 @@
"examples": [
{
"title": "Remove an account",
"curl": "curl -d'{\"method\": \"account_remove\", \"params\": {\"account_id\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\"}}' http://localhost:5279/",
"lbrynet": "lbrynet account remove mue613K8x5kLXpsePncrd5xqSoRi7NXmYx",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_remove\", \"params\": {\"account_id\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\"}}).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\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1621405324,\n \"name\": \"generated account\",\n \"private_key\": \"tprv8ZgxMBicQKsPeotZxjhxcL98N5eitgmSNgPrxekYztXJ7brMFd9ARZVC43QpNgvrY2exF1KxJQ4A69X5WaaADjcScHdoGKfU2dACXhaBdE7\",\n \"public_key\": \"tpubD6NzVbkrYhZ4YGvMrPNZ1joEw7Af41xLwyzeFAnrRAKgx677t1xkc474E9dTquq7uzegJexpLhtvkyDDy8z63CEwyVr7jPix8DB3mq2Emey\",\n \"seed\": \"remember bamboo bacon absurd copper easy hill wish soccer office lawn limb\"\n }\n}"
"curl": "curl -d'{\"method\": \"account_remove\", \"params\": {\"account_id\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\"}}' http://localhost:5279/",
"lbrynet": "lbrynet account remove mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_remove\", \"params\": {\"account_id\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\"}}).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\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1602862425,\n \"name\": \"generated account\",\n \"private_key\": \"tprv8ZgxMBicQKsPdKjSM3yfb29VuJBXyr9SJYQ7iAwXEsPA4NnGgDgFJu9KF3xDQJqEKPJLZbSd7EUAaYVqM9HMz92tG2BcDX2A1u59NVmBCM3\",\n \"public_key\": \"tpubD6NzVbkrYhZ4WnmEEheFzRocUKhU9BLLsqztzgypf9BYts33JcVqVPmBRBZkMfZCqjpgbRbmKwSisEW3w5Ex256TmeqXZfiMUEbRFn5TZPG\",\n \"seed\": \"canyon divert wave luxury danger furnace age music fetch circle ship penalty\"\n }\n}"
}
]
},
@@ -782,10 +764,10 @@
"examples": [
{
"title": "Modify maximum number of times a change address can be reused",
"curl": "curl -d'{\"method\": \"account_set\", \"params\": {\"account_id\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\", \"default\": false, \"change_max_uses\": 10}}' http://localhost:5279/",
"lbrynet": "lbrynet account set mue613K8x5kLXpsePncrd5xqSoRi7NXmYx --change_max_uses=10",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_set\", \"params\": {\"account_id\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\", \"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\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1621405324,\n \"name\": \"new account\",\n \"private_key\": \"tprv8ZgxMBicQKsPeotZxjhxcL98N5eitgmSNgPrxekYztXJ7brMFd9ARZVC43QpNgvrY2exF1KxJQ4A69X5WaaADjcScHdoGKfU2dACXhaBdE7\",\n \"public_key\": \"tpubD6NzVbkrYhZ4YGvMrPNZ1joEw7Af41xLwyzeFAnrRAKgx677t1xkc474E9dTquq7uzegJexpLhtvkyDDy8z63CEwyVr7jPix8DB3mq2Emey\",\n \"seed\": \"remember bamboo bacon absurd copper easy hill wish soccer office lawn limb\"\n }\n}"
"curl": "curl -d'{\"method\": \"account_set\", \"params\": {\"account_id\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\", \"default\": false, \"change_max_uses\": 10}}' http://localhost:5279/",
"lbrynet": "lbrynet account set mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY --change_max_uses=10",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_set\", \"params\": {\"account_id\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\", \"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\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1602862425,\n \"name\": \"new account\",\n \"private_key\": \"tprv8ZgxMBicQKsPdKjSM3yfb29VuJBXyr9SJYQ7iAwXEsPA4NnGgDgFJu9KF3xDQJqEKPJLZbSd7EUAaYVqM9HMz92tG2BcDX2A1u59NVmBCM3\",\n \"public_key\": \"tpubD6NzVbkrYhZ4WnmEEheFzRocUKhU9BLLsqztzgypf9BYts33JcVqVPmBRBZkMfZCqjpgbRbmKwSisEW3w5Ex256TmeqXZfiMUEbRFn5TZPG\",\n \"seed\": \"canyon divert wave luxury danger furnace age music fetch circle ship penalty\"\n }\n}"
}
]
}
@@ -821,9 +803,9 @@
"examples": [
{
"title": "Check if address is mine",
"curl": "curl -d'{\"method\": \"address_is_mine\", \"params\": {\"address\": \"mwzRFUu7mKpzqPvh1uaAQivEKd1wDUp41X\"}}' http://localhost:5279/",
"lbrynet": "lbrynet address is_mine mwzRFUu7mKpzqPvh1uaAQivEKd1wDUp41X",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_is_mine\", \"params\": {\"address\": \"mwzRFUu7mKpzqPvh1uaAQivEKd1wDUp41X\"}}).json()",
"curl": "curl -d'{\"method\": \"address_is_mine\", \"params\": {\"address\": \"mvW5fF65d8WiGavNWjJcuQ6uRoa4AsSmLZ\"}}' http://localhost:5279/",
"lbrynet": "lbrynet address is_mine mvW5fF65d8WiGavNWjJcuQ6uRoa4AsSmLZ",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_is_mine\", \"params\": {\"address\": \"mvW5fF65d8WiGavNWjJcuQ6uRoa4AsSmLZ\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": true\n}"
}
]
@@ -870,14 +852,14 @@
"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 \"items\": [\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mfeQWMvmtnuZnSpGwjNDy33jQvgy2nu4vR\",\n \"pubkey\": \"tpubDA9GDAntyJu4Ytag2HiGb2Hrmgtjga1oSRTdWNZz6Vh6mW2yWyMkhKtJS9rH3ctZzPFvFhenoTfoArgceQgaLSXXQATSa9r5iVjAWHHxpBc\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mhgyiqzXraHQvoYN4oRsnmZGeB5e27v7X6\",\n \"pubkey\": \"tpubDA9GDAntyJu56nZDL32W3uoYzpZQ3HuE5zDDzVnCzNzgH3fAaHx2p8PgX9oETY13FKHdiiN8zZEgZHxGks6B12exJigtntT9FQTPrYpwuKH\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"miXEEjwhrMsbL91dccqwTJeTkRmgDGSYoP\",\n \"pubkey\": \"tpubDA9GDAntyJu4NUN7zjtAZaH7SwJJGrNw3GGXpLXus5dTmGEcHUsuAC9M7tH5oeirCACaY4kWWwo6zEFFYt8xK6JgUSSR24ZwmcHsbPaCxNr\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mjhaqbLhpch3DebPyWr21ppDGLukn1YSeh\",\n \"pubkey\": \"tpubDA9GDAntyJu4cZWdAgJTwKrWNEXdbNPrydUPVLiURVv6DmDYRTAAAMMW4y7RXJkPYNofLKohDGNPmbV6yNwnxVijRhxkVNYY4Ei6amXvrVA\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mk6aLnMyWNce5z7pkAFjT7VKvgddRfpuPZ\",\n \"pubkey\": \"tpubDA9GDAntyJu4V1BUGVmutJZCuz1TtuzwidW2b7masz8qtFuZmpJ7HZvVy95TL1MQpszsmuK5KgmEXXRzAfg2xRRituyqqaKtQHjxxHnyXtz\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mkygHEMa1gckjft4HdnXdBCA2qNn8ocEnd\",\n \"pubkey\": \"tpubDA9GDAntyJu4juqLBa7brBP1W1x3G7XvPCTRqUsunQh7u2Ly3jmevsLu3BDmsFJUuwdLx38BTHa5ip6wVoFVqUinnp6EahBfd9uSDXZZrkM\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mmGWzcEtP4BYh2rxf82c9L7cdVyvbkxhfB\",\n \"pubkey\": \"tpubDA9GDAntyJu4XQhL61tDESr7XG7YnKJRzRM6hCvRxv4x3tMTqK2yv17k8qXWiVziW2jdFwbGpeVLkcdxonchVPj4beHsv8hRy1dfmipdrm3\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mn8SVfBD3117apKuXMVjVeefpeHVfni2xW\",\n \"pubkey\": \"tpubDA9GDAntyJu4QuRUc8EBJvTo74ZbvQiN1StbbZnFX6qBBCoVocV3VsFFC6SUteRFj2rJp2LGxUDXmQHcHqZa3LhFpKeCtguhimnxgKaYtYJ\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mnwPnyB24JZfXUqd7vn8MsMhmNTRkj4Amr\",\n \"pubkey\": \"tpubDA9GDAntyJu4LW5QvSz76VzXmRsAUoQ4otyRRnKz3yrANK2G39avPvQigzzVj1wVyYZxVqot7C6LjzdyFE5prYR49tcWJUYfFvqdnvy2FbG\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mo2ydnUzgxFX1YsZPuECeQxeRwiuR9haHK\",\n \"pubkey\": \"tpubDA9GDAntyJu4gTKzy4MShkNiFnhQxEZQ5S7y7nKtvhWFsxqQ8mGuSWCQJUGL4jdNcFFRU9neXyJaDjMZP3RuKTDXi5BFz6Ao7GFfc9cFmsn\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"moEwuQhAkg3hT7qhTjHXiFuf7KBcUhGzCt\",\n \"pubkey\": \"tpubDA9GDAntyJu52jXcb9gAsJXM1CVAabeFAktL9nw3yBoFWpE3m5mocdwDANmosEhdna2tUb2uuR6wBnFXR3RmQ3fsuHsEVucP3BcHquzKmXm\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"morR7jG1kXb7AbvQRXRYH554jpCnQkfXYg\",\n \"pubkey\": \"tpubDA9GDAntyJu4G59VFEdQaAoKs3LeNRP9rKTZ8a1rK5ocUPV8i8i9hbZiGbCgEFZiH3dGvf8Gstw7nbfxA5R5gum7Mf9GRa9vCi6xhXn7rPs\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mouye7ULsS8mZ6GDZ6t4LyNDKt1NR9YYxS\",\n \"pubkey\": \"tpubDA9GDAntyJu4wQF2sSaUSY4RpHuypUbKKbuVJz3Dyv4VZsnuMetXPVnx1RuGBgLAj8ARSqNe5xF9j6Y4JuBHca98YDS2DQxbzVbqsdDcAVw\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mpZtKoHsPTyPoUPdmhG6sDpj6AJeKWeB5g\",\n \"pubkey\": \"tpubDA9GDAntyJu4fHj1PXGSc2DLHTxwphZRVAg4qo8p56iUaigrzzgo3qSaeCEEMkKjUgBxy6oq8Y9Rfm6epyF7DTzcbMuYBRt8acTf4SAZpaT\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mqKfz8h1dEwid46RueaL1RSZ6KAACn4iPw\",\n \"pubkey\": \"tpubDA9GDAntyJu4JPiW5aSsNcqLb49zqbKNLVZcMhDKF5vWyv5XRzHFtbwKXPfNUW9mX7ahKiC9qUMxtGVtJP9oBVupKZFifEGXDEwZvWvXWMP\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"msSrvvj7mbVxFE65GQcGyTqfgjCqHGjRWS\",\n \"pubkey\": \"tpubDA9GDAntyJu4RA2NaDmVC8192ZULDVGbbsBFNv87jbjqfX6mtNHWVarfxJR9dEbxFivrJAfnggyg1ysVGWWa746mp4pXq9kKKG56HWnQDpJ\",\n \"Line truncated
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mh9VwE8HKhw3QjPCPZh3PU6e3juobVGeME\",\n \"pubkey\": \"tpubDA9GDAntyJu4nEGYmLc4ihro5xv9bSSwfZTPEQQfN25mm2exgoUugfQE4ZMM3boheswEyS3zJMMYneaz2AuYowwhYFPZhYrPv5ktZz5xMQV\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mh9fMDTWpwF954grmVnzzntFSWXk8KYy8B\",\n \"pubkey\": \"tpubDA9GDAntyJu4L5oH2g4AeUbTqNd4mnJF7T1xamBiV5hJTwLdqPT3YsGZToqMEZvWu4266AyyraszWAybYcAPP8PJonQPj3J2odScqVUvvxd\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mj3pFoj1BLFA293quWByDf2WrSVn76Bvbz\",\n \"pubkey\": \"tpubDA9GDAntyJu4pLDopCn5sXCqmJSMD8f4J2mErt5E3pPmvY2o2xauN9wc2cgA217stad8Und2yumurTL5xpSqbnC95NC3wFik8VTqbWE9HbN\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mmKD7WwB8A86K7RAtf7ncr79wgbvzfsJpe\",\n \"pubkey\": \"tpubDA9GDAntyJu4N6C1Craod75L2Kf1dK2KDCS3Q2s2xxWFo2KGtp9xhMVLjwQzCVYwDDXT7ZG2uNCjthqEJZdSeGcH7WgBSYcpJkwBPciGyKn\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mmmGb7DUQec3QFrbi1m3MWC232phHGGDrX\",\n \"pubkey\": \"tpubDA9GDAntyJu53kygACiiUPY4Fm6Gf3AvGBk86noTQ6yZoczchTeiz49XnbaCHVnXM7tJRfnrUR73DUbAg4LMJNU5evYmbBfsuA87bn2U58M\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mnY7nggBwEtNAKhpYhQWzA1AfeFo7G5AyD\",\n \"pubkey\": \"tpubDA9GDAntyJu4VEy1YcEvFNLKNTWEZFdPM9CFeLoreu4d7cmtTeHcTMkdE4i2sw4YAi5saSd6NEY9oh9WgiLcApK3GrBaoNUeRtG5BZxAnwD\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"moK5kBNW2hTfUpNPe1ZaQLgEq4Z8N5cj1A\",\n \"pubkey\": \"tpubDA9GDAntyJu4dudWYrKMLH5k8xe7F9BfzEt1tE16AQgRfaaknKQmGz1Z8Bt4ws3ZgFoD5D8ZF5fW1ziHaC7cJvgNagsP7jCXN5DsVuwCe99\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"moRQq9jHEJ6sL9cX6wq4A7EKTh5f8n8U9h\",\n \"pubkey\": \"tpubDA9GDAntyJu4RWtNN1XU4ny3qgphTYxToGUQRHZgJoS29hz7UcmLmsTeDUeToyfckDz94okiNkE6oRHh3v71auGJV6rai5Sff2sQxk3mBGB\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"moRkYbPJKGS8ihvNaedGzKQcskudaGdo6j\",\n \"pubkey\": \"tpubDA9GDAntyJu4Fvmm66NdhqkSx2xZJTbjCPhu1zTECuxM5RCTzmuozN9VyAFg8uM3S3nt1EKQqMycTnBoNFTThNHRuWYNz5rH7E9Jx9MyCun\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mpqZ2sJifp18baqMntvEp3tgR8Kevo6vyV\",\n \"pubkey\": \"tpubDA9GDAntyJu4tboRaZAXEepzyJEDT29hxnu12gPpWoubZKEnM7XbbnenooLDtq6f7941UTEzkSrQs2ddRmEy14isbjgyHdvA163wcoMxrzN\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mpvW6Ck65nk9fNUmMGmSdPFxTX4CsGw8Eb\",\n \"pubkey\": \"tpubDA9GDAntyJu4qzJ1846T1k1ynJfKK6NcLRm2NKrMpqnHADxzWkod9D2pBC9TtY4mQLmrTcmt18kVJaWnqXEMDC2zTWccf1MFNddpyxdexZa\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mqEDRQrRnfFzaX6m2HSgdrCsCd7Vy6MDf2\",\n \"pubkey\": \"tpubDA9GDAntyJu4Q1UUt4uC8M5gp7phTP2E1FeU46kYzXb5VBGf5nU7cyUNsyPX2yLU76vp1ZLvkxJYCd6HeAptBfjE5T6YqfWtBYcKmGJLQ1q\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mqHzaj6FHs9AePR7W5fFLTik7YDUaFUZRx\",\n \"pubkey\": \"tpubDA9GDAntyJu4iQrq8iPMTQ1YBzjcnMQuLUArHUPJ3snffAYaiYX1K691wxwnuLk1nLQq4wafiw7JDYEAWxNRr9BHwkqiyWq4ZDg3pgc1R7J\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mr5hNzrQodvcRT7S7Jo7TdrGF8o5QYPSsx\",\n \"pubkey\": \"tpubDA9GDAntyJu4vriftRQep2iT7d7ZJfsNNhMgXCsNZsa7J6Czt1WEyNE2WQkuqsWswafmx6yYmqQQei3HHUedeqiBhiMdHxWUzVZvohGLXgs\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mr9FzGLW7kH4t2vVJsqc98R9DNMnZT1PDZ\",\n \"pubkey\": \"tpubDA9GDAntyJu4LoaQBgqDM1xUkcUtRsS117uA9CDSmFrTR4GGi5X65VoUf7VDRE2oRKnrXDv2bNdfyMBJ23UQpcWhBHZhKM7GsbswhmhEw4T\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mrGjJdkoEE5okDJDVJjNPYRm8xJks7TYc1\",\n \"pubkey\": \"tpubDA9GDAntyJu4fT9pBRSPRketsXUkxLhvswEZEG4Fx1e99GDUmpJnRyZoiyN3PaE1ToWazfcx74VQoNqzfhMxDARiGQVPu6JZVcuRRxGAw7d\",\n \"Line truncated
},
{
"title": "List addresses in specified account",
"curl": "curl -d'{\"method\": \"address_list\", \"params\": {\"account_id\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\"}}' http://localhost:5279/",
"lbrynet": "lbrynet address list --account_id=\"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_list\", \"params\": {\"account_id\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mfeQWMvmtnuZnSpGwjNDy33jQvgy2nu4vR\",\n \"pubkey\": \"tpubDA9GDAntyJu4Ytag2HiGb2Hrmgtjga1oSRTdWNZz6Vh6mW2yWyMkhKtJS9rH3ctZzPFvFhenoTfoArgceQgaLSXXQATSa9r5iVjAWHHxpBc\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mhgyiqzXraHQvoYN4oRsnmZGeB5e27v7X6\",\n \"pubkey\": \"tpubDA9GDAntyJu56nZDL32W3uoYzpZQ3HuE5zDDzVnCzNzgH3fAaHx2p8PgX9oETY13FKHdiiN8zZEgZHxGks6B12exJigtntT9FQTPrYpwuKH\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"miXEEjwhrMsbL91dccqwTJeTkRmgDGSYoP\",\n \"pubkey\": \"tpubDA9GDAntyJu4NUN7zjtAZaH7SwJJGrNw3GGXpLXus5dTmGEcHUsuAC9M7tH5oeirCACaY4kWWwo6zEFFYt8xK6JgUSSR24ZwmcHsbPaCxNr\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mjhaqbLhpch3DebPyWr21ppDGLukn1YSeh\",\n \"pubkey\": \"tpubDA9GDAntyJu4cZWdAgJTwKrWNEXdbNPrydUPVLiURVv6DmDYRTAAAMMW4y7RXJkPYNofLKohDGNPmbV6yNwnxVijRhxkVNYY4Ei6amXvrVA\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mk6aLnMyWNce5z7pkAFjT7VKvgddRfpuPZ\",\n \"pubkey\": \"tpubDA9GDAntyJu4V1BUGVmutJZCuz1TtuzwidW2b7masz8qtFuZmpJ7HZvVy95TL1MQpszsmuK5KgmEXXRzAfg2xRRituyqqaKtQHjxxHnyXtz\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mkygHEMa1gckjft4HdnXdBCA2qNn8ocEnd\",\n \"pubkey\": \"tpubDA9GDAntyJu4juqLBa7brBP1W1x3G7XvPCTRqUsunQh7u2Ly3jmevsLu3BDmsFJUuwdLx38BTHa5ip6wVoFVqUinnp6EahBfd9uSDXZZrkM\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mmGWzcEtP4BYh2rxf82c9L7cdVyvbkxhfB\",\n \"pubkey\": \"tpubDA9GDAntyJu4XQhL61tDESr7XG7YnKJRzRM6hCvRxv4x3tMTqK2yv17k8qXWiVziW2jdFwbGpeVLkcdxonchVPj4beHsv8hRy1dfmipdrm3\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mn8SVfBD3117apKuXMVjVeefpeHVfni2xW\",\n \"pubkey\": \"tpubDA9GDAntyJu4QuRUc8EBJvTo74ZbvQiN1StbbZnFX6qBBCoVocV3VsFFC6SUteRFj2rJp2LGxUDXmQHcHqZa3LhFpKeCtguhimnxgKaYtYJ\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mnwPnyB24JZfXUqd7vn8MsMhmNTRkj4Amr\",\n \"pubkey\": \"tpubDA9GDAntyJu4LW5QvSz76VzXmRsAUoQ4otyRRnKz3yrANK2G39avPvQigzzVj1wVyYZxVqot7C6LjzdyFE5prYR49tcWJUYfFvqdnvy2FbG\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mo2ydnUzgxFX1YsZPuECeQxeRwiuR9haHK\",\n \"pubkey\": \"tpubDA9GDAntyJu4gTKzy4MShkNiFnhQxEZQ5S7y7nKtvhWFsxqQ8mGuSWCQJUGL4jdNcFFRU9neXyJaDjMZP3RuKTDXi5BFz6Ao7GFfc9cFmsn\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"moEwuQhAkg3hT7qhTjHXiFuf7KBcUhGzCt\",\n \"pubkey\": \"tpubDA9GDAntyJu52jXcb9gAsJXM1CVAabeFAktL9nw3yBoFWpE3m5mocdwDANmosEhdna2tUb2uuR6wBnFXR3RmQ3fsuHsEVucP3BcHquzKmXm\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"morR7jG1kXb7AbvQRXRYH554jpCnQkfXYg\",\n \"pubkey\": \"tpubDA9GDAntyJu4G59VFEdQaAoKs3LeNRP9rKTZ8a1rK5ocUPV8i8i9hbZiGbCgEFZiH3dGvf8Gstw7nbfxA5R5gum7Mf9GRa9vCi6xhXn7rPs\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mouye7ULsS8mZ6GDZ6t4LyNDKt1NR9YYxS\",\n \"pubkey\": \"tpubDA9GDAntyJu4wQF2sSaUSY4RpHuypUbKKbuVJz3Dyv4VZsnuMetXPVnx1RuGBgLAj8ARSqNe5xF9j6Y4JuBHca98YDS2DQxbzVbqsdDcAVw\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mpZtKoHsPTyPoUPdmhG6sDpj6AJeKWeB5g\",\n \"pubkey\": \"tpubDA9GDAntyJu4fHj1PXGSc2DLHTxwphZRVAg4qo8p56iUaigrzzgo3qSaeCEEMkKjUgBxy6oq8Y9Rfm6epyF7DTzcbMuYBRt8acTf4SAZpaT\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"mqKfz8h1dEwid46RueaL1RSZ6KAACn4iPw\",\n \"pubkey\": \"tpubDA9GDAntyJu4JPiW5aSsNcqLb49zqbKNLVZcMhDKF5vWyv5XRzHFtbwKXPfNUW9mX7ahKiC9qUMxtGVtJP9oBVupKZFifEGXDEwZvWvXWMP\",\n \"used_times\": 0\n },\n {\n \"account\": \"mue613K8x5kLXpsePncrd5xqSoRi7NXmYx\",\n \"address\": \"msSrvvj7mbVxFE65GQcGyTqfgjCqHGjRWS\",\n \"pubkey\": \"tpubDA9GDAntyJu4RA2NaDmVC8192ZULDVGbbsBFNv87jbjqfX6mtNHWVarfxJR9dEbxFivrJAfnggyg1ysVGWWa746mp4pXq9kKKG56HWnQDpJ\",\n \"Line truncated
"curl": "curl -d'{\"method\": \"address_list\", \"params\": {\"account_id\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\"}}' http://localhost:5279/",
"lbrynet": "lbrynet address list --account_id=\"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_list\", \"params\": {\"account_id\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mh9VwE8HKhw3QjPCPZh3PU6e3juobVGeME\",\n \"pubkey\": \"tpubDA9GDAntyJu4nEGYmLc4ihro5xv9bSSwfZTPEQQfN25mm2exgoUugfQE4ZMM3boheswEyS3zJMMYneaz2AuYowwhYFPZhYrPv5ktZz5xMQV\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mh9fMDTWpwF954grmVnzzntFSWXk8KYy8B\",\n \"pubkey\": \"tpubDA9GDAntyJu4L5oH2g4AeUbTqNd4mnJF7T1xamBiV5hJTwLdqPT3YsGZToqMEZvWu4266AyyraszWAybYcAPP8PJonQPj3J2odScqVUvvxd\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mj3pFoj1BLFA293quWByDf2WrSVn76Bvbz\",\n \"pubkey\": \"tpubDA9GDAntyJu4pLDopCn5sXCqmJSMD8f4J2mErt5E3pPmvY2o2xauN9wc2cgA217stad8Und2yumurTL5xpSqbnC95NC3wFik8VTqbWE9HbN\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mmKD7WwB8A86K7RAtf7ncr79wgbvzfsJpe\",\n \"pubkey\": \"tpubDA9GDAntyJu4N6C1Craod75L2Kf1dK2KDCS3Q2s2xxWFo2KGtp9xhMVLjwQzCVYwDDXT7ZG2uNCjthqEJZdSeGcH7WgBSYcpJkwBPciGyKn\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mmmGb7DUQec3QFrbi1m3MWC232phHGGDrX\",\n \"pubkey\": \"tpubDA9GDAntyJu53kygACiiUPY4Fm6Gf3AvGBk86noTQ6yZoczchTeiz49XnbaCHVnXM7tJRfnrUR73DUbAg4LMJNU5evYmbBfsuA87bn2U58M\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mnY7nggBwEtNAKhpYhQWzA1AfeFo7G5AyD\",\n \"pubkey\": \"tpubDA9GDAntyJu4VEy1YcEvFNLKNTWEZFdPM9CFeLoreu4d7cmtTeHcTMkdE4i2sw4YAi5saSd6NEY9oh9WgiLcApK3GrBaoNUeRtG5BZxAnwD\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"moK5kBNW2hTfUpNPe1ZaQLgEq4Z8N5cj1A\",\n \"pubkey\": \"tpubDA9GDAntyJu4dudWYrKMLH5k8xe7F9BfzEt1tE16AQgRfaaknKQmGz1Z8Bt4ws3ZgFoD5D8ZF5fW1ziHaC7cJvgNagsP7jCXN5DsVuwCe99\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"moRQq9jHEJ6sL9cX6wq4A7EKTh5f8n8U9h\",\n \"pubkey\": \"tpubDA9GDAntyJu4RWtNN1XU4ny3qgphTYxToGUQRHZgJoS29hz7UcmLmsTeDUeToyfckDz94okiNkE6oRHh3v71auGJV6rai5Sff2sQxk3mBGB\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"moRkYbPJKGS8ihvNaedGzKQcskudaGdo6j\",\n \"pubkey\": \"tpubDA9GDAntyJu4Fvmm66NdhqkSx2xZJTbjCPhu1zTECuxM5RCTzmuozN9VyAFg8uM3S3nt1EKQqMycTnBoNFTThNHRuWYNz5rH7E9Jx9MyCun\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mpqZ2sJifp18baqMntvEp3tgR8Kevo6vyV\",\n \"pubkey\": \"tpubDA9GDAntyJu4tboRaZAXEepzyJEDT29hxnu12gPpWoubZKEnM7XbbnenooLDtq6f7941UTEzkSrQs2ddRmEy14isbjgyHdvA163wcoMxrzN\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mpvW6Ck65nk9fNUmMGmSdPFxTX4CsGw8Eb\",\n \"pubkey\": \"tpubDA9GDAntyJu4qzJ1846T1k1ynJfKK6NcLRm2NKrMpqnHADxzWkod9D2pBC9TtY4mQLmrTcmt18kVJaWnqXEMDC2zTWccf1MFNddpyxdexZa\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mqEDRQrRnfFzaX6m2HSgdrCsCd7Vy6MDf2\",\n \"pubkey\": \"tpubDA9GDAntyJu4Q1UUt4uC8M5gp7phTP2E1FeU46kYzXb5VBGf5nU7cyUNsyPX2yLU76vp1ZLvkxJYCd6HeAptBfjE5T6YqfWtBYcKmGJLQ1q\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mqHzaj6FHs9AePR7W5fFLTik7YDUaFUZRx\",\n \"pubkey\": \"tpubDA9GDAntyJu4iQrq8iPMTQ1YBzjcnMQuLUArHUPJ3snffAYaiYX1K691wxwnuLk1nLQq4wafiw7JDYEAWxNRr9BHwkqiyWq4ZDg3pgc1R7J\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mr5hNzrQodvcRT7S7Jo7TdrGF8o5QYPSsx\",\n \"pubkey\": \"tpubDA9GDAntyJu4vriftRQep2iT7d7ZJfsNNhMgXCsNZsa7J6Czt1WEyNE2WQkuqsWswafmx6yYmqQQei3HHUedeqiBhiMdHxWUzVZvohGLXgs\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mr9FzGLW7kH4t2vVJsqc98R9DNMnZT1PDZ\",\n \"pubkey\": \"tpubDA9GDAntyJu4LoaQBgqDM1xUkcUtRsS117uA9CDSmFrTR4GGi5X65VoUf7VDRE2oRKnrXDv2bNdfyMBJ23UQpcWhBHZhKM7GsbswhmhEw4T\",\n \"used_times\": 0\n },\n {\n \"account\": \"mqEbuKqeB8k7Bar1Rg9wVXWYvhHq1cAprY\",\n \"address\": \"mrGjJdkoEE5okDJDVJjNPYRm8xJks7TYc1\",\n \"pubkey\": \"tpubDA9GDAntyJu4fT9pBRSPRketsXUkxLhvswEZEG4Fx1e99GDUmpJnRyZoiyN3PaE1ToWazfcx74VQoNqzfhMxDARiGQVPu6JZVcuRRxGAw7d\",\n \"Line truncated
}
]
},
@@ -905,7 +887,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\": \"mwzRFUu7mKpzqPvh1uaAQivEKd1wDUp41X\"\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": \"mvW5fF65d8WiGavNWjJcuQ6uRoa4AsSmLZ\"\n}"
}
]
}
@@ -955,10 +937,10 @@
"examples": [
{
"title": "Delete a blob",
"curl": "curl -d'{\"method\": \"blob_delete\", \"params\": {\"blob_hash\": \"c279adc5346f64aaa7135c83b6170ff7f2efdbbb76efc6ef6a346a07b505fe1860b6ad82b837c161b92bfe1e01907ee7\"}}' http://localhost:5279/",
"lbrynet": "lbrynet blob delete c279adc5346f64aaa7135c83b6170ff7f2efdbbb76efc6ef6a346a07b505fe1860b6ad82b837c161b92bfe1e01907ee7",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"blob_delete\", \"params\": {\"blob_hash\": \"c279adc5346f64aaa7135c83b6170ff7f2efdbbb76efc6ef6a346a07b505fe1860b6ad82b837c161b92bfe1e01907ee7\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": \"Deleted c279adc5346f64aaa7135c83b6170ff7f2efdbbb76efc6ef6a346a07b505fe1860b6ad82b837c161b92bfe1e01907ee7\"\n}"
"curl": "curl -d'{\"method\": \"blob_delete\", \"params\": {\"blob_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\"}}' http://localhost:5279/",
"lbrynet": "lbrynet blob delete d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"blob_delete\", \"params\": {\"blob_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": \"Deleted d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\"\n}"
}
]
},
@@ -1036,7 +1018,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 \"items\": [\n \"c279adc5346f64aaa7135c83b6170ff7f2efdbbb76efc6ef6a346a07b505fe1860b6ad82b837c161b92bfe1e01907ee7\",\n \"a6f0d442c48c63004f85151f3424da59c9e358680c60174202a174e1a9d2152e909cfca24ef182c0fcf44e91978a9121\",\n \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"9656965659aa2e1e3e4b07e2ad6047c13341769af4742ff1bca364682dbff614e3761cfb0a4fece29155331110611a10\"\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 4,\n \"total_pages\": 1\n }\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"64389e7847bc5fbf401d21133bac00ed788c65dba6154026924dbcb72fe6aa37f9646cf78d7841685d503d8a747c6624\",\n \"a035353881b061795536e73b3fb84361a601a90cfdd928531a7c4e133800f46173f8bfd97a929844e521851805ece1b2\",\n \"f71fb71a3ddd6bd2ce60c6941c2f9faf5317510bf7ea65d56286fa17066405522ba4fc4880d0982c7cfce84375bf8507\"\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 4,\n \"total_pages\": 1\n }\n}"
}
]
},
@@ -1117,10 +1099,10 @@
"examples": [
{
"title": "Abandon a channel claim",
"curl": "curl -d'{\"method\": \"channel_abandon\", \"params\": {\"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\", \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet channel abandon 20ccc609603f9c6f01d74f2d6a133867d2903fc2",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_abandon\", \"params\": {\"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\", \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001942c37d36793290feb0e2ab637e6da02b1eea67d85a872dff83c8b0c19a322ff000000006b48304502210097bf5a07e8051956c2f9291207c7cd5acb4becbb4057ceeff56f55cd00d34b2902200b99e51cb96ea088fd76a914348d8487e6e22c74edff84e4573f54572d9d426c01210353931cc595ec3293186c7f9d63a8e1b8aecc5cc4fd0e010092d2b40483213902ffffffff0134b7f505000000001976a9140bc6abe6b62ea58b85132979e66092310a33ab5588ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 9,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mgbDj6pkqZoTouwLRaAfCTueUTyZRHMCbB\",\n \"amount\": \"0.999893\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"5a1104a6f7094b070fe9b286204903e05c0982124436d9d68d8f3de26993033d\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000107\",\n \"total_input\": \"1.0\",\n \"total_output\": \"0.999893\",\n \"txid\": \"5a1104a6f7094b070fe9b286204903e05c0982124436d9d68d8f3de26993033d\"\n }\n}"
"curl": "curl -d'{\"method\": \"channel_abandon\", \"params\": {\"claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\", \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet channel abandon 5dc92b3ab696844e2e043f542b50a2dd0a95d6f2",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_abandon\", \"params\": {\"claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\", \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000112e4e8fb6fb977bea835761def95a4747bd712b2e0fce3301defbfd75af2e83e000000006a47304402202ccafb731d9f42ab097e655526e8956c53def70018fb441489ab5ac7401a6b1702200d8c1ada5636d42a0c57bccfe16e292b078aa199fe4cc9df8c14c6cc9aa4758801210368cfa299e5d7db0b87e2ea90267a40e7de62ff496eebd05fbda7265a4de27b33ffffffff0134b7f505000000001976a914c017140cff818203be7ed9eb831d516beeae380e88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mofqoKUmhmPTCoudQRXgjzGSDnCyJvZAZg\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"claim_op\": \"update\",\n \"confirmations\": 8,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"timestamp\": 1602862456,\n \"txid\": \"3ee8f25ad7bfef1d30e3fce0b212d77b74a495ef1d7635a8be77b96ffbe8e412\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200049b4cbe0f5275e7b1c170f458af09628ba75401fd95d0205ed9de9037b396f60936d555da2bc8dd09b1804b250f32d1bd07382bd3a4aaa2700b08b137b91f1159\",\n \"public_key_id\": \"mkVrRXQGgjhBaygCP3dNpbmtm5Yohno8q2\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"my2dgPteE6c6TiFWk8hcfijZut58dE5FM3\",\n \"amount\": \"0.999893\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"fe572f8d040b941d2a2b8c863111e6213ed47075d35add195d9718e8ef119fe0\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000107\",\n \"total_input\": \"1.0\",\n \"total_output\": \"0.999893\",\n \"txid\": \"fe572f8d040b941d2a2b8c863111e6213ed47075d35add195d9718e8ef119fe0\"\n }\n}"
}
]
},
@@ -1250,14 +1232,14 @@
"curl": "curl -d'{\"method\": \"channel_create\", \"params\": {\"name\": \"@channel\", \"bid\": \"1.0\", \"featured\": [], \"tags\": [], \"languages\": [], \"locations\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": 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\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001a2a08aed2135620a6c05793822961a98dc9cccb41eb629d6865dc29b2dccf0d0010000006b483045022100c5400dc6883d3a4bbc7856ce2398ce65cb1f3c78c7656898c5dc50a1e2becf2702206d1544c74b380cb5b5e2bbdabe19c15e9115f2cea5566eb9defba3a6b0f196fd012103755009dd0af23759ad72b338313e1f9635070afebd056af92a62a4f6cb5b0353ffffffff0200e1f5050000000084b508406368616e6e656c4c5d00125a0a583056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b866d7576a91433ad5a86909d2aeb60f6bb427cfaf9acfd51078e88acc462a029000000001976a9143941a8e680e7196066423b400ac8edd4549c35de88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mjRVJULUCxB7s3guxUriGqN5C7RFj6Fsxh\",\n \"amount\": \"7.999876\",\n \"confirmations\": 2,\n \"height\": 207,\n \"nout\": 1,\n \"timestamp\": 1621405355,\n \"txid\": \"d0f0cc2d9bc25d86d629b61eb4cc9cdc981a96223879056c0a623521ed8aa0a2\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"has_signing_key\": true,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": null,\n \"txid\": \"eb0a964da8ebe0a011047502489b4e3e6252caba7b4b1a88a2d207ba084e38bb\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mkjhU7Go11ZuCbGEp6edSr4At5CBDW23xH\",\n \"amount\": \"6.983769\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"eb0a964da8ebe0a011047502489b4e3e6252caba7b4b1a88a2d207ba084e38bb\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.016107\",\n \"total_input\": \"7.999876\",\n \"total_output\": \"7.983769\",\n \"txid\": \"eb0a964da8ebe0a011047502489b4e3e6252caba7b4b1a88a2d207ba084e38bb\"\n }\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000158533d2d042f919166ee2e1579846af0b49c4caf9db4cd82a7ca37362f374769010000006b483045022100b6ce1836a430d4394ddbf3dffa642a800b275729604725dbc1b7c6c81c56e53c02205a4fbfcc83265681ac90fc1e18676124371f746eb4d7b383a81e063cbcdee161012103d82be71a914cffdc96e54df3ee5e7b7e224078010ecc85fd19efd25a50f23a9fffffffff0200e1f5050000000084b508406368616e6e656c4c5d00125a0a583056301006072a8648ce3d020106052b8104000a034200049b4cbe0f5275e7b1c170f458af09628ba75401fd95d0205ed9de9037b396f60936d555da2bc8dd09b1804b250f32d1bd07382bd3a4aaa2700b08b137b91f11596d7576a914596f53ebf6552729fea4e2dbdc62e9662b8757c788acc462a029000000001976a91471452ebd78a856d51b47902e7224373cbfa308f488ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mxbsGa4jf99tDFJtiFtxyVJ7N3xPUsD9qo\",\n \"amount\": \"7.999876\",\n \"confirmations\": 2,\n \"height\": 207,\n \"nout\": 1,\n \"timestamp\": 1602862456,\n \"txid\": \"6947372f3637caa782cdb49daf4c9cb4f06a8479152eee6691912f042d3d5358\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mofqoKUmhmPTCoudQRXgjzGSDnCyJvZAZg\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"has_signing_key\": true,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"timestamp\": null,\n \"txid\": \"60a1a3111e5dd85cbc1040d931cbb09c86c078eeb11df6aebf5c5d8845e64629\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200049b4cbe0f5275e7b1c170f458af09628ba75401fd95d0205ed9de9037b396f60936d555da2bc8dd09b1804b250f32d1bd07382bd3a4aaa2700b08b137b91f1159\",\n \"public_key_id\": \"mkVrRXQGgjhBaygCP3dNpbmtm5Yohno8q2\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mqqsXcxFmcQBN6JFR1hRE4UtDYtDXp1u4f\",\n \"amount\": \"6.983769\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"60a1a3111e5dd85cbc1040d931cbb09c86c078eeb11df6aebf5c5d8845e64629\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.016107\",\n \"total_input\": \"7.999876\",\n \"total_output\": \"7.983769\",\n \"txid\": \"60a1a3111e5dd85cbc1040d931cbb09c86c078eeb11df6aebf5c5d8845e64629\"\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\", \"funding_account_ids\": [], \"preview\": false, \"blocking\": 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\", \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001942c37d36793290feb0e2ab637e6da02b1eea67d85a872dff83c8b0c19a322ff010000006b483045022100f3ffa25ac1f85a5401eab38c796a4bce7af42d230142617634731f22256662f102207373f746f06fefe1b8998dae433b8aa01816c388d1ffb2c03ba0cab67cc9cbe8012103f10e8cfbe3f83dfa4ac39c22d5bf47b3bbfa96c7a43ab951c0480b9956bf86dcffffffff0200e1f50500000000fd5001b50b406269676368616e6e656c4d25010012ab010a583056301006072a8648ce3d020106052b8104000a03420004cd1aec7a333657cd8e881fd07817e7ddf71edee513a954bc118608348a94945066d352a9397937944db8ae9f30c87d937a200ad5e9c549a306fe542d618def4d121663726561746f7240736d616c6c6d656469612e636f6d1a15687474703a2f2f736d616c6c6d656469612e636f6d22202a1e687474703a2f2f736d616c6c6d656469612e636f6d2f6c6f676f2e6a7067420b426967204368616e6e656c4a1e41206368616e6e656c2077697468206c6f7473206f6620766964656f732e52202a1e687474703a2f2f736d616c6c6d656469612e636f6d2f6c6f676f2e6a70675a056d757369635a0361727462050883011820620308ab016a0208206a0908e9011a044b6979766d7576a9144db8fdeee2015a424c5ba86fa68b7261bd8c33d088ace221d305000000001976a914a03ab95f4d7565fff8a76ff10859fb5fc0572f7f88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mxfwopyUuJxZQZXA7HvmGQXk9jVMLC97gr\",\n \"amount\": \"1.9993355\",\n \"confirmations\": 1,\n \"height\": 210,\n \"nout\": 1,\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mnbuwHjbMJRqWHMhqzo2Co8QvMLfA7RPzL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"d877c978e04ff30ccbd8133ca07116064430f4eb\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"has_signing_key\": true,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"@bigchannel\",\n \"normalized_name\": \"@bigchannel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@bigchannel#d877c978e04ff30ccbd8133ca07116064430f4eb\",\n \"timestamp\": null,\n \"txid\": \"2441d3f16fd54914ff30dc89c1ec086eb30d05f7252df041d4f2fb09a5f1a453\",\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\": \"3056301006072a8648ce3d020106052b8104000a03420004cd1aec7a333657cd8e881fd07817e7ddf71edee513a954bc118608348a94945066d352a9397937944db8ae9f30c87d937a200ad5e9c549a306fe542d618def4d\",\n \"public_key_id\": \"mwHUnTRHRMZRvQUK8h15HihHQ5Ujz3mybi\",\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\": \"mv8AkyC2tGywD9ARYqEkznnjM7gs8LG17A\",\n \"amount\": \"0.9772285\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"2441d3f16fd54914ff30dc89c1ec086eb30d05f7252df041d4f2fb09a5f1a453\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.022107\",\n \"total_input\": \"1.9993355\",\n \"total_output\": \"1.9772285\",\n \"txid\": \"2441d3f16fd54914ff30dc89c1ec086eb30d05f7252df041d4f2fb09a5f1a453\"\n }\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000112e4e8fb6fb977bea835761def95a4747bd712b2e0fce3301defbfd75af2e83e010000006b483045022100f400356b4588a1106ca630f418e6737d39da0f522e09cbce2190ebac9d1713ac0220423d8cde9e4ede9985c47606c04bb941dea7bf2e6644f5f79b6eb169e50e8194012102dce4926e5905334758fab58a5ac2e143f6410c9bea71d9a4fd51560a8603ce0cffffffff0200e1f50500000000fd5001b50b406269676368616e6e656c4d25010012ab010a583056301006072a8648ce3d020106052b8104000a034200049909f498c2b3c3c649d91778426bfcf8dd895943e15567956a490a95b66876d7535efb3dd402c5d359c68bbebdc45118be228dfa1a553f556ce3bff01b6eb7fd121663726561746f7240736d616c6c6d656469612e636f6d1a15687474703a2f2f736d616c6c6d656469612e636f6d22202a1e687474703a2f2f736d616c6c6d656469612e636f6d2f6c6f676f2e6a7067420b426967204368616e6e656c4a1e41206368616e6e656c2077697468206c6f7473206f6620766964656f732e52202a1e687474703a2f2f736d616c6c6d656469612e636f6d2f6c6f676f2e6a70675a056d757369635a0361727462050883011820620308ab016a0208206a0908e9011a044b6979766d7576a914a45f9e7b68cd294a21fa75ee23c7fdfeb35f237b88ace221d305000000001976a9149ac52fa70e513b792b36846c00a6b23b4e72ee9988ac00000000\",\n \"inputs\": [\n {\n \"address\": \"moH3m15AhmpjZVZUwYEQciKNAnBqug5VwM\",\n \"amount\": \"1.9993355\",\n \"confirmations\": 1,\n \"height\": 210,\n \"nout\": 1,\n \"timestamp\": 1602862456,\n \"txid\": \"3ee8f25ad7bfef1d30e3fce0b212d77b74a495ef1d7635a8be77b96ffbe8e412\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mvW5fF65d8WiGavNWjJcuQ6uRoa4AsSmLZ\",\n \"amount\": \"1.0\",\n \"claim_id\": \"9289606d85caabe4c8adcc142eda730022d1b3bd\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"has_signing_key\": true,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"@bigchannel\",\n \"normalized_name\": \"@bigchannel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@bigchannel#9289606d85caabe4c8adcc142eda730022d1b3bd\",\n \"timestamp\": null,\n \"txid\": \"cc77ce3035437425d1cd14b48ded892f1283f13d63e9756d1f589bf35d214347\",\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\": \"3056301006072a8648ce3d020106052b8104000a034200049909f498c2b3c3c649d91778426bfcf8dd895943e15567956a490a95b66876d7535efb3dd402c5d359c68bbebdc45118be228dfa1a553f556ce3bff01b6eb7fd\",\n \"public_key_id\": \"n3N9RDkMdpvemT83QfEWuJ1es1uNyVHydK\",\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\": \"mudJaL41pUBkS3VRifB26xD4YLNWDNVrau\",\n \"amount\": \"0.9772285\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"cc77ce3035437425d1cd14b48ded892f1283f13d63e9756d1f589bf35d214347\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.022107\",\n \"total_input\": \"1.9993355\",\n \"total_output\": \"1.9772285\",\n \"txid\": \"cc77ce3035437425d1cd14b48ded892f1283f13d63e9756d1f589bf35d214347\"\n }\n}"
}
]
},
@@ -1379,55 +1361,17 @@
"curl": "curl -d'{\"method\": \"channel_list\", \"params\": {\"name\": [], \"claim_id\": [], \"is_spent\": false, \"resolve\": false, \"no_totals\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet channel list",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_list\", \"params\": {\"name\": [], \"claim_id\": [], \"is_spent\": false, \"resolve\": false, \"no_totals\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"has_signing_key\": true,\n \"height\": 209,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"eb0a964da8ebe0a011047502489b4e3e6252caba7b4b1a88a2d207ba084e38bb\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\"\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\": \"mofqoKUmhmPTCoudQRXgjzGSDnCyJvZAZg\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"has_signing_key\": true,\n \"height\": 209,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"timestamp\": 1602862456,\n \"txid\": \"60a1a3111e5dd85cbc1040d931cbb09c86c078eeb11df6aebf5c5d8845e64629\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200049b4cbe0f5275e7b1c170f458af09628ba75401fd95d0205ed9de9037b396f60936d555da2bc8dd09b1804b250f32d1bd07382bd3a4aaa2700b08b137b91f1159\",\n \"public_key_id\": \"mkVrRXQGgjhBaygCP3dNpbmtm5Yohno8q2\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
},
{
"title": "Paginate your channel claims",
"curl": "curl -d'{\"method\": \"channel_list\", \"params\": {\"name\": [], \"claim_id\": [], \"is_spent\": false, \"page\": 1, \"page_size\": 20, \"resolve\": false, \"no_totals\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet channel list --page=1 --page_size=20",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_list\", \"params\": {\"name\": [], \"claim_id\": [], \"is_spent\": false, \"page\": 1, \"page_size\": 20, \"resolve\": false, \"no_totals\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"has_signing_key\": true,\n \"height\": 209,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"eb0a964da8ebe0a011047502489b4e3e6252caba7b4b1a88a2d207ba084e38bb\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\"\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\": \"mofqoKUmhmPTCoudQRXgjzGSDnCyJvZAZg\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"has_signing_key\": true,\n \"height\": 209,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"timestamp\": 1602862456,\n \"txid\": \"60a1a3111e5dd85cbc1040d931cbb09c86c078eeb11df6aebf5c5d8845e64629\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200049b4cbe0f5275e7b1c170f458af09628ba75401fd95d0205ed9de9037b396f60936d555da2bc8dd09b1804b250f32d1bd07382bd3a4aaa2700b08b137b91f1159\",\n \"public_key_id\": \"mkVrRXQGgjhBaygCP3dNpbmtm5Yohno8q2\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
}
]
},
{
"name": "channel_sign",
"description": "Signs data using the specified channel signing key.",
"arguments": [
{
"name": "channel_name",
"type": "str",
"description": "name of channel used to sign (or use channel id)",
"is_required": false
},
{
"name": "channel_id",
"type": "str",
"description": "claim id of channel used to sign (or use channel name)",
"is_required": false
},
{
"name": "hexdata",
"type": "str",
"description": "data to sign, encoded as hexadecimal",
"is_required": false
},
{
"name": "channel_account_id",
"type": "str",
"description": "one or more account ids for accounts to look in for channel certificates, defaults to all accounts.",
"is_required": false
},
{
"name": "wallet_id",
"type": "str",
"description": "restrict operation to specific wallet",
"is_required": false
}
],
"returns": "(dict) Signature if successfully made, (None) or an error otherwise\n {\n \"signature\": (str) The signature of the comment,\n \"signing_ts\": (str) The timestamp used to sign the comment,\n }",
"examples": []
},
{
"name": "channel_update",
"description": "Update an existing channel claim.",
@@ -1581,10 +1525,10 @@
"examples": [
{
"title": "Update a channel claim",
"curl": "curl -d'{\"method\": \"channel_update\", \"params\": {\"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\", \"title\": \"New Channel\", \"featured\": [], \"clear_featured\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"new_signing_key\": false, \"funding_account_ids\": [], \"preview\": false, \"blocking\": false, \"replace\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet channel update 20ccc609603f9c6f01d74f2d6a133867d2903fc2 --title=\"New Channel\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_update\", \"params\": {\"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\", \"title\": \"New Channel\", \"featured\": [], \"clear_featured\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"new_signing_key\": false, \"funding_account_ids\": [], \"preview\": false, \"blocking\": false, \"replace\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000002bb384e08ba07d2a2881a4b7bbaca52623e4e9b4802750411a0e0eba84d960aeb000000006b483045022100f86030e4a9e901fcfd8ac8b89d7341ae03f9ef73a7019c282ffedcc6f4c24e0502206e6f7ad8b6eff9b6ea13f6ac1866af80d5ab132a4bad19a9afd8ad407c268ef001210353931cc595ec3293186c7f9d63a8e1b8aecc5cc4fd0e010092d2b40483213902fffffffff5b85f1547c5ec0ed1940d5fe14da6d48f86948c2a5dd1bc4abbfa103d080dac000000006b483045022100816dd9784eb76b97ed127984f5d42b19a8368de3d5a7ef79733500662cb28c39022025f20e6d5820987af30253bd8002940e54e177b1ee188e0422cb939e6fc90af701210211196ea4ea6217ea95455ee10e84bb9d5fc615e7b7e852a1a34e04acb50b108dffffffff0200e1f50500000000a6b708406368616e6e656c14c23f90d26738136a2d4fd7016f9c3f6009c6cc204c6a00125a0a583056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86420b4e6577204368616e6e656c6d6d76a91433ad5a86909d2aeb60f6bb427cfaf9acfd51078e88ac6ebeea0b000000001976a914bc2d79ca1969aceba4290c8f8f04677062d2376b88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"has_signing_key\": true,\n \"height\": 209,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"eb0a964da8ebe0a011047502489b4e3e6252caba7b4b1a88a2d207ba084e38bb\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"ms6EPFDDfSb3gVMgyBZ5drGuYH9uqvvmPq\",\n \"amount\": \"1.999604\",\n \"confirmations\": 1,\n \"height\": 209,\n \"nout\": 0,\n \"timestamp\": 1621405355,\n \"txid\": \"ac0d083d10fabb4abcd15d2a8c94868fd4a64de15f0d94d10eecc547155fb8f5\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": -2,\n \"has_signing_key\": true,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": null,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mxfwopyUuJxZQZXA7HvmGQXk9jVMLC97gr\",\n \"amount\": \"1.9993355\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.0002685\",\n \"total_input\": \"2.999604\",\n \"total_output\": \"2.9993355\",\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\"\n }\n}"
"curl": "curl -d'{\"method\": \"channel_update\", \"params\": {\"claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\", \"title\": \"New Channel\", \"featured\": [], \"clear_featured\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"new_signing_key\": false, \"funding_account_ids\": [], \"preview\": false, \"blocking\": false, \"replace\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet channel update 5dc92b3ab696844e2e043f542b50a2dd0a95d6f2 --title=\"New Channel\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_update\", \"params\": {\"claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\", \"title\": \"New Channel\", \"featured\": [], \"clear_featured\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"new_signing_key\": false, \"funding_account_ids\": [], \"preview\": false, \"blocking\": false, \"replace\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000022946e645885d5cbfaef61db1ee78c0869cb0cb31d94010bc5cd85d1e11a3a160000000006a47304402206468e077adeba3c21673ed78920c859588722d3a87fb732dad55f2517a5f6c8402206e310605a42dd6292f9fdd28fd9d98641f8d1f6449c28f16a99c8d917341033b01210368cfa299e5d7db0b87e2ea90267a40e7de62ff496eebd05fbda7265a4de27b33ffffffff16499bbabc8965d2f65610b5be2856939351adf0463c345ef047dc4a1e4b414b000000006a47304402207ec9d5cca07d5f1718c2186318362332b26023bd11b0c25a847bdb45941be5b70220571fa748c26741777916e639d6e1d43b00141f24f150315abbc086640ebb261d012103386e2ac35f59e8ad77be0888e75f2fd52963138f53f1accb21ceef9f45abc74effffffff0200e1f50500000000a6b708406368616e6e656c14f2d6950adda2502b543f042e4e8496b63a2bc95d4c6a00125a0a583056301006072a8648ce3d020106052b8104000a034200049b4cbe0f5275e7b1c170f458af09628ba75401fd95d0205ed9de9037b396f60936d555da2bc8dd09b1804b250f32d1bd07382bd3a4aaa2700b08b137b91f1159420b4e6577204368616e6e656c6d6d76a914596f53ebf6552729fea4e2dbdc62e9662b8757c788ac6ebeea0b000000001976a914551fbe93b46bf72e02981bc529201b0ab6016ddf88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mofqoKUmhmPTCoudQRXgjzGSDnCyJvZAZg\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"has_signing_key\": true,\n \"height\": 209,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"timestamp\": 1602862456,\n \"txid\": \"60a1a3111e5dd85cbc1040d931cbb09c86c078eeb11df6aebf5c5d8845e64629\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200049b4cbe0f5275e7b1c170f458af09628ba75401fd95d0205ed9de9037b396f60936d555da2bc8dd09b1804b250f32d1bd07382bd3a4aaa2700b08b137b91f1159\",\n \"public_key_id\": \"mkVrRXQGgjhBaygCP3dNpbmtm5Yohno8q2\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mkwDGRHqKvQXW9zwfumqrJUhiBDWbzPr1M\",\n \"amount\": \"1.999604\",\n \"confirmations\": 1,\n \"height\": 209,\n \"nout\": 0,\n \"timestamp\": 1602862456,\n \"txid\": \"4b414b1e4adc47f05e343c46f0ad5193935628beb51056f6d26589bcba9b4916\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mofqoKUmhmPTCoudQRXgjzGSDnCyJvZAZg\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"claim_op\": \"update\",\n \"confirmations\": -2,\n \"has_signing_key\": true,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"timestamp\": null,\n \"txid\": \"3ee8f25ad7bfef1d30e3fce0b212d77b74a495ef1d7635a8be77b96ffbe8e412\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200049b4cbe0f5275e7b1c170f458af09628ba75401fd95d0205ed9de9037b396f60936d555da2bc8dd09b1804b250f32d1bd07382bd3a4aaa2700b08b137b91f1159\",\n \"public_key_id\": \"mkVrRXQGgjhBaygCP3dNpbmtm5Yohno8q2\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"moH3m15AhmpjZVZUwYEQciKNAnBqug5VwM\",\n \"amount\": \"1.9993355\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"3ee8f25ad7bfef1d30e3fce0b212d77b74a495ef1d7635a8be77b96ffbe8e412\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.0002685\",\n \"total_input\": \"2.999604\",\n \"total_output\": \"2.9993355\",\n \"txid\": \"3ee8f25ad7bfef1d30e3fce0b212d77b74a495ef1d7635a8be77b96ffbe8e412\"\n }\n}"
}
]
}
@@ -1639,18 +1583,6 @@
"description": "restrict results to specific wallet",
"is_required": false
},
{
"name": "has_source",
"type": "bool",
"description": "list claims containing a source field",
"is_required": false
},
{
"name": "has_no_source",
"type": "bool",
"description": "list claims not containing a source field",
"is_required": false
},
{
"name": "page",
"type": "int",
@@ -1684,7 +1616,7 @@
{
"name": "include_received_tips",
"type": "bool",
"description": "calculate the amount of tips received for claim outputs",
"description": "calculate the amount of tips recieved for claim outputs",
"is_required": false
}
],
@@ -1692,17 +1624,17 @@
"examples": [
{
"title": "List all your claims",
"curl": "curl -d'{\"method\": \"claim_list\", \"params\": {\"claim_type\": [], \"claim_id\": [], \"name\": [], \"is_spent\": false, \"channel_id\": [], \"has_source\": false, \"has_no_source\": false, \"resolve\": false, \"no_totals\": false, \"include_received_tips\": false}}' http://localhost:5279/",
"curl": "curl -d'{\"method\": \"claim_list\", \"params\": {\"claim_type\": [], \"claim_id\": [], \"name\": [], \"is_spent\": false, \"channel_id\": [], \"resolve\": false, \"no_totals\": false, \"include_received_tips\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet claim list",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_list\", \"params\": {\"claim_type\": [], \"claim_id\": [], \"name\": [], \"is_spent\": false, \"channel_id\": [], \"has_source\": false, \"has_no_source\": false, \"resolve\": false, \"no_totals\": false, \"include_received_tips\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1621405356,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\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}"
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_list\", \"params\": {\"claim_type\": [], \"claim_id\": [], \"name\": [], \"is_spent\": false, \"channel_id\": [], \"resolve\": false, \"no_totals\": false, \"include_received_tips\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mzNC6CMEetGVw6QDGChpUM3HfV7DpWGZ7R\",\n \"amount\": \"1.0\",\n \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"signing_channel\": {\n \"address\": \"mofqoKUmhmPTCoudQRXgjzGSDnCyJvZAZg\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"timestamp\": 1602862456,\n \"txid\": \"3ee8f25ad7bfef1d30e3fce0b212d77b74a495ef1d7635a8be77b96ffbe8e412\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200049b4cbe0f5275e7b1c170f458af09628ba75401fd95d0205ed9de9037b396f60936d555da2bc8dd09b1804b250f32d1bd07382bd3a4aaa2700b08b137b91f1159\",\n \"public_key_id\": \"mkVrRXQGgjhBaygCP3dNpbmtm5Yohno8q2\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1602862457,\n \"txid\": \"c620b71698533d88efa10c80d79a30b74464214cb0d893ec5ab4ec1c37d1676e\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpk0n0x2sb\",\n \"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mofqoKUmhmPTCoudQRXgjzGSDnCyJvZAZg\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"timestamp\": 1602862456,\n \"txid\": \"3ee8f25ad7bfef1d30e3fce0b212d77b74a495ef1d7635a8be77b96ffbe8e412\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200049b4cbe0f5275e7b1c170f458af09628ba75401fd95d0205ed9de9037b396f60936d555da2bc8dd09b1804b250f32d1bd07382bd3a4aaa2700b08b137b91f1159\",\n \"public_key_id\": \"mkVrRXQGgjhBaygCP3dNpbmtm5Yohno8q2\",\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}"
},
{
"title": "Paginate your claims",
"curl": "curl -d'{\"method\": \"claim_list\", \"params\": {\"claim_type\": [], \"claim_id\": [], \"name\": [], \"is_spent\": false, \"channel_id\": [], \"has_source\": false, \"has_no_source\": false, \"page\": 1, \"page_size\": 20, \"resolve\": false, \"no_totals\": false, \"include_received_tips\": false}}' http://localhost:5279/",
"curl": "curl -d'{\"method\": \"claim_list\", \"params\": {\"claim_type\": [], \"claim_id\": [], \"name\": [], \"is_spent\": false, \"channel_id\": [], \"page\": 1, \"page_size\": 20, \"resolve\": false, \"no_totals\": false, \"include_received_tips\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet claim list --page=1 --page_size=20",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_list\", \"params\": {\"claim_type\": [], \"claim_id\": [], \"name\": [], \"is_spent\": false, \"channel_id\": [], \"has_source\": false, \"has_no_source\": false, \"page\": 1, \"page_size\": 20, \"resolve\": false, \"no_totals\": false, \"include_received_tips\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1621405356,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\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}"
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_list\", \"params\": {\"claim_type\": [], \"claim_id\": [], \"name\": [], \"is_spent\": false, \"channel_id\": [], \"page\": 1, \"page_size\": 20, \"resolve\": false, \"no_totals\": false, \"include_received_tips\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mzNC6CMEetGVw6QDGChpUM3HfV7DpWGZ7R\",\n \"amount\": \"1.0\",\n \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"signing_channel\": {\n \"address\": \"mofqoKUmhmPTCoudQRXgjzGSDnCyJvZAZg\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"timestamp\": 1602862456,\n \"txid\": \"3ee8f25ad7bfef1d30e3fce0b212d77b74a495ef1d7635a8be77b96ffbe8e412\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200049b4cbe0f5275e7b1c170f458af09628ba75401fd95d0205ed9de9037b396f60936d555da2bc8dd09b1804b250f32d1bd07382bd3a4aaa2700b08b137b91f1159\",\n \"public_key_id\": \"mkVrRXQGgjhBaygCP3dNpbmtm5Yohno8q2\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1602862457,\n \"txid\": \"c620b71698533d88efa10c80d79a30b74464214cb0d893ec5ab4ec1c37d1676e\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpk0n0x2sb\",\n \"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mofqoKUmhmPTCoudQRXgjzGSDnCyJvZAZg\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"timestamp\": 1602862456,\n \"txid\": \"3ee8f25ad7bfef1d30e3fce0b212d77b74a495ef1d7635a8be77b96ffbe8e412\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200049b4cbe0f5275e7b1c170f458af09628ba75401fd95d0205ed9de9037b396f60936d555da2bc8dd09b1804b250f32d1bd07382bd3a4aaa2700b08b137b91f1159\",\n \"public_key_id\": \"mkVrRXQGgjhBaygCP3dNpbmtm5Yohno8q2\",\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}"
}
]
},
@@ -1899,7 +1831,7 @@
{
"name": "claim_type",
"type": "str",
"description": "filter by 'channel', 'stream', 'repost' or 'collection'",
"description": "filter by 'channel', 'stream' or 'unknown'",
"is_required": false
},
{
@@ -2013,7 +1945,7 @@
{
"name": "wallet_id",
"type": "str",
"description": "wallet to check for claim purchase receipts",
"description": "wallet to check for claim purchase reciepts",
"is_required": false
},
{
@@ -2028,24 +1960,6 @@
"description": "lookup and include a boolean indicating if claim being resolved is yours",
"is_required": false
},
{
"name": "remove_duplicates",
"type": "bool",
"description": "removes duplicated content from search by picking either the original claim or the oldest matching repost",
"is_required": false
},
{
"name": "has_source",
"type": "bool",
"description": "find claims containing a source field",
"is_required": false
},
{
"name": "has_no_source",
"type": "bool",
"description": "find claims not containing a source field",
"is_required": false
},
{
"name": "new_sdk_server",
"type": "str",
@@ -2057,17 +1971,17 @@
"examples": [
{
"title": "Search for all claims in channel",
"curl": "curl -d'{\"method\": \"claim_search\", \"params\": {\"claim_ids\": [], \"channel\": \"@channel\", \"channel_ids\": [], \"not_channel_ids\": [], \"has_channel_signature\": false, \"valid_channel_signature\": false, \"invalid_channel_signature\": false, \"is_controlling\": false, \"stream_types\": [], \"media_types\": [], \"any_tags\": [], \"all_tags\": [], \"not_tags\": [], \"any_languages\": [], \"all_languages\": [], \"not_languages\": [], \"any_locations\": [], \"all_locations\": [], \"not_locations\": [], \"order_by\": [], \"no_totals\": false, \"include_purchase_receipt\": false, \"include_is_my_output\": false, \"remove_duplicates\": false, \"has_source\": false, \"has_no_source\": false}}' http://localhost:5279/",
"curl": "curl -d'{\"method\": \"claim_search\", \"params\": {\"claim_ids\": [], \"channel\": \"@channel\", \"channel_ids\": [], \"not_channel_ids\": [], \"has_channel_signature\": false, \"valid_channel_signature\": false, \"invalid_channel_signature\": false, \"is_controlling\": false, \"stream_types\": [], \"media_types\": [], \"any_tags\": [], \"all_tags\": [], \"not_tags\": [], \"any_languages\": [], \"all_languages\": [], \"not_languages\": [], \"any_locations\": [], \"all_locations\": [], \"not_locations\": [], \"order_by\": [], \"include_purchase_receipt\": false, \"include_is_my_output\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet claim search --channel=@channel",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_search\", \"params\": {\"claim_ids\": [], \"channel\": \"@channel\", \"channel_ids\": [], \"not_channel_ids\": [], \"has_channel_signature\": false, \"valid_channel_signature\": false, \"invalid_channel_signature\": false, \"is_controlling\": false, \"stream_types\": [], \"media_types\": [], \"any_tags\": [], \"all_tags\": [], \"not_tags\": [], \"any_languages\": [], \"all_languages\": [], \"not_languages\": [], \"any_locations\": [], \"all_locations\": [], \"not_locations\": [], \"order_by\": [], \"no_totals\": false, \"include_purchase_receipt\": false, \"include_is_my_output\": false, \"remove_duplicates\": false, \"has_source\": false, \"has_no_source\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blocked\": {\n \"channels\": [],\n \"total\": 0\n },\n \"items\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#2/astream#e\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"meta\": {\n \"activation_height\": 213,\n \"creation_height\": 213,\n \"creation_timestamp\": 1621405356,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263187,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 213,\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#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"short_url\": \"lbry://astream#e\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#2\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": false,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 209,\n \"claims_in_channel\": 1,\n \"creation_height\": 209,\n \"creation_timestamp\": 1621405355,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263183,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 209,\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#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"short_url\": \"lbry://@channel#2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1621405356,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_search\", \"params\": {\"claim_ids\": [], \"channel\": \"@channel\", \"channel_ids\": [], \"not_channel_ids\": [], \"has_channel_signature\": false, \"valid_channel_signature\": false, \"invalid_channel_signature\": false, \"is_controlling\": false, \"stream_types\": [], \"media_types\": [], \"any_tags\": [], \"all_tags\": [], \"not_tags\": [], \"any_languages\": [], \"all_languages\": [], \"not_languages\": [], \"any_locations\": [], \"all_locations\": [], \"not_locations\": [], \"order_by\": [], \"include_purchase_receipt\": false, \"include_is_my_output\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blocked\": {\n \"channels\": [],\n \"total\": 0\n },\n \"items\": [\n {\n \"address\": \"mzNC6CMEetGVw6QDGChpUM3HfV7DpWGZ7R\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#5/astream#f\",\n \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"meta\": {\n \"activation_height\": 213,\n \"creation_height\": 213,\n \"creation_timestamp\": 1602862457,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263187,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 213,\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#fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"short_url\": \"lbry://astream#f\",\n \"signing_channel\": {\n \"address\": \"mofqoKUmhmPTCoudQRXgjzGSDnCyJvZAZg\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#5\",\n \"claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": false,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 209,\n \"claims_in_channel\": 1,\n \"creation_height\": 209,\n \"creation_timestamp\": 1602862456,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263183,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 209,\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#5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"short_url\": \"lbry://@channel#5\",\n \"timestamp\": 1602862456,\n \"txid\": \"3ee8f25ad7bfef1d30e3fce0b212d77b74a495ef1d7635a8be77b96ffbe8e412\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200049b4cbe0f5275e7b1c170f458af09628ba75401fd95d0205ed9de9037b396f60936d555da2bc8dd09b1804b250f32d1bd07382bd3a4aaa2700b08b137b91f1159\",\n \"public_key_id\": \"mkVrRXQGgjhBaygCP3dNpbmtm5Yohno8q2\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1602862457,\n \"txid\": \"c620b71698533d88efa10c80d79a30b74464214cb0d893ec5ab4ec1c37d1676e\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpk0n0x2sb\",\n \"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
},
{
"title": "Search for claims matching a name",
"curl": "curl -d'{\"method\": \"claim_search\", \"params\": {\"name\": \"astream\", \"claim_ids\": [], \"channel_ids\": [], \"not_channel_ids\": [], \"has_channel_signature\": false, \"valid_channel_signature\": false, \"invalid_channel_signature\": false, \"is_controlling\": false, \"stream_types\": [], \"media_types\": [], \"any_tags\": [], \"all_tags\": [], \"not_tags\": [], \"any_languages\": [], \"all_languages\": [], \"not_languages\": [], \"any_locations\": [], \"all_locations\": [], \"not_locations\": [], \"order_by\": [], \"no_totals\": false, \"include_purchase_receipt\": false, \"include_is_my_output\": false, \"remove_duplicates\": false, \"has_source\": false, \"has_no_source\": false}}' http://localhost:5279/",
"curl": "curl -d'{\"method\": \"claim_search\", \"params\": {\"name\": \"astream\", \"claim_ids\": [], \"channel_ids\": [], \"not_channel_ids\": [], \"has_channel_signature\": false, \"valid_channel_signature\": false, \"invalid_channel_signature\": false, \"is_controlling\": false, \"stream_types\": [], \"media_types\": [], \"any_tags\": [], \"all_tags\": [], \"not_tags\": [], \"any_languages\": [], \"all_languages\": [], \"not_languages\": [], \"any_locations\": [], \"all_locations\": [], \"not_locations\": [], \"order_by\": [], \"include_purchase_receipt\": false, \"include_is_my_output\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet claim search --name=\"astream\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_search\", \"params\": {\"name\": \"astream\", \"claim_ids\": [], \"channel_ids\": [], \"not_channel_ids\": [], \"has_channel_signature\": false, \"valid_channel_signature\": false, \"invalid_channel_signature\": false, \"is_controlling\": false, \"stream_types\": [], \"media_types\": [], \"any_tags\": [], \"all_tags\": [], \"not_tags\": [], \"any_languages\": [], \"all_languages\": [], \"not_languages\": [], \"any_locations\": [], \"all_locations\": [], \"not_locations\": [], \"order_by\": [], \"no_totals\": false, \"include_purchase_receipt\": false, \"include_is_my_output\": false, \"remove_duplicates\": false, \"has_source\": false, \"has_no_source\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blocked\": {\n \"channels\": [],\n \"total\": 0\n },\n \"items\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#2/astream#e\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"meta\": {\n \"activation_height\": 213,\n \"creation_height\": 213,\n \"creation_timestamp\": 1621405356,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263187,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 213,\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#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"short_url\": \"lbry://astream#e\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#2\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": false,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 209,\n \"claims_in_channel\": 1,\n \"creation_height\": 209,\n \"creation_timestamp\": 1621405355,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263183,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 209,\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#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"short_url\": \"lbry://@channel#2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1621405356,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_search\", \"params\": {\"name\": \"astream\", \"claim_ids\": [], \"channel_ids\": [], \"not_channel_ids\": [], \"has_channel_signature\": false, \"valid_channel_signature\": false, \"invalid_channel_signature\": false, \"is_controlling\": false, \"stream_types\": [], \"media_types\": [], \"any_tags\": [], \"all_tags\": [], \"not_tags\": [], \"any_languages\": [], \"all_languages\": [], \"not_languages\": [], \"any_locations\": [], \"all_locations\": [], \"not_locations\": [], \"order_by\": [], \"include_purchase_receipt\": false, \"include_is_my_output\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blocked\": {\n \"channels\": [],\n \"total\": 0\n },\n \"items\": [\n {\n \"address\": \"mzNC6CMEetGVw6QDGChpUM3HfV7DpWGZ7R\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#5/astream#f\",\n \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"meta\": {\n \"activation_height\": 213,\n \"creation_height\": 213,\n \"creation_timestamp\": 1602862457,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263187,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 213,\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#fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"short_url\": \"lbry://astream#f\",\n \"signing_channel\": {\n \"address\": \"mofqoKUmhmPTCoudQRXgjzGSDnCyJvZAZg\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#5\",\n \"claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": false,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 209,\n \"claims_in_channel\": 1,\n \"creation_height\": 209,\n \"creation_timestamp\": 1602862456,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263183,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 209,\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#5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"short_url\": \"lbry://@channel#5\",\n \"timestamp\": 1602862456,\n \"txid\": \"3ee8f25ad7bfef1d30e3fce0b212d77b74a495ef1d7635a8be77b96ffbe8e412\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200049b4cbe0f5275e7b1c170f458af09628ba75401fd95d0205ed9de9037b396f60936d555da2bc8dd09b1804b250f32d1bd07382bd3a4aaa2700b08b137b91f1159\",\n \"public_key_id\": \"mkVrRXQGgjhBaygCP3dNpbmtm5Yohno8q2\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1602862457,\n \"txid\": \"c620b71698533d88efa10c80d79a30b74464214cb0d893ec5ab4ec1c37d1676e\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpk0n0x2sb\",\n \"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
}
]
}
@@ -2146,7 +2060,7 @@
"name": "claims",
"type": "list",
"description": "claim ids to be included in the collection",
"is_required": false
"is_required": true
},
{
"name": "allow_duplicate_name",
@@ -2196,24 +2110,6 @@
"description": "thumbnail url",
"is_required": false
},
{
"name": "channel_id",
"type": "str",
"description": "claim id of the publisher channel",
"is_required": false
},
{
"name": "channel_name",
"type": "str",
"description": "name of the publisher channel",
"is_required": false
},
{
"name": "channel_account_id",
"type": "str",
"description": "one or more account ids for accounts to look in for channel certificates, defaults to all accounts.",
"is_required": false
},
{
"name": "account_id",
"type": "str",
@@ -2252,26 +2148,12 @@
}
],
"returns": " {\n \"txid\": \"hash of transaction in hex\",\n \"height\": \"block where transaction was recorded\",\n \"inputs\": [\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_received\": \"true if txo was sent from external account to this account\",\n \"is_spent\": \"true if txo is spent\",\n \"is_mine\": \"payment to one of your accounts, only available when it can be determined\",\n \"type\": \"one of 'claim', 'support' or 'purchase'\",\n \"name\": \"when type is 'claim' or 'support', this is the claim name\",\n \"claim_id\": \"when type is 'claim', 'support' or 'purchase', 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 \"claim\": \"for purchase outputs only, metadata of purchased claim\",\n \"reposted_claim\": \"for repost claims only, metadata of claim being reposted\",\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 \"purchase_receipt\": \"metadata for the purchase transaction associated with this claim\"\n }\n ],\n \"outputs\": [\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_received\": \"true if txo was sent from external account to this account\",\n \"is_spent\": \"true if txo is spent\",\n \"is_mine\": \"payment to one of your accounts, only available when it can be determined\",\n \"type\": \"one of 'claim', 'support' or 'purchase'\",\n \"name\": \"when type is 'claim' or 'support', this is the claim name\",\n \"claim_id\": \"when type is 'claim', 'support' or 'purchase', 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 \"claim\": \"for purchase outputs only, metadata of purchased claim\",\n \"reposted_claim\": \"for repost claims only, metadata of claim being reposted\",\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 \"purchase_receipt\": \"metadata for the purchase transaction associated with this claim\"\n }\n ],\n \"total_input\": \"sum of inputs as a decimal\",\n \"total_output\": \"sum of outputs, sans fee, as a decimal\",\n \"total_feLine truncated
"examples": [
{
"title": "Create a collection of one stream",
"curl": "curl -d'{\"method\": \"collection_create\", \"params\": {\"name\": \"tom\", \"bid\": \"1.0\", \"claims\": [\"ea41b9f807c6982cf97a1178838dfef64feaa014\"], \"allow_duplicate_name\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\", \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet collection create --name=tom --bid=1.0 --channel_id=20ccc609603f9c6f01d74f2d6a133867d2903fc2 --claims=ea41b9f807c6982cf97a1178838dfef64feaa014",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"collection_create\", \"params\": {\"name\": \"tom\", \"bid\": \"1.0\", \"claims\": [\"ea41b9f807c6982cf97a1178838dfef64feaa014\"], \"allow_duplicate_name\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\", \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000011552a7efeb31dafb72d77acd8dff177d3ab93525ed1b9abde9997412348ae34f010000006b483045022100ec009f539259e608e0a876beb86bfc7cc5439b8d0fe09188ec5711cda2f49e5902207a58d4af049513c5ccd6f1bdd24bc0d7e16f823027e436523f8bb939a69fc530012102b9174bcb2bb1f01a1c17be57386fdb7922f5cabfdeccb0318611ecbc554337cbffffffff0200e1f5050000000091b503746f6d4c6f01c23f90d26738136a2d4fd7016f9c3f6009c6cc20ab977ae13013c5115619502f2a730af6fd385eb74fd78cd7d3df1c0d01d32002e25f9bdfbd15db7a8bd557ffdcdacf475204b1f6df7de65ef174c1a0a43232b01a1812160a1414a0ea4ff6fe8d8378117af92c98c607f8b941ea6d7576a914f27bcbde9870d0d372378d0e2f33bbb92ce0194588ac202c7e17000000001976a91410011067a2603a2f53b941403aec639db140561488ac00000000\",\n \"inputs\": [\n {\n \"address\": \"n1V4V9jbac2vgqPKghf7uCw9AJ51unJhfd\",\n \"amount\": \"4.947555\",\n \"confirmations\": 2,\n \"height\": 215,\n \"nout\": 1,\n \"timestamp\": 1621405356,\n \"txid\": \"4fe38a34127499e9bd9a1bed2535b93a7d17ff8dcd7ad772fbda31ebefa75215\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"n3d67zugu7tXuuBLhAajnSt56j9Yv2yQ2w\",\n \"amount\": \"1.0\",\n \"claim_id\": \"e60f8f8c2252950c925a4bbb0efa4165aa7a0055\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"is_channel_signature_valid\": true,\n \"meta\": {},\n \"name\": \"tom\",\n \"normalized_name\": \"tom\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://tom#e60f8f8c2252950c925a4bbb0efa4165aa7a0055\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 7,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": null,\n \"txid\": \"abf38341355905c1a84f387cd6d12c9c6ff5d63186fec3afda4aafb2c2eb415f\",\n \"type\": \"claim\",\n \"value\": {\n \"claims\": [\n \"ea41b9f807c6982cf97a1178838dfef64feaa014\"\n ]\n },\n \"value_type\": \"collection\"\n },\n {\n \"address\": \"mgyaP4FvA3DLPfatc7bfJS8a62c2AHQZH1\",\n \"amount\": \"3.941448\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"abf38341355905c1a84f387cd6d12c9c6ff5d63186fec3afda4aafb2c2eb415f\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.006107\",\n \"total_input\": \"4.947555\",\n \"total_output\": \"4.941448\",\n \"txid\": \"abf38341355905c1a84f387cd6d12c9c6ff5d63186fec3afda4aafb2c2eb415f\"\n }\n}"
}
]
"examples": []
},
{
"name": "collection_list",
"description": "List my collection claims.",
"arguments": [
{
"name": "resolve",
"type": "bool",
"description": "resolve collection claim",
"is_required": false
},
{
"name": "resolve_claims",
"type": "int",
@@ -2304,15 +2186,7 @@
}
],
"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_received\": \"true if txo was sent from external account to this account\",\n \"is_spent\": \"true if txo is spent\",\n \"is_mine\": \"payment to one of your accounts, only available when it can be determined\",\n \"type\": \"one of 'claim', 'support' or 'purchase'\",\n \"name\": \"when type is 'claim' or 'support', this is the claim name\",\n \"claim_id\": \"when type is 'claim', 'support' or 'purchase', 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 \"claim\": \"for purchase outputs only, metadata of purchased claim\",\n \"reposted_claim\": \"for repost claims only, metadata of claim being reposted\",\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 \"purchase_receipt\": \"metadata for the purchase transaction associated with this claim\"\n }\n ]\n }",
"examples": [
{
"title": "List collections",
"curl": "curl -d'{\"method\": \"collection_list\", \"params\": {\"resolve_claims\": 1, \"resolve\": true}}' http://localhost:5279/",
"lbrynet": "lbrynet collection list --resolve --resolve_claims=1",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"collection_list\", \"params\": {\"resolve_claims\": 1, \"resolve\": true}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"n3d67zugu7tXuuBLhAajnSt56j9Yv2yQ2w\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#2/tom#e\",\n \"claim_id\": \"e60f8f8c2252950c925a4bbb0efa4165aa7a0055\",\n \"claim_op\": \"create\",\n \"claims\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#2/astream#e\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"update\",\n \"confirmations\": 4,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"meta\": {\n \"activation_height\": 213,\n \"creation_height\": 213,\n \"creation_timestamp\": 1621405356,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263187,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 213,\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#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"short_url\": \"lbry://astream#e\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#2\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 8,\n \"has_signing_key\": false,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 209,\n \"claims_in_channel\": 2,\n \"creation_height\": 209,\n \"creation_timestamp\": 1621405355,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263183,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 209,\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#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"short_url\": \"lbry://@channel#2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1621405356,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"confirmations\": 1,\n \"height\": 217,\n \"is_channel_signature_valid\": true,\n \"meta\": {\n \"activation_height\": 217,\n \"creation_height\": 217,\n \"creation_timestamp\": 1621405356,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263191,\n \"is_controlling\": true,\n \"reposted\": 0,\n \"support_amount\": \"0.0\",\n \"take_over_height\": 217,\n \"trending_global\": 0.0,\n \"trending_group\": 0,\n \"trending_local\": 0.0,\n \"trending_mixed\": 0.0\n },\n \"name\"Line truncated
}
]
"examples": []
},
{
"name": "collection_resolve",
@@ -2458,6 +2332,12 @@
"description": "address where the collection is sent",
"is_required": false
},
{
"name": "new_signing_key",
"type": "bool",
"description": "generate a new signing key, will invalidate all previous publishes",
"is_required": false
},
{
"name": "preview",
"type": "bool",
@@ -2506,10 +2386,10 @@
"examples": [
{
"title": "Abandon a comment",
"curl": "curl -d'{\"method\": \"comment_abandon\", \"params\": {\"comment_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\"}}' http://localhost:5279/",
"lbrynet": "lbrynet comment abandon 137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_abandon\", \"params\": {\"comment_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\": {\n \"abandoned\": true\n }\n }\n}"
"curl": "curl -d'{\"method\": \"comment_abandon\", \"params\": {\"comment_id\": \"34ffe236decc147c7c0c7e0c24c2e5380a312c1084e6ed7bb2c3332a89e95cbf\"}}' http://localhost:5279/",
"lbrynet": "lbrynet comment abandon 34ffe236decc147c7c0c7e0c24c2e5380a312c1084e6ed7bb2c3332a89e95cbf",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_abandon\", \"params\": {\"comment_id\": \"34ffe236decc147c7c0c7e0c24c2e5380a312c1084e6ed7bb2c3332a89e95cbf\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"error\": {\n \"code\": -32000,\n \"data\": null,\n \"message\": \"could not get claim from sdk with claim id 5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\"\n },\n \"id\": 1,\n \"jsonrpc\": \"2.0\"\n }\n}"
}
]
},
@@ -2564,17 +2444,17 @@
"examples": [
{
"title": "Posting a comment as your channel",
"curl": "curl -d'{\"method\": \"comment_create\", \"params\": {\"comment\": \"Thank you Based God\", \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"channel_name\": \"@channel\", \"channel_account_id\": []}}' http://localhost:5279/",
"lbrynet": "lbrynet comment create --comment=\"Thank you Based God\" --channel_name=@channel --claim_id=ea41b9f807c6982cf97a1178838dfef64feaa014",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_create\", \"params\": {\"comment\": \"Thank you Based God\", \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"channel_name\": \"@channel\", \"channel_account_id\": []}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"comment\": \"Thank you Based God\",\n \"comment_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\",\n \"is_claim_signature_valid\": true,\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"signature\": \"371cc84d6d2d487592d1483a4d915b793ced4d6ed843402f958e1aeb22325b977b88a41ac0b1d87094634ade2e68a305bda7a3521139f4c5c6ea7b9167afa1d9\",\n \"signing_ts\": \"1621405333\",\n \"timestamp\": \"1621405333\"\n }\n}"
"curl": "curl -d'{\"method\": \"comment_create\", \"params\": {\"comment\": \"Thank you Based God\", \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\", \"channel_name\": \"@channel\", \"channel_account_id\": []}}' http://localhost:5279/",
"lbrynet": "lbrynet comment create --comment=\"Thank you Based God\" --channel_name=@channel --claim_id=fe7ee643b50b724f6029f6edfe90d67b5512b3ae",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_create\", \"params\": {\"comment\": \"Thank you Based God\", \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\", \"channel_name\": \"@channel\", \"channel_account_id\": []}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"channel_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"comment\": \"Thank you Based God\",\n \"comment_id\": \"34ffe236decc147c7c0c7e0c24c2e5380a312c1084e6ed7bb2c3332a89e95cbf\",\n \"is_claim_signature_valid\": true,\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"signature\": \"c9cf386ed5af52fa1beb060898c5590f4c7fe02010228e1db49dc42b5bcf2d83218825876ae75f60a42cee0bf27d311904299e10fa2b6daef158a38cf4deb06c\",\n \"signing_ts\": \"1602862434\",\n \"timestamp\": 1602862434\n }\n}"
},
{
"title": "Use the parent_id param to make replies",
"curl": "curl -d'{\"method\": \"comment_create\", \"params\": {\"comment\": \"I have photographic evidence confirming Sasquatch exists\", \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"parent_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\", \"channel_name\": \"@channel\", \"channel_account_id\": []}}' http://localhost:5279/",
"lbrynet": "lbrynet comment create --comment=\"I have photographic evidence confirming Sasquatch exists\" --channel_name=@channel --parent_id=137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d --claim_id=ea41b9f807c6982cf97a1178838dfef64feaa014",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_create\", \"params\": {\"comment\": \"I have photographic evidence confirming Sasquatch exists\", \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"parent_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\", \"channel_name\": \"@channel\", \"channel_account_id\": []}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"comment\": \"I have photographic evidence confirming Sasquatch exists\",\n \"comment_id\": \"168b09f4067231cd5fd065f2ac466a12af98a44477a9a7d68513ef0a26856c6e26fea4bceb6c8c4b182c4bec7d6a316a0d1ed19455123c701806816c317ee417\",\n \"is_claim_signature_valid\": true,\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"parent_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\",\n \"signature\": \"df5b9417c995e7d1e5864074d7f759b7b0053847cc2a4d741e130d67f029a8fa729e2ef188babc4dfb604474657afceb3a5c4be2de50063cc1a9c71472f76240\",\n \"signing_ts\": \"1621405333\",\n \"timestamp\": \"1621405333\"\n }\n}"
"curl": "curl -d'{\"method\": \"comment_create\", \"params\": {\"comment\": \"I have photographic evidence confirming Sasquatch exists\", \"parent_id\": \"34ffe236decc147c7c0c7e0c24c2e5380a312c1084e6ed7bb2c3332a89e95cbf\", \"channel_name\": \"@channel\", \"channel_account_id\": []}}' http://localhost:5279/",
"lbrynet": "lbrynet comment create --comment=\"I have photographic evidence confirming Sasquatch exists\" --channel_name=@channel --parent_id=34ffe236decc147c7c0c7e0c24c2e5380a312c1084e6ed7bb2c3332a89e95cbf",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_create\", \"params\": {\"comment\": \"I have photographic evidence confirming Sasquatch exists\", \"parent_id\": \"34ffe236decc147c7c0c7e0c24c2e5380a312c1084e6ed7bb2c3332a89e95cbf\", \"channel_name\": \"@channel\", \"channel_account_id\": []}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"channel_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"claim_id\": \"\",\n \"comment\": \"I have photographic evidence confirming Sasquatch exists\",\n \"comment_id\": \"bc36b0956118363b6b4ca20fed91c76f1e596ce0fc0ca0545366298fc6b22186\",\n \"is_claim_signature_valid\": true,\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"parent_id\": \"34ffe236decc147c7c0c7e0c24c2e5380a312c1084e6ed7bb2c3332a89e95cbf\",\n \"signature\": \"459065ca93c600a81d51ea2038a6afad7eb0d03c94bd674f3b73cb14a0b65815d09eb788c40c30163e04cc1e48c6238f6c78a7ecda62aaf0e7afd7cd3b98b66a\",\n \"signing_ts\": \"1602862434\",\n \"timestamp\": 1602862435\n }\n}"
}
]
},
@@ -2661,17 +2541,17 @@
"examples": [
{
"title": "List all comments on a claim",
"curl": "curl -d'{\"method\": \"comment_list\", \"params\": {\"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"include_replies\": true, \"skip_validation\": false, \"is_channel_signature_valid\": false, \"visible\": false, \"hidden\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet comment list ea41b9f807c6982cf97a1178838dfef64feaa014 --include_replies",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_list\", \"params\": {\"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"include_replies\": true, \"skip_validation\": false, \"is_channel_signature_valid\": false, \"visible\": false, \"hidden\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"has_hidden_comments\": false,\n \"items\": [\n {\n \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"comment\": \"I have photographic evidence confirming Sasquatch exists\",\n \"comment_id\": \"168b09f4067231cd5fd065f2ac466a12af98a44477a9a7d68513ef0a26856c6e26fea4bceb6c8c4b182c4bec7d6a316a0d1ed19455123c701806816c317ee417\",\n \"is_channel_signature_valid\": true,\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"parent_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\",\n \"signature\": \"df5b9417c995e7d1e5864074d7f759b7b0053847cc2a4d741e130d67f029a8fa729e2ef188babc4dfb604474657afceb3a5c4be2de50063cc1a9c71472f76240\",\n \"signing_ts\": \"1621405333\",\n \"timestamp\": \"1621405333\"\n },\n {\n \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"comment\": \"Thank you Based God\",\n \"comment_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\",\n \"is_channel_signature_valid\": true,\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"signature\": \"371cc84d6d2d487592d1483a4d915b793ced4d6ed843402f958e1aeb22325b977b88a41ac0b1d87094634ade2e68a305bda7a3521139f4c5c6ea7b9167afa1d9\",\n \"signing_ts\": \"1621405333\",\n \"timestamp\": \"1621405333\"\n }\n ],\n \"page\": 1,\n \"page_size\": 50,\n \"total_items\": 2,\n \"total_pages\": 1\n }\n}"
"curl": "curl -d'{\"method\": \"comment_list\", \"params\": {\"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\", \"include_replies\": true, \"skip_validation\": false, \"is_channel_signature_valid\": false, \"visible\": false, \"hidden\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet comment list fe7ee643b50b724f6029f6edfe90d67b5512b3ae --include_replies",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_list\", \"params\": {\"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\", \"include_replies\": true, \"skip_validation\": false, \"is_channel_signature_valid\": false, \"visible\": false, \"hidden\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"has_hidden_comments\": false,\n \"items\": [\n {\n \"channel_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"comment\": \"Thank you Based God\",\n \"comment_id\": \"34ffe236decc147c7c0c7e0c24c2e5380a312c1084e6ed7bb2c3332a89e95cbf\",\n \"is_channel_signature_valid\": true,\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"signature\": \"c9cf386ed5af52fa1beb060898c5590f4c7fe02010228e1db49dc42b5bcf2d83218825876ae75f60a42cee0bf27d311904299e10fa2b6daef158a38cf4deb06c\",\n \"signing_ts\": \"1602862434\",\n \"timestamp\": 1602862434\n }\n ],\n \"page\": 1,\n \"page_size\": 50,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
},
{
"title": "List a comment thread replying to a top level comment",
"curl": "curl -d'{\"method\": \"comment_list\", \"params\": {\"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"parent_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\", \"include_replies\": false, \"skip_validation\": false, \"is_channel_signature_valid\": false, \"visible\": false, \"hidden\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet comment list ea41b9f807c6982cf97a1178838dfef64feaa014 --parent_id=137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_list\", \"params\": {\"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"parent_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\", \"include_replies\": false, \"skip_validation\": false, \"is_channel_signature_valid\": false, \"visible\": false, \"hidden\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"has_hidden_comments\": false,\n \"items\": [\n {\n \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"comment\": \"I have photographic evidence confirming Sasquatch exists\",\n \"comment_id\": \"168b09f4067231cd5fd065f2ac466a12af98a44477a9a7d68513ef0a26856c6e26fea4bceb6c8c4b182c4bec7d6a316a0d1ed19455123c701806816c317ee417\",\n \"is_channel_signature_valid\": true,\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"parent_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\",\n \"signature\": \"df5b9417c995e7d1e5864074d7f759b7b0053847cc2a4d741e130d67f029a8fa729e2ef188babc4dfb604474657afceb3a5c4be2de50063cc1a9c71472f76240\",\n \"signing_ts\": \"1621405333\",\n \"timestamp\": \"1621405333\"\n },\n {\n \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"comment\": \"Thank you Based God\",\n \"comment_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\",\n \"is_channel_signature_valid\": true,\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"signature\": \"371cc84d6d2d487592d1483a4d915b793ced4d6ed843402f958e1aeb22325b977b88a41ac0b1d87094634ade2e68a305bda7a3521139f4c5c6ea7b9167afa1d9\",\n \"signing_ts\": \"1621405333\",\n \"timestamp\": \"1621405333\"\n }\n ],\n \"page\": 1,\n \"page_size\": 50,\n \"total_items\": 2,\n \"total_pages\": 1\n }\n}"
"curl": "curl -d'{\"method\": \"comment_list\", \"params\": {\"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\", \"parent_id\": \"34ffe236decc147c7c0c7e0c24c2e5380a312c1084e6ed7bb2c3332a89e95cbf\", \"include_replies\": false, \"skip_validation\": false, \"is_channel_signature_valid\": false, \"visible\": false, \"hidden\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet comment list fe7ee643b50b724f6029f6edfe90d67b5512b3ae --parent_id=34ffe236decc147c7c0c7e0c24c2e5380a312c1084e6ed7bb2c3332a89e95cbf",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_list\", \"params\": {\"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\", \"parent_id\": \"34ffe236decc147c7c0c7e0c24c2e5380a312c1084e6ed7bb2c3332a89e95cbf\", \"include_replies\": false, \"skip_validation\": false, \"is_channel_signature_valid\": false, \"visible\": false, \"hidden\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"has_hidden_comments\": false,\n \"page\": 1,\n \"page_size\": 50,\n \"total_items\": 0,\n \"total_pages\": 0\n }\n}"
}
]
},
@@ -2840,10 +2720,10 @@
"examples": [
{
"title": "Edit the contents of a comment",
"curl": "curl -d'{\"method\": \"comment_update\", \"params\": {\"comment\": \"Where there was once sasquatch, there is not\", \"comment_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\"}}' http://localhost:5279/",
"lbrynet": "lbrynet comment update Where there was once sasquatch, there is not --comment_id=137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_update\", \"params\": {\"comment\": \"Where there was once sasquatch, there is not\", \"comment_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"comment\": \"Where there was once sasquatch, there is not\",\n \"comment_id\": \"137a4cd974dcc1f2c733e77391557208c46c53645147898f2bda5e96b42729d5201f421a588682e93cb976407280830cef5ec79860a1508391437095cbb3963d\",\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"parent_id\": null,\n \"signature\": \"56408942b909552d7636cee888f3b964cb3aafd5fed90bca5a24a87e821dd9d808e37c57d4b25a956661b6e91472e8ae7d937ae4ab1c64b88162185fd755e536\",\n \"signing_ts\": \"1621405333\",\n \"timestamp\": \"1621405333\"\n }\n}"
"curl": "curl -d'{\"method\": \"comment_update\", \"params\": {\"comment\": \"Where there was once sasquatch, there is not\", \"comment_id\": \"34ffe236decc147c7c0c7e0c24c2e5380a312c1084e6ed7bb2c3332a89e95cbf\"}}' http://localhost:5279/",
"lbrynet": "lbrynet comment update Where there was once sasquatch, there is not --comment_id=34ffe236decc147c7c0c7e0c24c2e5380a312c1084e6ed7bb2c3332a89e95cbf",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_update\", \"params\": {\"comment\": \"Where there was once sasquatch, there is not\", \"comment_id\": \"34ffe236decc147c7c0c7e0c24c2e5380a312c1084e6ed7bb2c3332a89e95cbf\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"error\": {\n \"code\": -32000,\n \"data\": null,\n \"message\": \"could not get claim from sdk with claim id 5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\"\n },\n \"id\": 1,\n \"jsonrpc\": \"2.0\"\n }\n}"
}
]
}
@@ -2933,9 +2813,9 @@
"examples": [
{
"title": "Delete a file",
"curl": "curl -d'{\"method\": \"file_delete\", \"params\": {\"delete_from_download_dir\": false, \"delete_all\": false, \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\"}}' http://localhost:5279/",
"lbrynet": "lbrynet file delete --claim_id=\"ea41b9f807c6982cf97a1178838dfef64feaa014\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_delete\", \"params\": {\"delete_from_download_dir\": false, \"delete_all\": false, \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\"}}).json()",
"curl": "curl -d'{\"method\": \"file_delete\", \"params\": {\"delete_from_download_dir\": false, \"delete_all\": false, \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\"}}' http://localhost:5279/",
"lbrynet": "lbrynet file delete --claim_id=\"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_delete\", \"params\": {\"delete_from_download_dir\": false, \"delete_all\": false, \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": true\n}"
}
]
@@ -3096,14 +2976,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 \"items\": [\n {\n \"added_on\": null,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\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 \"is_fully_reflected\": true,\n \"key\": \"1331d793facb0a628aa3416c5f1b2c59\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01c23f90d26738136a2d4fd7016f9c3f6009c6cc2097c286c8bea94843a4f2796781afd1797a19737f2ae770022e06b623fedaea0a9654fc9e098271a9c186889d14e0bab2cc75cd36b1e67efe284d06467438d0ed0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d70766363706a763239180b22186170706c69636174696f6e2f6f637465742d73747265616d323054ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"purchase_receipt\": null,\n \"reflector_progress\": 100,\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"aacc5131b8a53b4254185d476dc6fcd254ab08945416c68bdfd09571c660e58862e813b90fe4f6cf1f6d85633268b385\",\n \"stream_name\": \"tmpvccpjv29\",\n \"streaming_url\": \"http://localhost:5280/stream/54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"suggested_file_name\": \"tmpvccpjv29\",\n \"timestamp\": null,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"uploading_to_reflector\": false,\n \"written_bytes\": 0\n },\n {\n \"added_on\": null,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"6cd66398c40603947d6e34122d82b782dac24424\",\n \"claim_name\": \"blank-image\",\n \"completed\": false,\n \"confirmations\": -1,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": -1,\n \"is_fully_reflected\": true,\n \"key\": \"f6a644c1b23e5f9eccc1c1aa7a348a79\",\n \"metadata\": {\n \"author\": \"Picaso\",\n \"description\": \"A blank PNG that is 5x7.\",\n \"fee\": {\n \"address\": \"mmqinVr6k9tg4Ndah8rU8euHavqDgPiBi4\",\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\": \"1621405331\",\n \"source\": {\n \"hash\": \"6c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545\",\n \"media_type\": \"image/png\",\n \"name\": \"tmpeu6brs_o.png\",\n \"sd_hash\": \"c279adc5346f64aaa7135c83b6170ff7f2efdbbb76efc6ef6a346a07b505fe1860b6ad82b837c161b92bfe1e01907ee7\",\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\": \"Line truncated
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"added_on\": null,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\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 \"is_fully_reflected\": true,\n \"key\": \"7acc8b9eac8e533c57b933928ab6fad0\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpk0n0x2sb\",\n \"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"c620b71698533d88efa10c80d79a30b74464214cb0d893ec5ab4ec1c37d1676e:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01f2d6950adda2502b543f042e4e8496b63a2bc95d1391e6159e2874bf75624f77339a61abf38b4da3237a5a52ad92aece2cefae8742c427064051fadb0dcfcc8f957b190341110ce64b8fd3f5cc874e16db11cbdc0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706b306e3078327362180b22186170706c69636174696f6e2f6f637465742d73747265616d3230d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"purchase_receipt\": null,\n \"reflector_progress\": 100,\n \"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"6b8f6829a8820cd430d23b3de7dd67ad77a11d912b04ac5577014d51af877a0c3a094e8d3d9bc2ae6b2c13c2ea44e477\",\n \"stream_name\": \"tmpk0n0x2sb\",\n \"streaming_url\": \"http://localhost:5280/stream/d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"suggested_file_name\": \"tmpk0n0x2sb\",\n \"timestamp\": null,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"c620b71698533d88efa10c80d79a30b74464214cb0d893ec5ab4ec1c37d1676e\",\n \"uploading_to_reflector\": false,\n \"written_bytes\": 0\n },\n {\n \"added_on\": null,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"dca7d8cee4b0dca9ac27d279bce24163b34d3237\",\n \"claim_name\": \"blank-image\",\n \"completed\": false,\n \"confirmations\": -1,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": -1,\n \"is_fully_reflected\": true,\n \"key\": \"a3f6d1b054670be4d383c657da6e56cd\",\n \"metadata\": {\n \"author\": \"Picaso\",\n \"description\": \"A blank PNG that is 5x7.\",\n \"fee\": {\n \"address\": \"msnpXocjCvdA7rj6Pnn8v1NTxaHMXcAwJ2\",\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\": \"1602862432\",\n \"source\": {\n \"hash\": \"6c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545\",\n \"media_type\": \"image/png\",\n \"name\": \"tmpej_krqnp.png\",\n \"sd_hash\": \"f71fb71a3ddd6bd2ce60c6941c2f9faf5317510bf7ea65d56286fa17066405522ba4fc4880d0982c7cfce84375bf8507\",\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\": \"Line truncated
},
{
"title": "List files matching a parameter",
"curl": "curl -d'{\"method\": \"file_list\", \"params\": {\"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"reverse\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet file list --claim_id=\"ea41b9f807c6982cf97a1178838dfef64feaa014\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_list\", \"params\": {\"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"reverse\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"added_on\": null,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 4,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": 214,\n \"is_fully_reflected\": true,\n \"key\": \"1331d793facb0a628aa3416c5f1b2c59\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01c23f90d26738136a2d4fd7016f9c3f6009c6cc2097c286c8bea94843a4f2796781afd1797a19737f2ae770022e06b623fedaea0a9654fc9e098271a9c186889d14e0bab2cc75cd36b1e67efe284d06467438d0ed0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d70766363706a763239180b22186170706c69636174696f6e2f6f637465742d73747265616d323054ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"purchase_receipt\": null,\n \"reflector_progress\": 100,\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"aacc5131b8a53b4254185d476dc6fcd254ab08945416c68bdfd09571c660e58862e813b90fe4f6cf1f6d85633268b385\",\n \"stream_name\": \"tmpvccpjv29\",\n \"streaming_url\": \"http://localhost:5280/stream/54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"suggested_file_name\": \"tmpvccpjv29\",\n \"timestamp\": 1621405356,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"uploading_to_reflector\": false,\n \"written_bytes\": 0\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
"curl": "curl -d'{\"method\": \"file_list\", \"params\": {\"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\", \"reverse\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet file list --claim_id=\"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_list\", \"params\": {\"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\", \"reverse\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"added_on\": null,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\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 \"is_fully_reflected\": true,\n \"key\": \"7acc8b9eac8e533c57b933928ab6fad0\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpk0n0x2sb\",\n \"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"c620b71698533d88efa10c80d79a30b74464214cb0d893ec5ab4ec1c37d1676e:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01f2d6950adda2502b543f042e4e8496b63a2bc95d1391e6159e2874bf75624f77339a61abf38b4da3237a5a52ad92aece2cefae8742c427064051fadb0dcfcc8f957b190341110ce64b8fd3f5cc874e16db11cbdc0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706b306e3078327362180b22186170706c69636174696f6e2f6f637465742d73747265616d3230d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"purchase_receipt\": null,\n \"reflector_progress\": 100,\n \"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"6b8f6829a8820cd430d23b3de7dd67ad77a11d912b04ac5577014d51af877a0c3a094e8d3d9bc2ae6b2c13c2ea44e477\",\n \"stream_name\": \"tmpk0n0x2sb\",\n \"streaming_url\": \"http://localhost:5280/stream/d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"suggested_file_name\": \"tmpk0n0x2sb\",\n \"timestamp\": 1602862457,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"c620b71698533d88efa10c80d79a30b74464214cb0d893ec5ab4ec1c37d1676e\",\n \"uploading_to_reflector\": false,\n \"written_bytes\": 0\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
}
]
},
@@ -3220,10 +3100,10 @@
"examples": [
{
"title": "Save a file to the downloads directory",
"curl": "curl -d'{\"method\": \"file_save\", \"params\": {\"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\"}}' http://localhost:5279/",
"lbrynet": "lbrynet file save --sd_hash=\"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_save\", \"params\": {\"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"added_on\": 1621405335,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 4,\n \"content_fee\": null,\n \"download_directory\": \"/tmp/tmp5s0wcgsl\",\n \"download_path\": \"/tmp/tmp5s0wcgsl/tmpvccpjv29_1\",\n \"file_name\": \"tmpvccpjv29_1\",\n \"height\": 214,\n \"is_fully_reflected\": false,\n \"key\": \"1331d793facb0a628aa3416c5f1b2c59\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01c23f90d26738136a2d4fd7016f9c3f6009c6cc2097c286c8bea94843a4f2796781afd1797a19737f2ae770022e06b623fedaea0a9654fc9e098271a9c186889d14e0bab2cc75cd36b1e67efe284d06467438d0ed0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d70766363706a763239180b22186170706c69636174696f6e2f6f637465742d73747265616d323054ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"purchase_receipt\": null,\n \"reflector_progress\": 0,\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"aacc5131b8a53b4254185d476dc6fcd254ab08945416c68bdfd09571c660e58862e813b90fe4f6cf1f6d85633268b385\",\n \"stream_name\": \"tmpvccpjv29\",\n \"streaming_url\": \"http://localhost:5280/stream/54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"suggested_file_name\": \"tmpvccpjv29\",\n \"timestamp\": 1621405356,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"uploading_to_reflector\": false,\n \"written_bytes\": 11\n }\n}"
"curl": "curl -d'{\"method\": \"file_save\", \"params\": {\"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\"}}' http://localhost:5279/",
"lbrynet": "lbrynet file save --sd_hash=\"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_save\", \"params\": {\"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"added_on\": 1602862436,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 3,\n \"content_fee\": null,\n \"download_directory\": \"/tmp/tmpzzr985r8\",\n \"download_path\": \"/tmp/tmpzzr985r8/tmpk0n0x2sb_1\",\n \"file_name\": \"tmpk0n0x2sb_1\",\n \"height\": 214,\n \"is_fully_reflected\": false,\n \"key\": \"7acc8b9eac8e533c57b933928ab6fad0\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpk0n0x2sb\",\n \"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"c620b71698533d88efa10c80d79a30b74464214cb0d893ec5ab4ec1c37d1676e:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01f2d6950adda2502b543f042e4e8496b63a2bc95d1391e6159e2874bf75624f77339a61abf38b4da3237a5a52ad92aece2cefae8742c427064051fadb0dcfcc8f957b190341110ce64b8fd3f5cc874e16db11cbdc0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706b306e3078327362180b22186170706c69636174696f6e2f6f637465742d73747265616d3230d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"purchase_receipt\": null,\n \"reflector_progress\": 0,\n \"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"6b8f6829a8820cd430d23b3de7dd67ad77a11d912b04ac5577014d51af877a0c3a094e8d3d9bc2ae6b2c13c2ea44e477\",\n \"stream_name\": \"tmpk0n0x2sb\",\n \"streaming_url\": \"http://localhost:5280/stream/d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"suggested_file_name\": \"tmpk0n0x2sb\",\n \"timestamp\": 1602862457,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"c620b71698533d88efa10c80d79a30b74464214cb0d893ec5ab4ec1c37d1676e\",\n \"uploading_to_reflector\": false,\n \"written_bytes\": 11\n }\n}"
}
]
},
@@ -3504,7 +3384,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 \"allowed_origin\": \"\",\n \"announce_head_and_sd_only\": true,\n \"api\": \"localhost:5279\",\n \"audio_encoder\": \"aac -b:a 160k\",\n \"blob_download_timeout\": 30.0,\n \"blob_lru_cache_size\": 0,\n \"blockchain_name\": \"lbrycrd_regtest\",\n \"coin_selection_strategy\": \"standard\",\n \"comment_server\": \"http://localhost:2903/api\",\n \"components_to_skip\": [\n \"dht\",\n \"upnp\",\n \"hash_announcer\",\n \"peer_protocol_server\",\n \"libtorrent_component\"\n ],\n \"concurrent_blob_announcers\": 10,\n \"concurrent_reflector_uploads\": 10,\n \"config\": \"/home/user/.local/share/lbry/lbrynet/daemon_settings.yml\",\n \"data_dir\": \"/tmp/tmp5s0wcgsl\",\n \"download_dir\": \"/tmp/tmp5s0wcgsl\",\n \"download_timeout\": 30.0,\n \"ffmpeg_path\": \"\",\n \"fixed_peer_delay\": 2.0,\n \"fixed_peers\": [\n [\n \"127.0.0.1\",\n 5567\n ]\n ],\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 \"max_wallet_server_fee\": \"0.0\",\n \"network_interface\": \"0.0.0.0\",\n \"node_rpc_timeout\": 5.0,\n \"peer_connect_timeout\": 3.0,\n \"prometheus_port\": 0,\n \"reflect_streams\": true,\n \"reflector_servers\": [\n [\n \"127.0.0.1\",\n 5566\n ]\n ],\n \"save_blobs\": true,\n \"save_files\": true,\n \"save_resolved_claims\": 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 \"track_bandwidth\": true,\n \"transaction_cache_size\": 10000,\n \"udp_port\": 4444,\n \"use_upnp\": false,\n \"video_bitrate_maximum\": 5000000,\n \"video_encoder\": \"libx264 -crf 24 -preset faster -pix_fmt yuv420p\",\n \"video_scaler\": \"-vf \\\"scale=if(gte(iw\\\\,ih)\\\\,min(1920\\\\,iw)\\\\,-2):if(lt(iw\\\\,ih)\\\\,min(1920\\\\,ih)\\\\,-2)\\\" -maxrate 5500K -bufsize 5000K\",\n \"volume_analysis_time\": 240,\n \"volume_filter\": \"\",\n \"wallet_dir\": \"/tmp/tmp5s0wcgsl\",\n \"wallets\": [\n \"default_wallet\"\n ]\n }\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"allowed_origin\": \"\",\n \"announce_head_and_sd_only\": true,\n \"api\": \"localhost:5279\",\n \"audio_encoder\": \"aac -b:a 160k\",\n \"blob_download_timeout\": 30.0,\n \"blob_lru_cache_size\": 0,\n \"blockchain_name\": \"lbrycrd_regtest\",\n \"coin_selection_strategy\": \"standard\",\n \"comment_server\": \"https://comments.lbry.com/api/v2\",\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/tmpzzr985r8\",\n \"download_dir\": \"/tmp/tmpzzr985r8\",\n \"download_timeout\": 30.0,\n \"ffmpeg_path\": \"\",\n \"fixed_peer_delay\": 2.0,\n \"fixed_peers\": [\n [\n \"127.0.0.1\",\n 5567\n ]\n ],\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 \"max_wallet_server_fee\": \"0.0\",\n \"network_interface\": \"0.0.0.0\",\n \"node_rpc_timeout\": 5.0,\n \"peer_connect_timeout\": 3.0,\n \"prometheus_port\": 0,\n \"reflect_streams\": true,\n \"reflector_servers\": [\n [\n \"127.0.0.1\",\n 5566\n ]\n ],\n \"save_blobs\": true,\n \"save_files\": true,\n \"save_resolved_claims\": 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 \"track_bandwidth\": true,\n \"transaction_cache_size\": 100000,\n \"udp_port\": 4444,\n \"use_upnp\": false,\n \"video_bitrate_maximum\": 5000000,\n \"video_encoder\": \"libx264 -crf 24 -preset faster -pix_fmt yuv420p\",\n \"video_scaler\": \"-vf \\\"scale=if(gte(iw\\\\,ih)\\\\,min(1920\\\\,iw)\\\\,-2):if(lt(iw\\\\,ih)\\\\,min(1920\\\\,ih)\\\\,-2)\\\" -maxrate 5500K -bufsize 5000K\",\n \"volume_analysis_time\": 240,\n \"volume_filter\": \"\",\n \"wallet_dir\": \"/tmp/tmpzzr985r8\",\n \"wallets\": [\n \"default_wallet\"\n ]\n }\n}"
}
]
},
@@ -3579,10 +3459,10 @@
"examples": [
{
"title": "Abandon a stream claim",
"curl": "curl -d'{\"method\": \"stream_abandon\", \"params\": {\"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream abandon ea41b9f807c6982cf97a1178838dfef64feaa014",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_abandon\", \"params\": {\"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000012b02e035e15a2d7b0ad580c13855b399916881dfb62f7739f34773cd4e07eb08000000006a47304402201f154b1ed0e658ed7cecd5eacde667fa53e6da238599c9e617676f78964c0b24022061a30c3d58ce2bab5ec15be078a1a01786d00e9b8fd08a9ae02c57b7b2266f4c0121030bb5d283d077a4d93a13dd43f6ab8886f8f2d39b3e4936fdb1f79baa95bbf19effffffff0134b7f505000000001976a9144eb00af05527118271650a5c534844db57da987e88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"update\",\n \"confirmations\": 4,\n \"height\": 214,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"timestamp\": 1621405356,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mnh1tgQ4wJwbPpNLh2iCSTpBm1Hp1xDTsT\",\n \"amount\": \"0.999893\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"cc04061078010a27c416a485b97fb61db50e49703b91a353fa03464a2ac7e264\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000107\",\n \"total_input\": \"1.0\",\n \"total_output\": \"0.999893\",\n \"txid\": \"cc04061078010a27c416a485b97fb61db50e49703b91a353fa03464a2ac7e264\"\n }\n}"
"curl": "curl -d'{\"method\": \"stream_abandon\", \"params\": {\"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\", \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream abandon fe7ee643b50b724f6029f6edfe90d67b5512b3ae",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_abandon\", \"params\": {\"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\", \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000016e67d1371cecb45aec93d8b04c216444b7309ad7800ca1ef883d539816b720c6000000006a47304402201a739f6404a0d2b3c7e6f37167b0b8b7d334cf6921df2a0e957f0fdf28810d0f02201738ca4c8a0406a2a1cf6e3a2f1edb3c9696c5e0dc3a2a3f262b7528446895b20121021ef1cb2d0e5f2d4afebf3f9a2c51b78d55a2fa584070831c33a540f7900b7d27ffffffff0134b7f505000000001976a9145013cace93019f49485a11c39bf6c22d246d5f6d88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mzNC6CMEetGVw6QDGChpUM3HfV7DpWGZ7R\",\n \"amount\": \"1.0\",\n \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"claim_op\": \"update\",\n \"confirmations\": 3,\n \"height\": 214,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"timestamp\": 1602862457,\n \"txid\": \"c620b71698533d88efa10c80d79a30b74464214cb0d893ec5ab4ec1c37d1676e\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpk0n0x2sb\",\n \"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mnpN4b33fqF5jCN4yRJU1ts5ZSvfBRDWcX\",\n \"amount\": \"0.999893\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"3ee7e6c2c25b891aa56475edbe8583d6e8e324692890ef8eb013c6506879a408\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000107\",\n \"total_input\": \"1.0\",\n \"total_output\": \"0.999893\",\n \"txid\": \"3ee7e6c2c25b891aa56475edbe8583d6e8e324692890ef8eb013c6506879a408\"\n }\n}"
}
]
},
@@ -3620,19 +3500,7 @@
"name": "file_path",
"type": "str",
"description": "path to file to be associated with name.",
"is_required": false
},
{
"name": "file_name",
"type": "str",
"description": "name of file to be associated with stream.",
"is_required": false
},
{
"name": "file_hash",
"type": "str",
"description": "hash of file to be associated with stream.",
"is_required": false
"is_required": true
},
{
"name": "validate_file",
@@ -3748,12 +3616,6 @@
"description": "audio/video duration in seconds, automatically calculated",
"is_required": false
},
{
"name": "sd_hash",
"type": "str",
"description": "sd_hash of stream",
"is_required": false
},
{
"name": "channel_id",
"type": "str",
@@ -3813,17 +3675,17 @@
"examples": [
{
"title": "Create a stream claim without metadata",
"curl": "curl -d'{\"method\": \"stream_create\", \"params\": {\"name\": \"astream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpvccpjv29\", \"validate_file\": false, \"optimize_file\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream create astream 1.0 /tmp/tmpvccpjv29",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_create\", \"params\": {\"name\": \"astream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpvccpjv29\", \"validate_file\": false, \"optimize_file\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001bb384e08ba07d2a2881a4b7bbaca52623e4e9b4802750411a0e0eba84d960aeb010000006b483045022100ee034d690c385f87e52db7a7c5ecec41c0f5d8eda08332778d9a674046583d7a02207ec24358481bf0c81d2a32fc9e1716e145eda810553d1d814b7c93a968468a49012102c21142e983b9c10d17cd922818fefd1a34f34a708849811a41c25ad13835320fffffffff0200e1f50500000000bab5076173747265616d4c94000a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d70766363706a763239180b22186170706c69636174696f6e2f6f637465742d73747265616d323054ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb76d7576a9141fcba83c5371c31a24cb491e9d74db9e397784af88ac38fb9423000000001976a914ebc5945ded112d0f109cfdc3d985668de7b27ada88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mkjhU7Go11ZuCbGEp6edSr4At5CBDW23xH\",\n \"amount\": \"6.983769\",\n \"confirmations\": 4,\n \"height\": 209,\n \"nout\": 1,\n \"timestamp\": 1621405355,\n \"txid\": \"eb0a964da8ebe0a011047502489b4e3e6252caba7b4b1a88a2d207ba084e38bb\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\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#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"timestamp\": null,\n \"txid\": \"e4374a9fd0fc7eedc8bb14865cb7c2a11fc808aac850f23121deb663fadb8359\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"n31bnChc7o13i4LjY3GMtdhEJoAqdsMb7w\",\n \"amount\": \"5.969662\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"e4374a9fd0fc7eedc8bb14865cb7c2a11fc808aac850f23121deb663fadb8359\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.014107\",\n \"total_input\": \"6.983769\",\n \"total_output\": \"6.969662\",\n \"txid\": \"e4374a9fd0fc7eedc8bb14865cb7c2a11fc808aac850f23121deb663fadb8359\"\n }\n}"
"curl": "curl -d'{\"method\": \"stream_create\", \"params\": {\"name\": \"astream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpk0n0x2sb\", \"validate_file\": false, \"optimize_file\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream create astream 1.0 /tmp/tmpk0n0x2sb",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_create\", \"params\": {\"name\": \"astream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpk0n0x2sb\", \"validate_file\": false, \"optimize_file\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000012946e645885d5cbfaef61db1ee78c0869cb0cb31d94010bc5cd85d1e11a3a160010000006b483045022100c2f28f3469f168c9bae13f8db2d5efa37cb806c3c6130ca4c85d22c49da0d3220220717880093ff7d0142930c2012176cc89667aa82d3b6d3cc8aa79bf4934602ff1012103e475aa118245138c9c60728635f29a02c3f7509332d7a73cf7f50321527e089fffffffff0200e1f50500000000bab5076173747265616d4c94000a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706b306e3078327362180b22186170706c69636174696f6e2f6f637465742d73747265616d3230d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d6d7576a914cec22985383752987fece466729c85a74f17a45588ac38fb9423000000001976a914f84bdf86b89b4754c88e23739b81a59b4d74173988ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mqqsXcxFmcQBN6JFR1hRE4UtDYtDXp1u4f\",\n \"amount\": \"6.983769\",\n \"confirmations\": 4,\n \"height\": 209,\n \"nout\": 1,\n \"timestamp\": 1602862456,\n \"txid\": \"60a1a3111e5dd85cbc1040d931cbb09c86c078eeb11df6aebf5c5d8845e64629\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mzNC6CMEetGVw6QDGChpUM3HfV7DpWGZ7R\",\n \"amount\": \"1.0\",\n \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\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#fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"timestamp\": null,\n \"txid\": \"6dec60b76943a027438ca3b86aef60f33feded0acf8b5ec3381bf8894cf2d6aa\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpk0n0x2sb\",\n \"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"n49pmPPUVED3aiwTfRe75yKpjXBhGCFx4n\",\n \"amount\": \"5.969662\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"6dec60b76943a027438ca3b86aef60f33feded0acf8b5ec3381bf8894cf2d6aa\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.014107\",\n \"total_input\": \"6.983769\",\n \"total_output\": \"6.969662\",\n \"txid\": \"6dec60b76943a027438ca3b86aef60f33feded0acf8b5ec3381bf8894cf2d6aa\"\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/tmpeu6brs_o.png\", \"validate_file\": false, \"optimize_file\": false, \"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\": 1621405331, \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\", \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream create blank-image 1.0 /tmp/tmpeu6brs_o.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=1621405331 --channel_id=\"20ccc609603f9c6f01d74f2d6a133867d2903fc2\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_create\", \"params\": {\"name\": \"blank-image\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpeu6brs_o.png\", \"validate_file\": false, \"optimize_file\": false, \"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\": 1621405331, \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\", \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000015983dbfa63b6de2131f250c8aa08c81fa1c2b75c8614bbc8ed7efcd09f4a37e4010000006b4830450221008fec0f41696f6bdc859e471a60f9f2598c721a197ab106ae24596d999a554542022045a2176cb13e5417bff7299505e382c66a9754d2540915f317b9d1c1a0a73545012102dab800fee684fddb84ce0ae74c3455b38fcb855ae038c60d272a07dbe40dac62ffffffff0200e1f50500000000fddc01b50b626c616e6b2d696d6167654db10101c23f90d26738136a2d4fd7016f9c3f6009c6cc20bc86cfc6d27ece4853069056b8995fc7369b9cad50c37d389390d868d7fa8f475b261f7dee284dcd39e29e3c9806cd02b68fd18869ad3c91d16889ef3ab4fdc30ae6010a82010a306c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545120f746d706575366272735f6f2e706e6718632209696d6167652f706e673230c279adc5346f64aaa7135c83b6170ff7f2efdbbb76efc6ef6a346a07b505fe1860b6ad82b837c161b92bfe1e01907ee7120650696361736f1a0d5075626c696320446f6d61696e2218687474703a2f2f7075626c69632d646f6d61696e2e6f72672893dd9285063222080112196f455d617873267c515540aeb9dc52903fafa112917f28c9dd188087a70e520408051007420b426c616e6b20496d6167654a184120626c616e6b20504e472074686174206973203578372e52252a23687474703a2f2f736d616c6c6d656469612e636f6d2f7468756d626e61696c2e6a70675a05626c616e6b5a03617274620208016a1308ec0112024e481a0a4d616e636865737465726d7576a914455d617873267c515540aeb9dc52903fafa1129188acac5e7d1d000000001976a914db06da1dd2cf5d45e1870016719db223fb230e5988ac00000000\",\n \"inputs\": [\n {\n \"address\": \"n31bnChc7o13i4LjY3GMtdhEJoAqdsMb7w\",\n \"amount\": \"5.969662\",\n \"confirmations\": 2,\n \"height\": 213,\n \"nout\": 1,\n \"timestamp\": 1621405356,\n \"txid\": \"e4374a9fd0fc7eedc8bb14865cb7c2a11fc808aac850f23121deb663fadb8359\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mmqinVr6k9tg4Ndah8rU8euHavqDgPiBi4\",\n \"amount\": \"1.0\",\n \"claim_id\": \"6cd66398c40603947d6e34122d82b782dac24424\",\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#6cd66398c40603947d6e34122d82b782dac24424\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": null,\n \"txid\": \"4fe38a34127499e9bd9a1bed2535b93a7d17ff8dcd7ad772fbda31ebefa75215\",\n \"type\": \"claim\",\n \"value\": {\n \"author\": \"Picaso\",\n \"description\": \"A blank PNG that is 5x7.\",\n \"fee\": {\n \"address\": \"mmqinVr6k9tg4Ndah8rU8euHavqDgPiBi4\",\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\": \"1621405331\",\n \"source\": {\n \"hash\": \"6c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545\",\n \"media_type\": \"image/png\",\n \"name\": \"tmpeu6brs_o.png\",\n \"sd_hash\": \"c279adc5346f64aaa7135c83b6170ff7f2efdbbb76efc6ef6a346a07b505fe1860b6ad82b837c161b92bfe1e01907ee7\",\n \"size\": \"99\"\n },\n \"stream_type\": \"image\",\n \"tags\": [\n \"blank\",\n \"art\"\n ],\n \"thuLine truncated
"curl": "curl -d'{\"method\": \"stream_create\", \"params\": {\"name\": \"blank-image\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpej_krqnp.png\", \"validate_file\": false, \"optimize_file\": false, \"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\": 1602862432, \"channel_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\", \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream create blank-image 1.0 /tmp/tmpej_krqnp.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=1602862432 --channel_id=\"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_create\", \"params\": {\"name\": \"blank-image\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpej_krqnp.png\", \"validate_file\": false, \"optimize_file\": false, \"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\": 1602862432, \"channel_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\", \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001aad6f24c89f81b38c35e8bcf0aeded3ff360ef6ab8a38c4327a04369b760ec6d010000006a473044022069b670698da195fcbcf94c16d60a145c633ea83d1cb42ef2405b4fdcc28e650a022035d8648a3ee03e2c212c308a2018a5bbb8dcc8412640af2bc865f17ca9083ebb0121025d0514acddc1ed8a9f55fdb651595a9184dd00637c9cb7a9903968ae6aea2c90ffffffff0200e1f50500000000fddc01b50b626c616e6b2d696d6167654db10101f2d6950adda2502b543f042e4e8496b63a2bc95d8a307fd753f2435d4cdec111e0f36d3a883763fb9a1e37df849fc8277afe984e31cd3864ff9016437012b5053ddfb5e43ea03d565a1a57b2effb45b87f3c4bb50ae6010a82010a306c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545120f746d70656a5f6b72716e702e706e6718632209696d6167652f706e673230f71fb71a3ddd6bd2ce60c6941c2f9faf5317510bf7ea65d56286fa17066405522ba4fc4880d0982c7cfce84375bf8507120650696361736f1a0d5075626c696320446f6d61696e2218687474703a2f2f7075626c69632d646f6d61696e2e6f726728e0faa6fc053222080112196f86a1af441ae42e3c56d3592fbcb2e63aee63817b81bc72cb188087a70e520408051007420b426c616e6b20496d6167654a184120626c616e6b20504e472074686174206973203578372e52252a23687474703a2f2f736d616c6c6d656469612e636f6d2f7468756d626e61696c2e6a70675a05626c616e6b5a03617274620208016a1308ec0112024e481a0a4d616e636865737465726d7576a91486a1af441ae42e3c56d3592fbcb2e63aee63817b88acac5e7d1d000000001976a9146f1cad0aebad9ea189bde7ed4e3b3d60780a21d888ac00000000\",\n \"inputs\": [\n {\n \"address\": \"n49pmPPUVED3aiwTfRe75yKpjXBhGCFx4n\",\n \"amount\": \"5.969662\",\n \"confirmations\": 2,\n \"height\": 213,\n \"nout\": 1,\n \"timestamp\": 1602862457,\n \"txid\": \"6dec60b76943a027438ca3b86aef60f33feded0acf8b5ec3381bf8894cf2d6aa\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"msnpXocjCvdA7rj6Pnn8v1NTxaHMXcAwJ2\",\n \"amount\": \"1.0\",\n \"claim_id\": \"dca7d8cee4b0dca9ac27d279bce24163b34d3237\",\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#dca7d8cee4b0dca9ac27d279bce24163b34d3237\",\n \"signing_channel\": {\n \"address\": \"mofqoKUmhmPTCoudQRXgjzGSDnCyJvZAZg\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"timestamp\": 1602862456,\n \"txid\": \"3ee8f25ad7bfef1d30e3fce0b212d77b74a495ef1d7635a8be77b96ffbe8e412\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200049b4cbe0f5275e7b1c170f458af09628ba75401fd95d0205ed9de9037b396f60936d555da2bc8dd09b1804b250f32d1bd07382bd3a4aaa2700b08b137b91f1159\",\n \"public_key_id\": \"mkVrRXQGgjhBaygCP3dNpbmtm5Yohno8q2\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": null,\n \"txid\": \"7887c6a4ad30222bd6a68482fae36c3532e7f6720e21e202799c2c0421fac2b5\",\n \"type\": \"claim\",\n \"value\": {\n \"author\": \"Picaso\",\n \"description\": \"A blank PNG that is 5x7.\",\n \"fee\": {\n \"address\": \"msnpXocjCvdA7rj6Pnn8v1NTxaHMXcAwJ2\",\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\": \"1602862432\",\n \"source\": {\n \"hash\": \"6c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545\",\n \"media_type\": \"image/png\",\n \"name\": \"tmpej_krqnp.png\",\n \"sd_hash\": \"f71fb71a3ddd6bd2ce60c6941c2f9faf5317510bf7ea65d56286fa17066405522ba4fc4880d0982c7cfce84375bf8507\",\n \"size\": \"99\"\n },\n \"stream_type\": \"image\",\n \"tags\": [\n \"blank\",\n \"art\"\n ],\n \"thumbLine truncated
}
]
},
@@ -3893,14 +3755,14 @@
"curl": "curl -d'{\"method\": \"stream_list\", \"params\": {\"name\": [], \"claim_id\": [], \"is_spent\": false, \"resolve\": false, \"no_totals\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream list",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_list\", \"params\": {\"name\": [], \"claim_id\": [], \"is_spent\": false, \"resolve\": false, \"no_totals\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1621405356,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"create\",\n \"confirmations\": 2,\n \"height\": 213,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"timestamp\": 1621405356,\n \"txid\": \"e4374a9fd0fc7eedc8bb14865cb7c2a11fc808aac850f23121deb663fadb8359\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\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\": \"mzNC6CMEetGVw6QDGChpUM3HfV7DpWGZ7R\",\n \"amount\": \"1.0\",\n \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"signing_channel\": {\n \"address\": \"mofqoKUmhmPTCoudQRXgjzGSDnCyJvZAZg\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"timestamp\": 1602862456,\n \"txid\": \"3ee8f25ad7bfef1d30e3fce0b212d77b74a495ef1d7635a8be77b96ffbe8e412\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200049b4cbe0f5275e7b1c170f458af09628ba75401fd95d0205ed9de9037b396f60936d555da2bc8dd09b1804b250f32d1bd07382bd3a4aaa2700b08b137b91f1159\",\n \"public_key_id\": \"mkVrRXQGgjhBaygCP3dNpbmtm5Yohno8q2\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1602862457,\n \"txid\": \"c620b71698533d88efa10c80d79a30b74464214cb0d893ec5ab4ec1c37d1676e\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpk0n0x2sb\",\n \"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mzNC6CMEetGVw6QDGChpUM3HfV7DpWGZ7R\",\n \"amount\": \"1.0\",\n \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"claim_op\": \"create\",\n \"confirmations\": 2,\n \"height\": 213,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"timestamp\": 1602862457,\n \"txid\": \"6dec60b76943a027438ca3b86aef60f33feded0acf8b5ec3381bf8894cf2d6aa\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpk0n0x2sb\",\n \"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 2,\n \"total_pages\": 1\n }\n}"
},
{
"title": "Paginate your stream claims",
"curl": "curl -d'{\"method\": \"stream_list\", \"params\": {\"name\": [], \"claim_id\": [], \"is_spent\": false, \"page\": 1, \"page_size\": 20, \"resolve\": false, \"no_totals\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream list --page=1 --page_size=20",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_list\", \"params\": {\"name\": [], \"claim_id\": [], \"is_spent\": false, \"page\": 1, \"page_size\": 20, \"resolve\": false, \"no_totals\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1621405356,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"create\",\n \"confirmations\": 2,\n \"height\": 213,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"timestamp\": 1621405356,\n \"txid\": \"e4374a9fd0fc7eedc8bb14865cb7c2a11fc808aac850f23121deb663fadb8359\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\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\": \"mzNC6CMEetGVw6QDGChpUM3HfV7DpWGZ7R\",\n \"amount\": \"1.0\",\n \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_channel_signature_valid\": true,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": false,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"signing_channel\": {\n \"address\": \"mofqoKUmhmPTCoudQRXgjzGSDnCyJvZAZg\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"timestamp\": 1602862456,\n \"txid\": \"3ee8f25ad7bfef1d30e3fce0b212d77b74a495ef1d7635a8be77b96ffbe8e412\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200049b4cbe0f5275e7b1c170f458af09628ba75401fd95d0205ed9de9037b396f60936d555da2bc8dd09b1804b250f32d1bd07382bd3a4aaa2700b08b137b91f1159\",\n \"public_key_id\": \"mkVrRXQGgjhBaygCP3dNpbmtm5Yohno8q2\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1602862457,\n \"txid\": \"c620b71698533d88efa10c80d79a30b74464214cb0d893ec5ab4ec1c37d1676e\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpk0n0x2sb\",\n \"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mzNC6CMEetGVw6QDGChpUM3HfV7DpWGZ7R\",\n \"amount\": \"1.0\",\n \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"claim_op\": \"create\",\n \"confirmations\": 2,\n \"height\": 213,\n \"is_internal_transfer\": false,\n \"is_my_input\": true,\n \"is_my_output\": true,\n \"is_spent\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"timestamp\": 1602862457,\n \"txid\": \"6dec60b76943a027438ca3b86aef60f33feded0acf8b5ec3381bf8894cf2d6aa\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpk0n0x2sb\",\n \"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 2,\n \"total_pages\": 1\n }\n}"
}
]
},
@@ -4162,12 +4024,6 @@
"description": "audio/video duration in seconds, automatically calculated",
"is_required": false
},
{
"name": "sd_hash",
"type": "str",
"description": "sd_hash of stream",
"is_required": false
},
{
"name": "channel_id",
"type": "str",
@@ -4239,10 +4095,10 @@
"examples": [
{
"title": "Update a stream claim to add channel",
"curl": "curl -d'{\"method\": \"stream_update\", \"params\": {\"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"validate_file\": false, \"optimize_file\": false, \"clear_fee\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\", \"clear_channel\": false, \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false, \"replace\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream update ea41b9f807c6982cf97a1178838dfef64feaa014 --channel_id=\"20ccc609603f9c6f01d74f2d6a133867d2903fc2\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_update\", \"params\": {\"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\", \"validate_file\": false, \"optimize_file\": false, \"clear_fee\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"channel_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\", \"clear_channel\": false, \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false, \"replace\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000025983dbfa63b6de2131f250c8aa08c81fa1c2b75c8614bbc8ed7efcd09f4a37e4000000006a473044022035dd8c46b38449f8e9dd343553e3c7c8980a8463ea586fb618ab307faf29b8ed02204cd801cea4125a0b38f0ff8505bfc500251c0991fe9b5ac06f944094f3db5a290121030bb5d283d077a4d93a13dd43f6ab8886f8f2d39b3e4936fdb1f79baa95bbf19effffffff53a4f1a509fbf2d441f02d25f7050db36e08ecc189dc30ff1449d56ff1d34124010000006b4830450221008bc1812dd520343aac1eb8fd949f143c43fa2d5922c71fb628422988d40ef6bf0220628378190c53883fe6a22ac8a0717aceeaa4a96896f789a9c16fc1891835b9490121037071cf357b535f0733476fc860a2d531c2186b84ad9d57af093118a0fdddca98ffffffff0200e1f50500000000fd2301b7076173747265616d1414a0ea4ff6fe8d8378117af92c98c607f8b941ea4ce801c23f90d26738136a2d4fd7016f9c3f6009c6cc2097c286c8bea94843a4f2796781afd1797a19737f2ae770022e06b623fedaea0a9654fc9e098271a9c186889d14e0bab2cc75cd36b1e67efe284d06467438d0ed0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d70766363706a763239180b22186170706c69636174696f6e2f6f637465742d73747265616d323054ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb76d6d76a9141fcba83c5371c31a24cb491e9d74db9e397784af88ac32a0d205000000001976a9146ff324c17cf183bd5df4fe6b6b1ec33d83320de388ac00000000\",\n \"inputs\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"height\": 213,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"timestamp\": 1621405356,\n \"txid\": \"e4374a9fd0fc7eedc8bb14865cb7c2a11fc808aac850f23121deb663fadb8359\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpvccpjv29\",\n \"sd_hash\": \"54ec72886f465bc3df47375713693c8d42e36e8837634207fd18de0e32115add3f705d7fa651adf6cd97ea89bc171eb7\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mv8AkyC2tGywD9ARYqEkznnjM7gs8LG17A\",\n \"amount\": \"0.9772285\",\n \"confirmations\": 3,\n \"height\": 211,\n \"nout\": 1,\n \"timestamp\": 1621405355,\n \"txid\": \"2441d3f16fd54914ff30dc89c1ec086eb30d05f7252df041d4f2fb09a5f1a453\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"miR5DMCS5nUcdcKdQ3Gsuffa9ZQQtDLFhd\",\n \"amount\": \"1.0\",\n \"claim_id\": \"ea41b9f807c6982cf97a1178838dfef64feaa014\",\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#ea41b9f807c6982cf97a1178838dfef64feaa014\",\n \"signing_channel\": {\n \"address\": \"mkECRf6x88VNeN1E7wgh3hVL1DvLRdNEUL\",\n \"amount\": \"1.0\",\n \"claim_id\": \"20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"claim_op\": \"update\",\n \"confirmations\": 4,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#20ccc609603f9c6f01d74f2d6a133867d2903fc2\",\n \"timestamp\": 1621405355,\n \"txid\": \"ff22a3190c8b3cf8df72a8857da6eeb102dae637b62a0eeb0f299367d3372c94\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004e93250829b529ec976a8663c8ed643e851c44028626020d3ebf3ca6cfd9d0dd1e10cda67469571e0044b82a22aa4cb78abf7d67c32604c5b0f318c9fd73b6b86\",\n \"public_key_id\": \"muK9uonhinC3s8fFAFNKxzxWu8ZHB1VbC5\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": null,\n \"txid\": \"08eb074ecd7347f339772fb6df81689199b35538c180d50a7b2d5ae135e0022b\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n Line truncated
"curl": "curl -d'{\"method\": \"stream_update\", \"params\": {\"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\", \"validate_file\": false, \"optimize_file\": false, \"clear_fee\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"channel_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\", \"clear_channel\": false, \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false, \"replace\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream update fe7ee643b50b724f6029f6edfe90d67b5512b3ae --channel_id=\"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_update\", \"params\": {\"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\", \"validate_file\": false, \"optimize_file\": false, \"clear_fee\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"channel_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\", \"clear_channel\": false, \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false, \"replace\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000002aad6f24c89f81b38c35e8bcf0aeded3ff360ef6ab8a38c4327a04369b760ec6d000000006a473044022059a3af9cb2fa8f77b777271c6b76b298d1ea8bb1c590efd1d8972b28985cbe50022063a41682e98bff3c8b478ce0c0c79940465897dd2dfcc8a420ff67204936f8030121021ef1cb2d0e5f2d4afebf3f9a2c51b78d55a2fa584070831c33a540f7900b7d27ffffffff4743215df39b581f6d75e9633df183122f89ed8db414cdd12574433530ce77cc010000006b483045022100b8886916522d73d8007f00163d4a497a3e80655d1058d884d5a1c7c2f7ea3a31022006d653c4a79ba85f5f58d6a57b3cae6fb2659495aa099b3e2fe1600a787ed20f012103907a04d6a55e4deff127af3ce813364bd35ac96c8fbf45c7dfa00aefcbc9ffeeffffffff0200e1f50500000000fd2301b7076173747265616d14aeb312557bd690feedf629604f720bb543e67efe4ce801f2d6950adda2502b543f042e4e8496b63a2bc95d1391e6159e2874bf75624f77339a61abf38b4da3237a5a52ad92aece2cefae8742c427064051fadb0dcfcc8f957b190341110ce64b8fd3f5cc874e16db11cbdc0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706b306e3078327362180b22186170706c69636174696f6e2f6f637465742d73747265616d3230d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d6d6d76a914cec22985383752987fece466729c85a74f17a45588ac32a0d205000000001976a9147a143358896b6a1ffb15d9a5b24b27ba9375650088ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mzNC6CMEetGVw6QDGChpUM3HfV7DpWGZ7R\",\n \"amount\": \"1.0\",\n \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"height\": 213,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"timestamp\": 1602862457,\n \"txid\": \"6dec60b76943a027438ca3b86aef60f33feded0acf8b5ec3381bf8894cf2d6aa\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpk0n0x2sb\",\n \"sd_hash\": \"d40576a4f0f745a868fafad794b3c5e1299cac415a911e55f6eef4395f524b63a649df4c8a75602ea1731a3c5d138b8d\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mudJaL41pUBkS3VRifB26xD4YLNWDNVrau\",\n \"amount\": \"0.9772285\",\n \"confirmations\": 3,\n \"height\": 211,\n \"nout\": 1,\n \"timestamp\": 1602862456,\n \"txid\": \"cc77ce3035437425d1cd14b48ded892f1283f13d63e9756d1f589bf35d214347\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mzNC6CMEetGVw6QDGChpUM3HfV7DpWGZ7R\",\n \"amount\": \"1.0\",\n \"claim_id\": \"fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\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#fe7ee643b50b724f6029f6edfe90d67b5512b3ae\",\n \"signing_channel\": {\n \"address\": \"mofqoKUmhmPTCoudQRXgjzGSDnCyJvZAZg\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"claim_op\": \"update\",\n \"confirmations\": 4,\n \"has_signing_key\": true,\n \"height\": 210,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#5dc92b3ab696844e2e043f542b50a2dd0a95d6f2\",\n \"timestamp\": 1602862456,\n \"txid\": \"3ee8f25ad7bfef1d30e3fce0b212d77b74a495ef1d7635a8be77b96ffbe8e412\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200049b4cbe0f5275e7b1c170f458af09628ba75401fd95d0205ed9de9037b396f60936d555da2bc8dd09b1804b250f32d1bd07382bd3a4aaa2700b08b137b91f1159\",\n \"public_key_id\": \"mkVrRXQGgjhBaygCP3dNpbmtm5Yohno8q2\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": null,\n \"txid\": \"c620b71698533d88efa10c80d79a30b74464214cb0d893ec5ab4ec1c37d1676e\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n Line truncated
}
]
}
@@ -4618,7 +4474,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 \"items\": [\n {\n \"abandon_info\": [],\n \"claim_info\": [],\n \"confirmations\": 1,\n \"date\": \"2021-05-19 03:22\",\n \"fee\": \"-0.000124\",\n \"purchase_info\": [],\n \"support_info\": [],\n \"timestamp\": 1621405355,\n \"txid\": \"d0f0cc2d9bc25d86d629b61eb4cc9cdc981a96223879056c0a623521ed8aa0a2\",\n \"update_info\": [],\n \"value\": \"0.0\"\n },\n {\n \"abandon_info\": [],\n \"claim_info\": [],\n \"confirmations\": 7,\n \"date\": \"2021-05-19 03:22\",\n \"fee\": \"0.0\",\n \"purchase_info\": [],\n \"support_info\": [],\n \"timestamp\": 1621405354,\n \"txid\": \"7a723b27c9cd2e9283da4916ec02c8aa839bf94785a64e4b012c2716cfaab958\",\n \"update_info\": [],\n \"value\": \"10.0\"\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 \"abandon_info\": [],\n \"claim_info\": [],\n \"confirmations\": 1,\n \"date\": \"2020-10-16 11:34\",\n \"fee\": \"-0.000124\",\n \"purchase_info\": [],\n \"support_info\": [],\n \"timestamp\": 1602862456,\n \"txid\": \"6947372f3637caa782cdb49daf4c9cb4f06a8479152eee6691912f042d3d5358\",\n \"update_info\": [],\n \"value\": \"0.0\"\n },\n {\n \"abandon_info\": [],\n \"claim_info\": [],\n \"confirmations\": 7,\n \"date\": \"2020-10-16 11:34\",\n \"fee\": \"0.0\",\n \"purchase_info\": [],\n \"support_info\": [],\n \"timestamp\": 1602862455,\n \"txid\": \"0843754aabf3d1313d22e51476d8a81dc1f6ce75df7844529d1d16013c803d59\",\n \"update_info\": [],\n \"value\": \"10.0\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 2,\n \"total_pages\": 1\n }\n}"
}
]
},
@@ -4669,12 +4525,6 @@
"description": "claims in this channel",
"is_required": false
},
{
"name": "not_channel_id",
"type": "str or list",
"description": "claims not in this channel",
"is_required": false
},
{
"name": "name",
"type": "str or list",
@@ -4732,7 +4582,7 @@
{
"name": "include_received_tips",
"type": "bool",
"description": "calculate the amount of tips received for claim outputs",
"description": "calculate the amount of tips recieved for claim outputs",
"is_required": false
},
{
@@ -4809,18 +4659,6 @@
"description": "claim name",
"is_required": false
},
{
"name": "channel_id",
"type": "str or list",
"description": "claims in this channel",
"is_required": false
},
{
"name": "not_channel_id",
"type": "str or list",
"description": "claims not in this channel",
"is_required": false
},
{
"name": "is_spent",
"type": "bool",
@@ -4937,12 +4775,6 @@
"description": "claims in this channel",
"is_required": false
},
{
"name": "not_channel_id",
"type": "str or list",
"description": "claims not in this channel",
"is_required": false
},
{
"name": "name",
"type": "str or list",
@@ -5035,18 +4867,6 @@
"description": "claim name",
"is_required": false
},
{
"name": "channel_id",
"type": "str or list",
"description": "claims in this channel",
"is_required": false
},
{
"name": "not_channel_id",
"type": "str or list",
"description": "claims not in this channel",
"is_required": false
},
{
"name": "is_spent",
"type": "bool",
+1 -1
View File
@@ -1,2 +1,2 @@
__version__ = "0.100.0"
__version__ = "0.87.0"
version = tuple(map(int, __version__.split('.'))) # pylint: disable=invalid-name
+2 -2
View File
@@ -2,7 +2,7 @@ import os
import typing
import asyncio
import logging
from lbry.utils import LRUCacheWithMetrics
from lbry.utils import LRUCache
from lbry.blob.blob_file import is_valid_blobhash, BlobFile, BlobBuffer, AbstractBlob
from lbry.stream.descriptor import StreamDescriptor
from lbry.connection_manager import ConnectionManager
@@ -32,7 +32,7 @@ class BlobManager:
else self._node_data_store.completed_blobs
self.blobs: typing.Dict[str, AbstractBlob] = {}
self.config = config
self.decrypted_blob_lru_cache = None if not self.config.blob_lru_cache_size else LRUCacheWithMetrics(
self.decrypted_blob_lru_cache = None if not self.config.blob_lru_cache_size else LRUCache(
self.config.blob_lru_cache_size)
self.connection_manager = ConnectionManager(loop)
+14 -99
View File
@@ -1,8 +1,8 @@
import os
import re
import sys
import typing
import logging
from typing import List, Dict, Tuple, Union, TypeVar, Generic, Optional
from argparse import ArgumentParser
from contextlib import contextmanager
from appdirs import user_data_dir, user_config_dir
@@ -15,7 +15,7 @@ log = logging.getLogger(__name__)
NOT_SET = type('NOT_SET', (object,), {}) # pylint: disable=invalid-name
T = TypeVar('T')
T = typing.TypeVar('T')
CURRENCIES = {
'BTC': {'type': 'crypto'},
@@ -24,11 +24,11 @@ CURRENCIES = {
}
class Setting(Generic[T]):
class Setting(typing.Generic[T]):
def __init__(self, doc: str, default: Optional[T] = None,
previous_names: Optional[List[str]] = None,
metavar: Optional[str] = None):
def __init__(self, doc: str, default: typing.Optional[T] = None,
previous_names: typing.Optional[typing.List[str]] = None,
metavar: typing.Optional[str] = None):
self.doc = doc
self.default = default
self.previous_names = previous_names or []
@@ -45,7 +45,7 @@ class Setting(Generic[T]):
def no_cli_name(self):
return f"--no-{self.name.replace('_', '-')}"
def __get__(self, obj: Optional['BaseConfig'], owner) -> T:
def __get__(self, obj: typing.Optional['BaseConfig'], owner) -> T:
if obj is None:
return self
for location in obj.search_order:
@@ -53,7 +53,7 @@ class Setting(Generic[T]):
return location[self.name]
return self.default
def __set__(self, obj: 'BaseConfig', val: Union[T, NOT_SET]):
def __set__(self, obj: 'BaseConfig', val: typing.Union[T, NOT_SET]):
if val == NOT_SET:
for location in obj.modify_order:
if self.name in location:
@@ -63,18 +63,6 @@ class Setting(Generic[T]):
for location in obj.modify_order:
location[self.name] = val
def is_set(self, obj: 'BaseConfig') -> bool:
for location in obj.search_order:
if self.name in location:
return True
return False
def is_set_to_default(self, obj: 'BaseConfig') -> bool:
for location in obj.search_order:
if self.name in location:
return location[self.name] == self.default
return False
def validate(self, value):
raise NotImplementedError()
@@ -99,7 +87,7 @@ class String(Setting[str]):
f"Setting '{self.name}' must be a string."
# TODO: removes this after pylint starts to understand generics
def __get__(self, obj: Optional['BaseConfig'], owner) -> str: # pylint: disable=useless-super-delegation
def __get__(self, obj: typing.Optional['BaseConfig'], owner) -> str: # pylint: disable=useless-super-delegation
return super().__get__(obj, owner)
@@ -212,7 +200,7 @@ class MaxKeyFee(Setting[dict]):
class StringChoice(String):
def __init__(self, doc: str, valid_values: List[str], default: str, *args, **kwargs):
def __init__(self, doc: str, valid_values: typing.List[str], default: str, *args, **kwargs):
super().__init__(doc, default, *args, **kwargs)
if not valid_values:
raise ValueError("No valid values provided")
@@ -285,75 +273,6 @@ class Strings(ListSetting):
f"'{self.name}' must be a string."
class KnownHubsList:
def __init__(self, config: 'Config' = None, file_name: str = 'known_hubs.yml'):
self.file_name = file_name
self.path = os.path.join(config.wallet_dir, self.file_name) if config else None
self.hubs: Dict[Tuple[str, int], Dict] = {}
if self.exists:
self.load()
@property
def exists(self):
return self.path and os.path.exists(self.path)
@property
def serialized(self) -> Dict[str, Dict]:
return {f"{host}:{port}": details for (host, port), details in self.hubs.items()}
def filter(self, match_none=False, **kwargs):
if not kwargs:
return self.hubs
result = {}
for hub, details in self.hubs.items():
for key, constraint in kwargs.items():
value = details.get(key)
if value == constraint or (match_none and value is None):
result[hub] = details
break
return result
def load(self):
if self.path:
with open(self.path, 'r') as known_hubs_file:
raw = known_hubs_file.read()
for hub, details in yaml.safe_load(raw).items():
self.set(hub, details)
def save(self):
if self.path:
with open(self.path, 'w') as known_hubs_file:
known_hubs_file.write(yaml.safe_dump(self.serialized, default_flow_style=False))
def set(self, hub: str, details: Dict):
if hub and hub.count(':') == 1:
host, port = hub.split(':')
hub_parts = (host, int(port))
if hub_parts not in self.hubs:
self.hubs[hub_parts] = details
return hub
def add_hubs(self, hubs: List[str]):
added = False
for hub in hubs:
if self.set(hub, {}) is not None:
added = True
return added
def items(self):
return self.hubs.items()
def __bool__(self):
return len(self) > 0
def __len__(self):
return self.hubs.__len__()
def __iter__(self):
return iter(self.hubs)
class EnvironmentAccess:
PREFIX = 'LBRY_'
@@ -458,7 +377,7 @@ class ConfigFileAccess:
del self.data[key]
TBC = TypeVar('TBC', bound='BaseConfig')
TBC = typing.TypeVar('TBC', bound='BaseConfig')
class BaseConfig:
@@ -589,9 +508,6 @@ class CLIConfig(TranscodeConfig):
class Config(CLIConfig):
jurisdiction = String("Limit interactions to wallet server in this jurisdiction.")
# directories
data_dir = Path("Directory path to store blobs.", metavar='DIR')
download_dir = Path(
@@ -739,7 +655,6 @@ class Config(CLIConfig):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.set_default_paths()
self.known_hubs = KnownHubsList(self)
def set_default_paths(self):
if 'darwin' in sys.platform.lower():
@@ -761,7 +676,7 @@ class Config(CLIConfig):
return os.path.join(self.data_dir, 'lbrynet.log')
def get_windows_directories() -> Tuple[str, str, str]:
def get_windows_directories() -> typing.Tuple[str, str, str]:
from lbry.winpaths import get_path, FOLDERID, UserHandle, \
PathNotFoundException # pylint: disable=import-outside-toplevel
@@ -783,14 +698,14 @@ def get_windows_directories() -> Tuple[str, str, str]:
return data_dir, lbryum_dir, download_dir
def get_darwin_directories() -> Tuple[str, str, str]:
def get_darwin_directories() -> typing.Tuple[str, str, str]:
data_dir = user_data_dir('LBRY')
lbryum_dir = os.path.expanduser('~/.lbryum')
download_dir = os.path.expanduser('~/Downloads')
return data_dir, lbryum_dir, download_dir
def get_linux_directories() -> Tuple[str, str, str]:
def get_linux_directories() -> typing.Tuple[str, str, str]:
try:
with open(os.path.join(user_config_dir(), 'user-dirs.dirs'), 'r') as xdg:
down_dir = re.search(r'XDG_DOWNLOAD_DIR=(.+)', xdg.read())
+40 -7
View File
@@ -3,6 +3,7 @@ import asyncio
import typing
import binascii
import socket
import time
from lbry.utils import resolve_host
from lbry.dht import constants
from lbry.dht.peer import make_kademlia_peer
@@ -17,6 +18,16 @@ if typing.TYPE_CHECKING:
log = logging.getLogger(__name__)
class NodeState:
def __init__(self,
routing_table_peers: typing.List[typing.Tuple[bytes, str, int, int]],
datastore: typing.List[typing.Tuple[bytes, str, int, int, bytes, float]]):
# List[Tuple[node_id, address, udp_port, tcp_port]]
self.routing_table_peers = routing_table_peers
# List[Tuple[node_id, address, udp_port, tcp_port, blob_hash, added_at]]
self.datastore = datastore
class Node:
def __init__(self, loop: asyncio.AbstractEventLoop, peer_manager: 'PeerManager', node_id: bytes, udp_port: int,
internal_udp_port: int, peer_port: int, external_ip: str, rpc_timeout: float = constants.RPC_TIMEOUT,
@@ -31,6 +42,7 @@ class Node:
self._join_task: asyncio.Task = None
self._refresh_task: asyncio.Task = None
self._storage = storage
self.started_listening = asyncio.Event()
async def refresh_node(self, force_once=False):
while True:
@@ -103,6 +115,7 @@ class Node:
return stored_to
def stop(self) -> None:
self.started_listening.clear()
if self.joined.is_set():
self.joined.clear()
if self._join_task:
@@ -118,18 +131,35 @@ class Node:
self.listening_port = None
log.info("Stopped DHT node")
def get_state(self) -> NodeState:
return NodeState(
routing_table_peers=[(p.node_id, p.address, p.udp_port, p.tcp_port)
for p in self.protocol.routing_table.get_peers()],
datastore=self.protocol.data_store.dump()
)
def load_state(self, state: NodeState):
now = self.loop.time()
for node_id, address, udp_port, tcp_port, blob_hash, added_at in state.datastore:
if added_at + constants.DATA_EXPIRATION < now:
continue
p = make_kademlia_peer(node_id, address, udp_port, tcp_port)
self.protocol.data_store.add_peer_to_blob(p, blob_hash)
async def start_listening(self, interface: str = '0.0.0.0') -> None:
if not self.listening_port:
self.listening_port, _ = await self.loop.create_datagram_endpoint(
lambda: self.protocol, (interface, self.internal_udp_port)
)
self.started_listening.set()
log.info("DHT node listening on UDP %s:%i", interface, self.internal_udp_port)
self.protocol.start()
else:
log.warning("Already bound to port %s", self.listening_port)
async def join_network(self, interface: str = '0.0.0.0',
known_node_urls: typing.Optional[typing.List[typing.Tuple[str, int]]] = None):
known_node_urls: typing.Optional[typing.List[typing.Tuple[str, int]]] = None,
persisted_peers: typing.List[typing.Tuple[bytes, str, int, int]] = []):
def peers_from_urls(urls: typing.Optional[typing.List[typing.Tuple[bytes, str, int, int]]]):
peer_addresses = []
for node_id, address, udp_port, tcp_port in urls:
@@ -148,15 +178,15 @@ class Node:
if not self.joined.is_set():
self.joined.set()
log.info(
"joined dht, %i peers known in %i buckets", len(self.protocol.routing_table.get_peers()),
"%s: joined dht, %i peers known in %i buckets",
bytes.fromhex(self.protocol.node_id)[:8],
len(self.protocol.routing_table.get_peers()),
self.protocol.routing_table.buckets_with_contacts()
)
else:
if self.joined.is_set():
self.joined.clear()
seed_peers = peers_from_urls(
await self._storage.get_persisted_kademlia_peers()
) if self._storage else []
seed_peers = peers_from_urls(persisted_peers) if persisted_peers else []
if not seed_peers:
try:
seed_peers.extend(peers_from_urls([
@@ -173,8 +203,11 @@ class Node:
await asyncio.sleep(1, loop=self.loop)
def start(self, interface: str, known_node_urls: typing.Optional[typing.List[typing.Tuple[str, int]]] = None):
self._join_task = self.loop.create_task(self.join_network(interface, known_node_urls))
def start(self, interface: str,
known_node_urls: typing.Optional[typing.List[typing.Tuple[str, int]]] = None,
persisted_peers: typing.List[typing.Tuple[bytes, str, int, int]] = []):
self._join_task = self.loop.create_task(self.join_network(interface, known_node_urls, persisted_peers))
def get_iterative_node_finder(self, key: bytes, shortlist: typing.Optional[typing.List['KademliaPeer']] = None,
bottom_out_limit: int = constants.BOTTOM_OUT_LIMIT,
+30 -11
View File
@@ -1,14 +1,14 @@
import typing
import asyncio
import logging
import ipaddress
from binascii import hexlify
from dataclasses import dataclass, field
from functools import lru_cache
from lbry.utils import is_valid_public_ipv4 as _is_valid_public_ipv4, LRUCache
from lbry.dht import constants
from lbry.dht.serialization.datagram import make_compact_address, make_compact_ip, decode_compact_address
ALLOW_LOCALHOST = False
log = logging.getLogger(__name__)
@@ -20,9 +20,28 @@ def make_kademlia_peer(node_id: typing.Optional[bytes], address: typing.Optional
return KademliaPeer(address, node_id, udp_port, tcp_port=tcp_port, allow_localhost=allow_localhost)
# the ipaddress module does not show these subnets as reserved
CARRIER_GRADE_NAT_SUBNET = ipaddress.ip_network('100.64.0.0/10')
IPV4_TO_6_RELAY_SUBNET = ipaddress.ip_network('192.88.99.0/24')
ALLOW_LOCALHOST = False
def is_valid_public_ipv4(address, allow_localhost: bool = False):
allow_localhost = bool(allow_localhost or ALLOW_LOCALHOST)
return _is_valid_public_ipv4(address, allow_localhost)
try:
parsed_ip = ipaddress.ip_address(address)
if parsed_ip.is_loopback and allow_localhost:
return True
if any((parsed_ip.version != 4, parsed_ip.is_unspecified, parsed_ip.is_link_local, parsed_ip.is_loopback,
parsed_ip.is_multicast, parsed_ip.is_reserved, parsed_ip.is_private, parsed_ip.is_reserved)):
return False
else:
return not any((CARRIER_GRADE_NAT_SUBNET.supernet_of(ipaddress.ip_network(f"{address}/32")),
IPV4_TO_6_RELAY_SUBNET.supernet_of(ipaddress.ip_network(f"{address}/32"))))
except (ipaddress.AddressValueError, ValueError):
return False
class PeerManager:
@@ -31,12 +50,12 @@ class PeerManager:
self._rpc_failures: typing.Dict[
typing.Tuple[str, int], typing.Tuple[typing.Optional[float], typing.Optional[float]]
] = {}
self._last_replied: typing.Dict[typing.Tuple[str, int], float] = LRUCache(2048)
self._last_sent: typing.Dict[typing.Tuple[str, int], float] = LRUCache(2048)
self._last_requested: typing.Dict[typing.Tuple[str, int], float] = LRUCache(2048)
self._node_id_mapping: typing.Dict[typing.Tuple[str, int], bytes] = LRUCache(2048)
self._node_id_reverse_mapping: typing.Dict[bytes, typing.Tuple[str, int]] = LRUCache(2048)
self._node_tokens: typing.Dict[bytes, (float, bytes)] = LRUCache(2048)
self._last_replied: typing.Dict[typing.Tuple[str, int], float] = {}
self._last_sent: typing.Dict[typing.Tuple[str, int], float] = {}
self._last_requested: typing.Dict[typing.Tuple[str, int], float] = {}
self._node_id_mapping: typing.Dict[typing.Tuple[str, int], bytes] = {}
self._node_id_reverse_mapping: typing.Dict[bytes, typing.Tuple[str, int]] = {}
self._node_tokens: typing.Dict[bytes, (float, bytes)] = {}
def reset(self):
for statistic in (self._rpc_failures, self._last_replied, self._last_sent, self._last_requested):
@@ -155,9 +174,9 @@ class KademliaPeer:
if self._node_id is not None:
if not len(self._node_id) == constants.HASH_LENGTH:
raise ValueError("invalid node_id: {}".format(hexlify(self._node_id).decode()))
if self.udp_port is not None and not 1024 <= self.udp_port <= 65535:
if self.udp_port is not None and not 1 <= self.udp_port <= 65535:
raise ValueError("invalid udp port")
if self.tcp_port is not None and not 1024 <= self.tcp_port <= 65535:
if self.tcp_port is not None and not 1 <= self.tcp_port <= 65535:
raise ValueError("invalid tcp port")
if not is_valid_public_ipv4(self.address, self.allow_localhost):
raise ValueError(f"invalid ip address: '{self.address}'")
+6
View File
@@ -68,3 +68,9 @@ class DictDataStore:
for _, stored in self._data_store.items():
peers.update(set(map(lambda tup: tup[0], stored)))
return list(peers)
def dump(self) -> typing.List[typing.Tuple[bytes, str, int, int, bytes, float]]:
data = []
for k, peers in self._data_store.items():
data.extend([(p.node_id, p.address, p.udp_port, p.tcp_port, k, added_at) for (p, added_at) in peers])
return data
+6
View File
@@ -287,6 +287,7 @@ class KademliaProtocol(DatagramProtocol):
self._to_add: typing.Set['KademliaPeer'] = set()
self._wakeup_routing_task = asyncio.Event(loop=self.loop)
self.maintaing_routing_task: typing.Optional[asyncio.Task] = None
self.event_queue = asyncio.Queue(maxsize=100)
@functools.lru_cache(128)
def get_rpc_peer(self, peer: 'KademliaPeer') -> RemoteKademliaRPC:
@@ -428,6 +429,11 @@ class KademliaProtocol(DatagramProtocol):
log.debug("%s:%i RECV CALL %s %s:%i", self.external_ip, self.udp_port, message.method.decode(),
sender_contact.address, sender_contact.udp_port)
try:
self.event_queue.put_nowait((sender_contact.node_id, sender_contact.address, method, args))
except asyncio.QueueFull:
pass
if method == b'ping':
result = self.node_rpc.ping()
elif method == b'store':
+1 -1
View File
@@ -286,7 +286,7 @@ class TreeRoutingTable:
to_pop = [i for i, bucket in enumerate(self.buckets) if len(bucket) == 0]
if not to_pop:
return
log.info("join buckets %i", len(to_pop))
log.debug("%s: join buckets %i", bytes.hex(self._parent_node_id)[:8], len(to_pop))
bucket_index_to_pop = to_pop[0]
assert len(self.buckets[bucket_index_to_pop]) == 0
can_go_lower = bucket_index_to_pop - 1 >= 0
+1 -1
View File
@@ -132,7 +132,7 @@ class AnalyticsManager:
async def run(self):
while True:
if self.enabled:
self.external_ip, _ = await utils.get_external_ip(self.conf.lbryum_servers)
self.external_ip = await utils.get_external_ip()
await self._send_heartbeat()
await asyncio.sleep(1800)
+18 -24
View File
@@ -119,14 +119,13 @@ class WalletComponent(Component):
async def get_status(self):
if self.wallet_manager is None:
return
is_connected = self.wallet_manager.ledger.network.is_connected
sessions = []
session_pool = self.wallet_manager.ledger.network.session_pool
sessions = session_pool.sessions
connected = None
if is_connected:
addr, port = self.wallet_manager.ledger.network.client.server
connected = f"{addr}:{port}"
sessions.append(self.wallet_manager.ledger.network.client)
if self.wallet_manager.ledger.network.client:
addr_and_port = self.wallet_manager.ledger.network.client.server_address_and_port
if addr_and_port:
connected = f"{addr_and_port[0]}:{addr_and_port[1]}"
result = {
'connected': connected,
'connected_features': self.wallet_manager.ledger.network.server_features,
@@ -138,8 +137,8 @@ class WalletComponent(Component):
'availability': session.available,
} for session in sessions
],
'known_servers': len(self.wallet_manager.ledger.network.known_hubs),
'available_servers': 1 if is_connected else 0
'known_servers': len(sessions),
'available_servers': len(list(session_pool.available_sessions))
}
if self.wallet_manager.ledger.network.remote_height:
@@ -275,7 +274,7 @@ class DHTComponent(Component):
external_ip = upnp_component.external_ip
storage = self.component_manager.get_component(DATABASE_COMPONENT)
if not external_ip:
external_ip, _ = await utils.get_external_ip(self.conf.lbryum_servers)
external_ip = await utils.get_external_ip()
if not external_ip:
log.warning("failed to get external ip")
@@ -329,7 +328,7 @@ class HashAnnouncerComponent(Component):
class FileManagerComponent(Component):
component_name = FILE_MANAGER_COMPONENT
depends_on = [BLOB_COMPONENT, DATABASE_COMPONENT, WALLET_COMPONENT]
depends_on = [BLOB_COMPONENT, DATABASE_COMPONENT, WALLET_COMPONENT, LIBTORRENT_COMPONENT]
def __init__(self, component_manager):
super().__init__(component_manager)
@@ -352,10 +351,7 @@ class FileManagerComponent(Component):
wallet = self.component_manager.get_component(WALLET_COMPONENT)
node = self.component_manager.get_component(DHT_COMPONENT) \
if self.component_manager.has_component(DHT_COMPONENT) else None
try:
torrent = self.component_manager.get_component(LIBTORRENT_COMPONENT) if TorrentSession else None
except NameError:
torrent = None
torrent = self.component_manager.get_component(LIBTORRENT_COMPONENT) if TorrentSession else None
log.info('Starting the file manager')
loop = asyncio.get_event_loop()
self.file_manager = FileManager(
@@ -364,7 +360,7 @@ class FileManagerComponent(Component):
self.file_manager.source_managers['stream'] = StreamManager(
loop, self.conf, blob_manager, wallet, storage, node,
)
if TorrentSession and LIBTORRENT_COMPONENT not in self.conf.components_to_skip:
if TorrentSession:
self.file_manager.source_managers['torrent'] = TorrentManager(
loop, self.conf, torrent, storage, self.component_manager.analytics_manager
)
@@ -476,7 +472,7 @@ class UPnPComponent(Component):
pass
if external_ip and not is_valid_public_ipv4(external_ip):
log.warning("UPnP returned a private/reserved ip - %s, checking lbry.com fallback", external_ip)
external_ip, _ = await utils.get_external_ip(self.conf.lbryum_servers)
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)
if external_ip:
@@ -534,15 +530,13 @@ class UPnPComponent(Component):
async def start(self):
log.info("detecting external ip")
if not self.use_upnp:
self.external_ip, _ = await utils.get_external_ip(self.conf.lbryum_servers)
self.external_ip = await utils.get_external_ip()
return
success = False
await self._maintain_redirects()
if self.upnp:
if not self.upnp_redirects and not all(
x in self.component_manager.skip_components
for x in (DHT_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT)
):
if not self.upnp_redirects and not all([x in self.component_manager.skip_components for x in
(DHT_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT)]):
log.error("failed to setup upnp")
else:
success = True
@@ -551,9 +545,9 @@ class UPnPComponent(Component):
else:
log.error("failed to setup upnp")
if not self.external_ip:
self.external_ip, probed_url = await utils.get_external_ip(self.conf.lbryum_servers)
self.external_ip = await utils.get_external_ip()
if self.external_ip:
log.info("detected external ip using %s fallback", probed_url)
log.info("detected external ip using lbry.com fallback")
if self.component_manager.analytics_manager:
self.component_manager.loop.create_task(
self.component_manager.analytics_manager.send_upnp_setup_success_fail(
+113 -151
View File
@@ -119,6 +119,13 @@ STREAM_STAGES = [
(DOWNLOAD_TIMEOUT_CODE, 'Stream timed out')
]
CONNECTION_STATUS_CONNECTED = 'connected'
CONNECTION_STATUS_NETWORK = 'network_connection'
CONNECTION_MESSAGES = {
CONNECTION_STATUS_CONNECTED: 'No connection problems detected',
CONNECTION_STATUS_NETWORK: "Your internet connection appears to have been interrupted",
}
SHORT_ID_LEN = 20
MAX_UPDATE_FEE_ESTIMATE = 0.3
DEFAULT_PAGE_SIZE = 20
@@ -332,13 +339,13 @@ class Daemon(metaclass=JSONRPCServerType):
skip_components=conf.components_to_skip or []
)
self.component_startup_task = None
self._connection_status: typing.Tuple[float, bool] = (self.component_manager.loop.time(), False)
logging.getLogger('aiohttp.access').setLevel(logging.WARN)
rpc_app = web.Application()
rpc_app.router.add_get('/lbryapi', self.handle_old_jsonrpc)
rpc_app.router.add_post('/lbryapi', self.handle_old_jsonrpc)
rpc_app.router.add_post('/', self.handle_old_jsonrpc)
rpc_app.router.add_options('/', self.add_cors_headers)
self.rpc_runner = web.AppRunner(rpc_app)
streaming_app = web.Application()
@@ -351,6 +358,9 @@ class Daemon(metaclass=JSONRPCServerType):
prom_app.router.add_get('/metrics', self.handle_metrics_get_request)
self.metrics_runner = web.AppRunner(prom_app)
self.need_connection_status_refresh = asyncio.Event()
self._connection_status_task: Optional[asyncio.Task] = None
@property
def dht_node(self) -> typing.Optional['Node']:
return self.component_manager.get_component(DHT_COMPONENT)
@@ -455,10 +465,31 @@ class Daemon(metaclass=JSONRPCServerType):
if not os.path.isdir(self.conf.download_dir):
os.makedirs(self.conf.download_dir)
async def update_connection_status(self):
connected = await utils.async_check_connection()
if connected and not self._connection_status[1]:
log.info("detected internet connection is working")
elif not connected and self._connection_status[1]:
log.warning("detected internet connection was lost")
self._connection_status = (self.component_manager.loop.time(), connected)
async def keep_connection_status_up_to_date(self):
while True:
try:
await asyncio.wait_for(self.need_connection_status_refresh.wait(), 300)
except asyncio.TimeoutError:
pass
await self.update_connection_status()
self.need_connection_status_refresh.clear()
async def start(self):
log.info("Starting LBRYNet Daemon")
log.debug("Settings: %s", json.dumps(self.conf.settings_dict, indent=2))
log.info("Platform: %s", json.dumps(self.platform_info, indent=2))
self.need_connection_status_refresh.set()
self._connection_status_task = self.component_manager.loop.create_task(
self.keep_connection_status_up_to_date()
)
await self.analytics_manager.send_server_startup()
await self.rpc_runner.setup()
@@ -518,6 +549,10 @@ class Daemon(metaclass=JSONRPCServerType):
await self.component_startup_task
async def stop(self):
if self._connection_status_task:
if not self._connection_status_task.done():
self._connection_status_task.cancel()
self._connection_status_task = None
if self.component_startup_task is not None:
if self.component_startup_task.done():
await self.component_manager.stop()
@@ -540,17 +575,6 @@ class Daemon(metaclass=JSONRPCServerType):
self.analytics_manager.stop()
log.info("finished shutting down")
async def add_cors_headers(self, request):
if self.conf.allowed_origin:
return web.Response(
headers={
'Access-Control-Allow-Origin': self.conf.allowed_origin,
'Access-Control-Allow-Methods': self.conf.allowed_origin,
'Access-Control-Allow-Headers': self.conf.allowed_origin,
}
)
return None
async def handle_old_jsonrpc(self, request):
ensure_request_allowed(request, self.conf)
data = await request.json()
@@ -571,16 +595,8 @@ class Daemon(metaclass=JSONRPCServerType):
'After successfully executing the command, failed to encode result for JSON RPC response.',
{'traceback': format_exc()}
), ledger=ledger)
headers = {}
if self.conf.allowed_origin:
headers.update({
'Access-Control-Allow-Origin': self.conf.allowed_origin,
'Access-Control-Allow-Methods': self.conf.allowed_origin,
'Access-Control-Allow-Headers': self.conf.allowed_origin,
})
return web.Response(
text=encoded_result,
headers=headers,
content_type='application/json'
)
@@ -920,6 +936,10 @@ class Daemon(metaclass=JSONRPCServerType):
}
}
"""
if not self._connection_status[1]:
self.need_connection_status_refresh.set()
connection_code = CONNECTION_STATUS_CONNECTED if self._connection_status[1] else CONNECTION_STATUS_NETWORK
ffmpeg_status = await self._video_file_analyzer.status()
running_components = self.component_manager.get_components_status()
response = {
@@ -927,6 +947,10 @@ class Daemon(metaclass=JSONRPCServerType):
'is_running': all(running_components.values()),
'skipped_components': self.component_manager.skip_components,
'startup_status': running_components,
'connection_status': {
'code': connection_code,
'message': CONNECTION_MESSAGES[connection_code],
},
'ffmpeg_status': ffmpeg_status
}
for component in self.component_manager.components:
@@ -975,7 +999,7 @@ class Daemon(metaclass=JSONRPCServerType):
Options:
--urls=<urls> : (str, list) one or more urls to resolve
--wallet_id=<wallet_id> : (str) wallet to check for claim purchase receipts
--wallet_id=<wallet_id> : (str) wallet to check for claim purchase reciepts
--new_sdk_server=<new_sdk_server> : (str) URL of the new SDK server (EXPERIMENTAL)
--include_purchase_receipt : (bool) lookup and include a receipt if this wallet
has purchased the claim being resolved
@@ -1088,7 +1112,7 @@ class Daemon(metaclass=JSONRPCServerType):
--download_directory=<download_directory> : (str) full path to the directory to download into
--timeout=<timeout> : (int) download timeout in number of seconds
--save_file=<save_file> : (bool) save the file to the downloads directory
--wallet_id=<wallet_id> : (str) wallet to check for claim purchase receipts
--wallet_id=<wallet_id> : (str) wallet to check for claim purchase reciepts
Returns: {File}
"""
@@ -1477,21 +1501,12 @@ class Daemon(metaclass=JSONRPCServerType):
outputs = []
for address in addresses:
self.valid_address_or_error(address, allow_script_address=True)
if self.ledger.is_pubkey_address(address):
outputs.append(
Output.pay_pubkey_hash(
amount, self.ledger.address_to_hash160(address)
)
self.valid_address_or_error(address)
outputs.append(
Output.pay_pubkey_hash(
amount, self.ledger.address_to_hash160(address)
)
elif self.ledger.is_script_address(address):
outputs.append(
Output.pay_script_hash(
amount, self.ledger.address_to_hash160(address)
)
)
else:
raise ValueError(f"Unsupported address: '{address}'")
)
tx = await Transaction.create(
[], outputs, accounts, account
@@ -1565,7 +1580,7 @@ class Daemon(metaclass=JSONRPCServerType):
wallet = self.wallet_manager.get_wallet_or_default(wallet_id)
account = wallet.get_account_or_default(account_id)
balance = await account.get_detailed_balance(
confirmations=confirmations, read_only=True
confirmations=confirmations, reserved_subtotals=True, read_only=True
)
return dict_values_to_lbc(balance)
@@ -2263,7 +2278,7 @@ class Daemon(metaclass=JSONRPCServerType):
Usage:
claim_list [--claim_type=<claim_type>...] [--claim_id=<claim_id>...] [--name=<name>...] [--is_spent]
[--channel_id=<channel_id>...] [--account_id=<account_id>] [--wallet_id=<wallet_id>]
[--has_source | --has_no_source] [--page=<page>] [--page_size=<page_size>]
[--page=<page>] [--page_size=<page_size>]
[--resolve] [--order_by=<order_by>] [--no_totals] [--include_received_tips]
Options:
@@ -2274,15 +2289,13 @@ class Daemon(metaclass=JSONRPCServerType):
--is_spent : (bool) shows previous claim updates and abandons
--account_id=<account_id> : (str) id of the account to query
--wallet_id=<wallet_id> : (str) restrict results to specific wallet
--has_source : (bool) list claims containing a source field
--has_no_source : (bool) list claims not containing a source field
--page=<page> : (int) page to return during paginating
--page_size=<page_size> : (int) number of items on page during pagination
--resolve : (bool) resolves each claim to provide additional metadata
--order_by=<order_by> : (str) field to order by: 'name', 'height', 'amount'
--no_totals : (bool) do not calculate the total number of pages and items in result set
(significant performance boost)
--include_received_tips : (bool) calculate the amount of tips received for claim outputs
--include_received_tips : (bool) calculate the amount of tips recieved for claim outputs
Returns: {Paginated[Output]}
"""
@@ -2359,9 +2372,8 @@ class Daemon(metaclass=JSONRPCServerType):
[--not_languages=<not_languages>...]
[--any_locations=<any_locations>...] [--all_locations=<all_locations>...]
[--not_locations=<not_locations>...]
[--order_by=<order_by>...] [--no_totals] [--page=<page>] [--page_size=<page_size>]
[--order_by=<order_by>...] [--page=<page>] [--page_size=<page_size>]
[--wallet_id=<wallet_id>] [--include_purchase_receipt] [--include_is_my_output]
[--remove_duplicates] [--has_source | --has_no_source]
[--new_sdk_server=<new_sdk_server>]
Options:
@@ -2439,7 +2451,7 @@ class Daemon(metaclass=JSONRPCServerType):
--reposted_claim_id=<reposted_claim_id>: (str) all reposts of the specified original claim id
--reposted=<reposted> : (int) claims reposted this many times (supports
equality constraints)
--claim_type=<claim_type> : (str) filter by 'channel', 'stream', 'repost' or 'collection'
--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
--fee_currency=<fee_currency> : (string) specify fee currency: LBC, BTC, USD
@@ -2465,15 +2477,11 @@ class Daemon(metaclass=JSONRPCServerType):
'trending_local', 'trending_global', 'activation_height'
--no_totals : (bool) do not calculate the total number of pages and items in result set
(significant performance boost)
--wallet_id=<wallet_id> : (str) wallet to check for claim purchase receipts
--wallet_id=<wallet_id> : (str) wallet to check for claim purchase reciepts
--include_purchase_receipt : (bool) lookup and include a receipt if this wallet
has purchased the claim
--include_is_my_output : (bool) lookup and include a boolean indicating
if claim being resolved is yours
--remove_duplicates : (bool) removes duplicated content from search by picking either the
original claim or the oldest matching repost
--has_source : (bool) find claims containing a source field
--has_no_source : (bool) find claims not containing a source field
--new_sdk_server=<new_sdk_server> : (str) URL of the new SDK server (EXPERIMENTAL)
Returns: {Paginated[Output]}
@@ -2485,8 +2493,6 @@ class Daemon(metaclass=JSONRPCServerType):
kwargs['signature_valid'] = 1
if kwargs.pop('invalid_channel_signature', False):
kwargs['signature_valid'] = 0
if 'has_no_source' in kwargs:
kwargs['has_source'] = not kwargs.pop('has_no_source')
page_num, page_size = abs(kwargs.pop('page', 1)), min(abs(kwargs.pop('page_size', DEFAULT_PAGE_SIZE)), 50)
kwargs.update({'offset': page_size * (page_num - 1), 'limit': page_size})
txos, blocked, _, total = await self.ledger.claim_search(wallet.accounts, **kwargs)
@@ -2802,12 +2808,7 @@ class Daemon(metaclass=JSONRPCServerType):
for channel certificates, defaults to all accounts.
--wallet_id=<wallet_id> : (str) restrict operation to specific wallet
Returns:
(dict) Signature if successfully made, (None) or an error otherwise
{
"signature": (str) The signature of the comment,
"signing_ts": (str) The timestamp used to sign the comment,
}
Returns: {}
"""
wallet = self.wallet_manager.get_wallet_or_default(wallet_id)
assert not wallet.is_locked, "Cannot spend funds with locked wallet, unlock first."
@@ -2900,7 +2901,7 @@ class Daemon(metaclass=JSONRPCServerType):
Returns: {Paginated[Output]}
"""
kwargs['type'] = 'channel'
if 'is_spent' not in kwargs or not kwargs['is_spent']:
if 'is_spent' not in kwargs:
kwargs['is_not_spent'] = True
return self.jsonrpc_txo_list(*args, **kwargs)
@@ -3009,13 +3010,13 @@ class Daemon(metaclass=JSONRPCServerType):
Usage:
publish (<name> | --name=<name>) [--bid=<bid>] [--file_path=<file_path>]
[--file_name=<file_name>] [--file_hash=<file_hash>] [--validate_file] [--optimize_file]
[--validate_file] [--optimize_file]
[--fee_currency=<fee_currency>] [--fee_amount=<fee_amount>] [--fee_address=<fee_address>]
[--title=<title>] [--description=<description>] [--author=<author>]
[--tags=<tags>...] [--languages=<languages>...] [--locations=<locations>...]
[--license=<license>] [--license_url=<license_url>] [--thumbnail_url=<thumbnail_url>]
[--release_time=<release_time>] [--width=<width>] [--height=<height>] [--duration=<duration>]
[--sd_hash=<sd_hash>] [--channel_id=<channel_id> | --channel_name=<channel_name>]
[--channel_id=<channel_id> | --channel_name=<channel_name>]
[--channel_account_id=<channel_account_id>...]
[--account_id=<account_id>] [--wallet_id=<wallet_id>]
[--claim_address=<claim_address>] [--funding_account_ids=<funding_account_ids>...]
@@ -3025,8 +3026,6 @@ class Daemon(metaclass=JSONRPCServerType):
--name=<name> : (str) name of the content (can only consist of a-z A-Z 0-9 and -(dash))
--bid=<bid> : (decimal) amount to back the claim
--file_path=<file_path> : (str) path to file to be associated with name.
--file_name=<file_name> : (str) name of file to be associated with stream.
--file_hash=<file_hash> : (str) hash of file to be associated with stream.
--validate_file : (bool) validate that the video container and encodings match
common web browser support or that optimization succeeds if specified.
FFmpeg is required
@@ -3089,7 +3088,6 @@ class Daemon(metaclass=JSONRPCServerType):
--width=<width> : (int) image/video width, automatically calculated from media file
--height=<height> : (int) image/video height, automatically calculated from media file
--duration=<duration> : (int) audio/video duration in seconds, automatically calculated
--sd_hash=<sd_hash> : (str) sd_hash of stream
--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
@@ -3116,6 +3114,8 @@ class Daemon(metaclass=JSONRPCServerType):
if len(claims) == 0:
if 'bid' not in kwargs:
raise Exception("'bid' is a required argument for new publishes.")
if 'file_path' not in kwargs:
raise Exception("'file_path' is a required argument for new publishes.")
return await self.jsonrpc_stream_create(name, **kwargs)
elif len(claims) == 1:
assert claims[0].claim.is_stream, f"Claim at name '{name}' is not a stream claim."
@@ -3199,7 +3199,7 @@ class Daemon(metaclass=JSONRPCServerType):
@requires(WALLET_COMPONENT, FILE_MANAGER_COMPONENT, BLOB_COMPONENT, DATABASE_COMPONENT)
async def jsonrpc_stream_create(
self, name, bid, file_path=None, allow_duplicate_name=False,
self, name, bid, file_path, allow_duplicate_name=False,
channel_id=None, channel_name=None, channel_account_id=None,
account_id=None, wallet_id=None, claim_address=None, funding_account_ids=None,
preview=False, blocking=False, validate_file=False, optimize_file=False, **kwargs):
@@ -3207,15 +3207,15 @@ class Daemon(metaclass=JSONRPCServerType):
Make a new stream claim and announce the associated file to lbrynet.
Usage:
stream_create (<name> | --name=<name>) (<bid> | --bid=<bid>) [<file_path> | --file_path=<file_path>]
[--file_name=<file_name>] [--file_hash=<file_hash>] [--validate_file] [--optimize_file]
stream_create (<name> | --name=<name>) (<bid> | --bid=<bid>) (<file_path> | --file_path=<file_path>)
[--validate_file] [--optimize_file]
[--allow_duplicate_name=<allow_duplicate_name>]
[--fee_currency=<fee_currency>] [--fee_amount=<fee_amount>] [--fee_address=<fee_address>]
[--title=<title>] [--description=<description>] [--author=<author>]
[--tags=<tags>...] [--languages=<languages>...] [--locations=<locations>...]
[--license=<license>] [--license_url=<license_url>] [--thumbnail_url=<thumbnail_url>]
[--release_time=<release_time>] [--width=<width>] [--height=<height>] [--duration=<duration>]
[--sd_hash=<sd_hash>] [--channel_id=<channel_id> | --channel_name=<channel_name>]
[--channel_id=<channel_id> | --channel_name=<channel_name>]
[--channel_account_id=<channel_account_id>...]
[--account_id=<account_id>] [--wallet_id=<wallet_id>]
[--claim_address=<claim_address>] [--funding_account_ids=<funding_account_ids>...]
@@ -3225,8 +3225,6 @@ class Daemon(metaclass=JSONRPCServerType):
--name=<name> : (str) name of the content (can only consist of a-z A-Z 0-9 and -(dash))
--bid=<bid> : (decimal) amount to back the claim
--file_path=<file_path> : (str) path to file to be associated with name.
--file_name=<file_name> : (str) name of file to be associated with stream.
--file_hash=<file_hash> : (str) hash of file to be associated with stream.
--validate_file : (bool) validate that the video container and encodings match
common web browser support or that optimization succeeds if specified.
FFmpeg is required
@@ -3291,14 +3289,13 @@ class Daemon(metaclass=JSONRPCServerType):
--width=<width> : (int) image/video width, automatically calculated from media file
--height=<height> : (int) image/video height, automatically calculated from media file
--duration=<duration> : (int) audio/video duration in seconds, automatically calculated
--sd_hash=<sd_hash> : (str) sd_hash of stream
--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_account_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 holding the transaction
--wallet_id=<wallet_id> : (str) restrict operation to specific wallet
--funding_account_ids=<funding_account_ids>: (list) ids of accounts to fund this transaction
--funding_account_ids=<funding_account_ids>: (list) ids of accounts to fund this transaction
--claim_address=<claim_address>: (str) address where the claim is sent to, if not specified
it will be determined automatically from the account
--preview : (bool) do not broadcast the transaction
@@ -3324,24 +3321,20 @@ class Daemon(metaclass=JSONRPCServerType):
f"Use --allow-duplicate-name flag to override."
)
if file_path is not None:
file_path, spec = await self._video_file_analyzer.verify_or_repair(
validate_file, optimize_file, file_path, ignore_non_video=True
)
kwargs.update(spec)
file_path, spec = await self._video_file_analyzer.verify_or_repair(
validate_file, optimize_file, file_path, ignore_non_video=True
)
kwargs.update(spec)
claim = Claim()
if file_path is not None:
claim.stream.update(file_path=file_path, sd_hash='0' * 96, **kwargs)
else:
claim.stream.update(**kwargs)
claim.stream.update(file_path=file_path, sd_hash='0' * 96, **kwargs)
tx = await Transaction.claim_create(
name, claim, amount, claim_address, funding_accounts, funding_accounts[0], channel
)
new_txo = tx.outputs[0]
file_stream = None
if not preview and file_path is not None:
if not preview:
file_stream = await self.file_manager.create_stream(file_path)
claim.stream.source.sd_hash = file_stream.sd_hash
new_txo.script.generate()
@@ -3357,8 +3350,7 @@ class Daemon(metaclass=JSONRPCServerType):
await self.storage.save_claims([self._old_get_temp_claim_info(
tx, new_txo, claim_address, claim, name, dewies_to_lbc(amount)
)])
if file_path is not None:
await self.storage.save_content_claim(file_stream.stream_hash, new_txo.id)
await self.storage.save_content_claim(file_stream.stream_hash, new_txo.id)
self.component_manager.loop.create_task(save_claims())
self.component_manager.loop.create_task(self.analytics_manager.send_claim_action('publish'))
@@ -3388,7 +3380,7 @@ class Daemon(metaclass=JSONRPCServerType):
[--locations=<locations>...] [--clear_locations]
[--license=<license>] [--license_url=<license_url>] [--thumbnail_url=<thumbnail_url>]
[--release_time=<release_time>] [--width=<width>] [--height=<height>] [--duration=<duration>]
[--sd_hash=<sd_hash>] [--channel_id=<channel_id> | --channel_name=<channel_name> | --clear_channel]
[--channel_id=<channel_id> | --channel_name=<channel_name> | --clear_channel]
[--channel_account_id=<channel_account_id>...]
[--account_id=<account_id>] [--wallet_id=<wallet_id>]
[--claim_address=<claim_address>] [--funding_account_ids=<funding_account_ids>...]
@@ -3467,7 +3459,6 @@ class Daemon(metaclass=JSONRPCServerType):
--width=<width> : (int) image/video width, automatically calculated from media file
--height=<height> : (int) image/video height, automatically calculated from media file
--duration=<duration> : (int) audio/video duration in seconds, automatically calculated
--sd_hash=<sd_hash> : (str) sd_hash of stream
--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
@@ -3539,10 +3530,9 @@ class Daemon(metaclass=JSONRPCServerType):
if replace:
claim = Claim()
if old_txo.claim.stream.has_source:
claim.stream.message.source.CopyFrom(
old_txo.claim.stream.message.source
)
claim.stream.message.source.CopyFrom(
old_txo.claim.stream.message.source
)
stream_type = old_txo.claim.stream.stream_type
if stream_type:
old_stream_type = getattr(old_txo.claim.stream.message, stream_type)
@@ -3713,16 +3703,14 @@ class Daemon(metaclass=JSONRPCServerType):
Usage:
collection_create (<name> | --name=<name>) (<bid> | --bid=<bid>)
(--claims=<claims>...)
[--allow_duplicate_name]
[--title=<title>] [--description=<description>]
[--tags=<tags>...] [--languages=<languages>...] [--locations=<locations>...]
[--thumbnail_url=<thumbnail_url>]
[--channel_id=<channel_id> | --channel_name=<channel_name>]
[--channel_account_id=<channel_account_id>...]
[--account_id=<account_id>] [--wallet_id=<wallet_id>]
[--claim_address=<claim_address>] [--funding_account_ids=<funding_account_ids>...]
[--preview] [--blocking]
(<claims>... | --claims=<claims>...)
[--allow_duplicate_name]
[--title=<title>] [--description=<description>]
[--tags=<tags>...] [--languages=<languages>...] [--locations=<locations>...]
[--thumbnail_url=<thumbnail_url>]
[--account_id=<account_id>] [--wallet_id=<wallet_id>]
[--claim_address=<claim_address>] [--funding_account_ids=<funding_account_ids>...]
[--preview] [--blocking]
Options:
--name=<name> : (str) name of the collection
@@ -3773,10 +3761,6 @@ class Daemon(metaclass=JSONRPCServerType):
... --locations="{'country': 'US', 'state': 'NH'}"
--thumbnail_url=<thumbnail_url>: (str) thumbnail url
--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
for channel certificates, defaults to all accounts.
--account_id=<account_id> : (str) account to use for holding the transaction
--wallet_id=<wallet_id> : (str) restrict operation to specific wallet
--funding_account_ids=<funding_account_ids>: (list) ids of accounts to fund this transaction
@@ -3840,7 +3824,7 @@ class Daemon(metaclass=JSONRPCServerType):
[--locations=<locations>...] [--clear_locations]
[--thumbnail_url=<thumbnail_url>] [--cover_url=<cover_url>]
[--account_id=<account_id>] [--wallet_id=<wallet_id>]
[--claim_address=<claim_address>]
[--claim_address=<claim_address>] [--new_signing_key]
[--funding_account_ids=<funding_account_ids>...]
[--preview] [--blocking] [--replace]
@@ -3898,6 +3882,7 @@ class Daemon(metaclass=JSONRPCServerType):
--wallet_id=<wallet_id> : (str) restrict operation to specific wallet
--funding_account_ids=<funding_account_ids>: (list) ids of accounts to fund this transaction
--claim_address=<claim_address>: (str) address where the collection is sent
--new_signing_key : (bool) generate a new signing key, will invalidate all previous publishes
--preview : (bool) do not broadcast the transaction
--blocking : (bool) wait until transaction is in mempool
--replace : (bool) instead of modifying specific values on
@@ -3949,6 +3934,9 @@ class Daemon(metaclass=JSONRPCServerType):
if replace:
claim = Claim()
claim.collection.message.source.CopyFrom(
old_txo.claim.collection.message.source
)
claim.collection.update(**kwargs)
else:
claim = Claim.from_bytes(old_txo.claim.to_bytes())
@@ -3958,6 +3946,8 @@ class Daemon(metaclass=JSONRPCServerType):
)
new_txo = tx.outputs[0]
new_txo.script.generate()
if channel:
new_txo.sign(channel)
await tx.sign(funding_accounts)
@@ -3995,18 +3985,15 @@ class Daemon(metaclass=JSONRPCServerType):
return await self.jsonrpc_stream_abandon(*args, **kwargs)
@requires(WALLET_COMPONENT)
def jsonrpc_collection_list(
self, resolve_claims=0, resolve=False, account_id=None,
wallet_id=None, page=None, page_size=None):
def jsonrpc_collection_list(self, resolve_claims=0, account_id=None, wallet_id=None, page=None, page_size=None):
"""
List my collection claims.
Usage:
collection_list [--resolve_claims=<resolve_claims>] [--resolve] [<account_id> | --account_id=<account_id>]
collection_list [--resolve_claims=<resolve_claims>] [<account_id> | --account_id=<account_id>]
[--wallet_id=<wallet_id>] [--page=<page>] [--page_size=<page_size>]
Options:
--resolve : (bool) resolve collection claim
--resolve_claims=<resolve_claims> : (int) resolve every claim
--account_id=<account_id> : (str) id of the account to use
--wallet_id=<wallet_id> : (str) restrict results to specific wallet
@@ -4023,10 +4010,7 @@ class Daemon(metaclass=JSONRPCServerType):
else:
collections = partial(self.ledger.get_collections, wallet=wallet, accounts=wallet.accounts)
collection_count = partial(self.ledger.get_collection_count, wallet=wallet, accounts=wallet.accounts)
return paginate_rows(
collections, collection_count, page, page_size,
resolve=resolve, resolve_claims=resolve_claims
)
return paginate_rows(collections, collection_count, page, page_size, resolve_claims=resolve_claims)
async def jsonrpc_collection_resolve(
self, claim_id=None, url=None, wallet_id=None, page=1, page_size=DEFAULT_PAGE_SIZE):
@@ -4080,7 +4064,7 @@ class Daemon(metaclass=JSONRPCServerType):
self, claim_id, amount, tip=False,
channel_id=None, channel_name=None, channel_account_id=None,
account_id=None, wallet_id=None, funding_account_ids=None,
comment=None, preview=False, blocking=False):
preview=False, blocking=False):
"""
Create a support or a tip for name claim.
@@ -4088,7 +4072,7 @@ class Daemon(metaclass=JSONRPCServerType):
support_create (<claim_id> | --claim_id=<claim_id>) (<amount> | --amount=<amount>)
[--tip] [--account_id=<account_id>] [--wallet_id=<wallet_id>]
[--channel_id=<channel_id> | --channel_name=<channel_name>]
[--channel_account_id=<channel_account_id>...] [--comment=<comment>]
[--channel_account_id=<channel_account_id>...]
[--preview] [--blocking] [--funding_account_ids=<funding_account_ids>...]
Options:
@@ -4102,7 +4086,6 @@ class Daemon(metaclass=JSONRPCServerType):
--account_id=<account_id> : (str) account to use for holding the transaction
--wallet_id=<wallet_id> : (str) restrict operation to specific wallet
--funding_account_ids=<funding_account_ids>: (list) ids of accounts to fund this transaction
--comment=<comment> : (str) add a comment to the support
--preview : (bool) do not broadcast the transaction
--blocking : (bool) wait until transaction is in mempool
@@ -4120,8 +4103,7 @@ class Daemon(metaclass=JSONRPCServerType):
claim_address = await account.receiving.get_or_create_usable_address()
tx = await Transaction.support(
claim.claim_name, claim_id, amount, claim_address, funding_accounts, funding_accounts[0], channel,
comment=comment
claim.claim_name, claim_id, amount, claim_address, funding_accounts, funding_accounts[0], channel
)
new_txo = tx.outputs[0]
@@ -4360,10 +4342,8 @@ class Daemon(metaclass=JSONRPCServerType):
@staticmethod
def _constrain_txo_from_kwargs(
constraints, type=None, txid=None, # pylint: disable=redefined-builtin
claim_id=None, channel_id=None, not_channel_id=None,
name=None, reposted_claim_id=None,
claim_id=None, channel_id=None, name=None, reposted_claim_id=None,
is_spent=False, is_not_spent=False,
has_source=None, has_no_source=None,
is_my_input_or_output=None, exclude_internal_transfers=False,
is_my_output=None, is_not_my_output=None,
is_my_input=None, is_not_my_input=None):
@@ -4371,10 +4351,6 @@ class Daemon(metaclass=JSONRPCServerType):
constraints['is_spent'] = True
elif is_not_spent:
constraints['is_spent'] = False
if has_source:
constraints['has_source'] = True
elif has_no_source:
constraints['has_source'] = False
constraints['exclude_internal_transfers'] = exclude_internal_transfers
if is_my_input_or_output is True:
constraints['is_my_input_or_output'] = True
@@ -4389,7 +4365,6 @@ class Daemon(metaclass=JSONRPCServerType):
constraints['is_my_output'] = False
database.constrain_single_or_list(constraints, 'txo_type', type, lambda x: TXO_TYPES[x])
database.constrain_single_or_list(constraints, 'channel_id', channel_id)
database.constrain_single_or_list(constraints, 'channel_id', not_channel_id, negate=True)
database.constrain_single_or_list(constraints, 'claim_id', claim_id)
database.constrain_single_or_list(constraints, 'claim_name', name)
database.constrain_single_or_list(constraints, 'txid', txid)
@@ -4404,9 +4379,9 @@ class Daemon(metaclass=JSONRPCServerType):
List my transaction outputs.
Usage:
txo_list [--account_id=<account_id>] [--type=<type>...] [--txid=<txid>...] [--claim_id=<claim_id>...]
[--channel_id=<channel_id>...] [--not_channel_id=<not_channel_id>...]
[--name=<name>...] [--is_spent | --is_not_spent]
txo_list [--account_id=<account_id>] [--type=<type>...] [--txid=<txid>...]
[--claim_id=<claim_id>...] [--channel_id=<channel_id>...] [--name=<name>...]
[--is_spent | --is_not_spent]
[--is_my_input_or_output |
[[--is_my_output | --is_not_my_output] [--is_my_input | --is_not_my_input]]
]
@@ -4420,7 +4395,6 @@ class Daemon(metaclass=JSONRPCServerType):
--txid=<txid> : (str or list) transaction id of outputs
--claim_id=<claim_id> : (str or list) claim id
--channel_id=<channel_id> : (str or list) claims in this channel
--not_channel_id=<not_channel_id>: (str or list) claims not in this channel
--name=<name> : (str or list) claim name
--is_spent : (bool) only show spent txos
--is_not_spent : (bool) only show not spent txos
@@ -4435,7 +4409,7 @@ class Daemon(metaclass=JSONRPCServerType):
"--is_my_input --is_my_output --type=other"
this allows to exclude "change" payments, this
flag can be used in combination with any of the other flags
--include_received_tips : (bool) calculate the amount of tips received for claim outputs
--include_received_tips : (bool) calculate the amount of tips recieved for claim outputs
--account_id=<account_id> : (str) id of the account to query
--wallet_id=<wallet_id> : (str) restrict results to specific wallet
--page=<page> : (int) page to return during paginating
@@ -4474,15 +4448,15 @@ class Daemon(metaclass=JSONRPCServerType):
@requires(WALLET_COMPONENT)
async def jsonrpc_txo_spend(
self, account_id=None, wallet_id=None, batch_size=100,
self, account_id=None, wallet_id=None, batch_size=500,
include_full_tx=False, preview=False, blocking=False, **kwargs):
"""
Spend transaction outputs, batching into multiple transactions as necessary.
Usage:
txo_spend [--account_id=<account_id>] [--type=<type>...] [--txid=<txid>...] [--claim_id=<claim_id>...]
[--channel_id=<channel_id>...] [--not_channel_id=<not_channel_id>...]
[--name=<name>...] [--is_my_input | --is_not_my_input]
txo_spend [--account_id=<account_id>] [--type=<type>...] [--txid=<txid>...]
[--claim_id=<claim_id>...] [--channel_id=<channel_id>...] [--name=<name>...]
[--is_my_input | --is_not_my_input]
[--exclude_internal_transfers] [--wallet_id=<wallet_id>]
[--preview] [--blocking] [--batch_size=<batch_size>] [--include_full_tx]
@@ -4492,7 +4466,6 @@ class Daemon(metaclass=JSONRPCServerType):
--txid=<txid> : (str or list) transaction id of outputs
--claim_id=<claim_id> : (str or list) claim id
--channel_id=<channel_id> : (str or list) claims in this channel
--not_channel_id=<not_channel_id>: (str or list) claims not in this channel
--name=<name> : (str or list) claim name
--is_my_input : (bool) show outputs created by you
--is_not_my_input : (bool) show outputs not created by you
@@ -4513,10 +4486,7 @@ class Daemon(metaclass=JSONRPCServerType):
accounts = [wallet.get_account_or_error(account_id)] if account_id else wallet.accounts
txos = await self.ledger.get_txos(
wallet=wallet, accounts=accounts, read_only=True,
no_tx=True, no_channel_info=True,
**self._constrain_txo_from_kwargs(
{}, is_not_spent=True, is_my_output=True, **kwargs
)
**self._constrain_txo_from_kwargs({}, is_not_spent=True, is_my_output=True, **kwargs)
)
txs = []
while txos:
@@ -4540,7 +4510,6 @@ class Daemon(metaclass=JSONRPCServerType):
Usage:
txo_list [--account_id=<account_id>] [--type=<type>...] [--txid=<txid>...]
[--channel_id=<channel_id>...] [--not_channel_id=<not_channel_id>...]
[--claim_id=<claim_id>...] [--name=<name>...]
[--is_spent] [--is_not_spent]
[--is_my_input_or_output |
@@ -4554,8 +4523,6 @@ class Daemon(metaclass=JSONRPCServerType):
--txid=<txid> : (str or list) transaction id of outputs
--claim_id=<claim_id> : (str or list) claim id
--name=<name> : (str or list) claim name
--channel_id=<channel_id> : (str or list) claims in this channel
--not_channel_id=<not_channel_id>: (str or list) claims not in this channel
--is_spent : (bool) only show spent txos
--is_not_spent : (bool) only show not spent txos
--is_my_input_or_output : (bool) txos which have your inputs or your outputs,
@@ -4590,7 +4557,6 @@ class Daemon(metaclass=JSONRPCServerType):
Usage:
txo_plot [--account_id=<account_id>] [--type=<type>...] [--txid=<txid>...]
[--claim_id=<claim_id>...] [--name=<name>...] [--is_spent] [--is_not_spent]
[--channel_id=<channel_id>...] [--not_channel_id=<not_channel_id>...]
[--is_my_input_or_output |
[[--is_my_output | --is_not_my_output] [--is_my_input | --is_not_my_input]]
]
@@ -4605,8 +4571,6 @@ class Daemon(metaclass=JSONRPCServerType):
--txid=<txid> : (str or list) transaction id of outputs
--claim_id=<claim_id> : (str or list) claim id
--name=<name> : (str or list) claim name
--channel_id=<channel_id> : (str or list) claims in this channel
--not_channel_id=<not_channel_id>: (str or list) claims not in this channel
--is_spent : (bool) only show spent txos
--is_not_spent : (bool) only show not spent txos
--is_my_input_or_output : (bool) txos which have your inputs or your outputs,
@@ -5536,11 +5500,9 @@ class Daemon(metaclass=JSONRPCServerType):
async def broadcast_or_release(self, tx, blocking=False):
await self.wallet_manager.broadcast_or_release(tx, blocking)
def valid_address_or_error(self, address, allow_script_address=False):
def valid_address_or_error(self, address):
try:
assert self.ledger.is_pubkey_address(address) or (
allow_script_address and self.ledger.is_script_address(address)
)
assert self.ledger.is_valid_address(address)
except:
raise Exception(f"'{address}' is not a valid address")
+62 -96
View File
@@ -2,10 +2,9 @@ import json
import time
import asyncio
import logging
from statistics import median
from decimal import Decimal
from typing import Optional, Iterable, Type
from aiohttp.client_exceptions import ContentTypeError, ClientConnectionError
from aiohttp.client_exceptions import ContentTypeError
from lbry.error import InvalidExchangeRateResponseError, CurrencyConversionError
from lbry.utils import aiohttp_request
from lbry.wallet.dewies import lbc_to_dewies
@@ -59,12 +58,9 @@ class MarketFeed:
raise NotImplementedError()
async def get_response(self):
async with aiohttp_request(
'get', self.url, params=self.params,
timeout=self.request_timeout, headers={"User-Agent": "lbrynet"}
) as response:
async with aiohttp_request('get', self.url, params=self.params, timeout=self.request_timeout) as response:
try:
self._last_response = await response.json(content_type=None)
self._last_response = await response.json()
except ContentTypeError as e:
self._last_response = {}
log.warning("Could not parse exchange rate response from %s: %s", self.name, e.message)
@@ -79,23 +75,18 @@ class MarketFeed:
log.debug("Saving rate update %f for %s from %s", rate, self.market, self.name)
self.rate = ExchangeRate(self.market, rate, int(time.time()))
self.last_check = time.time()
self.event.set()
return self.rate
except asyncio.CancelledError:
raise
except asyncio.TimeoutError:
log.warning("Timed out fetching exchange rate from %s.", self.name)
except json.JSONDecodeError as e:
msg = e.doc if '<html>' not in e.doc else 'unexpected content type.'
log.warning("Could not parse exchange rate response from %s: %s", self.name, msg)
log.debug(e.doc)
log.warning("Could not parse exchange rate response from %s: %s", self.name, e.doc)
except InvalidExchangeRateResponseError as e:
log.warning(str(e))
except ClientConnectionError as e:
log.warning("Error trying to connect to exchange rate %s: %s", self.name, str(e))
except Exception as e:
log.exception("Exchange rate error (%s from %s):", self.market, self.name)
finally:
self.event.set()
async def keep_updated(self):
while True:
@@ -113,92 +104,70 @@ class MarketFeed:
self.event.clear()
class BaseBittrexFeed(MarketFeed):
class BittrexFeed(MarketFeed):
name = "Bittrex"
market = None
url = None
market = "BTCLBC"
url = "https://bittrex.com/api/v1.1/public/getmarkethistory"
params = {'market': 'BTC-LBC', 'count': 50}
fee = 0.0025
def get_rate_from_response(self, json_response):
if 'lastTradeRate' not in json_response:
raise InvalidExchangeRateResponseError(self.name, 'result not found')
return 1.0 / float(json_response['lastTradeRate'])
class BittrexBTCFeed(BaseBittrexFeed):
market = "BTCLBC"
url = "https://api.bittrex.com/v3/markets/LBC-BTC/ticker"
class BittrexUSDFeed(BaseBittrexFeed):
market = "USDLBC"
url = "https://api.bittrex.com/v3/markets/LBC-USD/ticker"
class BaseCoinExFeed(MarketFeed):
name = "CoinEx"
market = None
url = None
def get_rate_from_response(self, json_response):
if 'data' not in json_response or \
'ticker' not in json_response['data'] or \
'last' not in json_response['data']['ticker']:
raise InvalidExchangeRateResponseError(self.name, 'result not found')
return 1.0 / float(json_response['data']['ticker']['last'])
class CoinExBTCFeed(BaseCoinExFeed):
market = "BTCLBC"
url = "https://api.coinex.com/v1/market/ticker?market=LBCBTC"
class CoinExUSDFeed(BaseCoinExFeed):
market = "USDLBC"
url = "https://api.coinex.com/v1/market/ticker?market=LBCUSDT"
class BaseHotbitFeed(MarketFeed):
name = "hotbit"
market = None
url = "https://api.hotbit.io/api/v1/market.last"
def get_rate_from_response(self, json_response):
if 'result' not in json_response:
raise InvalidExchangeRateResponseError(self.name, 'result not found')
return 1.0 / float(json_response['result'])
trades = json_response['result']
if len(trades) == 0:
raise InvalidExchangeRateResponseError(self.name, 'trades not found')
totals = sum([i['Total'] for i in trades])
qtys = sum([i['Quantity'] for i in trades])
if totals <= 0 or qtys <= 0:
raise InvalidExchangeRateResponseError(self.name, 'quantities were not positive')
vwap = totals / qtys
return float(1.0 / vwap)
class HotbitBTCFeed(BaseHotbitFeed):
class LBRYFeed(MarketFeed):
name = "lbry.com"
market = "BTCLBC"
params = {"market": "LBC/BTC"}
class HotbitUSDFeed(BaseHotbitFeed):
market = "USDLBC"
params = {"market": "LBC/USDT"}
class UPbitBTCFeed(MarketFeed):
name = "UPbit"
market = "BTCLBC"
url = "https://api.upbit.com/v1/ticker"
params = {"markets": "BTC-LBC"}
url = "https://api.lbry.com/lbc/exchange_rate"
def get_rate_from_response(self, json_response):
if len(json_response) != 1 or 'trade_price' not in json_response[0]:
if 'data' not in json_response:
raise InvalidExchangeRateResponseError(self.name, 'result not found')
return 1.0 / float(json_response[0]['trade_price'])
return 1.0 / json_response['data']['lbc_btc']
class LBRYBTCFeed(LBRYFeed):
market = "USDBTC"
def get_rate_from_response(self, json_response):
if 'data' not in json_response:
raise InvalidExchangeRateResponseError(self.name, 'result not found')
return 1.0 / json_response['data']['btc_usd']
class CryptonatorFeed(MarketFeed):
name = "cryptonator.com"
market = "BTCLBC"
url = "https://api.cryptonator.com/api/ticker/btc-lbc"
def get_rate_from_response(self, json_response):
if 'ticker' not in json_response or len(json_response['ticker']) == 0 or \
'success' not in json_response or json_response['success'] is not True:
raise InvalidExchangeRateResponseError(self.name, 'result not found')
return float(json_response['ticker']['price'])
class CryptonatorBTCFeed(CryptonatorFeed):
market = "USDBTC"
url = "https://api.cryptonator.com/api/ticker/usd-btc"
FEEDS: Iterable[Type[MarketFeed]] = (
BittrexBTCFeed,
BittrexUSDFeed,
CoinExBTCFeed,
CoinExUSDFeed,
HotbitBTCFeed,
HotbitUSDFeed,
UPbitBTCFeed,
LBRYFeed,
LBRYBTCFeed,
BittrexFeed,
# CryptonatorFeed,
# CryptonatorBTCFeed,
)
@@ -222,23 +191,20 @@ class ExchangeRateManager:
source.stop()
def convert_currency(self, from_currency, to_currency, amount):
log.debug(
"Converting %f %s to %s, rates: %s",
amount, from_currency, to_currency,
[market.rate for market in self.market_feeds]
)
rates = [market.rate for market in self.market_feeds]
log.debug("Converting %f %s to %s, rates: %s", amount, from_currency, to_currency, rates)
if from_currency == to_currency:
return round(amount, 8)
rates = []
for market in self.market_feeds:
if (market.has_rate and market.is_online and
market.rate.currency_pair == (from_currency, to_currency)):
rates.append(market.rate.spot)
if rates:
return round(amount * Decimal(median(rates)), 8)
return round(amount * Decimal(market.rate.spot), 8)
for market in self.market_feeds:
if (market.has_rate and market.is_online and
market.rate.currency_pair[0] == from_currency):
return round(self.convert_currency(
market.rate.currency_pair[1], to_currency, amount * Decimal(market.rate.spot)), 8)
raise CurrencyConversionError(
f'Unable to convert {amount} from {from_currency} to {to_currency}')
@@ -234,6 +234,8 @@ class JSONResponseEncoder(JSONEncoder):
output['value_type'] = txo.claim.claim_type
if txo.claim.is_channel:
output['has_signing_key'] = txo.has_private_key
elif txo.script.is_support_claim_data:
output['value_type'] = 'emoji'
if check_signature and txo.signable.is_signed:
if txo.channel is not None:
output['signing_channel'] = self.encode_output(txo.channel)
+4 -16
View File
@@ -85,11 +85,8 @@ class FileManager:
raise ResolveError("cannot download a channel claim, specify a /path")
try:
resolved_result = await asyncio.wait_for(
self.wallet_manager.ledger.resolve(
wallet.accounts, [uri],
include_purchase_receipt=True,
include_is_my_output=True
), resolve_timeout
self.wallet_manager.ledger.resolve(wallet.accounts, [uri], include_purchase_receipt=True),
resolve_timeout
)
except asyncio.TimeoutError:
raise ResolveTimeoutError(uri)
@@ -117,11 +114,9 @@ class FileManager:
if claim.stream.source.bt_infohash:
source_manager = self.source_managers['torrent']
existing = source_manager.get_filtered(bt_infohash=claim.stream.source.bt_infohash)
elif claim.stream.source.sd_hash:
else:
source_manager = self.source_managers['stream']
existing = source_manager.get_filtered(sd_hash=claim.stream.source.sd_hash)
else:
raise ResolveError(f"There is nothing to download at {uri} - Source is unknown or unset")
# resume or update an existing stream, if the stream changed: download it and delete the old one after
to_replace, updated_stream = None, None
@@ -175,14 +170,7 @@ class FileManager:
# pay fee
####################
needs_purchasing = (
not to_replace and
not txo.is_my_output and
txo.has_price and
not txo.purchase_receipt
)
if needs_purchasing:
if not to_replace and txo.has_price and not txo.purchase_receipt:
payment = await self.wallet_manager.create_purchase_transaction(
wallet.accounts, txo, exchange_rate_manager
)
+1 -1
View File
@@ -132,7 +132,7 @@ class SourceManager:
else:
streams = list(self._sources.values())
if sort_by:
streams.sort(key=lambda s: getattr(s, sort_by) or "")
streams.sort(key=lambda s: getattr(s, sort_by))
if reverse:
streams.reverse()
return streams
-24
View File
@@ -1,24 +0,0 @@
Schema
=====
Those files are generated from the [types repo](https://github.com/lbryio/types). If you are modifying/adding a new type, make sure it is cloned in the same root folder as the SDK repo, like:
```
repos/
- lbry-sdk/
- types/
```
Then, [download protoc 3.2.0](https://github.com/protocolbuffers/protobuf/releases/tag/v3.2.0), add it to your PATH. On linux it is:
```bash
cd ~/.local/bin
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.2.0/protoc-3.2.0-linux-x86_64.zip
unzip protoc-3.2.0-linux-x86_64.zip bin/protoc -d..
```
Finally, `make` should update everything in place.
### Why protoc 3.2.0?
Different/newer versions will generate larger diffs and we need to make sure they are good. In theory, we can just update to latest and it will all work, but it is a good practice to check blockchain data and retro compatibility before bumping versions (if you do, please update this section!).
+5 -13
View File
@@ -32,17 +32,6 @@ def calculate_sha384_file_hash(file_path):
return sha384.digest()
def country_int_to_str(country: int) -> str:
r = LocationMessage.Country.Name(country)
return r[1:] if r.startswith('R') else r
def country_str_to_int(country: str) -> int:
if len(country) == 3:
country = 'R' + country
return LocationMessage.Country.Value(country)
class Dimmensional(Metadata):
__slots__ = ()
@@ -434,11 +423,14 @@ class Language(Metadata):
@property
def region(self) -> str:
if self.message.region:
return country_int_to_str(self.message.region)
r = LocationMessage.Country.Name(self.message.region)
return r[1:] if r.startswith('R') else r
@region.setter
def region(self, region: str):
self.message.region = country_str_to_int(region)
if len(region) == 3:
region = 'R'+region
self.message.region = LocationMessage.Country.Value(region)
class LanguageList(BaseMessageList[Language]):
-4
View File
@@ -303,10 +303,6 @@ class Stream(BaseClaim):
def has_fee(self) -> bool:
return self.message.HasField('fee')
@property
def has_source(self) -> bool:
return self.message.HasField('source')
@property
def source(self) -> Source:
return Source(self.message.source)
+2 -4
View File
@@ -46,8 +46,8 @@ types_map = {
'.ksh': ('text/plain', 'document'),
'.latex': ('application/x-latex', 'binary'),
'.m1v': ('video/mpeg', 'video'),
'.m3u': ('application/x-mpegurl', 'audio'),
'.m3u8': ('application/x-mpegurl', 'video'),
'.m3u': ('application/vnd.apple.mpegurl', 'audio'),
'.m3u8': ('application/vnd.apple.mpegurl', 'video'),
'.man': ('application/x-troff-man', 'document'),
'.markdown': ('text/markdown', 'document'),
'.md': ('text/markdown', 'document'),
@@ -66,7 +66,6 @@ types_map = {
'.mpeg': ('video/mpeg', 'video'),
'.mpg': ('video/mpeg', 'video'),
'.ms': ('application/x-troff-ms', 'binary'),
'.m4s': ('video/iso.segment', 'binary'),
'.nc': ('application/x-netcdf', 'binary'),
'.nws': ('message/rfc822', 'document'),
'.o': ('application/octet-stream', 'binary'),
@@ -120,7 +119,6 @@ types_map = {
'.tif': ('image/tiff', 'image'),
'.tiff': ('image/tiff', 'image'),
'.tr': ('application/x-troff', 'binary'),
'.ts': ('video/mp2t', 'video'),
'.tsv': ('text/tab-separated-values', 'document'),
'.txt': ('text/plain', 'document'),
'.ustar': ('application/x-ustar', 'binary'),
+50 -37
View File
@@ -5,60 +5,74 @@ from binascii import hexlify
from itertools import chain
from lbry.error import ResolveCensoredError
from lbry.schema.types.v2.result_pb2 import Outputs as OutputsMessage
from lbry.schema.types.v2.result_pb2 import Error as ErrorMessage
from lbry.schema.types.v2.result_pb2 import \
Outputs as OutputsMessage, \
Output as OutputMessage, \
Error as ErrorMessage
INVALID = ErrorMessage.Code.Name(ErrorMessage.INVALID)
NOT_FOUND = ErrorMessage.Code.Name(ErrorMessage.NOT_FOUND)
BLOCKED = ErrorMessage.Code.Name(ErrorMessage.BLOCKED)
def set_reference(reference, txo_row):
if txo_row:
reference.tx_hash = txo_row['txo_hash'][:32]
reference.nout = struct.unpack('<I', txo_row['txo_hash'][32:])[0]
reference.height = txo_row['height']
def set_reference(reference, claim_hash, rows):
if claim_hash:
for txo in rows:
if claim_hash == txo['claim_hash']:
reference.tx_hash = txo['txo_hash'][:32]
reference.nout = struct.unpack('<I', txo['txo_hash'][32:])[0]
reference.height = txo['height']
return
class Censor:
NOT_CENSORED = 0
SEARCH = 1
RESOLVE = 2
__slots__ = 'streams', 'channels', 'limit_claims_per_channel', 'censored', 'claims_in_channel', 'total'
__slots__ = 'censor_type', 'censored'
def __init__(self, censor_type):
self.censor_type = censor_type
def __init__(self, streams: dict = None, channels: dict = None, limit_claims_per_channel: int = None):
self.streams = streams or {}
self.channels = channels or {}
self.limit_claims_per_channel = limit_claims_per_channel # doesn't count as censored
self.censored = {}
def is_censored(self, row):
return (row.get('censor_type') or self.NOT_CENSORED) >= self.censor_type
def apply(self, rows):
return [row for row in rows if not self.censor(row)]
self.claims_in_channel = {}
self.total = 0
def censor(self, row) -> bool:
if self.is_censored(row):
censoring_channel_hash = row['censoring_channel_hash']
self.censored.setdefault(censoring_channel_hash, set())
self.censored[censoring_channel_hash].add(row['tx_hash'])
return True
return False
was_censored = False
for claim_hash, lookup in (
(row['claim_hash'], self.streams),
(row['claim_hash'], self.channels),
(row['channel_hash'], self.channels),
(row['reposted_claim_hash'], self.streams),
(row['reposted_claim_hash'], self.channels)):
censoring_channel_hash = lookup.get(claim_hash)
if censoring_channel_hash:
was_censored = True
self.censored.setdefault(censoring_channel_hash, 0)
self.censored[censoring_channel_hash] += 1
break
if was_censored:
self.total += 1
if not was_censored and self.limit_claims_per_channel is not None and row['channel_hash']:
self.claims_in_channel.setdefault(row['channel_hash'], 0)
self.claims_in_channel[row['channel_hash']] += 1
if self.claims_in_channel[row['channel_hash']] > self.limit_claims_per_channel:
return True
return was_censored
def to_message(self, outputs: OutputsMessage, extra_txo_rows: dict):
def to_message(self, outputs: OutputsMessage, extra_txo_rows):
outputs.blocked_total = self.total
for censoring_channel_hash, count in self.censored.items():
blocked = outputs.blocked.add()
blocked.count = len(count)
set_reference(blocked.channel, extra_txo_rows.get(censoring_channel_hash))
outputs.blocked_total += len(count)
blocked.count = count
set_reference(blocked.channel, censoring_channel_hash, extra_txo_rows)
class Outputs:
__slots__ = 'txos', 'extra_txos', 'txs', 'offset', 'total', 'blocked', 'blocked_total'
def __init__(self, txos: List, extra_txos: List, txs: set,
def __init__(self, txos: List[OutputMessage], extra_txos: List, txs: set,
offset: int, total: int, blocked: List, blocked_total: int):
self.txos = txos
self.txs = txs
@@ -156,7 +170,6 @@ class Outputs:
@classmethod
def to_bytes(cls, txo_rows, extra_txo_rows, offset=0, total=None, blocked: Censor = None) -> bytes:
extra_txo_rows = {row['claim_hash']: row for row in extra_txo_rows}
page = OutputsMessage()
page.offset = offset
if total is not None:
@@ -165,12 +178,12 @@ class Outputs:
blocked.to_message(page, extra_txo_rows)
for row in txo_rows:
cls.row_to_message(row, page.txos.add(), extra_txo_rows)
for row in extra_txo_rows.values():
for row in extra_txo_rows:
cls.row_to_message(row, page.extra_txos.add(), extra_txo_rows)
return page.SerializeToString()
@classmethod
def row_to_message(cls, txo, txo_message, extra_row_dict: dict):
def row_to_message(cls, txo, txo_message, extra_txo_rows):
if isinstance(txo, Exception):
txo_message.error.text = txo.args[0]
if isinstance(txo, ValueError):
@@ -179,7 +192,7 @@ class Outputs:
txo_message.error.code = ErrorMessage.NOT_FOUND
elif isinstance(txo, ResolveCensoredError):
txo_message.error.code = ErrorMessage.BLOCKED
set_reference(txo_message.error.blocked.channel, extra_row_dict.get(txo.censor_hash))
set_reference(txo_message.error.blocked.channel, txo.censor_hash, extra_txo_rows)
return
txo_message.tx_hash = txo['txo_hash'][:32]
txo_message.nout, = struct.unpack('<I', txo['txo_hash'][32:])
@@ -202,5 +215,5 @@ class Outputs:
txo_message.claim.trending_mixed = txo['trending_mixed']
txo_message.claim.trending_local = txo['trending_local']
txo_message.claim.trending_global = txo['trending_global']
set_reference(txo_message.claim.channel, extra_row_dict.get(txo['channel_hash']))
set_reference(txo_message.claim.repost, extra_row_dict.get(txo['reposted_claim_hash']))
set_reference(txo_message.claim.channel, txo['channel_hash'], extra_txo_rows)
set_reference(txo_message.claim.repost, txo['reposted_claim_hash'], extra_txo_rows)
-8
View File
@@ -13,11 +13,3 @@ class Support(Signable):
@emoji.setter
def emoji(self, emoji: str):
self.message.emoji = emoji
@property
def comment(self) -> str:
return self.message.comment
@comment.setter
def comment(self, comment: str):
self.message.comment = comment
+2 -9
View File
@@ -19,7 +19,7 @@ DESCRIPTOR = _descriptor.FileDescriptor(
name='support.proto',
package='pb',
syntax='proto3',
serialized_pb=_b('\n\rsupport.proto\x12\x02pb\")\n\x07Support\x12\r\n\x05\x65moji\x18\x01 \x01(\t\x12\x0f\n\x07\x63omment\x18\x02 \x01(\tb\x06proto3')
serialized_pb=_b('\n\rsupport.proto\x12\x02pb\"\x18\n\x07Support\x12\r\n\x05\x65moji\x18\x01 \x01(\tb\x06proto3')
)
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
@@ -40,13 +40,6 @@ _SUPPORT = _descriptor.Descriptor(
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
_descriptor.FieldDescriptor(
name='comment', full_name='pb.Support.comment', 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,
options=None),
],
extensions=[
],
@@ -60,7 +53,7 @@ _SUPPORT = _descriptor.Descriptor(
oneofs=[
],
serialized_start=21,
serialized_end=62,
serialized_end=45,
)
DESCRIPTOR.message_types_by_name['Support'] = _SUPPORT
-8
View File
@@ -55,14 +55,6 @@ class PathSegment(NamedTuple):
def normalized(self):
return normalize_name(self.name)
@property
def is_shortid(self):
return self.claim_id is not None and len(self.claim_id) < 40
@property
def is_fullid(self):
return self.claim_id is not None and len(self.claim_id) == 40
def to_dict(self):
q = {'name': self.name}
if self.claim_id is not None:
+2 -2
View File
@@ -183,11 +183,11 @@ class StreamDescriptor:
raise InvalidStreamDescriptorError("Does not decode as valid JSON")
if decoded['blobs'][-1]['length'] != 0:
raise InvalidStreamDescriptorError("Does not end with a zero-length blob.")
if any(blob_info['length'] == 0 for blob_info in decoded['blobs'][:-1]):
if any([blob_info['length'] == 0 for blob_info in decoded['blobs'][:-1]]):
raise InvalidStreamDescriptorError("Contains zero-length data blob")
if 'blob_hash' in decoded['blobs'][-1]:
raise InvalidStreamDescriptorError("Stream terminator blob should not have a hash")
if any(i != blob_info['blob_num'] for i, blob_info in enumerate(decoded['blobs'])):
if any([i != blob_info['blob_num'] for i, blob_info in enumerate(decoded['blobs'])]):
raise InvalidStreamDescriptorError("Stream contains out of order or skipped blobs")
descriptor = cls(
loop, blob_dir,
+3
View File
@@ -372,6 +372,9 @@ class ManagedStream(ManagedDownloadSource):
protocol.transport.close()
self.uploading_to_reflector = False
if not self.fully_reflected.is_set():
self.fully_reflected.set()
await self.blob_manager.storage.update_reflected_stream(self.sd_hash, f"{host}:{port}")
return sent
async def update_content_claim(self, claim_info: Optional[typing.Dict] = None):
+1 -1
View File
@@ -59,7 +59,7 @@ class StreamReflectorClient(asyncio.Protocol):
return
async def send_request(self, request_dict: typing.Dict, timeout: int = 180):
msg = json.dumps(request_dict, sort_keys=True)
msg = json.dumps(request_dict)
try:
self.transport.write(msg.encode())
self.pending_request = self.loop.create_task(asyncio.wait_for(self.response_queue.get(), timeout))
+13 -18
View File
@@ -17,7 +17,7 @@ log = logging.getLogger(__name__)
class ReflectorServerProtocol(asyncio.Protocol):
def __init__(self, blob_manager: 'BlobManager', response_chunk_size: int = 10000,
stop_event: asyncio.Event = None, incoming_event: asyncio.Event = None,
not_incoming_event: asyncio.Event = None, partial_event: asyncio.Event = None):
not_incoming_event: asyncio.Event = None):
self.loop = asyncio.get_event_loop()
self.blob_manager = blob_manager
self.server_task: asyncio.Task = None
@@ -34,7 +34,6 @@ class ReflectorServerProtocol(asyncio.Protocol):
self.stop_event = stop_event or asyncio.Event(loop=self.loop)
self.chunk_size = response_chunk_size
self.wait_for_stop_task: typing.Optional[asyncio.Task] = None
self.partial_event = partial_event
async def wait_for_stop(self):
await self.stop_event.wait()
@@ -116,14 +115,10 @@ class ReflectorServerProtocol(asyncio.Protocol):
if self.writer:
self.writer.close_handle()
self.writer = None
needs = [blob.blob_hash
for blob in self.descriptor.blobs[:-1]
if not self.blob_manager.get_blob(blob.blob_hash).get_is_verified()]
if needs and not self.partial_event.is_set():
needs = needs[:3]
self.partial_event.set()
self.send_response({"send_sd_blob": False, 'needed_blobs': needs})
self.send_response({"send_sd_blob": False, 'needed': [
blob.blob_hash for blob in self.descriptor.blobs[:-1]
if not self.blob_manager.get_blob(blob.blob_hash).get_is_verified()
]})
return
return
elif self.descriptor:
@@ -158,7 +153,7 @@ class ReflectorServerProtocol(asyncio.Protocol):
class ReflectorServer:
def __init__(self, blob_manager: 'BlobManager', response_chunk_size: int = 10000,
stop_event: asyncio.Event = None, incoming_event: asyncio.Event = None,
not_incoming_event: asyncio.Event = None, partial_needs=False):
not_incoming_event: asyncio.Event = None):
self.loop = asyncio.get_event_loop()
self.blob_manager = blob_manager
self.server_task: typing.Optional[asyncio.Task] = None
@@ -168,19 +163,19 @@ class ReflectorServer:
self.not_incoming_event = not_incoming_event or asyncio.Event(loop=self.loop)
self.response_chunk_size = response_chunk_size
self.stop_event = stop_event
self.partial_needs = partial_needs # for testing cases where it doesn't know what it wants
def start_server(self, port: int, interface: typing.Optional[str] = '0.0.0.0'):
if self.server_task is not None:
raise Exception("already running")
async def _start_server():
partial_event = asyncio.Event()
if not self.partial_needs:
partial_event.set()
server = await self.loop.create_server(lambda: ReflectorServerProtocol(
self.blob_manager, self.response_chunk_size, self.stop_event, self.incoming_event,
self.not_incoming_event, partial_event), interface, port)
server = await self.loop.create_server(
lambda: ReflectorServerProtocol(
self.blob_manager, self.response_chunk_size, self.stop_event, self.incoming_event,
self.not_incoming_event
),
interface, port
)
self.started_listening.set()
self.stopped_listening.clear()
log.info("Reflector server listening on TCP %s:%i", interface, port)
+1 -7
View File
@@ -215,7 +215,7 @@ class StreamManager(SourceManager):
server, port = random.choice(self.config.reflector_servers)
if stream.sd_hash in self.running_reflector_uploads:
return self.running_reflector_uploads[stream.sd_hash]
task = self.loop.create_task(self._retriable_reflect_stream(stream, server, port))
task = self.loop.create_task(stream.upload_to_reflector(server, port))
self.running_reflector_uploads[stream.sd_hash] = task
task.add_done_callback(
lambda _: None if stream.sd_hash not in self.running_reflector_uploads else
@@ -223,12 +223,6 @@ class StreamManager(SourceManager):
)
return task
async def _retriable_reflect_stream(self, stream, host, port):
sent = await stream.upload_to_reflector(host, port)
while not stream.is_fully_reflected and stream.reflector_progress > 0 and len(sent) > 0:
stream.reflector_progress = 0
sent = await stream.upload_to_reflector(host, port)
async def create(self, file_path: str, key: Optional[bytes] = None,
iv_generator: Optional[typing.Generator[bytes, None, None]] = None) -> ManagedStream:
descriptor = await StreamDescriptor.create_stream(
+17 -48
View File
@@ -23,13 +23,12 @@ from lbry.wallet.orchstr8.node import BlockchainNode, WalletNode
from lbry.extras.daemon.daemon import Daemon, jsonrpc_dumps_pretty
from lbry.extras.daemon.components import Component, WalletComponent
from lbry.extras.daemon.components import (
DHT_COMPONENT,
HASH_ANNOUNCER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT,
UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, LIBTORRENT_COMPONENT
DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT,
UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT
)
from lbry.extras.daemon.componentmanager import ComponentManager
from lbry.extras.daemon.exchange_rate_manager import (
ExchangeRateManager, ExchangeRate, BittrexBTCFeed, BittrexUSDFeed
ExchangeRateManager, ExchangeRate, LBRYFeed, LBRYBTCFeed
)
from lbry.extras.daemon.storage import SQLiteStorage
from lbry.blob.blob_manager import BlobManager
@@ -84,7 +83,6 @@ class AsyncioTestCase(unittest.TestCase):
# https://bugs.python.org/issue32972
LOOP_SLOW_CALLBACK_DURATION = 0.2
TIMEOUT = 120.0
maxDiff = None
@@ -138,8 +136,6 @@ class AsyncioTestCase(unittest.TestCase):
with outcome.testPartExecutor(self, isTest=True):
maybe_coroutine = testMethod()
if asyncio.iscoroutine(maybe_coroutine):
if self.TIMEOUT:
self.loop.call_later(self.TIMEOUT, self.cancel)
self.loop.run_until_complete(maybe_coroutine)
outcome.expecting_failure = False
with outcome.testPartExecutor(self):
@@ -192,12 +188,6 @@ class AsyncioTestCase(unittest.TestCase):
if asyncio.iscoroutine(maybe_coroutine):
self.loop.run_until_complete(maybe_coroutine)
def cancel(self):
for task in asyncio.all_tasks(self.loop):
if not task.done():
task.print_stack()
task.cancel()
class AdvanceTimeTestCase(AsyncioTestCase):
@@ -291,8 +281,8 @@ class FakeExchangeRateManager(ExchangeRateManager):
def get_fake_exchange_rate_manager(rates=None):
return FakeExchangeRateManager(
[BittrexBTCFeed(), BittrexUSDFeed()],
rates or {'BTCLBC': 3.0, 'USDLBC': 2.0}
[LBRYFeed(), LBRYBTCFeed()],
rates or {'BTCLBC': 3.0, 'USDBTC': 2.0}
)
@@ -330,7 +320,6 @@ class CommandTestCase(IntegrationTestCase):
self.server_blob_manager = None
self.server = None
self.reflector = None
self.skip_libtorrent = True
async def asyncSetUp(self):
await super().asyncSetUp()
@@ -350,11 +339,7 @@ class CommandTestCase(IntegrationTestCase):
server_tmp_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, server_tmp_dir)
self.server_config = Config(
data_dir=server_tmp_dir,
wallet_dir=server_tmp_dir,
download_dir=server_tmp_dir
)
self.server_config = Config()
self.server_config.transaction_cache_size = 10000
self.server_storage = SQLiteStorage(self.server_config, ':memory:')
await self.server_storage.open()
@@ -378,7 +363,6 @@ class CommandTestCase(IntegrationTestCase):
await daemon.stop()
async def add_daemon(self, wallet_node=None, seed=None):
start_wallet_node = False
if wallet_node is None:
wallet_node = WalletNode(
self.wallet_node.manager_class,
@@ -386,23 +370,22 @@ class CommandTestCase(IntegrationTestCase):
port=self.extra_wallet_node_port
)
self.extra_wallet_node_port += 1
start_wallet_node = True
await wallet_node.start(self.conductor.spv_node, seed=seed)
self.extra_wallet_nodes.append(wallet_node)
upload_dir = os.path.join(wallet_node.data_path, 'uploads')
os.mkdir(upload_dir)
conf = Config(
# needed during instantiation to access known_hubs path
data_dir=wallet_node.data_path,
wallet_dir=wallet_node.data_path,
download_dir=wallet_node.data_path
)
conf = Config()
conf.data_dir = wallet_node.data_path
conf.wallet_dir = wallet_node.data_path
conf.download_dir = wallet_node.data_path
conf.upload_dir = upload_dir # not a real conf setting
conf.share_usage_data = False
conf.use_upnp = False
conf.reflect_streams = True
conf.blockchain_name = 'lbrycrd_regtest'
conf.lbryum_servers = [(self.conductor.spv_node.hostname, self.conductor.spv_node.port)]
conf.lbryum_servers = [('127.0.0.1', 50001)]
conf.reflector_servers = [('127.0.0.1', 5566)]
conf.fixed_peers = [('127.0.0.1', 5567)]
conf.known_dht_nodes = []
@@ -412,15 +395,7 @@ class CommandTestCase(IntegrationTestCase):
DHT_COMPONENT, UPNP_COMPONENT, HASH_ANNOUNCER_COMPONENT,
PEER_PROTOCOL_SERVER_COMPONENT
]
if self.skip_libtorrent:
conf.components_to_skip.append(LIBTORRENT_COMPONENT)
if start_wallet_node:
await wallet_node.start(self.conductor.spv_node, seed=seed, config=conf)
self.extra_wallet_nodes.append(wallet_node)
else:
wallet_node.manager.config = conf
wallet_node.manager.ledger.config['known_hubs'] = conf.known_hubs
wallet_node.manager.config = conf
def wallet_maker(component_manager):
wallet_component = WalletComponent(component_manager)
@@ -431,7 +406,7 @@ class CommandTestCase(IntegrationTestCase):
daemon = Daemon(conf, ComponentManager(
conf, skip_components=conf.components_to_skip, wallet=wallet_maker,
exchange_rate_manager=partial(ExchangeRateManagerComponent, rates={
'BTCLBC': 1.0, 'USDLBC': 2.0
'BTCLBC': 1.0, 'USDBTC': 2.0
})
))
await daemon.initialize()
@@ -460,9 +435,8 @@ class CommandTestCase(IntegrationTestCase):
async def generate(self, blocks):
""" Ask lbrycrd to generate some blocks and wait until ledger has them. """
prepare = self.ledger.on_header.where(self.blockchain.is_expected_block)
await self.blockchain.generate(blocks)
await prepare # no guarantee that it didn't happen already, so start waiting from before calling generate
await self.ledger.on_header.where(self.blockchain.is_expected_block)
async def blockchain_claim_name(self, name: str, value: str, amount: str, confirm=True):
txid = await self.blockchain._cli_cmnd('claimname', name, value, amount)
@@ -502,7 +476,7 @@ class CommandTestCase(IntegrationTestCase):
async def stream_create(
self, name='hovercraft', bid='1.0', file_path=None,
data=b'hi!', confirm=True, prefix=None, suffix=None, **kwargs):
if file_path is None and data is not None:
if file_path is None:
file_path = self.create_upload_file(data=data, prefix=prefix, suffix=suffix)
return await self.confirm_and_render(
self.daemon.jsonrpc_stream_create(name, bid, file_path=file_path, **kwargs), confirm
@@ -589,11 +563,6 @@ class CommandTestCase(IntegrationTestCase):
self.daemon.jsonrpc_support_abandon(*args, **kwargs), confirm
)
async def account_send(self, *args, confirm=True, **kwargs):
return await self.confirm_and_render(
self.daemon.jsonrpc_account_send(*args, **kwargs), confirm
)
async def wallet_send(self, *args, confirm=True, **kwargs):
return await self.confirm_and_render(
self.daemon.jsonrpc_wallet_send(*args, **kwargs), confirm
+19 -132
View File
@@ -21,6 +21,7 @@ import pkg_resources
import certifi
import aiohttp
from prometheus_client import Counter
from prometheus_client.registry import REGISTRY
from lbry.schema.claim import Claim
@@ -104,6 +105,10 @@ def check_connection(server="lbry.com", port=80, timeout=5) -> bool:
return False
async def async_check_connection(server="lbry.com", port=80, timeout=1) -> bool:
return await asyncio.get_event_loop().run_in_executor(None, check_connection, server, port, timeout)
def random_string(length=10, chars=string.ascii_lowercase):
return ''.join([random.choice(chars) for _ in range(length)])
@@ -187,8 +192,6 @@ def cache_concurrent(async_fn):
async def resolve_host(url: str, port: int, proto: str) -> str:
if proto not in ['udp', 'tcp']:
raise Exception("invalid protocol")
if url.lower() == 'localhost':
return '127.0.0.1'
try:
if ipaddress.ip_address(url):
return url
@@ -203,7 +206,7 @@ async def resolve_host(url: str, port: int, proto: str) -> str:
))[0][4][0]
class LRUCacheWithMetrics:
class LRUCache:
__slots__ = [
'capacity',
'cache',
@@ -228,7 +231,7 @@ class LRUCacheWithMetrics:
f"{metric_name}_cache_miss_count", "Number of cache misses", namespace=namespace
)
except ValueError as err:
log.debug("failed to set up prometheus %s_cache_miss_count metric: %s", metric_name, err)
log.warning("failed to set up prometheus %s_cache_miss_count metric: %s", metric_name, err)
self._track_metrics = False
self.hits = self.misses = None
@@ -275,68 +278,20 @@ class LRUCacheWithMetrics:
def __del__(self):
self.clear()
class LRUCache:
__slots__ = [
'capacity',
'cache'
]
def __init__(self, capacity: int):
self.capacity = capacity
self.cache = collections.OrderedDict()
def get(self, key, default=None):
try:
value = self.cache.pop(key)
except KeyError:
return default
self.cache[key] = value
return value
def set(self, key, value):
try:
self.cache.pop(key)
except KeyError:
if len(self.cache) >= self.capacity:
self.cache.popitem(last=False)
self.cache[key] = value
def items(self):
return self.cache.items()
def clear(self):
self.cache.clear()
def pop(self, key, default=None):
return self.cache.pop(key, default)
def __setitem__(self, key, value):
return self.set(key, value)
def __getitem__(self, item):
return self.get(item)
def __contains__(self, item) -> bool:
return item in self.cache
def __len__(self):
return len(self.cache)
def __delitem__(self, key):
self.cache.pop(key)
def __del__(self):
self.clear()
if self._track_metrics: # needed for tests
try:
REGISTRY.unregister(self.hits)
REGISTRY.unregister(self.misses)
except AttributeError:
pass
def lru_cache_concurrent(cache_size: typing.Optional[int] = None,
override_lru_cache: typing.Optional[LRUCacheWithMetrics] = None):
override_lru_cache: typing.Optional[LRUCache] = None):
if not cache_size and override_lru_cache is None:
raise ValueError("invalid cache size")
concurrent_cache = {}
lru_cache = override_lru_cache if override_lru_cache is not None else LRUCacheWithMetrics(cache_size)
lru_cache = override_lru_cache if override_lru_cache is not None else LRUCache(cache_size)
def wrapper(async_fn):
@@ -367,86 +322,18 @@ def get_ssl_context() -> ssl.SSLContext:
@contextlib.asynccontextmanager
async def aiohttp_request(method, url, **kwargs) -> typing.AsyncContextManager[aiohttp.ClientResponse]:
async with aiohttp.ClientSession() as session:
async with session.request(method, url, **kwargs) as response:
async with session.request(method, url, ssl=get_ssl_context(), **kwargs) as response:
yield response
# the ipaddress module does not show these subnets as reserved
CARRIER_GRADE_NAT_SUBNET = ipaddress.ip_network('100.64.0.0/10')
IPV4_TO_6_RELAY_SUBNET = ipaddress.ip_network('192.88.99.0/24')
def is_valid_public_ipv4(address, allow_localhost: bool = False, allow_lan: bool = False):
try:
parsed_ip = ipaddress.ip_address(address)
if parsed_ip.is_loopback and allow_localhost:
return True
if allow_lan and parsed_ip.is_private:
return True
if any((parsed_ip.version != 4, parsed_ip.is_unspecified, parsed_ip.is_link_local, parsed_ip.is_loopback,
parsed_ip.is_multicast, parsed_ip.is_reserved, parsed_ip.is_private)):
return False
else:
return not any((CARRIER_GRADE_NAT_SUBNET.supernet_of(ipaddress.ip_network(f"{address}/32")),
IPV4_TO_6_RELAY_SUBNET.supernet_of(ipaddress.ip_network(f"{address}/32"))))
except (ipaddress.AddressValueError, ValueError):
return False
async def fallback_get_external_ip(): # used if spv servers can't be used for ip detection
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:
response = await resp.json()
if response['success']:
return response['data']['ip'], None
return response['data']['ip']
except Exception:
return None, None
async def _get_external_ip(default_servers) -> typing.Tuple[typing.Optional[str], typing.Optional[str]]:
# used if upnp is disabled or non-functioning
from lbry.wallet.server.udp import SPVStatusClientProtocol # pylint: disable=C0415
hostname_to_ip = {}
ip_to_hostnames = collections.defaultdict(list)
async def resolve_spv(server, port):
try:
server_addr = await resolve_host(server, port, 'udp')
hostname_to_ip[server] = (server_addr, port)
ip_to_hostnames[(server_addr, port)].append(server)
except Exception:
log.exception("error looking up dns for spv servers")
# accumulate the dns results
await asyncio.gather(*(resolve_spv(server, port) for (server, port) in default_servers))
loop = asyncio.get_event_loop()
pong_responses = asyncio.Queue()
connection = SPVStatusClientProtocol(pong_responses)
try:
await loop.create_datagram_endpoint(lambda: connection, ('0.0.0.0', 0))
# could raise OSError if it cant bind
randomized_servers = list(ip_to_hostnames.keys())
random.shuffle(randomized_servers)
for server in randomized_servers:
connection.ping(server)
try:
_, pong = await asyncio.wait_for(pong_responses.get(), 1)
if is_valid_public_ipv4(pong.ip_address):
return pong.ip_address, ip_to_hostnames[server][0]
except asyncio.TimeoutError:
pass
return None, None
finally:
connection.close()
async def get_external_ip(default_servers) -> typing.Tuple[typing.Optional[str], typing.Optional[str]]:
ip_from_spv_servers = await _get_external_ip(default_servers)
if not ip_from_spv_servers[1]:
return await fallback_get_external_ip()
return ip_from_spv_servers
return
def is_running_from_bundle():
+31 -9
View File
@@ -5,6 +5,7 @@ import logging
import typing
import asyncio
import random
from functools import partial
from hashlib import sha256
from string import hexdigits
from typing import Type, Dict, Tuple, Optional, Any, List
@@ -15,7 +16,7 @@ from lbry.crypto.crypt import aes_encrypt, aes_decrypt
from .bip32 import PrivateKey, PubKey, from_extended_key_string
from .mnemonic import Mnemonic
from .constants import COIN, TXO_TYPES
from .constants import COIN, CLAIM_TYPES, TXO_TYPES
from .transaction import Transaction, Input, Output
if typing.TYPE_CHECKING:
@@ -565,14 +566,35 @@ class Account:
if gap_changed:
self.wallet.save()
async def get_detailed_balance(self, confirmations=0, read_only=False):
constraints = {}
if confirmations > 0:
height = self.ledger.headers.height - (confirmations-1)
constraints.update({'height__lte': height, 'height__gt': 0})
return await self.ledger.db.get_detailed_balance(
accounts=[self], read_only=read_only, **constraints
)
async def get_detailed_balance(self, confirmations=0, reserved_subtotals=False, read_only=False):
tips_balance, supports_balance, claims_balance = 0, 0, 0
get_total_balance = partial(self.get_balance, read_only=read_only, confirmations=confirmations,
include_claims=True)
total = await get_total_balance()
if reserved_subtotals:
claims_balance = await get_total_balance(txo_type__in=CLAIM_TYPES)
for txo in await self.get_support_summary():
if confirmations > 0 and not 0 < txo.tx_ref.height <= self.ledger.headers.height - (confirmations - 1):
continue
if txo.is_my_input:
supports_balance += txo.amount
else:
tips_balance += txo.amount
reserved = claims_balance + supports_balance + tips_balance
else:
reserved = await self.get_balance(
confirmations=confirmations, include_claims=True, txo_type__gt=0
)
return {
'total': total,
'available': total - reserved,
'reserved': reserved,
'reserved_subtotals': {
'claims': claims_balance,
'supports': supports_balance,
'tips': tips_balance
} if reserved_subtotals else None
}
def get_transaction_history(self, read_only=False, **constraints):
return self.ledger.get_transaction_history(
+36 -104
View File
@@ -18,7 +18,7 @@ from .constants import TXO_TYPES, CLAIM_TYPES
from .util import date_to_julian_day
from concurrent.futures.thread import ThreadPoolExecutor # pylint: disable=wrong-import-order
if platform.system() == 'Windows' or ({'ANDROID_ARGUMENT', 'KIVY_BUILD'} & os.environ.keys()):
if platform.system() == 'Windows' or 'ANDROID_ARGUMENT' or 'KIVY_BUILD' in os.environ:
from concurrent.futures.thread import ThreadPoolExecutor as ReaderExecutorClass # pylint: disable=reimported
else:
from concurrent.futures.process import ProcessPoolExecutor as ReaderExecutorClass
@@ -387,31 +387,14 @@ def interpolate(sql, values):
return sql
def constrain_single_or_list(constraints, column, value, convert=lambda x: x, negate=False):
def constrain_single_or_list(constraints, column, value, convert=lambda x: x):
if value is not None:
if isinstance(value, list):
value = [convert(v) for v in value]
if len(value) == 1:
if negate:
constraints[f"{column}__or"] = {
f"{column}__is_null": True,
f"{column}__not": value[0]
}
else:
constraints[column] = value[0]
constraints[column] = value[0]
elif len(value) > 1:
if negate:
constraints[f"{column}__or"] = {
f"{column}__is_null": True,
f"{column}__not_in": value
}
else:
constraints[f"{column}__in"] = value
elif negate:
constraints[f"{column}__or"] = {
f"{column}__is_null": True,
f"{column}__not": convert(value)
}
constraints[f"{column}__in"] = value
else:
constraints[column] = convert(value)
return constraints
@@ -446,10 +429,6 @@ class SQLiteMixin:
version = await self.db.execute_fetchone("SELECT version FROM version LIMIT 1;")
if version == (self.SCHEMA_VERSION,):
return
if version == ("1.5",) and self.SCHEMA_VERSION == "1.6":
await self.db.execute("ALTER TABLE txo ADD COLUMN has_source bool DEFAULT 1;")
await self.db.execute("UPDATE version SET version = ?", (self.SCHEMA_VERSION,))
return
await self.db.executescript('\n'.join(
f"DROP TABLE {table};" for table in tables
) + '\n' + 'PRAGMA WAL_CHECKPOINT(FULL);' + '\n' + 'VACUUM;')
@@ -596,7 +575,7 @@ def get_and_reserve_spendable_utxos(transaction: sqlite3.Connection, accounts: L
class Database(SQLiteMixin):
SCHEMA_VERSION = "1.6"
SCHEMA_VERSION = "1.5"
PRAGMAS = """
pragma journal_mode=WAL;
@@ -650,7 +629,6 @@ class Database(SQLiteMixin):
txo_type integer not null default 0,
claim_id text,
claim_name text,
has_source bool,
channel_id text,
reposted_claim_id text
@@ -695,8 +673,7 @@ class Database(SQLiteMixin):
'address': txo.get_address(self.ledger),
'position': txo.position,
'amount': txo.amount,
'script': sqlite3.Binary(txo.script.source),
'has_source': False,
'script': sqlite3.Binary(txo.script.source)
}
if txo.is_claim:
if txo.can_decode_claim:
@@ -704,18 +681,12 @@ class Database(SQLiteMixin):
row['txo_type'] = TXO_TYPES.get(claim.claim_type, TXO_TYPES['stream'])
if claim.is_repost:
row['reposted_claim_id'] = claim.repost.reference.claim_id
row['has_source'] = True
if claim.is_signed:
row['channel_id'] = claim.signing_channel_id
if claim.is_stream:
row['has_source'] = claim.stream.has_source
else:
row['txo_type'] = TXO_TYPES['stream']
elif txo.is_support:
row['txo_type'] = TXO_TYPES['support']
support = txo.can_decode_support
if support and support.is_signed:
row['channel_id'] = support.signing_channel_id
elif txo.purchase is not None:
row['txo_type'] = TXO_TYPES['purchase']
row['claim_id'] = txo.purchased_claim_id
@@ -769,10 +740,9 @@ class Database(SQLiteMixin):
conn.execute(*self._insert_sql(
"txo", self.txo_to_row(tx, txo), ignore_duplicate=True
)).fetchall()
elif txo.script.is_pay_script_hash and is_my_input:
conn.execute(*self._insert_sql(
"txo", self.txo_to_row(tx, txo), ignore_duplicate=True
)).fetchall()
elif txo.script.is_pay_script_hash:
# TODO: implement script hash payments
log.warning('Database.save_transaction_io: pay script hash is not implemented!')
def save_transaction_io(self, tx: Transaction, address, txhash, history):
return self.save_transaction_io_batch([tx], address, txhash, history)
@@ -975,18 +945,16 @@ class Database(SQLiteMixin):
sql.append("LEFT JOIN txi ON (txi.position=0 AND txi.txid=txo.txid)")
return await self.db.execute_fetchall(*query(' '.join(sql), **constraints), read_only=read_only)
async def get_txos(self, wallet=None, no_tx=False, no_channel_info=False, read_only=False, **constraints):
async def get_txos(self, wallet=None, no_tx=False, read_only=False, **constraints):
include_is_spent = constraints.get('include_is_spent', False)
include_is_my_input = constraints.get('include_is_my_input', False)
include_is_my_output = constraints.pop('include_is_my_output', False)
include_received_tips = constraints.pop('include_received_tips', False)
select_columns = [
"tx.txid, tx.height, tx.position as tx_position, tx.is_verified, "
"tx.txid, raw, tx.height, tx.position as tx_position, tx.is_verified, "
"txo_type, txo.position as txo_position, amount, script"
]
if not no_tx:
select_columns.append("raw")
my_accounts = {a.public_key.address for a in wallet.accounts} if wallet else set()
my_accounts_sql = ""
@@ -1025,7 +993,7 @@ class Database(SQLiteMixin):
if 'order_by' not in constraints or constraints['order_by'] == 'height':
constraints['order_by'] = [
"tx.height in (0, -1) DESC", "tx.height DESC", "tx.position DESC", "txo.position"
"tx.height=0 DESC", "tx.height DESC", "tx.position DESC", "txo.position"
]
elif constraints.get('order_by', None) == 'none':
del constraints['order_by']
@@ -1064,33 +1032,32 @@ class Database(SQLiteMixin):
txo.received_tips = row['received_tips']
txos.append(txo)
if not no_channel_info:
channel_ids = set()
channel_ids = set()
for txo in txos:
if txo.is_claim and txo.can_decode_claim:
if txo.claim.is_signed:
channel_ids.add(txo.claim.signing_channel_id)
if txo.claim.is_channel and wallet:
for account in wallet.accounts:
private_key = await account.get_channel_private_key(
txo.claim.channel.public_key_bytes
)
if private_key:
txo.private_key = private_key
break
if channel_ids:
channels = {
txo.claim_id: txo for txo in
(await self.get_channels(
wallet=wallet,
claim_id__in=channel_ids,
read_only=read_only
))
}
for txo in txos:
if txo.is_claim and txo.can_decode_claim:
if txo.claim.is_signed:
channel_ids.add(txo.claim.signing_channel_id)
if txo.claim.is_channel and wallet:
for account in wallet.accounts:
private_key = await account.get_channel_private_key(
txo.claim.channel.public_key_bytes
)
if private_key:
txo.private_key = private_key
break
if channel_ids:
channels = {
txo.claim_id: txo for txo in
(await self.get_channels(
wallet=wallet,
claim_id__in=channel_ids,
read_only=read_only
))
}
for txo in txos:
if txo.is_claim and txo.can_decode_claim:
txo.channel = channels.get(txo.claim.signing_channel_id, None)
txo.channel = channels.get(txo.claim.signing_channel_id, None)
return txos
@@ -1152,41 +1119,6 @@ class Database(SQLiteMixin):
)
return balance[0]['total'] or 0
async def get_detailed_balance(self, accounts, read_only=False, **constraints):
constraints['accounts'] = accounts
result = (await self.select_txos(
f"COALESCE(SUM(amount), 0) AS total,"
f"COALESCE(SUM("
f" CASE WHEN"
f" txo_type NOT IN ({TXO_TYPES['other']}, {TXO_TYPES['purchase']})"
f" THEN amount ELSE 0 END), 0) AS reserved,"
f"COALESCE(SUM("
f" CASE WHEN"
f" txo_type IN ({','.join(map(str, CLAIM_TYPES))})"
f" THEN amount ELSE 0 END), 0) AS claims,"
f"COALESCE(SUM(CASE WHEN txo_type = {TXO_TYPES['support']} THEN amount ELSE 0 END), 0) AS supports,"
f"COALESCE(SUM("
f" CASE WHEN"
f" txo_type = {TXO_TYPES['support']} AND"
f" TXI.address IS NOT NULL AND"
f" TXI.address IN (SELECT address FROM account_address WHERE account = :$account__in0)"
f" THEN amount ELSE 0 END), 0) AS my_supports",
is_spent=False,
include_is_my_input=True,
read_only=read_only,
**constraints
))[0]
return {
"total": result["total"],
"available": result["total"] - result["reserved"],
"reserved": result["reserved"],
"reserved_subtotals": {
"claims": result["claims"],
"supports": result["my_supports"],
"tips": result["supports"] - result["my_supports"]
}
}
async def select_addresses(self, cols, read_only=False, **constraints):
return await self.db.execute_fetchall(*query(
f"SELECT {cols} FROM pubkey_address JOIN account_address USING (address)",
+10 -48
View File
@@ -14,7 +14,7 @@ from lbry.schema.result import Outputs, INVALID, NOT_FOUND
from lbry.schema.url import URL
from lbry.crypto.hash import hash160, double_sha256, sha256
from lbry.crypto.base58 import Base58
from lbry.utils import LRUCacheWithMetrics
from lbry.utils import LRUCache
from .tasks import TaskGroup
from .database import Database
@@ -155,7 +155,7 @@ class Ledger(metaclass=LedgerRegistry):
self._on_ready_controller = StreamController()
self.on_ready = self._on_ready_controller.stream
self._tx_cache = LRUCacheWithMetrics(self.config.get("tx_cache_size", 1024), metric_name='tx')
self._tx_cache = LRUCache(self.config.get("tx_cache_size", 1024), metric_name='tx')
self._update_tasks = TaskGroup()
self._other_tasks = TaskGroup() # that we dont need to start
self._utxo_reservation_lock = asyncio.Lock()
@@ -167,7 +167,7 @@ class Ledger(metaclass=LedgerRegistry):
self._known_addresses_out_of_sync = set()
self.fee_per_name_char = self.config.get('fee_per_name_char', self.default_fee_per_name_char)
self._balance_cache = LRUCacheWithMetrics(2 ** 15)
self._balance_cache = LRUCache(2 ** 15)
@classmethod
def get_id(cls):
@@ -178,25 +178,15 @@ class Ledger(metaclass=LedgerRegistry):
raw_address = cls.pubkey_address_prefix + h160
return Base58.encode(bytearray(raw_address + double_sha256(raw_address)[0:4]))
@classmethod
def hash160_to_script_address(cls, h160):
raw_address = cls.script_address_prefix + h160
return Base58.encode(bytearray(raw_address + double_sha256(raw_address)[0:4]))
@staticmethod
def address_to_hash160(address):
return Base58.decode(address)[1:21]
@classmethod
def is_pubkey_address(cls, address):
def is_valid_address(cls, address):
decoded = Base58.decode_check(address)
return decoded[0] == cls.pubkey_address_prefix[0]
@classmethod
def is_script_address(cls, address):
decoded = Base58.decode_check(address)
return decoded[0] == cls.script_address_prefix[0]
@classmethod
def public_key_to_address(cls, public_key):
return cls.hash160_to_address(hash160(public_key))
@@ -241,7 +231,7 @@ class Ledger(metaclass=LedgerRegistry):
async def get_effective_amount_estimators(self, funding_accounts: Iterable[Account]):
estimators = []
for account in funding_accounts:
utxos = await account.get_utxos(no_tx=True, no_channel_info=True)
utxos = await account.get_utxos()
for utxo in utxos:
estimators.append(utxo.get_estimator(self))
return estimators
@@ -548,7 +538,7 @@ class Ledger(metaclass=LedgerRegistry):
"request %i transactions, %i/%i for %s are already synced", len(to_request), len(already_synced),
len(remote_history), address
)
remote_history_txids = {txid for txid, _ in remote_history}
remote_history_txids = set(txid for txid, _ in remote_history)
async for tx in self.request_synced_transactions(to_request, remote_history_txids, address):
pending_synced_history[tx_indexes[tx.id]] = f"{tx.id}:{tx.height}:"
if len(pending_synced_history) % 100 == 0:
@@ -723,10 +713,8 @@ class Ledger(metaclass=LedgerRegistry):
self.hash160_to_address(txi.txo_ref.txo.pubkey_hash)
)
for txo in tx.outputs:
if txo.is_pubkey_hash:
if txo.has_address:
addresses.add(self.hash160_to_address(txo.pubkey_hash))
elif txo.is_script_hash:
addresses.add(self.hash160_to_script_address(txo.script_hash))
start = int(time.perf_counter())
while timeout and (int(time.perf_counter()) - start) <= timeout:
if await self._wait_round(tx, height, addresses):
@@ -949,11 +937,6 @@ class Ledger(metaclass=LedgerRegistry):
return self.db.get_purchase_count(**constraints)
async def _resolve_for_local_results(self, accounts, txos):
txos = await self._resolve_for_local_claim_results(accounts, txos)
txos = await self._resolve_for_local_support_results(accounts, txos)
return txos
async def _resolve_for_local_claim_results(self, accounts, txos):
results = []
response = await self.resolve(
accounts, [txo.permanent_url for txo in txos if txo.can_decode_claim]
@@ -969,23 +952,6 @@ class Ledger(metaclass=LedgerRegistry):
results.append(txo)
return results
async def _resolve_for_local_support_results(self, accounts, txos):
channel_ids = set()
signed_support_txos = []
for txo in txos:
support = txo.can_decode_support
if support and support.signing_channel_id:
channel_ids.add(support.signing_channel_id)
signed_support_txos.append(txo)
if channel_ids:
channels = {
channel.claim_id: channel for channel in
(await self.claim_search(accounts, claim_ids=list(channel_ids)))[0]
}
for txo in signed_support_txos:
txo.channel = channels.get(txo.support.signing_channel_id)
return txos
async def get_claims(self, resolve=False, **constraints):
claims = await self.db.get_claims(**constraints)
if resolve:
@@ -1034,10 +1000,8 @@ class Ledger(metaclass=LedgerRegistry):
claims.append(None)
return claims
async def get_collections(self, resolve_claims=0, resolve=False, **constraints):
async def get_collections(self, resolve_claims=0, **constraints):
collections = await self.db.get_collections(**constraints)
if resolve:
collections = await self._resolve_for_local_results(constraints.get('accounts', []), collections)
if resolve_claims > 0:
for collection in collections:
collection.claims = await self.resolve_collection(collection, page_size=resolve_claims)
@@ -1072,7 +1036,7 @@ class Ledger(metaclass=LedgerRegistry):
'abandon_info': [],
'purchase_info': []
}
is_my_inputs = all(txi.is_my_input for txi in tx.inputs)
is_my_inputs = all([txi.is_my_input for txi in tx.inputs])
if is_my_inputs:
# fees only matter if we are the ones paying them
item['value'] = dewies_to_lbc(tx.net_account_balance + tx.fee)
@@ -1183,7 +1147,7 @@ class Ledger(metaclass=LedgerRegistry):
balance = self._balance_cache.get(account.id)
if not balance:
balance = self._balance_cache[account.id] = \
await account.get_detailed_balance(confirmations)
await account.get_detailed_balance(confirmations, reserved_subtotals=True)
for key, value in balance.items():
if key == 'reserved_subtotals':
for subkey, subvalue in value.items():
@@ -1192,7 +1156,6 @@ class Ledger(metaclass=LedgerRegistry):
result[key] += value
return result
class TestNetLedger(Ledger):
network_name = 'testnet'
pubkey_address_prefix = bytes((111,))
@@ -1201,7 +1164,6 @@ class TestNetLedger(Ledger):
extended_private_key_prefix = unhexlify('04358394')
checkpoints = {}
class RegTestLedger(Ledger):
network_name = 'regtest'
headers_class = UnvalidatedHeaders
+2 -14
View File
@@ -8,7 +8,7 @@ from decimal import Decimal
from typing import List, Type, MutableSequence, MutableMapping, Optional
from lbry.error import KeyFeeAboveMaxAllowedError
from lbry.conf import Config, NOT_SET
from lbry.conf import Config
from .dewies import dewies_to_lbc
from .account import Account
@@ -182,10 +182,7 @@ class WalletManager:
ledger_config = {
'auto_connect': True,
'explicit_servers': [],
'default_servers': config.lbryum_servers,
'known_hubs': config.known_hubs,
'jurisdiction': config.jurisdiction,
'data_path': config.wallet_dir,
'tx_cache_size': config.transaction_cache_size
}
@@ -198,10 +195,6 @@ class WalletManager:
os.path.join(wallets_directory, 'default_wallet')
)
if Config.lbryum_servers.is_set_to_default(config):
with config.update_config() as c:
c.lbryum_servers = NOT_SET
manager = cls.from_config({
'ledgers': {ledger_id: ledger_config},
'wallets': [
@@ -232,14 +225,9 @@ class WalletManager:
async def reset(self):
self.ledger.config = {
'auto_connect': True,
'explicit_servers': [],
'default_servers': Config.lbryum_servers.default,
'known_hubs': self.config.known_hubs,
'jurisdiction': self.config.jurisdiction,
'default_servers': self.config.lbryum_servers,
'data_path': self.config.wallet_dir,
}
if Config.lbryum_servers.is_set(self.config):
self.ledger.config['explicit_servers'] = self.config.lbryum_servers
await self.ledger.stop()
await self.ledger.start()
+176 -228
View File
@@ -1,29 +1,26 @@
import logging
import asyncio
import json
import socket
import random
from time import perf_counter
from collections import defaultdict
from operator import itemgetter
from typing import Dict, Optional, Tuple
import aiohttp
from lbry import __version__
from lbry.utils import resolve_host
from lbry.error import IncompatibleWalletServerError
from lbry.wallet.rpc import RPCSession as BaseClientSession, Connector, RPCError, ProtocolError
from lbry.wallet.stream import StreamController
from lbry.wallet.server.udp import SPVStatusClientProtocol, SPVPong
from lbry.conf import KnownHubsList
log = logging.getLogger(__name__)
class ClientSession(BaseClientSession):
def __init__(self, *args, network: 'Network', server, timeout=30, **kwargs):
def __init__(self, *args, network, server, timeout=30, on_connect_callback=None, **kwargs):
self.network = network
self.server = server
super().__init__(*args, **kwargs)
self._on_disconnect_controller = StreamController()
self.on_disconnected = self._on_disconnect_controller.stream
self.framer.max_size = self.max_errors = 1 << 32
self.timeout = timeout
self.max_seconds_idle = timeout * 2
@@ -31,6 +28,8 @@ class ClientSession(BaseClientSession):
self.connection_latency: Optional[float] = None
self._response_samples = 0
self.pending_amount = 0
self._on_connect_cb = on_connect_callback or (lambda: None)
self.trigger_urgent_reconnect = asyncio.Event()
@property
def available(self):
@@ -57,7 +56,7 @@ class ClientSession(BaseClientSession):
async def send_request(self, method, args=()):
self.pending_amount += 1
log.debug("send %s%s to %s:%i (%i timeout)", method, tuple(args), self.server[0], self.server[1], self.timeout)
log.debug("send %s%s to %s:%i", method, tuple(args), *self.server)
try:
if method == 'server.version':
return await self.send_timed_server_version_request(args, self.timeout)
@@ -68,7 +67,7 @@ class ClientSession(BaseClientSession):
log.debug("Time since last packet: %s", perf_counter() - self.last_packet_received)
if (perf_counter() - self.last_packet_received) < self.timeout:
continue
log.warning("timeout sending %s to %s:%i", method, *self.server)
log.info("timeout sending %s to %s:%i", method, *self.server)
raise asyncio.TimeoutError
if done:
try:
@@ -88,12 +87,44 @@ class ClientSession(BaseClientSession):
self.synchronous_close()
raise
except asyncio.CancelledError:
log.warning("cancelled sending %s to %s:%i", method, *self.server)
log.info("cancelled sending %s to %s:%i", method, *self.server)
# self.synchronous_close()
raise
finally:
self.pending_amount -= 1
async def ensure_session(self):
# Handles reconnecting and maintaining a session alive
# TODO: change to 'ping' on newer protocol (above 1.2)
retry_delay = default_delay = 1.0
while True:
try:
if self.is_closing():
await self.create_connection(self.timeout)
await self.ensure_server_version()
self._on_connect_cb()
if (perf_counter() - self.last_send) > self.max_seconds_idle or self.response_time is None:
await self.ensure_server_version()
retry_delay = default_delay
except RPCError as e:
await self.close()
log.debug("Server error, ignoring for 1h: %s:%d -- %s", *self.server, e.message)
retry_delay = 60 * 60
except IncompatibleWalletServerError:
await self.close()
retry_delay = 60 * 60
log.debug("Wallet server has an incompatible version, retrying in 1h: %s:%d", *self.server)
except (asyncio.TimeoutError, OSError):
await self.close()
retry_delay = min(60, retry_delay * 2)
log.debug("Wallet server timeout (retry in %s seconds): %s:%d", retry_delay, *self.server)
try:
await asyncio.wait_for(self.trigger_urgent_reconnect.wait(), timeout=retry_delay)
except asyncio.TimeoutError:
pass
finally:
self.trigger_urgent_reconnect.clear()
async def ensure_server_version(self, required=None, timeout=3):
required = required or self.network.PROTOCOL_VERSION
response = await asyncio.wait_for(
@@ -103,25 +134,6 @@ class ClientSession(BaseClientSession):
raise IncompatibleWalletServerError(*self.server)
return response
async def keepalive_loop(self, timeout=3, max_idle=60):
try:
while True:
now = perf_counter()
if min(self.last_send, self.last_packet_received) + max_idle < now:
await asyncio.wait_for(
self.send_request('server.ping', []), timeout=timeout
)
else:
await asyncio.sleep(max(0, max_idle - (now - self.last_send)))
except Exception as err:
if isinstance(err, asyncio.CancelledError):
log.warning("closing connection to %s:%i", *self.server)
else:
log.exception("lost connection to spv")
finally:
if not self.is_closing():
self._close()
async def create_connection(self, timeout=6):
connector = Connector(lambda: self, *self.server)
start = perf_counter()
@@ -133,14 +145,12 @@ class ClientSession(BaseClientSession):
controller.add(request.args)
def connection_lost(self, exc):
log.warning("Connection lost: %s:%d", *self.server)
log.debug("Connection lost: %s:%d", *self.server)
super().connection_lost(exc)
self.response_time = None
self.connection_latency = None
self._response_samples = 0
# self._on_disconnect_controller.add(True)
if self.network:
self.network.disconnect()
self._on_disconnect_controller.add(True)
class Network:
@@ -150,9 +160,10 @@ class Network:
def __init__(self, ledger):
self.ledger = ledger
self.session_pool = SessionPool(network=self, timeout=self.config.get('connect_timeout', 6))
self.client: Optional[ClientSession] = None
self.server_features = None
# self._switch_task: Optional[asyncio.Task] = None
self._switch_task: Optional[asyncio.Task] = None
self.running = False
self.remote_height: int = 0
self._concurrency = asyncio.Semaphore(16)
@@ -166,213 +177,64 @@ class Network:
self._on_status_controller = StreamController(merge_repeated_events=True)
self.on_status = self._on_status_controller.stream
self._on_hub_controller = StreamController(merge_repeated_events=True)
self.on_hub = self._on_hub_controller.stream
self.subscription_controllers = {
'blockchain.headers.subscribe': self._on_header_controller,
'blockchain.address.subscribe': self._on_status_controller,
'blockchain.peers.subscribe': self._on_hub_controller,
}
self.aiohttp_session: Optional[aiohttp.ClientSession] = None
self._urgent_need_reconnect = asyncio.Event()
self._loop_task: Optional[asyncio.Task] = None
self._keepalive_task: Optional[asyncio.Task] = None
@property
def config(self):
return self.ledger.config
@property
def known_hubs(self):
if 'known_hubs' not in self.config:
return KnownHubsList()
return self.config['known_hubs']
@property
def jurisdiction(self):
return self.config.get("jurisdiction")
def disconnect(self):
if self._keepalive_task and not self._keepalive_task.done():
self._keepalive_task.cancel()
self._keepalive_task = None
async def start(self):
if not self.running:
self.running = True
self.aiohttp_session = aiohttp.ClientSession()
self.on_header.listen(self._update_remote_height)
self.on_hub.listen(self._update_hubs)
self._loop_task = asyncio.create_task(self.network_loop())
self._urgent_need_reconnect.set()
def loop_task_done_callback(f):
try:
f.result()
except Exception:
if self.running:
log.exception("wallet server connection loop crashed")
self._loop_task.add_done_callback(loop_task_done_callback)
async def resolve_spv_dns(self):
hostname_to_ip = {}
ip_to_hostnames = defaultdict(list)
async def resolve_spv(server, port):
try:
server_addr = await resolve_host(server, port, 'udp')
hostname_to_ip[server] = (server_addr, port)
ip_to_hostnames[(server_addr, port)].append(server)
except socket.error:
log.warning("error looking up dns for spv server %s:%i", server, port)
except Exception:
log.exception("error looking up dns for spv server %s:%i", server, port)
# accumulate the dns results
if self.config['explicit_servers']:
hubs = self.config['explicit_servers']
elif self.known_hubs:
hubs = self.known_hubs
else:
hubs = self.config['default_servers']
await asyncio.gather(*(resolve_spv(server, port) for (server, port) in hubs))
return hostname_to_ip, ip_to_hostnames
async def get_n_fastest_spvs(self, timeout=3.0) -> Dict[Tuple[str, int], Optional[SPVPong]]:
loop = asyncio.get_event_loop()
pong_responses = asyncio.Queue()
connection = SPVStatusClientProtocol(pong_responses)
sent_ping_timestamps = {}
_, ip_to_hostnames = await self.resolve_spv_dns()
n = len(ip_to_hostnames)
log.info("%i possible spv servers to try (%i urls in config)", n, len(self.config['explicit_servers']))
pongs = {}
known_hubs = self.known_hubs
try:
await loop.create_datagram_endpoint(lambda: connection, ('0.0.0.0', 0))
# could raise OSError if it cant bind
start = perf_counter()
for server in ip_to_hostnames:
connection.ping(server)
sent_ping_timestamps[server] = perf_counter()
while len(pongs) < n:
(remote, ts), pong = await asyncio.wait_for(pong_responses.get(), timeout - (perf_counter() - start))
latency = ts - start
log.info("%s:%i has latency of %sms (available: %s, height: %i)",
'/'.join(ip_to_hostnames[remote]), remote[1], round(latency * 1000, 2),
pong.available, pong.height)
known_hubs.hubs.setdefault((ip_to_hostnames[remote][0], remote[1]), {}).update(
{"country": pong.country_name}
)
if pong.available:
pongs[(ip_to_hostnames[remote][0], remote[1])] = pong
return pongs
except asyncio.TimeoutError:
if pongs:
log.info("%i/%i probed spv servers are accepting connections", len(pongs), len(ip_to_hostnames))
return pongs
else:
log.warning("%i spv status probes failed, retrying later. servers tried: %s",
len(sent_ping_timestamps),
', '.join('/'.join(hosts) + f' ({ip})' for ip, hosts in ip_to_hostnames.items()))
random_server = random.choice(list(ip_to_hostnames.keys()))
host, port = random_server
log.warning("trying fallback to randomly selected spv: %s:%i", host, port)
known_hubs.hubs.setdefault((host, port), {})
return {(host, port): None}
finally:
connection.close()
async def connect_to_fastest(self) -> Optional[ClientSession]:
fastest_spvs = await self.get_n_fastest_spvs()
for (host, port), pong in fastest_spvs.items():
if (pong is not None and self.jurisdiction is not None) and \
(pong.country_name != self.jurisdiction):
continue
client = ClientSession(network=self, server=(host, port))
try:
await client.create_connection()
log.warning("Connected to spv server %s:%i", host, port)
await client.ensure_server_version()
return client
except (asyncio.TimeoutError, ConnectionError, OSError, IncompatibleWalletServerError, RPCError):
log.warning("Connecting to %s:%d failed", host, port)
client._close()
return
async def network_loop(self):
sleep_delay = 30
async def switch_forever(self):
while self.running:
await asyncio.wait(
[asyncio.sleep(30), self._urgent_need_reconnect.wait()], return_when=asyncio.FIRST_COMPLETED
)
if self._urgent_need_reconnect.is_set():
sleep_delay = 30
self._urgent_need_reconnect.clear()
if not self.is_connected:
client = await self.connect_to_fastest()
if not client:
log.warning("failed to connect to any spv servers, retrying later")
sleep_delay *= 2
sleep_delay = min(sleep_delay, 300)
continue
log.debug("get spv server features %s:%i", *client.server)
features = await client.send_request('server.features', [])
self.client, self.server_features = client, features
log.debug("discover other hubs %s:%i", *client.server)
await self._update_hubs(await client.send_request('server.peers.subscribe', []))
log.info("subscribe to headers %s:%i", *client.server)
if self.is_connected:
await self.client.on_disconnected.first
self.server_features = None
self.client = None
continue
self.client = await self.session_pool.wait_for_fastest_session()
log.info("Switching to SPV wallet server: %s:%d", *self.client.server)
try:
self.server_features = await self.get_server_features()
self._update_remote_height((await self.subscribe_headers(),))
self._on_connected_controller.add(True)
server_str = "%s:%i" % client.server
log.info("maintaining connection to spv server %s", server_str)
self._keepalive_task = asyncio.create_task(self.client.keepalive_loop())
try:
if not self._urgent_need_reconnect.is_set():
await asyncio.wait(
[self._keepalive_task, self._urgent_need_reconnect.wait()],
return_when=asyncio.FIRST_COMPLETED
)
else:
await self._keepalive_task
if self._urgent_need_reconnect.is_set():
log.warning("urgent reconnect needed")
self._urgent_need_reconnect.clear()
if self._keepalive_task and not self._keepalive_task.done():
self._keepalive_task.cancel()
except asyncio.CancelledError:
pass
finally:
self._keepalive_task = None
self.client = None
self.server_features = None
log.warning("connection lost to %s", server_str)
log.info("network loop finished")
log.info("Subscribed to headers: %s:%d", *self.client.server)
except (asyncio.TimeoutError, ConnectionError):
log.info("Switching to %s:%d timed out, closing and retrying.", *self.client.server)
self.client.synchronous_close()
self.server_features = None
self.client = None
async def start(self):
self.running = True
self.aiohttp_session = aiohttp.ClientSession()
self._switch_task = asyncio.ensure_future(self.switch_forever())
# this may become unnecessary when there are no more bugs found,
# but for now it helps understanding log reports
self._switch_task.add_done_callback(lambda _: log.info("Wallet client switching task stopped."))
self.session_pool.start(self.config['default_servers'])
self.on_header.listen(self._update_remote_height)
async def stop(self):
self.running = False
self.disconnect()
if self._loop_task and not self._loop_task.done():
self._loop_task.cancel()
self._loop_task = None
if self.aiohttp_session:
if self.running:
self.running = False
await self.aiohttp_session.close()
self.aiohttp_session = None
self._switch_task.cancel()
self.session_pool.stop()
@property
def is_connected(self):
return self.client and not self.client.is_closing()
def rpc(self, list_or_method, args, restricted=True, session: Optional[ClientSession] = None):
if session or self.is_connected:
session = session or self.client
def rpc(self, list_or_method, args, restricted=True, session=None):
session = session or (self.client if restricted else self.session_pool.fastest_session)
if session and not session.is_closing():
return session.send_request(list_or_method, args)
else:
self._urgent_need_reconnect.set()
self.session_pool.trigger_nodelay_connect()
raise ConnectionError("Attempting to send rpc request when connection is not available.")
async def retriable_call(self, function, *args, **kwargs):
@@ -380,28 +242,19 @@ class Network:
while self.running:
if not self.is_connected:
log.warning("Wallet server unavailable, waiting for it to come back and retry.")
self._urgent_need_reconnect.set()
await self.on_connected.first
await self.session_pool.wait_for_fastest_session()
try:
return await function(*args, **kwargs)
except asyncio.TimeoutError:
log.warning("Wallet server call timed out, retrying.")
except ConnectionError:
log.warning("connection error")
pass
raise asyncio.CancelledError() # if we got here, we are shutting down
def _update_remote_height(self, header_args):
self.remote_height = header_args[0]["height"]
async def _update_hubs(self, hubs):
if hubs and hubs != ['']:
try:
if self.known_hubs.add_hubs(hubs):
self.known_hubs.save()
except Exception:
log.exception("could not add hubs: %s", hubs)
def get_transaction(self, tx_hash, known_height=None):
# use any server if its old, otherwise restrict to who gave us the history
restricted = known_height in (None, -1, 0) or 0 > known_height > self.remote_height - 10
@@ -459,6 +312,9 @@ class Network:
def get_server_features(self):
return self.rpc('server.features', (), restricted=True)
def get_claims_by_ids(self, claim_ids):
return self.rpc('blockchain.claimtrie.getclaimsbyids', claim_ids)
def resolve(self, urls, session_override=None):
return self.rpc('blockchain.claimtrie.resolve', urls, False, session_override)
@@ -483,3 +339,95 @@ class Network:
async with self.aiohttp_session.post(server, json=message) as r:
result = await r.json()
return result['result']
class SessionPool:
def __init__(self, network: Network, timeout: float):
self.network = network
self.sessions: Dict[ClientSession, Optional[asyncio.Task]] = dict()
self.timeout = timeout
self.new_connection_event = asyncio.Event()
@property
def online(self):
return any(not session.is_closing() for session in self.sessions)
@property
def available_sessions(self):
return (session for session in self.sessions if session.available)
@property
def fastest_session(self):
if not self.online:
return None
return min(
[((session.response_time + session.connection_latency) * (session.pending_amount + 1), session)
for session in self.available_sessions] or [(0, None)],
key=itemgetter(0)
)[1]
def _get_session_connect_callback(self, session: ClientSession):
loop = asyncio.get_event_loop()
def callback():
duplicate_connections = [
s for s in self.sessions
if s is not session and s.server_address_and_port == session.server_address_and_port
]
already_connected = None if not duplicate_connections else duplicate_connections[0]
if already_connected:
self.sessions.pop(session).cancel()
session.synchronous_close()
log.debug("wallet server %s resolves to the same server as %s, rechecking in an hour",
session.server[0], already_connected.server[0])
loop.call_later(3600, self._connect_session, session.server)
return
self.new_connection_event.set()
log.info("connected to %s:%i", *session.server)
return callback
def _connect_session(self, server: Tuple[str, int]):
session = None
for s in self.sessions:
if s.server == server:
session = s
break
if not session:
session = ClientSession(
network=self.network, server=server
)
session._on_connect_cb = self._get_session_connect_callback(session)
task = self.sessions.get(session, None)
if not task or task.done():
task = asyncio.create_task(session.ensure_session())
task.add_done_callback(lambda _: self.ensure_connections())
self.sessions[session] = task
def start(self, default_servers):
for server in default_servers:
self._connect_session(server)
def stop(self):
for session, task in self.sessions.items():
task.cancel()
session.synchronous_close()
self.sessions.clear()
def ensure_connections(self):
for session in self.sessions:
self._connect_session(session.server)
def trigger_nodelay_connect(self):
# used when other parts of the system sees we might have internet back
# bypasses the retry interval
for session in self.sessions:
session.trigger_urgent_reconnect.set()
async def wait_for_fastest_session(self):
while not self.fastest_session:
self.trigger_nodelay_connect()
self.new_connection_event.clear()
await self.new_connection_event.wait()
return self.fastest_session
+8 -24
View File
@@ -11,13 +11,11 @@ import importlib
from binascii import hexlify
from typing import Type, Optional
import urllib.request
from uuid import uuid4
import lbry
from lbry.wallet.server.server import Server
from lbry.wallet.server.env import Env
from lbry.wallet import Wallet, Ledger, RegTestLedger, WalletManager, Account, BlockHeightEvent
from lbry.conf import KnownHubsList, Config
log = logging.getLogger(__name__)
@@ -108,8 +106,7 @@ class Conductor:
class WalletNode:
def __init__(self, manager_class: Type[WalletManager], ledger_class: Type[Ledger],
verbose: bool = False, port: int = 5280, default_seed: str = None,
data_path: str = None) -> None:
verbose: bool = False, port: int = 5280, default_seed: str = None) -> None:
self.manager_class = manager_class
self.ledger_class = ledger_class
self.verbose = verbose
@@ -117,12 +114,12 @@ class WalletNode:
self.ledger: Optional[Ledger] = None
self.wallet: Optional[Wallet] = None
self.account: Optional[Account] = None
self.data_path: str = data_path or tempfile.mkdtemp()
self.data_path: Optional[str] = None
self.port = port
self.default_seed = default_seed
self.known_hubs = KnownHubsList()
async def start(self, spv_node: 'SPVNode', seed=None, connect=True, config=None):
async def start(self, spv_node: 'SPVNode', seed=None, connect=True):
self.data_path = tempfile.mkdtemp()
wallets_dir = os.path.join(self.data_path, 'wallets')
os.mkdir(wallets_dir)
wallet_file_name = os.path.join(wallets_dir, 'my_wallet.json')
@@ -132,15 +129,12 @@ class WalletNode:
'ledgers': {
self.ledger_class.get_id(): {
'api_port': self.port,
'explicit_servers': [(spv_node.hostname, spv_node.port)],
'default_servers': Config.lbryum_servers.default,
'data_path': self.data_path,
'known_hubs': config.known_hubs if config else KnownHubsList()
'default_servers': [(spv_node.hostname, spv_node.port)],
'data_path': self.data_path
}
},
'wallets': [wallet_file_name]
})
self.manager.config = config
self.ledger = self.manager.ledgers[self.ledger_class]
self.wallet = self.manager.default_wallet
if not self.wallet:
@@ -174,10 +168,8 @@ class SPVNode:
self.server = None
self.hostname = 'localhost'
self.port = 50001 + node_number # avoid conflict with default daemon
self.udp_port = self.port
self.session_timeout = 600
self.rpc_port = '0' # disabled by default
self.stopped = False
async def start(self, blockchain_node: 'BlockchainNode', extraconf=None):
self.data_path = tempfile.mkdtemp()
@@ -190,13 +182,10 @@ class SPVNode:
'REORG_LIMIT': '100',
'HOST': self.hostname,
'TCP_PORT': str(self.port),
'UDP_PORT': str(self.udp_port),
'SESSION_TIMEOUT': str(self.session_timeout),
'MAX_QUERY_WORKERS': '0',
'INDIVIDUAL_TAG_INDEXES': '',
'RPC_PORT': self.rpc_port,
'ES_INDEX_PREFIX': uuid4().hex,
'ES_MODE': 'writer',
'RPC_PORT': self.rpc_port
}
if extraconf:
conf.update(extraconf)
@@ -207,13 +196,8 @@ class SPVNode:
await self.server.start()
async def stop(self, cleanup=True):
if self.stopped:
return
try:
await self.server.db.search_index.delete_index()
await self.server.db.search_index.stop()
await self.server.stop()
self.stopped = True
finally:
cleanup and self.cleanup()
@@ -419,7 +403,7 @@ class BlockchainNode:
return self._cli_cmnd('getnewaddress', "", address_type)
async def get_balance(self):
return await self._cli_cmnd('getbalance')
return float(await self._cli_cmnd('getbalance'))
def send_to_address(self, address, amount):
return self._cli_cmnd('sendtoaddress', address, str(amount))
+3
View File
@@ -108,6 +108,9 @@ class Response:
class CodeMessageError(Exception):
def __init__(self, code, message):
super().__init__(code, message)
@property
def code(self):
return self.args[0]
-3
View File
@@ -32,13 +32,10 @@ import inspect
# other_params: None means cannot be called with keyword arguments only
# any means any name is good
from functools import lru_cache
SignatureInfo = namedtuple('SignatureInfo', 'min_args max_args '
'required_names other_names')
@lru_cache(256)
def signature_info(func):
params = inspect.signature(func).parameters
min_args = max_args = 0
+29 -23
View File
@@ -5,12 +5,12 @@ from concurrent.futures.thread import ThreadPoolExecutor
from typing import Optional
from prometheus_client import Gauge, Histogram
import lbry
from lbry.schema.claim import Claim
from lbry.wallet.server.db.writer import SQLDB
from lbry.wallet.server.daemon import DaemonError
from lbry.wallet.server.hash import hash_to_hex_str, HASHX_LEN
from lbry.wallet.server.util import chunks, class_logger
from lbry.wallet.server.leveldb import FlushData
from lbry.wallet.server.udp import StatusServer
class Prefetcher:
@@ -185,7 +185,6 @@ class BlockProcessor:
self.search_cache = {}
self.history_cache = {}
self.status_server = StatusServer()
async def run_in_thread_with_lock(self, func, *args):
# Run in a thread to prevent blocking. Shielded so that
@@ -214,8 +213,6 @@ class BlockProcessor:
if hprevs == chain:
start = time.perf_counter()
await self.run_in_thread_with_lock(self.advance_blocks, blocks)
if self.sql:
await self.db.search_index.claim_consumer(self.sql.claim_producer())
for cache in self.search_cache.values():
cache.clear()
self.history_cache.clear()
@@ -224,14 +221,10 @@ class BlockProcessor:
processed_time = time.perf_counter() - start
self.block_count_metric.set(self.height)
self.block_update_time_metric.observe(processed_time)
self.status_server.set_height(self.db.fs_height, self.db.db_tip)
if not self.db.first_sync:
s = '' if len(blocks) == 1 else 's'
self.logger.info('processed {:,d} block{} in {:.1f}s'.format(len(blocks), s, processed_time))
if self._caught_up_event.is_set():
if self.sql:
await self.db.search_index.apply_filters(self.sql.blocked_streams, self.sql.blocked_channels,
self.sql.filtered_streams, self.sql.filtered_channels)
await self.notifications.on_block(self.touched, self.height)
self.touched = set()
elif hprevs[0] != chain[0]:
@@ -286,6 +279,7 @@ class BlockProcessor:
await self.run_in_thread_with_lock(flush_backup)
last -= len(raw_blocks)
await self.run_in_thread_with_lock(self.db.sql.delete_claims_above_height, self.height)
await self.prefetcher.reset_height(self.height)
self.reorg_count_metric.inc()
except:
@@ -605,7 +599,8 @@ class BlockProcessor:
# Key: b'h' + compressed_tx_hash + tx_idx + tx_num
# Value: hashX
prefix = b'h' + tx_hash[:4] + idx_packed
candidates = dict(self.db.utxo_db.iterator(prefix=prefix))
candidates = {db_key: hashX for db_key, hashX
in self.db.utxo_db.iterator(prefix=prefix)}
for hdb_key, hashX in candidates.items():
tx_num_packed = hdb_key[-4:]
if len(candidates) > 1:
@@ -653,11 +648,7 @@ class BlockProcessor:
self.reorg_count = 0
else:
blocks = self.prefetcher.get_prefetched_blocks()
try:
await self.check_and_advance_blocks(blocks)
except Exception:
self.logger.exception("error while processing txs")
raise
await self.check_and_advance_blocks(blocks)
async def _first_caught_up(self):
self.logger.info(f'caught up to height {self.height}')
@@ -691,11 +682,9 @@ class BlockProcessor:
disk before exiting, as otherwise a significant amount of work
could be lost.
"""
self._caught_up_event = caught_up_event
try:
await self._first_open_dbs()
self.status_server.set_height(self.db.fs_height, self.db.db_tip)
await asyncio.wait([
self.prefetcher.main_loop(self.height),
self._process_prefetched_blocks()
@@ -706,7 +695,6 @@ class BlockProcessor:
self.logger.exception("Block processing failed!")
raise
finally:
self.status_server.stop()
# Shut down block processing
self.logger.info('flushing to DB for a clean shutdown...')
await self.flush(True)
@@ -726,6 +714,7 @@ class BlockProcessor:
class Timer:
def __init__(self, name):
self.name = name
self.total = 0
@@ -788,22 +777,39 @@ class LBRYBlockProcessor(BlockProcessor):
self.timer = Timer('BlockProcessor')
def advance_blocks(self, blocks):
if self.sql:
self.sql.begin()
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:
if self.sql:
self.sql.commit()
self.sql.commit()
if self.db.first_sync and self.height == self.daemon.cached_height():
self.timer.run(self.sql.execute, self.sql.SEARCH_INDEXES, timer_name='executing SEARCH_INDEXES')
if self.env.individual_tag_indexes:
self.timer.run(self.sql.execute, self.sql.TAG_INDEXES, timer_name='executing TAG_INDEXES')
self.timer.run(self.sql.execute, self.sql.LANGUAGE_INDEXES, timer_name='executing LANGUAGE_INDEXES')
def advance_txs(self, height, txs, header, block_hash):
timer = self.timer.sub_timers['advance_blocks']
undo = timer.run(super().advance_txs, height, txs, header, block_hash, timer_name='super().advance_txs')
if self.sql:
timer.run(self.sql.advance_txs, height, txs, header, self.daemon.cached_height(), forward_timer=True)
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(10):
self.timer.show(height=height)
return undo
def _checksig(self, value, address):
try:
claim_dict = Claim.from_bytes(value)
cert_id = claim_dict.signing_channel_hash
if not self.should_validate_signatures:
return cert_id
if cert_id:
cert_claim = self.db.get_claim_info(cert_id)
if cert_claim:
certificate = Claim.from_bytes(cert_claim.value)
claim_dict.validate_signature(address, certificate)
return cert_id
except Exception:
pass
+2 -4
View File
@@ -8,7 +8,7 @@ from lbry.wallet.server.server import Server
def get_argument_parser():
parser = argparse.ArgumentParser(
prog="lbry-hub"
prog="torba-server"
)
parser.add_argument("spvserver", type=str, help="Python class path to SPV server implementation.",
nargs="?", default="lbry.wallet.server.coin.LBC")
@@ -25,10 +25,8 @@ def main():
parser = get_argument_parser()
args = parser.parse_args()
coin_class = get_coin_class(args.spvserver)
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)-4s %(name)s:%(lineno)d: %(message)s")
logging.basicConfig(level=logging.INFO)
logging.info('lbry.server starting')
logging.getLogger('aiohttp').setLevel(logging.WARNING)
logging.getLogger('elasticsearch').setLevel(logging.WARNING)
try:
server = Server(Env(coin_class))
server.run()
+3 -3
View File
@@ -6,7 +6,7 @@ from functools import wraps
import aiohttp
from prometheus_client import Gauge, Histogram
from lbry.utils import LRUCacheWithMetrics
from lbry.utils import LRUCache
from lbry.wallet.rpc.jsonrpc import RPCError
from lbry.wallet.server.util import hex_to_bytes, class_logger
from lbry.wallet.rpc import JSONRPC
@@ -54,8 +54,8 @@ class Daemon:
self._height = None
self.available_rpcs = {}
self.connector = aiohttp.TCPConnector()
self._block_hash_cache = LRUCacheWithMetrics(100000)
self._block_cache = LRUCacheWithMetrics(2 ** 16, metric_name='block', namespace=NAMESPACE)
self._block_hash_cache = LRUCache(100000)
self._block_cache = LRUCache(2**16, metric_name='block', namespace=NAMESPACE)
async def close(self):
if self.connector:
+5 -1
View File
@@ -17,6 +17,10 @@ class FindShortestID:
if self.short_id:
return '#'+self.short_id
@classmethod
def factory(cls):
return cls(), cls.step, cls.finalize
def register_canonical_functions(connection):
connection.create_aggregate("shortest_id", 2, FindShortestID)
connection.createaggregatefunction("shortest_id", FindShortestID.factory, 2)
+2 -3
View File
@@ -1,8 +1,7 @@
CLAIM_TYPES = {
'stream': 1,
'channel': 2,
'repost': 3,
'collection': 4,
'repost': 3
}
STREAM_TYPES = {
@@ -11,7 +10,7 @@ STREAM_TYPES = {
'image': 3,
'document': 4,
'binary': 5,
'model': 6,
'model': 6
}
# 9/21/2020
@@ -1 +0,0 @@
from .search import SearchIndex
@@ -1,61 +0,0 @@
INDEX_DEFAULT_SETTINGS = {
"settings":
{"analysis":
{"analyzer": {
"default": {"tokenizer": "whitespace", "filter": ["lowercase", "porter_stem"]}}},
"index":
{"refresh_interval": -1,
"number_of_shards": 1,
"number_of_replicas": 0,
"sort": {
"field": ["trending_mixed", "release_time"],
"order": ["desc", "desc"]
}}
},
"mappings": {
"properties": {
"claim_id": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text",
"index_prefixes": {
"min_chars": 1,
"max_chars": 10
}
},
"height": {"type": "integer"},
"claim_type": {"type": "byte"},
"censor_type": {"type": "byte"},
"trending_mixed": {"type": "float"},
"release_time": {"type": "long"},
}
}
}
FIELDS = {'is_controlling', 'last_take_over_height', 'claim_id', 'claim_name', 'normalized', 'tx_position', 'amount',
'timestamp', 'creation_timestamp', 'height', 'creation_height', 'activation_height', 'expiration_height',
'release_time', 'short_url', 'canonical_url', 'title', 'author', 'description', 'claim_type', 'reposted',
'stream_type', 'media_type', 'fee_amount', 'fee_currency', 'duration', 'reposted_claim_hash', 'censor_type',
'claims_in_channel', 'channel_join', 'signature_valid', 'effective_amount', 'support_amount',
'trending_group', 'trending_mixed', 'trending_local', 'trending_global', 'channel_id', 'tx_id', 'tx_nout',
'signature', 'signature_digest', 'public_key_bytes', 'public_key_hash', 'public_key_id', '_id', 'tags',
'reposted_claim_id'}
TEXT_FIELDS = {'author', 'canonical_url', 'channel_id', 'claim_name', 'description', 'claim_id',
'media_type', 'normalized', 'public_key_bytes', 'public_key_hash', 'short_url', 'signature',
'signature_digest', 'stream_type', 'title', 'tx_id', 'fee_currency', 'reposted_claim_id', 'tags'}
RANGE_FIELDS = {
'height', 'creation_height', 'activation_height', 'expiration_height',
'timestamp', 'creation_timestamp', 'duration', 'release_time', 'fee_amount',
'tx_position', 'channel_join', 'reposted', 'limit_claims_per_channel',
'amount', 'effective_amount', 'support_amount',
'trending_group', 'trending_mixed', 'censor_type',
'trending_local', 'trending_global',
}
REPLACEMENTS = {
'name': 'normalized',
'txid': 'tx_id',
'claim_hash': '_id'
}
@@ -1,641 +0,0 @@
import asyncio
import struct
from binascii import unhexlify
from collections import Counter, deque
from decimal import Decimal
from operator import itemgetter
from typing import Optional, List, Iterable, Union
from elasticsearch import AsyncElasticsearch, NotFoundError, ConnectionError
from elasticsearch.helpers import async_streaming_bulk
from lbry.crypto.base58 import Base58
from lbry.error import ResolveCensoredError, claim_id as parse_claim_id
from lbry.schema.result import Outputs, Censor
from lbry.schema.tags import clean_tags
from lbry.schema.url import URL, normalize_name
from lbry.utils import LRUCache
from lbry.wallet.server.db.common import CLAIM_TYPES, STREAM_TYPES
from lbry.wallet.server.db.elasticsearch.constants import INDEX_DEFAULT_SETTINGS, REPLACEMENTS, FIELDS, TEXT_FIELDS, \
RANGE_FIELDS
from lbry.wallet.server.util import class_logger
class ChannelResolution(str):
@classmethod
def lookup_error(cls, url):
return LookupError(f'Could not find channel in "{url}".')
class StreamResolution(str):
@classmethod
def lookup_error(cls, url):
return LookupError(f'Could not find claim at "{url}".')
class IndexVersionMismatch(Exception):
def __init__(self, got_version, expected_version):
self.got_version = got_version
self.expected_version = expected_version
class SearchIndex:
VERSION = 1
def __init__(self, index_prefix: str, search_timeout=3.0, elastic_host='localhost', elastic_port=9200):
self.search_timeout = search_timeout
self.sync_timeout = 600 # wont hit that 99% of the time, but can hit on a fresh import
self.search_client: Optional[AsyncElasticsearch] = None
self.sync_client: Optional[AsyncElasticsearch] = None
self.index = index_prefix + 'claims'
self.logger = class_logger(__name__, self.__class__.__name__)
self.claim_cache = LRUCache(2 ** 15)
self.short_id_cache = LRUCache(2 ** 17)
self.search_cache = LRUCache(2 ** 17)
self.resolution_cache = LRUCache(2 ** 17)
self._elastic_host = elastic_host
self._elastic_port = elastic_port
async def get_index_version(self) -> int:
try:
template = await self.sync_client.indices.get_template(self.index)
return template[self.index]['version']
except NotFoundError:
return 0
async def set_index_version(self, version):
await self.sync_client.indices.put_template(
self.index, body={'version': version, 'index_patterns': ['ignored']}, ignore=400
)
async def start(self) -> bool:
if self.sync_client:
return False
hosts = [{'host': self._elastic_host, 'port': self._elastic_port}]
self.sync_client = AsyncElasticsearch(hosts, timeout=self.sync_timeout)
self.search_client = AsyncElasticsearch(hosts, timeout=self.search_timeout)
while True:
try:
await self.sync_client.cluster.health(wait_for_status='yellow')
break
except ConnectionError:
self.logger.warning("Failed to connect to Elasticsearch. Waiting for it!")
await asyncio.sleep(1)
res = await self.sync_client.indices.create(self.index, INDEX_DEFAULT_SETTINGS, ignore=400)
acked = res.get('acknowledged', False)
if acked:
await self.set_index_version(self.VERSION)
return acked
index_version = await self.get_index_version()
if index_version != self.VERSION:
self.logger.error("es search index has an incompatible version: %s vs %s", index_version, self.VERSION)
raise IndexVersionMismatch(index_version, self.VERSION)
return acked
def stop(self):
clients = [self.sync_client, self.search_client]
self.sync_client, self.search_client = None, None
return asyncio.ensure_future(asyncio.gather(*(client.close() for client in clients)))
def delete_index(self):
return self.sync_client.indices.delete(self.index, ignore_unavailable=True)
async def _consume_claim_producer(self, claim_producer):
count = 0
for op, doc in claim_producer:
if op == 'delete':
yield {'_index': self.index, '_op_type': 'delete', '_id': doc}
else:
yield extract_doc(doc, self.index)
count += 1
if count % 100 == 0:
self.logger.info("Indexing in progress, %d claims.", count)
self.logger.info("Indexing done for %d claims.", count)
async def claim_consumer(self, claim_producer):
touched = set()
async for ok, item in async_streaming_bulk(self.sync_client, self._consume_claim_producer(claim_producer),
raise_on_error=False):
if not ok:
self.logger.warning("indexing failed for an item: %s", item)
else:
item = item.popitem()[1]
touched.add(item['_id'])
await self.sync_client.indices.refresh(self.index)
self.logger.info("Indexing done.")
def update_filter_query(self, censor_type, blockdict, channels=False):
blockdict = {key[::-1].hex(): value[::-1].hex() for key, value in blockdict.items()}
if channels:
update = expand_query(channel_id__in=list(blockdict.keys()), censor_type=f"<{censor_type}")
else:
update = expand_query(claim_id__in=list(blockdict.keys()), censor_type=f"<{censor_type}")
key = 'channel_id' if channels else 'claim_id'
update['script'] = {
"source": f"ctx._source.censor_type={censor_type}; ctx._source.censoring_channel_hash=params[ctx._source.{key}]",
"lang": "painless",
"params": blockdict
}
return update
async def apply_filters(self, blocked_streams, blocked_channels, filtered_streams, filtered_channels):
if filtered_streams:
await self.sync_client.update_by_query(
self.index, body=self.update_filter_query(Censor.SEARCH, filtered_streams), slices=4)
await self.sync_client.indices.refresh(self.index)
if filtered_channels:
await self.sync_client.update_by_query(
self.index, body=self.update_filter_query(Censor.SEARCH, filtered_channels), slices=4)
await self.sync_client.indices.refresh(self.index)
await self.sync_client.update_by_query(
self.index, body=self.update_filter_query(Censor.SEARCH, filtered_channels, True), slices=4)
await self.sync_client.indices.refresh(self.index)
if blocked_streams:
await self.sync_client.update_by_query(
self.index, body=self.update_filter_query(Censor.RESOLVE, blocked_streams), slices=4)
await self.sync_client.indices.refresh(self.index)
if blocked_channels:
await self.sync_client.update_by_query(
self.index, body=self.update_filter_query(Censor.RESOLVE, blocked_channels), slices=4)
await self.sync_client.indices.refresh(self.index)
await self.sync_client.update_by_query(
self.index, body=self.update_filter_query(Censor.RESOLVE, blocked_channels, True), slices=4)
await self.sync_client.indices.refresh(self.index)
self.clear_caches()
def clear_caches(self):
self.search_cache.clear()
self.short_id_cache.clear()
self.claim_cache.clear()
self.resolution_cache.clear()
async def session_query(self, query_name, kwargs):
offset, total = kwargs.get('offset', 0) if isinstance(kwargs, dict) else 0, 0
total_referenced = []
if query_name == 'resolve':
total_referenced, response, censor = await self.resolve(*kwargs)
else:
cache_item = ResultCacheItem.from_cache(str(kwargs), self.search_cache)
if cache_item.result is not None:
return cache_item.result
async with cache_item.lock:
if cache_item.result:
return cache_item.result
censor = Censor(Censor.SEARCH)
if kwargs.get('no_totals'):
response, offset, total = await self.search(**kwargs, censor_type=Censor.NOT_CENSORED)
else:
response, offset, total = await self.search(**kwargs)
censor.apply(response)
total_referenced.extend(response)
if censor.censored:
response, _, _ = await self.search(**kwargs, censor_type=Censor.NOT_CENSORED)
total_referenced.extend(response)
result = Outputs.to_base64(
response, await self._get_referenced_rows(total_referenced), offset, total, censor
)
cache_item.result = result
return result
return Outputs.to_base64(response, await self._get_referenced_rows(total_referenced), offset, total, censor)
async def resolve(self, *urls):
censor = Censor(Censor.RESOLVE)
results = [await self.resolve_url(url) for url in urls]
# just heat the cache
await self.populate_claim_cache(*filter(lambda x: isinstance(x, str), results))
results = [self._get_from_cache_or_error(url, result) for url, result in zip(urls, results)]
censored = [
result if not isinstance(result, dict) or not censor.censor(result)
else ResolveCensoredError(url, result['censoring_channel_hash'])
for url, result in zip(urls, results)
]
return results, censored, censor
def _get_from_cache_or_error(self, url: str, resolution: Union[LookupError, StreamResolution, ChannelResolution]):
cached = self.claim_cache.get(resolution)
return cached or (resolution if isinstance(resolution, LookupError) else resolution.lookup_error(url))
async def get_many(self, *claim_ids):
await self.populate_claim_cache(*claim_ids)
return filter(None, map(self.claim_cache.get, claim_ids))
async def populate_claim_cache(self, *claim_ids):
missing = [claim_id for claim_id in claim_ids if self.claim_cache.get(claim_id) is None]
if missing:
results = await self.search_client.mget(
index=self.index, body={"ids": missing}
)
for result in expand_result(filter(lambda doc: doc['found'], results["docs"])):
self.claim_cache.set(result['claim_id'], result)
async def full_id_from_short_id(self, name, short_id, channel_id=None):
key = '#'.join((channel_id or '', name, short_id))
if key not in self.short_id_cache:
query = {'name': name, 'claim_id': short_id}
if channel_id:
query['channel_id'] = channel_id
query['order_by'] = ['^channel_join']
query['signature_valid'] = True
else:
query['order_by'] = '^creation_height'
result, _, _ = await self.search(**query, limit=1)
if len(result) == 1:
result = result[0]['claim_id']
self.short_id_cache[key] = result
return self.short_id_cache.get(key, None)
async def search(self, **kwargs):
if 'channel' in kwargs:
kwargs['channel_id'] = await self.resolve_url(kwargs.pop('channel'))
if not kwargs['channel_id'] or not isinstance(kwargs['channel_id'], str):
return [], 0, 0
try:
return await self.search_ahead(**kwargs)
except NotFoundError:
return [], 0, 0
return expand_result(result['hits']), 0, result.get('total', {}).get('value', 0)
async def search_ahead(self, **kwargs):
# 'limit_claims_per_channel' case. Fetch 1000 results, reorder, slice, inflate and return
per_channel_per_page = kwargs.pop('limit_claims_per_channel', 0) or 0
remove_duplicates = kwargs.pop('remove_duplicates', False)
page_size = kwargs.pop('limit', 10)
offset = kwargs.pop('offset', 0)
kwargs['limit'] = 1000
cache_item = ResultCacheItem.from_cache(f"ahead{per_channel_per_page}{kwargs}", self.search_cache)
if cache_item.result is not None:
reordered_hits = cache_item.result
else:
async with cache_item.lock:
if cache_item.result:
reordered_hits = cache_item.result
else:
query = expand_query(**kwargs)
search_hits = deque((await self.search_client.search(
query, index=self.index, track_total_hits=False,
_source_includes=['_id', 'channel_id', 'reposted_claim_id', 'creation_height']
))['hits']['hits'])
if remove_duplicates:
search_hits = self.__remove_duplicates(search_hits)
if per_channel_per_page > 0:
reordered_hits = self.__search_ahead(search_hits, page_size, per_channel_per_page)
else:
reordered_hits = [(hit['_id'], hit['_source']['channel_id']) for hit in search_hits]
cache_item.result = reordered_hits
result = list(await self.get_many(*(claim_id for claim_id, _ in reordered_hits[offset:(offset + page_size)])))
return result, 0, len(reordered_hits)
def __remove_duplicates(self, search_hits: deque) -> deque:
known_ids = {} # claim_id -> (creation_height, hit_id), where hit_id is either reposted claim id or original
dropped = set()
for hit in search_hits:
hit_height, hit_id = hit['_source']['creation_height'], hit['_source']['reposted_claim_id'] or hit['_id']
if hit_id not in known_ids:
known_ids[hit_id] = (hit_height, hit['_id'])
else:
previous_height, previous_id = known_ids[hit_id]
if hit_height < previous_height:
known_ids[hit_id] = (hit_height, hit['_id'])
dropped.add(previous_id)
else:
dropped.add(hit['_id'])
return deque(hit for hit in search_hits if hit['_id'] not in dropped)
def __search_ahead(self, search_hits: list, page_size: int, per_channel_per_page: int):
reordered_hits = []
channel_counters = Counter()
next_page_hits_maybe_check_later = deque()
while search_hits or next_page_hits_maybe_check_later:
if reordered_hits and len(reordered_hits) % page_size == 0:
channel_counters.clear()
elif not reordered_hits:
pass
else:
break # means last page was incomplete and we are left with bad replacements
for _ in range(len(next_page_hits_maybe_check_later)):
claim_id, channel_id = next_page_hits_maybe_check_later.popleft()
if per_channel_per_page > 0 and channel_counters[channel_id] < per_channel_per_page:
reordered_hits.append((claim_id, channel_id))
channel_counters[channel_id] += 1
else:
next_page_hits_maybe_check_later.append((claim_id, channel_id))
while search_hits:
hit = search_hits.popleft()
hit_id, hit_channel_id = hit['_id'], hit['_source']['channel_id']
if hit_channel_id is None or per_channel_per_page <= 0:
reordered_hits.append((hit_id, hit_channel_id))
elif channel_counters[hit_channel_id] < per_channel_per_page:
reordered_hits.append((hit_id, hit_channel_id))
channel_counters[hit_channel_id] += 1
if len(reordered_hits) % page_size == 0:
break
else:
next_page_hits_maybe_check_later.append((hit_id, hit_channel_id))
return reordered_hits
async def resolve_url(self, raw_url):
if raw_url not in self.resolution_cache:
self.resolution_cache[raw_url] = await self._resolve_url(raw_url)
return self.resolution_cache[raw_url]
async def _resolve_url(self, raw_url):
try:
url = URL.parse(raw_url)
except ValueError as e:
return e
stream = LookupError(f'Could not find claim at "{raw_url}".')
channel_id = await self.resolve_channel_id(url)
if isinstance(channel_id, LookupError):
return channel_id
stream = (await self.resolve_stream(url, channel_id if isinstance(channel_id, str) else None)) or stream
if url.has_stream:
return StreamResolution(stream)
else:
return ChannelResolution(channel_id)
async def resolve_channel_id(self, url: URL):
if not url.has_channel:
return
if url.channel.is_fullid:
return url.channel.claim_id
if url.channel.is_shortid:
channel_id = await self.full_id_from_short_id(url.channel.name, url.channel.claim_id)
if not channel_id:
return LookupError(f'Could not find channel in "{url}".')
return channel_id
query = url.channel.to_dict()
if set(query) == {'name'}:
query['is_controlling'] = True
else:
query['order_by'] = ['^creation_height']
matches, _, _ = await self.search(**query, limit=1)
if matches:
channel_id = matches[0]['claim_id']
else:
return LookupError(f'Could not find channel in "{url}".')
return channel_id
async def resolve_stream(self, url: URL, channel_id: str = None):
if not url.has_stream:
return None
if url.has_channel and channel_id is None:
return None
query = url.stream.to_dict()
if url.stream.claim_id is not None:
if url.stream.is_fullid:
claim_id = url.stream.claim_id
else:
claim_id = await self.full_id_from_short_id(query['name'], query['claim_id'], channel_id)
return claim_id
if channel_id is not None:
if set(query) == {'name'}:
# temporarily emulate is_controlling for claims in channel
query['order_by'] = ['effective_amount', '^height']
else:
query['order_by'] = ['^channel_join']
query['channel_id'] = channel_id
query['signature_valid'] = True
elif set(query) == {'name'}:
query['is_controlling'] = True
matches, _, _ = await self.search(**query, limit=1)
if matches:
return matches[0]['claim_id']
async def _get_referenced_rows(self, txo_rows: List[dict]):
txo_rows = [row for row in txo_rows if isinstance(row, dict)]
referenced_ids = set(filter(None, map(itemgetter('reposted_claim_id'), txo_rows)))
referenced_ids |= set(filter(None, (row['channel_id'] for row in txo_rows)))
referenced_ids |= set(map(parse_claim_id, filter(None, (row['censoring_channel_hash'] for row in txo_rows))))
referenced_txos = []
if referenced_ids:
referenced_txos.extend(await self.get_many(*referenced_ids))
referenced_ids = set(filter(None, (row['channel_id'] for row in referenced_txos)))
if referenced_ids:
referenced_txos.extend(await self.get_many(*referenced_ids))
return referenced_txos
def extract_doc(doc, index):
doc['claim_id'] = doc.pop('claim_hash')[::-1].hex()
if doc['reposted_claim_hash'] is not None:
doc['reposted_claim_id'] = doc.pop('reposted_claim_hash')[::-1].hex()
else:
doc['reposted_claim_id'] = None
channel_hash = doc.pop('channel_hash')
doc['channel_id'] = channel_hash[::-1].hex() if channel_hash else channel_hash
channel_hash = doc.pop('censoring_channel_hash')
doc['censoring_channel_hash'] = channel_hash[::-1].hex() if channel_hash else channel_hash
txo_hash = doc.pop('txo_hash')
doc['tx_id'] = txo_hash[:32][::-1].hex()
doc['tx_nout'] = struct.unpack('<I', txo_hash[32:])[0]
doc['is_controlling'] = bool(doc['is_controlling'])
doc['signature'] = (doc.pop('signature') or b'').hex() or None
doc['signature_digest'] = (doc.pop('signature_digest') or b'').hex() or None
doc['public_key_bytes'] = (doc.pop('public_key_bytes') or b'').hex() or None
doc['public_key_hash'] = (doc.pop('public_key_hash') or b'').hex() or None
doc['signature_valid'] = bool(doc['signature_valid'])
doc['claim_type'] = doc.get('claim_type', 0) or 0
doc['stream_type'] = int(doc.get('stream_type', 0) or 0)
doc['has_source'] = bool(doc['has_source'])
return {'doc': doc, '_id': doc['claim_id'], '_index': index, '_op_type': 'update', 'doc_as_upsert': True}
def expand_query(**kwargs):
if "amount_order" in kwargs:
kwargs["limit"] = 1
kwargs["order_by"] = "effective_amount"
kwargs["offset"] = int(kwargs["amount_order"]) - 1
if 'name' in kwargs:
kwargs['name'] = normalize_name(kwargs.pop('name'))
if kwargs.get('is_controlling') is False:
kwargs.pop('is_controlling')
query = {'must': [], 'must_not': []}
collapse = None
for key, value in kwargs.items():
key = key.replace('claim.', '')
many = key.endswith('__in') or isinstance(value, list)
if many:
key = key.replace('__in', '')
value = list(filter(None, value))
if value is None or isinstance(value, list) and len(value) == 0:
continue
key = REPLACEMENTS.get(key, key)
if key in FIELDS:
partial_id = False
if key == 'claim_type':
if isinstance(value, str):
value = CLAIM_TYPES[value]
else:
value = [CLAIM_TYPES[claim_type] for claim_type in value]
if key == '_id':
if isinstance(value, Iterable):
value = [item[::-1].hex() for item in value]
else:
value = value[::-1].hex()
if not many and key in ('_id', 'claim_id') and len(value) < 20:
partial_id = True
if key == 'public_key_id':
key = 'public_key_hash'
value = Base58.decode(value)[1:21].hex()
if key == 'signature_valid':
continue # handled later
if key in TEXT_FIELDS:
key += '.keyword'
ops = {'<=': 'lte', '>=': 'gte', '<': 'lt', '>': 'gt'}
if partial_id:
query['must'].append({"prefix": {"claim_id": value}})
elif key in RANGE_FIELDS and isinstance(value, str) and value[0] in ops:
operator_length = 2 if value[:2] in ops else 1
operator, value = value[:operator_length], value[operator_length:]
if key == 'fee_amount':
value = str(Decimal(value)*1000)
query['must'].append({"range": {key: {ops[operator]: value}}})
elif many:
query['must'].append({"terms": {key: value}})
else:
if key == 'fee_amount':
value = str(Decimal(value)*1000)
query['must'].append({"term": {key: {"value": value}}})
elif key == 'not_channel_ids':
for channel_id in value:
query['must_not'].append({"term": {'channel_id.keyword': channel_id}})
query['must_not'].append({"term": {'_id': channel_id}})
elif key == 'channel_ids':
query['must'].append({"terms": {'channel_id.keyword': value}})
elif key == 'claim_ids':
query['must'].append({"terms": {'claim_id.keyword': value}})
elif key == 'media_types':
query['must'].append({"terms": {'media_type.keyword': value}})
elif key == 'stream_types':
query['must'].append({"terms": {'stream_type': [STREAM_TYPES[stype] for stype in value]}})
elif key == 'any_languages':
query['must'].append({"terms": {'languages': clean_tags(value)}})
elif key == 'any_languages':
query['must'].append({"terms": {'languages': value}})
elif key == 'all_languages':
query['must'].extend([{"term": {'languages': tag}} for tag in value])
elif key == 'any_tags':
query['must'].append({"terms": {'tags.keyword': clean_tags(value)}})
elif key == 'all_tags':
query['must'].extend([{"term": {'tags.keyword': tag}} for tag in clean_tags(value)])
elif key == 'not_tags':
query['must_not'].extend([{"term": {'tags.keyword': tag}} for tag in clean_tags(value)])
elif key == 'not_claim_id':
query['must_not'].extend([{"term": {'claim_id.keyword': cid}} for cid in value])
elif key == 'limit_claims_per_channel':
collapse = ('channel_id.keyword', value)
if kwargs.get('has_channel_signature'):
query['must'].append({"exists": {"field": "signature_digest"}})
if 'signature_valid' in kwargs:
query['must'].append({"term": {"signature_valid": bool(kwargs["signature_valid"])}})
elif 'signature_valid' in kwargs:
query.setdefault('should', [])
query["minimum_should_match"] = 1
query['should'].append({"bool": {"must_not": {"exists": {"field": "signature_digest"}}}})
query['should'].append({"term": {"signature_valid": bool(kwargs["signature_valid"])}})
if 'has_source' in kwargs:
query.setdefault('should', [])
query["minimum_should_match"] = 1
is_stream_or_repost = {"terms": {"claim_type": [CLAIM_TYPES['stream'], CLAIM_TYPES['repost']]}}
query['should'].append(
{"bool": {"must": [{"match": {"has_source": kwargs['has_source']}}, is_stream_or_repost]}})
query['should'].append({"bool": {"must_not": [is_stream_or_repost]}})
query['should'].append({"bool": {"must": [{"term": {"reposted_claim_type": CLAIM_TYPES['channel']}}]}})
if kwargs.get('text'):
query['must'].append(
{"simple_query_string":
{"query": kwargs["text"], "fields": [
"claim_name^4", "channel_name^8", "title^1", "description^.5", "author^1", "tags^.5"
]}})
query = {
"_source": {"excludes": ["description", "title"]},
'query': {'bool': query},
"sort": [],
}
if "limit" in kwargs:
query["size"] = kwargs["limit"]
if 'offset' in kwargs:
query["from"] = kwargs["offset"]
if 'order_by' in kwargs:
if isinstance(kwargs["order_by"], str):
kwargs["order_by"] = [kwargs["order_by"]]
for value in kwargs['order_by']:
if 'trending_group' in value:
# fixme: trending_mixed is 0 for all records on variable decay, making sort slow.
continue
is_asc = value.startswith('^')
value = value[1:] if is_asc else value
value = REPLACEMENTS.get(value, value)
if value in TEXT_FIELDS:
value += '.keyword'
query['sort'].append({value: "asc" if is_asc else "desc"})
if collapse:
query["collapse"] = {
"field": collapse[0],
"inner_hits": {
"name": collapse[0],
"size": collapse[1],
"sort": query["sort"]
}
}
return query
def expand_result(results):
inner_hits = []
expanded = []
for result in results:
if result.get("inner_hits"):
for _, inner_hit in result["inner_hits"].items():
inner_hits.extend(inner_hit["hits"]["hits"])
continue
result = result['_source']
result['claim_hash'] = unhexlify(result['claim_id'])[::-1]
if result['reposted_claim_id']:
result['reposted_claim_hash'] = unhexlify(result['reposted_claim_id'])[::-1]
else:
result['reposted_claim_hash'] = None
result['channel_hash'] = unhexlify(result['channel_id'])[::-1] if result['channel_id'] else None
result['txo_hash'] = unhexlify(result['tx_id'])[::-1] + struct.pack('<I', result['tx_nout'])
result['tx_hash'] = unhexlify(result['tx_id'])[::-1]
if result['censoring_channel_hash']:
result['censoring_channel_hash'] = unhexlify(result['censoring_channel_hash'])[::-1]
expanded.append(result)
if inner_hits:
return expand_result(inner_hits)
return expanded
class ResultCacheItem:
__slots__ = '_result', 'lock', 'has_result'
def __init__(self):
self.has_result = asyncio.Event()
self.lock = asyncio.Lock()
self._result = None
@property
def result(self) -> str:
return self._result
@result.setter
def result(self, result: str):
self._result = result
if result is not None:
self.has_result.set()
@classmethod
def from_cache(cls, cache_key, cache):
cache_item = cache.get(cache_key)
if cache_item is None:
cache_item = cache[cache_key] = ResultCacheItem()
return cache_item
-116
View File
@@ -1,116 +0,0 @@
import argparse
import asyncio
import logging
import os
from collections import namedtuple
from multiprocessing import Process
import sqlite3
from elasticsearch import AsyncElasticsearch
from elasticsearch.helpers import async_bulk
from lbry.wallet.server.env import Env
from lbry.wallet.server.coin import LBC
from lbry.wallet.server.db.elasticsearch.search import extract_doc, SearchIndex, IndexVersionMismatch
async def get_all(db, shard_num, shards_total, limit=0, index_name='claims'):
logging.info("shard %d starting", shard_num)
def namedtuple_factory(cursor, row):
Row = namedtuple('Row', (d[0] for d in cursor.description))
return Row(*row)
db.row_factory = namedtuple_factory
total = db.execute(f"select count(*) as total from claim where height % {shards_total} = {shard_num};").fetchone()[0]
for num, claim in enumerate(db.execute(f"""
SELECT claimtrie.claim_hash as is_controlling,
claimtrie.last_take_over_height,
(select group_concat(tag, ',,') from tag where tag.claim_hash in (claim.claim_hash, claim.reposted_claim_hash)) as tags,
(select group_concat(language, ' ') from language where language.claim_hash in (claim.claim_hash, claim.reposted_claim_hash)) as languages,
(select cr.has_source from claim cr where cr.claim_hash = claim.reposted_claim_hash) as reposted_has_source,
(select cr.claim_type from claim cr where cr.claim_hash = claim.reposted_claim_hash) as reposted_claim_type,
claim.*
FROM claim LEFT JOIN claimtrie USING (claim_hash)
WHERE claim.height % {shards_total} = {shard_num}
ORDER BY claim.height desc
""")):
claim = dict(claim._asdict())
claim['has_source'] = bool(claim.pop('reposted_has_source') or claim['has_source'])
claim['censor_type'] = 0
claim['censoring_channel_hash'] = None
claim['tags'] = claim['tags'].split(',,') if claim['tags'] else []
claim['languages'] = claim['languages'].split(' ') if claim['languages'] else []
if num % 10_000 == 0:
logging.info("%d/%d", num, total)
yield extract_doc(claim, index_name)
if 0 < limit <= num:
break
async def consume(producer, index_name):
env = Env(LBC)
logging.info("ES sync host: %s:%i", env.elastic_host, env.elastic_port)
es = AsyncElasticsearch([{'host': env.elastic_host, 'port': env.elastic_port}])
try:
await async_bulk(es, producer, request_timeout=120)
await es.indices.refresh(index=index_name)
finally:
await es.close()
async def make_es_index(index=None):
env = Env(LBC)
if index is None:
index = SearchIndex('', elastic_host=env.elastic_host, elastic_port=env.elastic_port)
try:
return await index.start()
except IndexVersionMismatch as err:
logging.info(
"dropping ES search index (version %s) for upgrade to version %s", err.got_version, err.expected_version
)
await index.delete_index()
await index.stop()
return await index.start()
finally:
index.stop()
async def run(db_path, clients, blocks, shard, index_name='claims'):
db = sqlite3.connect(db_path, isolation_level=None, check_same_thread=False, uri=True)
db.execute('pragma journal_mode=wal;')
db.execute('pragma temp_store=memory;')
producer = get_all(db, shard, clients, limit=blocks, index_name=index_name)
await asyncio.gather(*(consume(producer, index_name=index_name) for _ in range(min(8, clients))))
def __run(args, shard):
asyncio.run(run(args.db_path, args.clients, args.blocks, shard))
def run_elastic_sync():
logging.basicConfig(level=logging.INFO)
logging.getLogger('aiohttp').setLevel(logging.WARNING)
logging.getLogger('elasticsearch').setLevel(logging.WARNING)
logging.info('lbry.server starting')
parser = argparse.ArgumentParser(prog="lbry-hub-elastic-sync")
parser.add_argument("db_path", type=str)
parser.add_argument("-c", "--clients", type=int, default=16)
parser.add_argument("-b", "--blocks", type=int, default=0)
parser.add_argument("-f", "--force", default=False, action='store_true')
args = parser.parse_args()
processes = []
if not args.force and not os.path.exists(args.db_path):
logging.info("DB path doesnt exist")
return
if not args.force and not asyncio.run(make_es_index()):
logging.info("ES is already initialized")
return
for i in range(args.clients):
processes.append(Process(target=__run, args=(args, i)))
processes[-1].start()
for process in processes:
process.join()
process.close()
+52
View File
@@ -0,0 +1,52 @@
from lbry.wallet.database import constraints_to_sql
CREATE_FULL_TEXT_SEARCH = """
create virtual table if not exists search using fts5(
claim_name, channel_name, title, description, author, tags,
content=claim, tokenize=porter
);
"""
FTS_ORDER_BY = "bm25(search, 4.0, 8.0, 1.0, 0.5, 1.0, 0.5)"
def fts_action_sql(claims=None, action='insert'):
select = {
'rowid': "claim.rowid",
'claim_name': "claim.normalized",
'channel_name': "channel.normalized",
'title': "claim.title",
'description': "claim.description",
'author': "claim.author",
'tags': "(select group_concat(tag, ' ') from tag where tag.claim_hash=claim.claim_hash)"
}
if action == 'delete':
select['search'] = '"delete"'
where, values = "", {}
if claims:
where, values = constraints_to_sql({'claim.claim_hash__in': claims})
where = 'WHERE '+where
return f"""
INSERT INTO search ({','.join(select.keys())})
SELECT {','.join(select.values())} FROM claim
LEFT JOIN claim as channel ON (claim.channel_hash=channel.claim_hash) {where}
""", values
def update_full_text_search(action, outputs, db, is_first_sync):
if is_first_sync:
return
if not outputs:
return
if action in ("before-delete", "before-update"):
db.execute(*fts_action_sql(outputs, 'delete'))
elif action in ("after-insert", "after-update"):
db.execute(*fts_action_sql(outputs, 'insert'))
else:
raise ValueError(f"Invalid action for updating full text search: '{action}'")
def first_sync_finished(db):
db.execute(*fts_action_sql())
@@ -1,6 +1,6 @@
import time
import struct
import sqlite3
import apsw
import logging
from operator import itemgetter
from typing import Tuple, List, Dict, Union, Type, Optional
@@ -18,23 +18,23 @@ from lbry.schema.tags import clean_tags
from lbry.schema.result import Outputs, Censor
from lbry.wallet import Ledger, RegTestLedger
from lbry.wallet.server.db.common import CLAIM_TYPES, STREAM_TYPES, COMMON_TAGS, INDEXED_LANGUAGES
from .common import CLAIM_TYPES, STREAM_TYPES, COMMON_TAGS, INDEXED_LANGUAGES
from .full_text_search import FTS_ORDER_BY
class SQLiteOperationalError(sqlite3.OperationalError):
class SQLiteOperationalError(apsw.Error):
def __init__(self, metrics):
super().__init__('sqlite query errored')
self.metrics = metrics
class SQLiteInterruptedError(sqlite3.OperationalError):
class SQLiteInterruptedError(apsw.InterruptError):
def __init__(self, metrics):
super().__init__('sqlite query interrupted')
self.metrics = metrics
ATTRIBUTE_ARRAY_MAX_LENGTH = 100
sqlite3.enable_callback_tracebacks(True)
INTEGER_PARAMS = {
'height', 'creation_height', 'activation_height', 'expiration_height',
@@ -53,7 +53,7 @@ SEARCH_PARAMS = {
'any_locations', 'all_locations', 'not_locations',
'any_languages', 'all_languages', 'not_languages',
'is_controlling', 'limit', 'offset', 'order_by',
'no_totals', 'has_source'
'no_totals',
} | INTEGER_PARAMS
@@ -64,7 +64,7 @@ ORDER_FIELDS = {
@dataclass
class ReaderState:
db: sqlite3.Connection
db: apsw.Connection
stack: List[List]
metrics: Dict
is_tracking_metrics: bool
@@ -91,13 +91,13 @@ class ReaderState:
self.db.interrupt()
return
self.db.set_progress_handler(interruptor, 100)
self.db.setprogresshandler(interruptor, 100)
def get_resolve_censor(self) -> Censor:
return Censor(Censor.RESOLVE)
return Censor(self.blocked_streams, self.blocked_channels)
def get_search_censor(self, limit_claims_per_channel: int) -> Censor:
return Censor(Censor.SEARCH)
return Censor(self.filtered_streams, self.filtered_channels, limit_claims_per_channel)
ctx: ContextVar[Optional[ReaderState]] = ContextVar('ctx')
@@ -106,13 +106,13 @@ ctx: ContextVar[Optional[ReaderState]] = ContextVar('ctx')
def row_factory(cursor, row):
return {
k[0]: (set(row[i].split(',')) if k[0] == 'tags' else row[i])
for i, k in enumerate(cursor.description)
for i, k in enumerate(cursor.getdescription())
}
def initializer(log, _path, _ledger_name, query_timeout, _measure=False, block_and_filter=None):
db = sqlite3.connect(_path, isolation_level=None, uri=True)
db.row_factory = row_factory
db = apsw.Connection(_path, flags=apsw.SQLITE_OPEN_READONLY | apsw.SQLITE_OPEN_URI)
db.setrowtrace(row_factory)
if block_and_filter:
blocked_streams, blocked_channels, filtered_streams, filtered_channels = block_and_filter
else:
@@ -185,12 +185,31 @@ def execute_query(sql, values, row_offset: int, row_limit: int, censor: Censor)
context = ctx.get()
context.set_query_timeout()
try:
rows = context.db.execute(sql, values).fetchall()
return rows[row_offset:row_limit]
except sqlite3.OperationalError as err:
c = context.db.cursor()
def row_filter(cursor, row):
nonlocal row_offset
row = row_factory(cursor, row)
if len(row) > 1 and censor.censor(row):
return
if row_offset:
row_offset -= 1
return
return row
c.setrowtrace(row_filter)
i, rows = 0, []
for row in c.execute(sql, values):
i += 1
rows.append(row)
if i >= row_limit:
break
return rows
except apsw.Error as err:
plain_sql = interpolate(sql, values)
if context.is_tracking_metrics:
context.metrics['execute_query'][-1]['sql'] = plain_sql
if isinstance(err, apsw.InterruptError):
context.log.warning("interrupted slow sqlite query:\n%s", plain_sql)
raise SQLiteInterruptedError(context.metrics)
context.log.exception('failed running query', exc_info=err)
raise SQLiteOperationalError(context.metrics)
@@ -323,7 +342,12 @@ def claims_query(cols, for_count=False, **constraints) -> Tuple[str, Dict]:
_apply_constraints_for_array_attributes(constraints, 'language', lambda _: _, for_count)
_apply_constraints_for_array_attributes(constraints, 'location', lambda _: _, for_count)
select = f"SELECT {cols} FROM claim"
if 'text' in constraints:
constraints["search"] = constraints.pop("text")
constraints["order_by"] = FTS_ORDER_BY
select = f"SELECT {cols} FROM search JOIN claim ON (search.rowid=claim.rowid)"
else:
select = f"SELECT {cols} FROM claim"
if not for_count:
select += " LEFT JOIN claimtrie USING (claim_hash)"
return query(select, **constraints)
@@ -348,7 +372,7 @@ def count_claims(**constraints) -> int:
constraints.pop('offset', None)
constraints.pop('limit', None)
constraints.pop('order_by', None)
count = select_claims(Censor(Censor.SEARCH), 'count(*) as row_count', for_count=True, **constraints)
count = select_claims(Censor(), 'count(*) as row_count', for_count=True, **constraints)
return count[0]['row_count']
+1 -1
View File
@@ -231,7 +231,7 @@ def run(db, height, final_height, recalculate_claim_hashes):
FROM claim
WHERE claim_hash IN
({','.join('?' for _ in recalculate_claim_hashes)});
""", list(recalculate_claim_hashes)):
""", recalculate_claim_hashes):
trending_data.update_claim(row[0], 1E-8*row[1], time_boost)
trending_log("done.\n")
@@ -5,7 +5,7 @@ decay rate for high valued claims.
import math
import time
import sqlite3
import apsw
# Half life in blocks *for lower LBC claims* (it's shorter for whale claims)
HALF_LIFE = 200
@@ -96,16 +96,16 @@ class TrendingDB:
"""
def __init__(self):
self.conn = sqlite3.connect(":memory:", check_same_thread=False)
self.conn = apsw.Connection(":memory:")
self.cursor = self.conn.cursor()
self.initialised = False
self.write_needed = set()
def execute(self, query, *args, **kwargs):
return self.conn.execute(query, *args, **kwargs)
return self.cursor.execute(query, *args, **kwargs)
def executemany(self, query, *args, **kwargs):
return self.conn.executemany(query, *args, **kwargs)
return self.cursor.executemany(query, *args, **kwargs)
def begin(self):
self.execute("BEGIN;")
@@ -251,7 +251,7 @@ class TrendingDB:
FROM claims
WHERE claim_hash IN
({','.join('?' for _ in self.write_needed)});
""", list(self.write_needed)).fetchall()
""", self.write_needed).fetchall()
db.executemany("""UPDATE claim SET trending_mixed = ?
WHERE claim_hash = ?;""", rows)
@@ -278,7 +278,7 @@ class TrendingDB:
FROM claim
WHERE claim_hash IN
({','.join('?' for _ in recalculate_claim_hashes)});
""", list(recalculate_claim_hashes)):
""", recalculate_claim_hashes):
claim_hash, lbc = row
# Insert into trending db if it does not exist
+6 -2
View File
@@ -47,10 +47,14 @@ class ZScore:
return self.last
return (self.last - self.mean) / (self.standard_deviation or 1)
@classmethod
def factory(cls):
return cls(), cls.step, cls.finalize
def install(connection):
connection.create_aggregate("zscore", 1, ZScore)
connection.executescript(CREATE_TREND_TABLE)
connection.createaggregatefunction("zscore", ZScore.factory, 1)
connection.cursor().execute(CREATE_TREND_TABLE)
def run(db, height, final_height, affected_claims):
+62 -124
View File
@@ -1,11 +1,11 @@
import os
import sqlite3
import apsw
from typing import Union, Tuple, Set, List
from itertools import chain
from decimal import Decimal
from collections import namedtuple
from binascii import unhexlify, hexlify
from multiprocessing import Manager
from binascii import unhexlify
from lbry.wallet.server.leveldb import LevelDB
from lbry.wallet.server.util import class_logger
from lbry.wallet.database import query, constraints_to_sql
@@ -15,13 +15,13 @@ from lbry.schema.mime_types import guess_stream_type
from lbry.wallet import Ledger, RegTestLedger
from lbry.wallet.transaction import Transaction, Output
from lbry.wallet.server.db.canonical import register_canonical_functions
from lbry.wallet.server.db.full_text_search import update_full_text_search, CREATE_FULL_TEXT_SEARCH, first_sync_finished
from lbry.wallet.server.db.trending import TRENDING_ALGORITHMS
from .common import CLAIM_TYPES, STREAM_TYPES, COMMON_TAGS, INDEXED_LANGUAGES
from lbry.wallet.server.db.elasticsearch import SearchIndex
ATTRIBUTE_ARRAY_MAX_LENGTH = 100
sqlite3.enable_callback_tracebacks(True)
class SQLDB:
@@ -55,7 +55,6 @@ class SQLDB:
description text,
claim_type integer,
has_source bool,
reposted integer default 0,
-- streams
@@ -135,22 +134,6 @@ class SQLDB:
create index if not exists claimtrie_claim_hash_idx on claimtrie (claim_hash);
"""
CREATE_CHANGELOG_TRIGGER = """
create table if not exists changelog (
claim_hash bytes primary key
);
create index if not exists claimtrie_claim_hash_idx on claimtrie (claim_hash);
create trigger if not exists claim_changelog after update on claim
begin
insert or ignore into changelog (claim_hash) values (new.claim_hash);
end;
create trigger if not exists claimtrie_changelog after update on claimtrie
begin
insert or ignore into changelog (claim_hash) values (new.claim_hash);
insert or ignore into changelog (claim_hash) values (old.claim_hash);
end;
"""
SEARCH_INDEXES = """
-- used by any tag clouds
create index if not exists tag_tag_idx on tag (tag, claim_hash);
@@ -206,10 +189,10 @@ class SQLDB:
CREATE_TABLES_QUERY = (
CREATE_CLAIM_TABLE +
CREATE_FULL_TEXT_SEARCH +
CREATE_SUPPORT_TABLE +
CREATE_CLAIMTRIE_TABLE +
CREATE_TAG_TABLE +
CREATE_CHANGELOG_TRIGGER +
CREATE_LANGUAGE_TABLE
)
@@ -220,6 +203,8 @@ class SQLDB:
self.db = None
self.logger = class_logger(__name__, self.__class__.__name__)
self.ledger = Ledger if main.coin.NET == 'mainnet' else RegTestLedger
self._fts_synced = False
self.state_manager = None
self.blocked_streams = None
self.blocked_channels = None
self.blocking_channel_hashes = {
@@ -231,22 +216,29 @@ class SQLDB:
unhexlify(channel_id)[::-1] for channel_id in filtering_channels if channel_id
}
self.trending = trending
self.pending_deletes = set()
def open(self):
self.db = sqlite3.connect(self._db_path, isolation_level=None, check_same_thread=False, uri=True)
def namedtuple_factory(cursor, row):
Row = namedtuple('Row', (d[0] for d in cursor.description))
return Row(*row)
self.db.row_factory = namedtuple_factory
self.db.executescript(self.PRAGMAS)
self.db.executescript(self.CREATE_TABLES_QUERY)
self.db = apsw.Connection(
self._db_path,
flags=(
apsw.SQLITE_OPEN_READWRITE |
apsw.SQLITE_OPEN_CREATE |
apsw.SQLITE_OPEN_URI
)
)
def exec_factory(cursor, statement, bindings):
tpl = namedtuple('row', (d[0] for d in cursor.getdescription()))
cursor.setrowtrace(lambda cursor, row: tpl(*row))
return True
self.db.setexectrace(exec_factory)
self.execute(self.PRAGMAS)
self.execute(self.CREATE_TABLES_QUERY)
register_canonical_functions(self.db)
self.blocked_streams = {}
self.blocked_channels = {}
self.filtered_streams = {}
self.filtered_channels = {}
self.state_manager = Manager()
self.blocked_streams = self.state_manager.dict()
self.blocked_channels = self.state_manager.dict()
self.filtered_streams = self.state_manager.dict()
self.filtered_channels = self.state_manager.dict()
self.update_blocked_and_filtered_claims()
for algorithm in self.trending:
algorithm.install(self.db)
@@ -254,6 +246,8 @@ class SQLDB:
def close(self):
if self.db is not None:
self.db.close()
if self.state_manager is not None:
self.state_manager.shutdown()
def update_blocked_and_filtered_claims(self):
self.update_claims_from_channel_hashes(
@@ -313,10 +307,10 @@ class SQLDB:
return f"DELETE FROM {table} WHERE {where}", values
def execute(self, *args):
return self.db.execute(*args)
return self.db.cursor().execute(*args)
def executemany(self, *args):
return self.db.executemany(*args)
return self.db.cursor().executemany(*args)
def begin(self):
self.execute('begin;')
@@ -360,7 +354,6 @@ class SQLDB:
'author': None,
'duration': None,
'claim_type': None,
'has_source': False,
'stream_type': None,
'media_type': None,
'release_time': None,
@@ -378,7 +371,6 @@ class SQLDB:
if claim.is_stream:
claim_record['claim_type'] = CLAIM_TYPES['stream']
claim_record['has_source'] = claim.stream.has_source
claim_record['media_type'] = claim.stream.source.media_type
claim_record['stream_type'] = STREAM_TYPES[guess_stream_type(claim_record['media_type'])]
claim_record['title'] = claim.stream.title
@@ -395,15 +387,12 @@ class SQLDB:
if isinstance(fee.currency, str):
claim_record['fee_currency'] = fee.currency.lower()
if isinstance(fee.amount, Decimal):
if fee.amount >= 0 and int(fee.amount*1000) < 9223372036854775807:
claim_record['fee_amount'] = int(fee.amount*1000)
claim_record['fee_amount'] = int(fee.amount*1000)
elif claim.is_repost:
claim_record['claim_type'] = CLAIM_TYPES['repost']
claim_record['reposted_claim_hash'] = claim.repost.reference.claim_hash
elif claim.is_channel:
claim_record['claim_type'] = CLAIM_TYPES['channel']
elif claim.is_collection:
claim_record['claim_type'] = CLAIM_TYPES['collection']
languages[(language, claim_hash)] = (language, claim_hash, tx.height)
@@ -428,14 +417,14 @@ class SQLDB:
claims = self._upsertable_claims(txos, header)
if claims:
self.executemany("""
INSERT OR REPLACE INTO claim (
INSERT OR IGNORE INTO claim (
claim_hash, claim_id, claim_name, normalized, txo_hash, tx_position, amount,
claim_type, media_type, stream_type, timestamp, creation_timestamp, has_source,
claim_type, media_type, stream_type, timestamp, creation_timestamp,
fee_currency, fee_amount, title, description, author, duration, height, reposted_claim_hash,
creation_height, release_time, activation_height, expiration_height, short_url)
VALUES (
:claim_hash, :claim_id, :claim_name, :normalized, :txo_hash, :tx_position, :amount,
:claim_type, :media_type, :stream_type, :timestamp, :timestamp, :has_source,
:claim_type, :media_type, :stream_type, :timestamp, :timestamp,
:fee_currency, :fee_amount, :title, :description, :author, :duration, :height, :reposted_claim_hash, :height,
CASE WHEN :release_time IS NOT NULL THEN :release_time ELSE :timestamp END,
CASE WHEN :normalized NOT IN (SELECT normalized FROM claimtrie) THEN :height END,
@@ -453,7 +442,7 @@ class SQLDB:
UPDATE claim SET
txo_hash=:txo_hash, tx_position=:tx_position, amount=:amount, height=:height,
claim_type=:claim_type, media_type=:media_type, stream_type=:stream_type,
timestamp=:timestamp, fee_amount=:fee_amount, fee_currency=:fee_currency, has_source=:has_source,
timestamp=:timestamp, fee_amount=:fee_amount, fee_currency=:fee_currency,
title=:title, duration=:duration, description=:description, author=:author, reposted_claim_hash=:reposted_claim_hash,
release_time=CASE WHEN :release_time IS NOT NULL THEN :release_time ELSE release_time END
WHERE claim_hash=:claim_hash;
@@ -537,7 +526,6 @@ class SQLDB:
WHERE claim_hash = ?
""", targets
)
return {target[0] for target in targets}
def validate_channel_signatures(self, height, new_claims, updated_claims, spent_claims, affected_channels, timer):
if not new_claims and not updated_claims and not spent_claims:
@@ -614,7 +602,7 @@ class SQLDB:
channel_hash IN ({','.join('?' for _ in changed_channel_keys)}) AND
signature IS NOT NULL
"""
for affected_claim in self.execute(sql, list(changed_channel_keys.keys())):
for affected_claim in self.execute(sql, changed_channel_keys.keys()):
if affected_claim.claim_hash not in signables:
claim_updates.append({
'claim_hash': affected_claim.claim_hash,
@@ -671,7 +659,7 @@ class SQLDB:
signature_valid=CASE WHEN signature IS NOT NULL THEN 0 END,
channel_join=NULL, canonical_url=NULL
WHERE channel_hash IN ({','.join('?' for _ in spent_claims)})
""", list(spent_claims)
""", spent_claims
)
sub_timer.stop()
@@ -704,7 +692,7 @@ class SQLDB:
claim_in_channel.channel_hash=claim.claim_hash
)
WHERE claim_hash = ?
""", [(channel_hash,) for channel_hash in all_channel_keys])
""", [(channel_hash,) for channel_hash in all_channel_keys.keys()])
sub_timer.stop()
sub_timer = timer.add_timer('update blocked claims list')
@@ -796,13 +784,12 @@ class SQLDB:
def update_claimtrie(self, height, changed_claim_hashes, deleted_names, timer):
r = timer.run
binary_claim_hashes = list(changed_claim_hashes)
r(self._calculate_activation_height, height)
r(self._update_support_amount, binary_claim_hashes)
r(self._update_support_amount, changed_claim_hashes)
r(self._update_effective_amount, height, binary_claim_hashes)
r(self._perform_overtake, height, binary_claim_hashes, list(deleted_names))
r(self._update_effective_amount, height, changed_claim_hashes)
r(self._perform_overtake, height, changed_claim_hashes, list(deleted_names))
r(self._update_effective_amount, height)
r(self._perform_overtake, height, [], [])
@@ -812,58 +799,11 @@ class SQLDB:
f"SELECT claim_hash, normalized FROM claim WHERE expiration_height = {height}"
)
def enqueue_changes(self):
query = """
SELECT claimtrie.claim_hash as is_controlling,
claimtrie.last_take_over_height,
(select group_concat(tag, ',,') from tag where tag.claim_hash in (claim.claim_hash, claim.reposted_claim_hash)) as tags,
(select group_concat(language, ' ') from language where language.claim_hash in (claim.claim_hash, claim.reposted_claim_hash)) as languages,
(select cr.has_source from claim cr where cr.claim_hash = claim.reposted_claim_hash) as reposted_has_source,
(select cr.claim_type from claim cr where cr.claim_hash = claim.reposted_claim_hash) as reposted_claim_type,
claim.*
FROM claim LEFT JOIN claimtrie USING (claim_hash)
WHERE claim.claim_hash in (SELECT claim_hash FROM changelog)
"""
for claim in self.execute(query):
claim = claim._asdict()
id_set = set(filter(None, (claim['claim_hash'], claim['channel_hash'], claim['reposted_claim_hash'])))
claim['censor_type'] = 0
claim['censoring_channel_hash'] = None
claim['has_source'] = bool(claim.pop('reposted_has_source') or claim['has_source'])
for reason_id in id_set:
if reason_id in self.blocked_streams:
claim['censor_type'] = 2
claim['censoring_channel_hash'] = self.blocked_streams.get(reason_id)
elif reason_id in self.blocked_channels:
claim['censor_type'] = 2
claim['censoring_channel_hash'] = self.blocked_channels.get(reason_id)
elif reason_id in self.filtered_streams:
claim['censor_type'] = 1
claim['censoring_channel_hash'] = self.filtered_streams.get(reason_id)
elif reason_id in self.filtered_channels:
claim['censor_type'] = 1
claim['censoring_channel_hash'] = self.filtered_channels.get(reason_id)
claim['tags'] = claim['tags'].split(',,') if claim['tags'] else []
claim['languages'] = claim['languages'].split(' ') if claim['languages'] else []
yield 'update', claim
def clear_changelog(self):
self.execute("delete from changelog;")
def claim_producer(self):
while self.pending_deletes:
claim_hash = self.pending_deletes.pop()
yield 'delete', hexlify(claim_hash[::-1]).decode()
for claim in self.enqueue_changes():
yield claim
self.clear_changelog()
def advance_txs(self, height, all_txs, header, daemon_height, timer):
insert_claims = []
update_claims = []
update_claim_hashes = set()
delete_claim_hashes = self.pending_deletes
delete_claim_hashes = set()
insert_supports = []
delete_support_txo_hashes = set()
recalculate_claim_hashes = set() # added/deleted supports, added/updated claim
@@ -932,17 +872,28 @@ class SQLDB:
expire_timer.stop()
r = timer.run
r(update_full_text_search, 'before-delete',
delete_claim_hashes, self.db.cursor(), self.main.first_sync)
affected_channels = r(self.delete_claims, delete_claim_hashes)
r(self.delete_supports, delete_support_txo_hashes)
r(self.insert_claims, insert_claims, header)
r(self.calculate_reposts, insert_claims)
r(update_full_text_search, 'after-insert',
[txo.claim_hash for txo in insert_claims], self.db.cursor(), self.main.first_sync)
r(update_full_text_search, 'before-update',
[txo.claim_hash for txo in update_claims], self.db.cursor(), self.main.first_sync)
r(self.update_claims, update_claims, header)
r(update_full_text_search, 'after-update',
[txo.claim_hash for txo in update_claims], self.db.cursor(), self.main.first_sync)
r(self.validate_channel_signatures, height, insert_claims,
update_claims, delete_claim_hashes, affected_channels, forward_timer=True)
r(self.insert_supports, insert_supports)
r(self.update_claimtrie, height, recalculate_claim_hashes, deleted_claim_names, forward_timer=True)
for algorithm in self.trending:
r(algorithm.run, self.db.cursor(), height, daemon_height, recalculate_claim_hashes)
if not self._fts_synced and self.main.first_sync and height == daemon_height:
r(first_sync_finished, self.db.cursor())
self._fts_synced = True
class LBRYLevelDB(LevelDB):
@@ -954,30 +905,17 @@ class LBRYLevelDB(LevelDB):
for algorithm_name in self.env.trending_algorithms:
if algorithm_name in TRENDING_ALGORITHMS:
trending.append(TRENDING_ALGORITHMS[algorithm_name])
if self.env.es_mode == 'reader':
self.logger.info('Index mode: reader')
self.sql = None
else:
self.logger.info('Index mode: writer. Using SQLite db to sync ES')
self.sql = SQLDB(
self, path,
self.env.default('BLOCKING_CHANNEL_IDS', '').split(' '),
self.env.default('FILTERING_CHANNEL_IDS', '').split(' '),
trending
)
# Search index
self.search_index = SearchIndex(
self.env.es_index_prefix, self.env.database_query_timeout, self.env.elastic_host, self.env.elastic_port
self.sql = SQLDB(
self, path,
self.env.default('BLOCKING_CHANNEL_IDS', '').split(' '),
self.env.default('FILTERING_CHANNEL_IDS', '').split(' '),
trending
)
def close(self):
super().close()
if self.sql:
self.sql.close()
self.sql.close()
async def _open_dbs(self, *args, **kwargs):
await self.search_index.start()
await super()._open_dbs(*args, **kwargs)
if self.sql:
self.sql.open()
self.sql.open()
+1 -12
View File
@@ -33,8 +33,6 @@ class Env:
self.allow_root = self.boolean('ALLOW_ROOT', False)
self.host = self.default('HOST', 'localhost')
self.rpc_host = self.default('RPC_HOST', 'localhost')
self.elastic_host = self.default('ELASTIC_HOST', 'localhost')
self.elastic_port = self.integer('ELASTIC_PORT', 9200)
self.loop_policy = self.set_event_loop_policy()
self.obsolete(['UTXO_MB', 'HIST_MB', 'NETWORK'])
self.db_dir = self.required('DB_DIRECTORY')
@@ -55,13 +53,10 @@ class Env:
coin_name = self.required('COIN').strip()
network = self.default('NET', 'mainnet').strip()
self.coin = Coin.lookup_coin_class(coin_name, network)
self.es_index_prefix = self.default('ES_INDEX_PREFIX', '')
self.es_mode = self.default('ES_MODE', 'writer')
self.cache_MB = self.integer('CACHE_MB', 1200)
self.reorg_limit = self.integer('REORG_LIMIT', self.coin.REORG_LIMIT)
# Server stuff
self.tcp_port = self.integer('TCP_PORT', None)
self.udp_port = self.integer('UDP_PORT', self.tcp_port)
self.ssl_port = self.integer('SSL_PORT', None)
if self.ssl_port:
self.ssl_certfile = self.required('SSL_CERTFILE')
@@ -73,12 +68,9 @@ class Env:
self.tor_banner_file = self.default('TOR_BANNER_FILE', self.banner_file)
self.anon_logs = self.boolean('ANON_LOGS', False)
self.log_sessions = self.integer('LOG_SESSIONS', 3600)
self.allow_lan_udp = self.boolean('ALLOW_LAN_UDP', False)
self.country = self.default('COUNTRY', 'US')
# Peer discovery
self.peer_discovery = self.peer_discovery_enum()
self.peer_announce = self.boolean('PEER_ANNOUNCE', True)
self.peer_hubs = self.extract_peer_hubs()
self.force_proxy = self.boolean('FORCE_PROXY', False)
self.tor_proxy_host = self.default('TOR_PROXY_HOST', 'localhost')
self.tor_proxy_port = self.integer('TOR_PROXY_PORT', None)
@@ -102,7 +94,7 @@ class Env:
self.identities = [identity
for identity in (clearnet_identity, tor_identity)
if identity is not None]
self.database_query_timeout = float(self.integer('QUERY_TIMEOUT_MS', 3000)) / 1000.0
self.database_query_timeout = float(self.integer('QUERY_TIMEOUT_MS', 250)) / 1000.0
@classmethod
def default(cls, envvar, default):
@@ -271,6 +263,3 @@ class Env:
return self.PD_SELF
else:
return self.PD_ON
def extract_peer_hubs(self):
return [hub.strip() for hub in self.default('PEER_HUBS', '').split(',')]
+6 -23
View File
@@ -12,7 +12,6 @@
import asyncio
import array
import ast
import base64
import os
import time
import zlib
@@ -25,7 +24,7 @@ from glob import glob
from struct import pack, unpack
from concurrent.futures.thread import ThreadPoolExecutor
import attr
from lbry.utils import LRUCacheWithMetrics
from lbry.utils import LRUCache
from lbry.wallet.server import util
from lbry.wallet.server.hash import hash_to_hex_str, HASHX_LEN
from lbry.wallet.server.merkle import Merkle, MerkleCache
@@ -83,7 +82,6 @@ class LevelDB:
self.utxo_db = None
self.tx_counts = None
self.headers = None
self.encoded_headers = LRUCacheWithMetrics(1 << 21, metric_name='encoded_headers', namespace='wallet_server')
self.last_flush = time.time()
self.logger.info(f'using {self.env.db_engine} for DB backend')
@@ -95,7 +93,7 @@ class LevelDB:
self.headers_db = None
self.tx_db = None
self._tx_and_merkle_cache = LRUCacheWithMetrics(2 ** 17, metric_name='tx_and_merkle', namespace="wallet_server")
self._tx_and_merkle_cache = LRUCache(2**17, metric_name='tx_and_merkle', namespace="wallet_server")
self.total_transactions = None
async def _read_tx_counts(self):
@@ -137,7 +135,9 @@ class LevelDB:
return
def get_headers():
return list(self.headers_db.iterator(prefix=HEADER_PREFIX, include_key=False))
return [
header for header in self.headers_db.iterator(prefix=HEADER_PREFIX, include_key=False)
]
headers = await asyncio.get_event_loop().run_in_executor(self.executor, get_headers)
assert len(headers) - 1 == self.db_height, f"{len(headers)} vs {self.db_height}"
@@ -440,16 +440,6 @@ class LevelDB:
raise IndexError(f'height {height:,d} out of range')
return header
def encode_headers(self, start_height, count, headers):
key = (start_height, count)
if not self.encoded_headers.get(key):
compressobj = zlib.compressobj(wbits=-15, level=1, memLevel=9)
headers = base64.b64encode(compressobj.compress(headers) + compressobj.flush()).decode()
if start_height % 1000 != 0:
return headers
self.encoded_headers[key] = headers
return self.encoded_headers.get(key)
def read_headers(self, start_height, count) -> typing.Tuple[bytes, int]:
"""Requires start_height >= 0, count >= 0. Reads as many headers as
are available starting at start_height up to count. This
@@ -476,14 +466,7 @@ class LevelDB:
tx_height = bisect_right(self.tx_counts, tx_num)
if tx_height > self.db_height:
return None, tx_height
try:
return self.total_transactions[tx_num], tx_height
except IndexError:
self.logger.exception(
"Failed to access a cached transaction, known bug #3142 "
"should be fixed in #3205"
)
return None, tx_height
return self.total_transactions[tx_num], tx_height
def _fs_transactions(self, txids: Iterable[str]):
unpack_be_uint64 = util.unpack_be_uint64
+3 -12
View File
@@ -210,15 +210,6 @@ class MemPool:
return deferred, {prevout: utxo_map[prevout] for prevout in unspent}
async def _mempool_loop(self, synchronized_event):
try:
return await self._refresh_hashes(synchronized_event)
except asyncio.CancelledError:
raise
except Exception as e:
self.logger.exception("MEMPOOL DIED")
raise e
async def _refresh_hashes(self, synchronized_event):
"""Refresh our view of the daemon's mempool."""
while True:
@@ -324,7 +315,7 @@ class MemPool:
for prevout in tx.prevouts
if prevout[0] not in all_hashes)
utxos = await self.api.lookup_utxos(prevouts)
utxo_map = dict(zip(prevouts, utxos))
utxo_map = {prevout: utxo for prevout, utxo in zip(prevouts, utxos)}
return self._accept_transactions(tx_map, utxo_map, touched)
@@ -335,7 +326,7 @@ class MemPool:
async def keep_synchronized(self, synchronized_event):
"""Keep the mempool synchronized with the daemon."""
await asyncio.wait([
self._mempool_loop(synchronized_event),
self._refresh_hashes(synchronized_event),
# self._refresh_histogram(synchronized_event),
self._logging(synchronized_event)
])
@@ -353,7 +344,7 @@ class MemPool:
value += sum(v for h168, v in tx.out_pairs if h168 == hashX)
return value
def compact_fee_histogram(self):
async def compact_fee_histogram(self):
"""Return a compact fee histogram of the current mempool."""
return self.cached_compact_histogram
+302
View File
@@ -0,0 +1,302 @@
# Copyright (c) 2017, Neil Booth
#
# All rights reserved.
#
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""Representation of a peer server."""
from ipaddress import ip_address
from lbry.wallet.server import util
from lbry.wallet.server.util import cachedproperty
from typing import Dict
class Peer:
# Protocol version
ATTRS = ('host', 'features',
# metadata
'source', 'ip_addr',
'last_good', 'last_try', 'try_count')
FEATURES = ('pruning', 'server_version', 'protocol_min', 'protocol_max',
'ssl_port', 'tcp_port')
# This should be set by the application
DEFAULT_PORTS: Dict[str, int] = {}
def __init__(self, host, features, source='unknown', ip_addr=None,
last_good=0, last_try=0, try_count=0):
"""Create a peer given a host name (or IP address as a string),
a dictionary of features, and a record of the source."""
assert isinstance(host, str)
assert isinstance(features, dict)
assert host in features.get('hosts', {})
self.host = host
self.features = features.copy()
# Canonicalize / clean-up
for feature in self.FEATURES:
self.features[feature] = getattr(self, feature)
# Metadata
self.source = source
self.ip_addr = ip_addr
# last_good represents the last connection that was
# successful *and* successfully verified, at which point
# try_count is set to 0. Failure to connect or failure to
# verify increment the try_count.
self.last_good = last_good
self.last_try = last_try
self.try_count = try_count
# Transient, non-persisted metadata
self.bad = False
self.other_port_pairs = set()
self.status = 2
@classmethod
def peers_from_features(cls, features, source):
peers = []
if isinstance(features, dict):
hosts = features.get('hosts')
if isinstance(hosts, dict):
peers = [Peer(host, features, source=source)
for host in hosts if isinstance(host, str)]
return peers
@classmethod
def deserialize(cls, item):
"""Deserialize from a dictionary."""
return cls(**item)
def matches(self, peers):
"""Return peers whose host matches our hostname or IP address.
Additionally include all peers whose IP address matches our
hostname if that is an IP address.
"""
candidates = (self.host.lower(), self.ip_addr)
return [peer for peer in peers
if peer.host.lower() in candidates
or peer.ip_addr == self.host]
def __str__(self):
return self.host
def update_features(self, features):
"""Update features in-place."""
try:
tmp = Peer(self.host, features)
except Exception:
pass
else:
self.update_features_from_peer(tmp)
def update_features_from_peer(self, peer):
if peer != self:
self.features = peer.features
for feature in self.FEATURES:
setattr(self, feature, getattr(peer, feature))
def connection_port_pairs(self):
"""Return a list of (kind, port) pairs to try when making a
connection."""
# Use a list not a set - it's important to try the registered
# ports first.
pairs = [('SSL', self.ssl_port), ('TCP', self.tcp_port)]
while self.other_port_pairs:
pairs.append(self.other_port_pairs.pop())
return [pair for pair in pairs if pair[1]]
def mark_bad(self):
"""Mark as bad to avoid reconnects but also to remember for a
while."""
self.bad = True
def check_ports(self, other):
"""Remember differing ports in case server operator changed them
or removed one."""
if other.ssl_port != self.ssl_port:
self.other_port_pairs.add(('SSL', other.ssl_port))
if other.tcp_port != self.tcp_port:
self.other_port_pairs.add(('TCP', other.tcp_port))
return bool(self.other_port_pairs)
@cachedproperty
def is_tor(self):
return self.host.endswith('.onion')
@cachedproperty
def is_valid(self):
ip = self.ip_address
if ip:
return ((ip.is_global or ip.is_private)
and not (ip.is_multicast or ip.is_unspecified))
return util.is_valid_hostname(self.host)
@cachedproperty
def is_public(self):
ip = self.ip_address
if ip:
return self.is_valid and not ip.is_private
else:
return self.is_valid and self.host != 'localhost'
@cachedproperty
def ip_address(self):
"""The host as a python ip_address object, or None."""
try:
return ip_address(self.host)
except ValueError:
return None
def bucket(self):
if self.is_tor:
return 'onion'
if not self.ip_addr:
return ''
return tuple(self.ip_addr.split('.')[:2])
def serialize(self):
"""Serialize to a dictionary."""
return {attr: getattr(self, attr) for attr in self.ATTRS}
def _port(self, key):
hosts = self.features.get('hosts')
if isinstance(hosts, dict):
host = hosts.get(self.host)
port = self._integer(key, host)
if port and 0 < port < 65536:
return port
return None
def _integer(self, key, d=None):
d = d or self.features
result = d.get(key) if isinstance(d, dict) else None
if isinstance(result, str):
try:
result = int(result)
except ValueError:
pass
return result if isinstance(result, int) else None
def _string(self, key):
result = self.features.get(key)
return result if isinstance(result, str) else None
@cachedproperty
def genesis_hash(self):
"""Returns None if no SSL port, otherwise the port as an integer."""
return self._string('genesis_hash')
@cachedproperty
def ssl_port(self):
"""Returns None if no SSL port, otherwise the port as an integer."""
return self._port('ssl_port')
@cachedproperty
def tcp_port(self):
"""Returns None if no TCP port, otherwise the port as an integer."""
return self._port('tcp_port')
@cachedproperty
def server_version(self):
"""Returns the server version as a string if known, otherwise None."""
return self._string('server_version')
@cachedproperty
def pruning(self):
"""Returns the pruning level as an integer. None indicates no
pruning."""
pruning = self._integer('pruning')
if pruning and pruning > 0:
return pruning
return None
def _protocol_version_string(self, key):
version_str = self.features.get(key)
ptuple = util.protocol_tuple(version_str)
return util.version_string(ptuple)
@cachedproperty
def protocol_min(self):
"""Minimum protocol version as a string, e.g., 1.0"""
return self._protocol_version_string('protocol_min')
@cachedproperty
def protocol_max(self):
"""Maximum protocol version as a string, e.g., 1.1"""
return self._protocol_version_string('protocol_max')
def to_tuple(self):
"""The tuple ((ip, host, details) expected in response
to a peers subscription."""
details = self.real_name().split()[1:]
return (self.ip_addr or self.host, self.host, details)
def real_name(self):
"""Real name of this peer as used on IRC."""
def port_text(letter, port):
if port == self.DEFAULT_PORTS.get(letter):
return letter
else:
return letter + str(port)
parts = [self.host, 'v' + self.protocol_max]
if self.pruning:
parts.append(f'p{self.pruning:d}')
for letter, port in (('s', self.ssl_port), ('t', self.tcp_port)):
if port:
parts.append(port_text(letter, port))
return ' '.join(parts)
@classmethod
def from_real_name(cls, real_name, source):
"""Real name is a real name as on IRC, such as
"erbium1.sytes.net v1.0 s t"
Returns an instance of this Peer class.
"""
host = 'nohost'
features = {}
ports = {}
for n, part in enumerate(real_name.split()):
if n == 0:
host = part
continue
if part[0] in ('s', 't'):
if len(part) == 1:
port = cls.DEFAULT_PORTS[part[0]]
else:
port = part[1:]
if part[0] == 's':
ports['ssl_port'] = port
else:
ports['tcp_port'] = port
elif part[0] == 'v':
features['protocol_max'] = features['protocol_min'] = part[1:]
elif part[0] == 'p':
features['pruning'] = part[1:]
features.update(ports)
features['hosts'] = {host: ports}
return cls(host, features, source)
+506
View File
@@ -0,0 +1,506 @@
# Copyright (c) 2017-2018, Neil Booth
#
# All rights reserved.
#
# See the file "LICENCE" for information about the copyright
# and warranty status of this software.
"""Peer management."""
import asyncio
import random
import socket
import ssl
import time
import typing
from asyncio import Event, sleep
from collections import defaultdict, Counter
from lbry.wallet.tasks import TaskGroup
from lbry.wallet.rpc import (
Connector, RPCSession, SOCKSProxy, Notification, handler_invocation,
SOCKSError, RPCError
)
from lbry.wallet.server.peer import Peer
from lbry.wallet.server.util import class_logger, protocol_tuple
PEER_GOOD, PEER_STALE, PEER_NEVER, PEER_BAD = range(4)
STALE_SECS = 24 * 3600
WAKEUP_SECS = 300
class BadPeerError(Exception):
pass
def assert_good(message, result, instance):
if not isinstance(result, instance):
raise BadPeerError(f'{message} returned bad result type '
f'{type(result).__name__}')
class PeerSession(RPCSession):
"""An outgoing session to a peer."""
async def handle_request(self, request):
# We subscribe so might be unlucky enough to get a notification...
if (isinstance(request, Notification) and
request.method == 'blockchain.headers.subscribe'):
pass
else:
await handler_invocation(None, request) # Raises
class PeerManager:
"""Looks after the DB of peer network servers.
Attempts to maintain a connection with up to 8 peers.
Issues a 'peers.subscribe' RPC to them and tells them our data.
"""
def __init__(self, env, db):
self.logger = class_logger(__name__, self.__class__.__name__)
# Initialise the Peer class
Peer.DEFAULT_PORTS = env.coin.PEER_DEFAULT_PORTS
self.env = env
self.db = db
# Our clearnet and Tor Peers, if any
sclass = env.coin.SESSIONCLS
self.myselves = [Peer(ident.host, sclass.server_features(env), 'env')
for ident in env.identities]
self.server_version_args = sclass.server_version_args()
# Peers have one entry per hostname. Once connected, the
# ip_addr property is either None, an onion peer, or the
# IP address that was connected to. Adding a peer will evict
# any other peers with the same host name or IP address.
self.peers: typing.Set[Peer] = set()
self.permit_onion_peer_time = time.time()
self.proxy = None
self.group = TaskGroup()
def _my_clearnet_peer(self):
"""Returns the clearnet peer representing this server, if any."""
clearnet = [peer for peer in self.myselves if not peer.is_tor]
return clearnet[0] if clearnet else None
def _set_peer_statuses(self):
"""Set peer statuses."""
cutoff = time.time() - STALE_SECS
for peer in self.peers:
if peer.bad:
peer.status = PEER_BAD
elif peer.last_good > cutoff:
peer.status = PEER_GOOD
elif peer.last_good:
peer.status = PEER_STALE
else:
peer.status = PEER_NEVER
def _features_to_register(self, peer, remote_peers):
"""If we should register ourselves to the remote peer, which has
reported the given list of known peers, return the clearnet
identity features to register, otherwise None.
"""
# Announce ourself if not present. Don't if disabled, we
# are a non-public IP address, or to ourselves.
if not self.env.peer_announce or peer in self.myselves:
return None
my = self._my_clearnet_peer()
if not my or not my.is_public:
return None
# Register if no matches, or ports have changed
for peer in my.matches(remote_peers):
if peer.tcp_port == my.tcp_port and peer.ssl_port == my.ssl_port:
return None
return my.features
def _permit_new_onion_peer(self):
"""Accept a new onion peer only once per random time interval."""
now = time.time()
if now < self.permit_onion_peer_time:
return False
self.permit_onion_peer_time = now + random.randrange(0, 1200)
return True
async def _import_peers(self):
"""Import hard-coded peers from a file or the coin defaults."""
imported_peers = self.myselves.copy()
# Add the hard-coded ones unless only reporting ourself
if self.env.peer_discovery != self.env.PD_SELF:
imported_peers.extend(Peer.from_real_name(real_name, 'coins.py')
for real_name in self.env.coin.PEERS)
await self._note_peers(imported_peers, limit=None)
async def _detect_proxy(self):
"""Detect a proxy if we don't have one and some time has passed since
the last attempt.
If found self.proxy is set to a SOCKSProxy instance, otherwise
None.
"""
host = self.env.tor_proxy_host
if self.env.tor_proxy_port is None:
ports = [9050, 9150, 1080]
else:
ports = [self.env.tor_proxy_port]
while True:
self.logger.info(f'trying to detect proxy on "{host}" '
f'ports {ports}')
proxy = await SOCKSProxy.auto_detect_host(host, ports, None)
if proxy:
self.proxy = proxy
self.logger.info(f'detected {proxy}')
return
self.logger.info('no proxy detected, will try later')
await sleep(900)
async def _note_peers(self, peers, limit=2, check_ports=False,
source=None):
"""Add a limited number of peers that are not already present."""
new_peers = []
for peer in peers:
if not peer.is_public or (peer.is_tor and not self.proxy):
continue
matches = peer.matches(self.peers)
if not matches:
new_peers.append(peer)
elif check_ports:
for match in matches:
if match.check_ports(peer):
self.logger.info(f'ports changed for {peer}')
match.retry_event.set()
if new_peers:
source = source or new_peers[0].source
if limit:
random.shuffle(new_peers)
use_peers = new_peers[:limit]
else:
use_peers = new_peers
for peer in use_peers:
self.logger.info(f'accepted new peer {peer} from {source}')
peer.retry_event = Event()
self.peers.add(peer)
await self.group.add(self._monitor_peer(peer))
async def _monitor_peer(self, peer):
# Stop monitoring if we were dropped (a duplicate peer)
while peer in self.peers:
if await self._should_drop_peer(peer):
self.peers.discard(peer)
break
# Figure out how long to sleep before retrying. Retry a
# good connection when it is about to turn stale, otherwise
# exponentially back off retries.
if peer.try_count == 0:
pause = STALE_SECS - WAKEUP_SECS * 2
else:
pause = WAKEUP_SECS * 2 ** peer.try_count
pending, done = await asyncio.wait([peer.retry_event.wait()], timeout=pause)
if done:
peer.retry_event.clear()
async def _should_drop_peer(self, peer):
peer.try_count += 1
is_good = False
for kind, port in peer.connection_port_pairs():
peer.last_try = time.time()
kwargs = {}
if kind == 'SSL':
kwargs['ssl'] = ssl.SSLContext(ssl.PROTOCOL_TLS)
host = self.env.cs_host(for_rpc=False)
if isinstance(host, list):
host = host[0]
if self.env.force_proxy or peer.is_tor:
if not self.proxy:
return
kwargs['proxy'] = self.proxy
kwargs['resolve'] = not peer.is_tor
elif host:
# Use our listening Host/IP for outgoing non-proxy
# connections so our peers see the correct source.
kwargs['local_addr'] = (host, None)
peer_text = f'[{peer}:{port} {kind}]'
try:
async with Connector(PeerSession, peer.host, port,
**kwargs) as session:
await asyncio.wait_for(
self._verify_peer(session, peer),
120 if peer.is_tor else 30
)
is_good = True
break
except BadPeerError as e:
self.logger.error(f'{peer_text} marking bad: ({e})')
peer.mark_bad()
break
except RPCError as e:
self.logger.error(f'{peer_text} RPC error: {e.message} '
f'({e.code})')
except (OSError, SOCKSError, ConnectionError, asyncio.TimeoutError) as e:
self.logger.info(f'{peer_text} {e}')
if is_good:
now = time.time()
elapsed = now - peer.last_try
self.logger.info(f'{peer_text} verified in {elapsed:.1f}s')
peer.try_count = 0
peer.last_good = now
peer.source = 'peer'
# At most 2 matches if we're a host name, potentially
# several if we're an IP address (several instances
# can share a NAT).
matches = peer.matches(self.peers)
for match in matches:
if match.ip_address:
if len(matches) > 1:
self.peers.remove(match)
# Force the peer's monitoring task to exit
match.retry_event.set()
elif peer.host in match.features['hosts']:
match.update_features_from_peer(peer)
else:
# Forget the peer if long-term unreachable
if peer.last_good and not peer.bad:
try_limit = 10
else:
try_limit = 3
if peer.try_count >= try_limit:
desc = 'bad' if peer.bad else 'unreachable'
self.logger.info(f'forgetting {desc} peer: {peer}')
return True
return False
async def _verify_peer(self, session, peer):
if not peer.is_tor:
address = session.peer_address()
if address:
peer.ip_addr = address[0]
# server.version goes first
message = 'server.version'
result = await session.send_request(message, self.server_version_args)
assert_good(message, result, list)
# Protocol version 1.1 returns a pair with the version first
if len(result) != 2 or not all(isinstance(x, str) for x in result):
raise BadPeerError(f'bad server.version result: {result}')
server_version, protocol_version = result
peer.server_version = server_version
peer.features['server_version'] = server_version
ptuple = protocol_tuple(protocol_version)
await asyncio.wait([
self._send_headers_subscribe(session, peer, ptuple),
self._send_server_features(session, peer),
self._send_peers_subscribe(session, peer)
])
async def _send_headers_subscribe(self, session, peer, ptuple):
message = 'blockchain.headers.subscribe'
result = await session.send_request(message)
assert_good(message, result, dict)
our_height = self.db.db_height
if ptuple < (1, 3):
their_height = result.get('block_height')
else:
their_height = result.get('height')
if not isinstance(their_height, int):
raise BadPeerError(f'invalid height {their_height}')
if abs(our_height - their_height) > 5:
raise BadPeerError(f'bad height {their_height:,d} '
f'(ours: {our_height:,d})')
# Check prior header too in case of hard fork.
check_height = min(our_height, their_height)
raw_header = self.db.raw_header(check_height)
if ptuple >= (1, 4):
ours = raw_header.hex()
message = 'blockchain.block.header'
theirs = await session.send_request(message, [check_height])
assert_good(message, theirs, str)
if ours != theirs:
raise BadPeerError(f'our header {ours} and '
f'theirs {theirs} differ')
else:
ours = self.env.coin.electrum_header(raw_header, check_height)
ours = ours.get('prev_block_hash')
message = 'blockchain.block.get_header'
theirs = await session.send_request(message, [check_height])
assert_good(message, theirs, dict)
theirs = theirs.get('prev_block_hash')
if ours != theirs:
raise BadPeerError(f'our header hash {ours} and '
f'theirs {theirs} differ')
async def _send_server_features(self, session, peer):
message = 'server.features'
features = await session.send_request(message)
assert_good(message, features, dict)
hosts = [host.lower() for host in features.get('hosts', {})]
if self.env.coin.GENESIS_HASH != features.get('genesis_hash'):
raise BadPeerError('incorrect genesis hash')
elif peer.host.lower() in hosts:
peer.update_features(features)
else:
raise BadPeerError(f'not listed in own hosts list {hosts}')
async def _send_peers_subscribe(self, session, peer):
message = 'server.peers.subscribe'
raw_peers = await session.send_request(message)
assert_good(message, raw_peers, list)
# Check the peers list we got from a remote peer.
# Each is expected to be of the form:
# [ip_addr, hostname, ['v1.0', 't51001', 's51002']]
# Call add_peer if the remote doesn't appear to know about us.
try:
real_names = [' '.join([u[1]] + u[2]) for u in raw_peers]
peers = [Peer.from_real_name(real_name, str(peer))
for real_name in real_names]
except Exception:
raise BadPeerError('bad server.peers.subscribe response')
await self._note_peers(peers)
features = self._features_to_register(peer, peers)
if not features:
return
self.logger.info(f'registering ourself with {peer}')
# We only care to wait for the response
await session.send_request('server.add_peer', [features])
#
# External interface
#
async def discover_peers(self):
"""Perform peer maintenance. This includes
1) Forgetting unreachable peers.
2) Verifying connectivity of new peers.
3) Retrying old peers at regular intervals.
"""
if self.env.peer_discovery != self.env.PD_ON:
self.logger.info('peer discovery is disabled')
return
self.logger.info(f'beginning peer discovery. Force use of '
f'proxy: {self.env.force_proxy}')
self.group.add(self._detect_proxy())
self.group.add(self._import_peers())
def info(self) -> typing.Dict[str, int]:
"""The number of peers."""
self._set_peer_statuses()
counter = Counter(peer.status for peer in self.peers)
return {
'bad': counter[PEER_BAD],
'good': counter[PEER_GOOD],
'never': counter[PEER_NEVER],
'stale': counter[PEER_STALE],
'total': len(self.peers),
}
async def add_localRPC_peer(self, real_name):
"""Add a peer passed by the admin over LocalRPC."""
await self._note_peers([Peer.from_real_name(real_name, 'RPC')])
async def on_add_peer(self, features, source_info):
"""Add a peer (but only if the peer resolves to the source)."""
if not source_info:
self.logger.info('ignored add_peer request: no source info')
return False
source = source_info[0]
peers = Peer.peers_from_features(features, source)
if not peers:
self.logger.info('ignored add_peer request: no peers given')
return False
# Just look at the first peer, require it
peer = peers[0]
host = peer.host
if peer.is_tor:
permit = self._permit_new_onion_peer()
reason = 'rate limiting'
else:
getaddrinfo = asyncio.get_event_loop().getaddrinfo
try:
infos = await getaddrinfo(host, 80, type=socket.SOCK_STREAM)
except socket.gaierror:
permit = False
reason = 'address resolution failure'
else:
permit = any(source == info[-1][0] for info in infos)
reason = 'source-destination mismatch'
if permit:
self.logger.info(f'accepted add_peer request from {source} '
f'for {host}')
await self._note_peers([peer], check_ports=True)
else:
self.logger.warning(f'rejected add_peer request from {source} '
f'for {host} ({reason})')
return permit
def on_peers_subscribe(self, is_tor):
"""Returns the server peers as a list of (ip, host, details) tuples.
We return all peers we've connected to in the last day.
Additionally, if we don't have onion routing, we return a few
hard-coded onion servers.
"""
cutoff = time.time() - STALE_SECS
recent = [peer for peer in self.peers
if peer.last_good > cutoff and
not peer.bad and peer.is_public]
onion_peers = []
# Always report ourselves if valid (even if not public)
peers = {myself for myself in self.myselves
if myself.last_good > cutoff}
# Bucket the clearnet peers and select up to two from each
buckets = defaultdict(list)
for peer in recent:
if peer.is_tor:
onion_peers.append(peer)
else:
buckets[peer.bucket()].append(peer)
for bucket_peers in buckets.values():
random.shuffle(bucket_peers)
peers.update(bucket_peers[:2])
# Add up to 20% onion peers (but up to 10 is OK anyway)
random.shuffle(onion_peers)
max_onion = 50 if is_tor else max(10, len(peers) // 4)
peers.update(onion_peers[:max_onion])
return [peer.to_tuple() for peer in peers]
def proxy_peername(self):
"""Return the peername of the proxy, if there is a proxy, otherwise
None."""
return self.proxy.peername if self.proxy else None
def rpc_data(self):
"""Peer data for the peers RPC method."""
self._set_peer_statuses()
descs = ['good', 'stale', 'never', 'bad']
def peer_data(peer):
data = peer.serialize()
data['status'] = descs[peer.status]
return data
def peer_key(peer):
return (peer.bad, -peer.last_good)
return [peer_data(peer) for peer in sorted(self.peers, key=peer_key)]
+1 -8
View File
@@ -94,7 +94,6 @@ class Server:
self.session_mgr = env.coin.SESSION_MANAGER(
env, db, bp, daemon, mempool, self.shutdown_event
)
self._indexer_task = None
async def start(self):
env = self.env
@@ -111,17 +110,11 @@ class Server:
self.cancellable_tasks.append(asyncio.ensure_future(run(*args, _flag)))
return _flag.wait()
await self.start_prometheus()
if self.env.udp_port:
await self.bp.status_server.start(
0, bytes.fromhex(self.bp.coin.GENESIS_HASH)[::-1], self.env.country,
self.env.host, self.env.udp_port, self.env.allow_lan_udp
)
await _start_cancellable(self.bp.fetch_and_process_blocks)
await self.db.populate_header_merkle_cache()
await _start_cancellable(self.mempool.keep_synchronized)
await _start_cancellable(self.session_mgr.serve, self.notifications)
await self.start_prometheus()
async def stop(self):
for task in reversed(self.cancellable_tasks):
+186 -81
View File
@@ -3,6 +3,7 @@ import ssl
import math
import time
import json
import zlib
import base64
import codecs
import typing
@@ -15,17 +16,16 @@ from asyncio import Event, sleep
from collections import defaultdict
from functools import partial
from binascii import hexlify
from binascii import hexlify, unhexlify
from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor
from elasticsearch import ConnectionTimeout
from prometheus_client import Counter, Info, Histogram, Gauge
import lbry
from lbry.utils import LRUCacheWithMetrics
from lbry.utils import LRUCache
from lbry.build_info import BUILD, COMMIT_HASH, DOCKER_TAG
from lbry.wallet.server.block_processor import LBRYBlockProcessor
from lbry.wallet.server.db.writer import LBRYLevelDB
from lbry.wallet.server.db import reader
from lbry.wallet.server.websocket import AdminWebSocket
from lbry.wallet.server.metrics import ServerLoadData, APICallMetrics
from lbry.wallet.rpc.framing import NewlineFramer
@@ -39,6 +39,7 @@ from lbry.wallet.server import text
from lbry.wallet.server import util
from lbry.wallet.server.hash import sha256, hash_to_hex_str, hex_str_to_hash, HASHX_LEN, Base58Error
from lbry.wallet.server.daemon import DaemonError
from lbry.wallet.server.peers import PeerManager
if typing.TYPE_CHECKING:
from lbry.wallet.server.env import Env
from lbry.wallet.server.mempool import MemPool
@@ -184,6 +185,7 @@ class SessionManager:
self.bp = bp
self.daemon = daemon
self.mempool = mempool
self.peer_mgr = PeerManager(env, db)
self.shutdown_event = shutdown_event
self.logger = util.class_logger(__name__, self.__class__.__name__)
self.servers: typing.Dict[str, asyncio.AbstractServer] = {}
@@ -207,7 +209,7 @@ class SessionManager:
else:
protocol_class = self.env.coin.SESSIONCLS
protocol_factory = partial(protocol_class, self, self.db,
self.mempool, kind)
self.mempool, self.peer_mgr, kind)
host, port = args[:2]
try:
@@ -245,12 +247,11 @@ class SessionManager:
async def _manage_servers(self):
paused = False
max_sessions = self.env.max_sessions
low_watermark = int(max_sessions * 0.95)
low_watermark = max_sessions * 19 // 20
while True:
await self.session_event.wait()
self.session_event.clear()
if not paused and len(self.sessions) >= max_sessions:
self.bp.status_server.set_unavailable()
self.logger.info(f'maximum sessions {max_sessions:,d} '
f'reached, stopping new connections until '
f'count drops to {low_watermark:,d}')
@@ -259,7 +260,6 @@ class SessionManager:
# Start listening for incoming connections if paused and
# session count has fallen
if paused and len(self.sessions) <= low_watermark:
self.bp.status_server.set_available()
self.logger.info('resuming listening for incoming connections')
await self._start_external_servers()
paused = False
@@ -367,7 +367,7 @@ class SessionManager:
'logged': logged,
'paused': paused,
'pid': os.getpid(),
'peers': [],
'peers': self.peer_mgr.info(),
'requests': pending_requests,
'method_counts': method_counts,
'sessions': self.session_count(),
@@ -434,7 +434,7 @@ class SessionManager:
real_name: "bch.electrumx.cash t50001 s50002" for example
"""
await self._notify_peer(real_name)
await self.peer_mgr.add_localRPC_peer(real_name)
return f"peer '{real_name}' added"
async def rpc_disconnect(self, session_ids):
@@ -485,7 +485,7 @@ class SessionManager:
async def rpc_peers(self):
"""Return a list of data about server peers."""
return self.env.peer_hubs
return self.peer_mgr.rpc_data()
async def rpc_query(self, items, limit):
"""Return a list of data about server peers."""
@@ -572,17 +572,16 @@ class SessionManager:
await self.start_other()
await self._start_external_servers()
server_listening_event.set()
self.bp.status_server.set_available()
# Peer discovery should start after the external servers
# because we connect to ourself
await asyncio.wait([
self.peer_mgr.discover_peers(),
self._clear_stale_sessions(),
self._log_sessions(),
self._manage_servers()
])
finally:
await self._close_servers(list(self.servers.keys()))
log.warning("disconnect %i sessions", len(self.sessions))
if self.sessions:
await asyncio.wait([
session.close(force_after=1) for session in self.sessions.values()
@@ -635,15 +634,6 @@ class SessionManager:
self.history_cache[hashX] = await self.db.limited_history(hashX, limit=limit)
return self.history_cache[hashX]
def _notify_peer(self, peer):
notify_tasks = [
session.send_notification('blockchain.peers.subscribe', [peer])
for session in self.sessions.values() if session.subscribe_peers
]
if notify_tasks:
self.logger.info(f'notify {len(notify_tasks)} sessions of new peers')
asyncio.create_task(asyncio.wait(notify_tasks))
async def _notify_sessions(self, height, touched, new_touched):
"""Notify sessions about height changes and touched addresses."""
height_changed = height != self.notified_height
@@ -710,7 +700,7 @@ class SessionBase(RPCSession):
request_handlers: typing.Dict[str, typing.Callable] = {}
version = '0.5.7'
def __init__(self, session_mgr, db, mempool, kind):
def __init__(self, session_mgr, db, mempool, peer_mgr, kind):
connection = JSONRPCConnection(JSONRPCAutoDetect)
self.env = session_mgr.env
super().__init__(connection=connection)
@@ -718,6 +708,7 @@ class SessionBase(RPCSession):
self.session_mgr = session_mgr
self.db = db
self.mempool = mempool
self.peer_mgr = peer_mgr
self.kind = kind # 'RPC', 'TCP' etc.
self.coin = self.env.coin
self.anon_logs = self.env.anon_logs
@@ -818,6 +809,9 @@ class LBRYSessionManager(SessionManager):
self.running = False
if self.env.websocket_host is not None and self.env.websocket_port is not None:
self.websocket = AdminWebSocket(self)
self.search_cache = self.bp.search_cache
self.search_cache['search'] = LRUCache(2**14, metric_name='search', namespace=NAMESPACE)
self.search_cache['resolve'] = LRUCache(2**16, metric_name='resolve', namespace=NAMESPACE)
async def process_metrics(self):
while self.running:
@@ -831,11 +825,22 @@ class LBRYSessionManager(SessionManager):
async def start_other(self):
self.running = True
path = os.path.join(self.env.db_dir, 'claims.db')
args = dict(
initializer=reader.initializer,
initargs=(
self.logger, path, self.env.coin.NET, self.env.database_query_timeout,
self.env.track_metrics, (
self.db.sql.blocked_streams, self.db.sql.blocked_channels,
self.db.sql.filtered_streams, self.db.sql.filtered_channels
)
)
)
if self.env.max_query_workers is not None and self.env.max_query_workers == 0:
self.query_executor = ThreadPoolExecutor(max_workers=1)
self.query_executor = ThreadPoolExecutor(max_workers=1, **args)
else:
self.query_executor = ProcessPoolExecutor(
max_workers=self.env.max_query_workers or max(os.cpu_count(), 4)
max_workers=self.env.max_query_workers or max(os.cpu_count(), 4), **args
)
if self.websocket is not None:
await self.websocket.start()
@@ -859,7 +864,6 @@ class LBRYElectrumX(SessionBase):
max_errors = math.inf # don't disconnect people for errors! let them happen...
session_mgr: LBRYSessionManager
version = lbry.__version__
cached_server_features = {}
@classmethod
def initialize_request_handlers(cls):
@@ -888,6 +892,7 @@ class LBRYElectrumX(SessionBase):
'blockchain.transaction.get_height': cls.transaction_get_height,
'blockchain.claimtrie.search': cls.claimtrie_search,
'blockchain.claimtrie.resolve': cls.claimtrie_resolve,
'blockchain.claimtrie.getclaimsbyids': cls.claimtrie_getclaimsbyids,
'blockchain.block.get_server_height': cls.get_server_height,
'mempool.get_fee_histogram': cls.mempool_compact_histogram,
'blockchain.block.headers': cls.block_headers,
@@ -905,16 +910,13 @@ class LBRYElectrumX(SessionBase):
super().__init__(*args, **kwargs)
if not LBRYElectrumX.request_handlers:
LBRYElectrumX.initialize_request_handlers()
if not LBRYElectrumX.cached_server_features:
LBRYElectrumX.set_server_features(self.env)
self.subscribe_headers = False
self.subscribe_headers_raw = False
self.subscribe_peers = False
self.connection.max_response_size = self.env.max_send
self.hashX_subs = {}
self.sv_seen = False
self.protocol_tuple = self.PROTOCOL_MIN
self.protocol_string = None
self.daemon = self.session_mgr.daemon
self.bp: LBRYBlockProcessor = self.session_mgr.bp
self.db: LBRYLevelDB = self.bp.db
@@ -925,10 +927,10 @@ class LBRYElectrumX(SessionBase):
for ver in (cls.PROTOCOL_MIN, cls.PROTOCOL_MAX)]
@classmethod
def set_server_features(cls, env):
def server_features(cls, env):
"""Return the server features dictionary."""
min_str, max_str = cls.protocol_min_max_strings()
cls.cached_server_features.update({
return {
'hosts': env.hosts_dict(),
'pruning': None,
'server_version': cls.version,
@@ -941,10 +943,10 @@ class LBRYElectrumX(SessionBase):
'daily_fee': env.daily_fee,
'hash_function': 'sha256',
'trending_algorithm': env.trending_algorithms[0]
})
}
async def server_features_async(self):
return self.cached_server_features
return self.server_features(self.env)
@classmethod
def server_version_args(cls):
@@ -993,6 +995,16 @@ class LBRYElectrumX(SessionBase):
)
except asyncio.CancelledError:
raise
except reader.SQLiteInterruptedError as error:
metrics = self.get_metrics_or_placeholder_for_api(query_name)
metrics.query_interrupt(start, error.metrics)
self.session_mgr.interrupt_count_metric.inc()
raise RPCError(JSONRPC.QUERY_TIMEOUT, 'sqlite query timed out')
except reader.SQLiteOperationalError as error:
metrics = self.get_metrics_or_placeholder_for_api(query_name)
metrics.query_error(start, error.metrics)
self.session_mgr.db_operational_error_metric.inc()
raise RPCError(JSONRPC.INTERNAL_ERROR, 'query failed to execute')
except Exception:
log.exception("dear devs, please handle this exception better")
metrics = self.get_metrics_or_placeholder_for_api(query_name)
@@ -1009,33 +1021,40 @@ class LBRYElectrumX(SessionBase):
self.session_mgr.pending_query_metric.dec()
self.session_mgr.executor_time_metric.observe(time.perf_counter() - start)
async def run_and_cache_query(self, query_name, kwargs):
start = time.perf_counter()
if isinstance(kwargs, dict):
kwargs['release_time'] = format_release_time(kwargs.get('release_time'))
try:
self.session_mgr.pending_query_metric.inc()
return await self.db.search_index.session_query(query_name, kwargs)
except ConnectionTimeout:
self.session_mgr.interrupt_count_metric.inc()
raise RPCError(JSONRPC.QUERY_TIMEOUT, 'query timed out')
finally:
self.session_mgr.pending_query_metric.dec()
self.session_mgr.executor_time_metric.observe(time.perf_counter() - start)
async def run_and_cache_query(self, query_name, function, kwargs):
metrics = self.get_metrics_or_placeholder_for_api(query_name)
metrics.start()
cache = self.session_mgr.search_cache[query_name]
cache_key = str(kwargs)
cache_item = cache.get(cache_key)
if cache_item is None:
cache_item = cache[cache_key] = ResultCacheItem()
elif cache_item.result is not None:
metrics.cache_response()
return cache_item.result
async with cache_item.lock:
if cache_item.result is None:
cache_item.result = await self.run_in_executor(
query_name, function, kwargs
)
else:
metrics = self.get_metrics_or_placeholder_for_api(query_name)
metrics.cache_response()
return cache_item.result
async def mempool_compact_histogram(self):
return self.mempool.compact_fee_histogram()
async def claimtrie_search(self, **kwargs):
if kwargs:
return await self.run_and_cache_query('search', kwargs)
return await self.run_and_cache_query('search', reader.search_to_bytes, kwargs)
async def claimtrie_resolve(self, *urls):
if urls:
count = len(urls)
try:
self.session_mgr.urls_to_resolve_count_metric.inc(count)
return await self.run_and_cache_query('resolve', urls)
return await self.run_and_cache_query('resolve', reader.resolve_to_bytes, urls)
finally:
self.session_mgr.resolved_url_count_metric.inc(count)
@@ -1052,6 +1071,67 @@ class LBRYElectrumX(SessionBase):
return -1
return None
async def claimtrie_getclaimsbyids(self, *claim_ids):
claims = await self.batched_formatted_claims_from_daemon(claim_ids)
return dict(zip(claim_ids, claims))
async def batched_formatted_claims_from_daemon(self, claim_ids):
claims = await self.daemon.getclaimsbyids(claim_ids)
result = []
for claim in claims:
if claim and claim.get('value'):
result.append(self.format_claim_from_daemon(claim))
return result
def format_claim_from_daemon(self, claim, name=None):
"""Changes the returned claim data to the format expected by lbry and adds missing fields."""
if not claim:
return {}
# this ISO-8859 nonsense stems from a nasty form of encoding extended characters in lbrycrd
# it will be fixed after the lbrycrd upstream merge to v17 is done
# it originated as a fear of terminals not supporting unicode. alas, they all do
if 'name' in claim:
name = claim['name'].encode('ISO-8859-1').decode()
info = self.db.sql.get_claims(claim_id=claim['claimId'])
if not info:
# raise RPCError("Lbrycrd has {} but not lbryumx, please submit a bug report.".format(claim_id))
return {}
address = info.address.decode()
# fixme: temporary
#supports = self.format_supports_from_daemon(claim.get('supports', []))
supports = []
amount = get_from_possible_keys(claim, 'amount', 'nAmount')
height = get_from_possible_keys(claim, 'height', 'nHeight')
effective_amount = get_from_possible_keys(claim, 'effective amount', 'nEffectiveAmount')
valid_at_height = get_from_possible_keys(claim, 'valid at height', 'nValidAtHeight')
result = {
"name": name,
"claim_id": claim['claimId'],
"txid": claim['txid'],
"nout": claim['n'],
"amount": amount,
"depth": self.db.db_height - height + 1,
"height": height,
"value": hexlify(claim['value'].encode('ISO-8859-1')).decode(),
"address": address, # from index
"supports": supports,
"effective_amount": effective_amount,
"valid_at_height": valid_at_height
}
if 'claim_sequence' in claim:
# TODO: ensure that lbrycrd #209 fills in this value
result['claim_sequence'] = claim['claim_sequence']
else:
result['claim_sequence'] = -1
if 'normalized_name' in claim:
result['normalized_name'] = claim['normalized_name'].encode('ISO-8859-1').decode()
return result
def assert_tx_hash(self, value):
'''Raise an RPCError if the value is not a valid transaction
hash.'''
@@ -1062,6 +1142,16 @@ class LBRYElectrumX(SessionBase):
pass
raise RPCError(1, f'{value} should be a transaction hash')
def assert_claim_id(self, value):
'''Raise an RPCError if the value is not a valid claim id
hash.'''
try:
if len(util.hex_to_bytes(value)) == 20:
return
except Exception:
pass
raise RPCError(1, f'{value} should be a claim id hash')
async def subscribe_headers_result(self):
"""The result of a header subscription or notification."""
return self.session_mgr.hsub_results[self.subscribe_headers_raw]
@@ -1090,8 +1180,7 @@ class LBRYElectrumX(SessionBase):
async def peers_subscribe(self):
"""Return the server peers as a list of (ip, host, details) tuples."""
self.subscribe_peers = True
return self.env.peer_hubs
return self.peer_mgr.on_peers_subscribe(self.is_tor())
async def address_status(self, hashX):
"""Returns an address status.
@@ -1179,9 +1268,10 @@ class LBRYElectrumX(SessionBase):
address: the address to subscribe to"""
if len(addresses) > 1000:
raise RPCError(BAD_REQUEST, f'too many addresses in subscription request: {len(addresses)}')
return [
await self.hashX_subscribe(self.address_to_hashX(address), address) for address in addresses
hashXes = [
(self.address_to_hashX(address), address) for address in addresses
]
return await asyncio.gather(*(self.hashX_subscribe(*args) for args in hashXes))
async def address_unsubscribe(self, address):
"""Unsubscribe an address.
@@ -1267,7 +1357,8 @@ class LBRYElectrumX(SessionBase):
headers, count = self.db.read_headers(start_height, count)
if b64:
headers = self.db.encode_headers(start_height, count, headers)
compressobj = zlib.compressobj(wbits=-15, level=1, memLevel=9)
headers = base64.b64encode(compressobj.compress(headers) + compressobj.flush()).decode()
else:
headers = headers.hex()
result = {
@@ -1334,7 +1425,11 @@ class LBRYElectrumX(SessionBase):
async def banner(self):
"""Return the server banner text."""
banner = f'You are connected to an {self.version} server.'
banner_file = self.env.banner_file
if self.is_tor():
banner_file = self.env.tor_banner_file
else:
banner_file = self.env.banner_file
if banner_file:
try:
with codecs.open(banner_file, 'r', 'utf-8') as f:
@@ -1372,8 +1467,7 @@ class LBRYElectrumX(SessionBase):
client_name: a string identifying the client
protocol_version: the protocol version spoken by the client
"""
if self.protocol_string is not None:
return self.version, self.protocol_string
if self.sv_seen and self.protocol_tuple >= (1, 4):
raise RPCError(BAD_REQUEST, f'server.version already sent')
self.sv_seen = True
@@ -1383,7 +1477,8 @@ class LBRYElectrumX(SessionBase):
if self.env.drop_client is not None and \
self.env.drop_client.match(client_name):
self.close_after_send = True
raise RPCError(BAD_REQUEST, f'unsupported client: {client_name}')
raise RPCError(BAD_REQUEST,
f'unsupported client: {client_name}')
if self.client_version != client_name[:17]:
self.session_mgr.session_count_metric.labels(version=self.client_version).dec()
self.client_version = client_name[:17]
@@ -1392,16 +1487,19 @@ class LBRYElectrumX(SessionBase):
# Find the highest common protocol version. Disconnect if
# that protocol version in unsupported.
ptuple, client_min = util.protocol_version(protocol_version, self.PROTOCOL_MIN, self.PROTOCOL_MAX)
ptuple, client_min = util.protocol_version(
protocol_version, self.PROTOCOL_MIN, self.PROTOCOL_MAX)
if ptuple is None:
ptuple, client_min = util.protocol_version(protocol_version, (1, 1, 0), (1, 4, 0))
if ptuple is None:
self.close_after_send = True
raise RPCError(BAD_REQUEST, f'unsupported protocol version: {protocol_version}')
# FIXME: this fills the logs
# if client_min > self.PROTOCOL_MIN:
# self.logger.info(f'client requested future protocol version '
# f'{util.version_string(client_min)} '
# f'- is your software out of date?')
self.close_after_send = True
raise RPCError(BAD_REQUEST,
f'unsupported protocol version: {protocol_version}')
self.protocol_tuple = ptuple
self.protocol_string = util.version_string(ptuple)
return self.version, self.protocol_string
return self.version, self.protocol_version_string()
async def transaction_broadcast(self, raw_tx):
"""Broadcast a raw transaction to the network.
@@ -1451,14 +1549,15 @@ class LBRYElectrumX(SessionBase):
else:
batch_result[tx_hash] = [raw_tx, {'block_height': -1}]
if needed_merkles:
def threaded_get_merkle():
for tx_hash, (raw_tx, block_txs, pos, block_height) in needed_merkles.items():
batch_result[tx_hash] = raw_tx, {
'merkle': self._get_merkle_branch(block_txs, pos),
'pos': pos,
'block_height': block_height
}
await asyncio.sleep(0) # heavy call, give other tasks a chance
if needed_merkles:
await asyncio.get_running_loop().run_in_executor(self.db.executor, threaded_get_merkle)
self.session_mgr.tx_replied_count_metric.inc(len(tx_hashes))
return batch_result
@@ -1513,20 +1612,26 @@ class LocalRPC(SessionBase):
return 'RPC'
class ResultCacheItem:
__slots__ = '_result', 'lock', 'has_result'
def __init__(self):
self.has_result = asyncio.Event()
self.lock = asyncio.Lock()
self._result = None
@property
def result(self) -> str:
return self._result
@result.setter
def result(self, result: str):
self._result = result
if result is not None:
self.has_result.set()
def get_from_possible_keys(dictionary, *keys):
for key in keys:
if key in dictionary:
return dictionary[key]
def format_release_time(release_time):
# round release time to 1000 so it caches better
# also set a default so we dont show claims in the future
def roundup_time(number, factor=360):
return int(1 + int(number / factor)) * factor
if isinstance(release_time, str) and len(release_time) > 0:
time_digits = ''.join(filter(str.isdigit, release_time))
time_prefix = release_time[:-len(time_digits)]
return time_prefix + str(roundup_time(int(time_digits)))
elif isinstance(release_time, int):
return roundup_time(release_time)
-236
View File
@@ -1,236 +0,0 @@
import asyncio
import struct
from time import perf_counter
import logging
from typing import Optional, Tuple, NamedTuple
from lbry.utils import LRUCache, is_valid_public_ipv4
from lbry.schema.attrs import country_str_to_int, country_int_to_str
# from prometheus_client import Counter
log = logging.getLogger(__name__)
_MAGIC = 1446058291 # genesis blocktime (which is actually wrong)
# ping_count_metric = Counter("ping_count", "Number of pings received", namespace='wallet_server_status')
_PAD_BYTES = b'\x00' * 64
PROTOCOL_VERSION = 1
class SPVPing(NamedTuple):
magic: int
protocol_version: int
pad_bytes: bytes
def encode(self):
return struct.pack(b'!lB64s', *self)
@staticmethod
def make() -> bytes:
return SPVPing(_MAGIC, PROTOCOL_VERSION, _PAD_BYTES).encode()
@classmethod
def decode(cls, packet: bytes):
decoded = cls(*struct.unpack(b'!lB64s', packet[:69]))
if decoded.magic != _MAGIC:
raise ValueError("invalid magic bytes")
return decoded
PONG_ENCODING = b'!BBL32s4sH'
class SPVPong(NamedTuple):
protocol_version: int
flags: int
height: int
tip: bytes
source_address_raw: bytes
country: int
def encode(self):
return struct.pack(PONG_ENCODING, *self)
@staticmethod
def encode_address(address: str):
return bytes(int(b) for b in address.split("."))
@classmethod
def make(cls, flags: int, height: int, tip: bytes, source_address: str, country: str) -> bytes:
return SPVPong(
PROTOCOL_VERSION, flags, height, tip,
cls.encode_address(source_address),
country_str_to_int(country)
).encode()
@classmethod
def make_sans_source_address(cls, flags: int, height: int, tip: bytes, country: str) -> Tuple[bytes, bytes]:
pong = cls.make(flags, height, tip, '0.0.0.0', country)
return pong[:38], pong[42:]
@classmethod
def decode(cls, packet: bytes):
return cls(*struct.unpack(PONG_ENCODING, packet[:44]))
@property
def available(self) -> bool:
return (self.flags & 0b00000001) > 0
@property
def ip_address(self) -> str:
return ".".join(map(str, self.source_address_raw))
@property
def country_name(self):
return country_int_to_str(self.country)
def __repr__(self) -> str:
return f"SPVPong(external_ip={self.ip_address}, version={self.protocol_version}, " \
f"available={'True' if self.flags & 1 > 0 else 'False'}," \
f" height={self.height}, tip={self.tip[::-1].hex()}, country={self.country_name})"
class SPVServerStatusProtocol(asyncio.DatagramProtocol):
def __init__(
self, height: int, tip: bytes, country: str,
throttle_cache_size: int = 1024, throttle_reqs_per_sec: int = 10,
allow_localhost: bool = False, allow_lan: bool = False
):
super().__init__()
self.transport: Optional[asyncio.transports.DatagramTransport] = None
self._height = height
self._tip = tip
self._flags = 0
self._country = country
self._left_cache = self._right_cache = None
self.update_cached_response()
self._throttle = LRUCache(throttle_cache_size)
self._should_log = LRUCache(throttle_cache_size)
self._min_delay = 1 / throttle_reqs_per_sec
self._allow_localhost = allow_localhost
self._allow_lan = allow_lan
def update_cached_response(self):
self._left_cache, self._right_cache = SPVPong.make_sans_source_address(
self._flags, max(0, self._height), self._tip, self._country
)
def set_unavailable(self):
self._flags &= 0b11111110
self.update_cached_response()
def set_available(self):
self._flags |= 0b00000001
self.update_cached_response()
def set_height(self, height: int, tip: bytes):
self._height, self._tip = height, tip
self.update_cached_response()
def should_throttle(self, host: str):
now = perf_counter()
last_requested = self._throttle.get(host, default=0)
self._throttle[host] = now
if now - last_requested < self._min_delay:
log_cnt = self._should_log.get(host, default=0) + 1
if log_cnt % 100 == 0:
log.warning("throttle spv status to %s", host)
self._should_log[host] = log_cnt
return True
return False
def make_pong(self, host):
return self._left_cache + SPVPong.encode_address(host) + self._right_cache
def datagram_received(self, data: bytes, addr: Tuple[str, int]):
if self.should_throttle(addr[0]):
return
try:
SPVPing.decode(data)
except (ValueError, struct.error, AttributeError, TypeError):
# log.exception("derp")
return
if addr[1] >= 1024 and is_valid_public_ipv4(
addr[0], allow_localhost=self._allow_localhost, allow_lan=self._allow_lan):
self.transport.sendto(self.make_pong(addr[0]), addr)
else:
log.warning("odd packet from %s:%i", addr[0], addr[1])
# ping_count_metric.inc()
def connection_made(self, transport) -> None:
self.transport = transport
def connection_lost(self, exc: Optional[Exception]) -> None:
self.transport = None
def close(self):
if self.transport:
self.transport.close()
class StatusServer:
def __init__(self):
self._protocol: Optional[SPVServerStatusProtocol] = None
async def start(self, height: int, tip: bytes, country: str, interface: str, port: int, allow_lan: bool = False):
if self.is_running:
return
loop = asyncio.get_event_loop()
interface = interface if interface.lower() != 'localhost' else '127.0.0.1'
self._protocol = SPVServerStatusProtocol(
height, tip, country, allow_localhost=interface == '127.0.0.1', allow_lan=allow_lan
)
await loop.create_datagram_endpoint(lambda: self._protocol, (interface, port))
log.info("started udp status server on %s:%i", interface, port)
def stop(self):
if self.is_running:
self._protocol.close()
self._protocol = None
@property
def is_running(self):
return self._protocol is not None
def set_unavailable(self):
if self.is_running:
self._protocol.set_unavailable()
def set_available(self):
if self.is_running:
self._protocol.set_available()
def set_height(self, height: int, tip: bytes):
if self.is_running:
self._protocol.set_height(height, tip)
class SPVStatusClientProtocol(asyncio.DatagramProtocol):
def __init__(self, responses: asyncio.Queue):
super().__init__()
self.transport: Optional[asyncio.transports.DatagramTransport] = None
self.responses = responses
self._ping_packet = SPVPing.make()
def datagram_received(self, data: bytes, addr: Tuple[str, int]):
try:
self.responses.put_nowait(((addr, perf_counter()), SPVPong.decode(data)))
except (ValueError, struct.error, AttributeError, TypeError, RuntimeError):
return
def connection_made(self, transport) -> None:
self.transport = transport
def connection_lost(self, exc: Optional[Exception]) -> None:
self.transport = None
log.info("closed udp spv server selection client")
def ping(self, server: Tuple[str, int]):
self.transport.sendto(self._ping_packet, server)
def close(self):
# log.info("close udp client")
if self.transport:
self.transport.close()
+1 -1
View File
@@ -1,3 +1,3 @@
# need this to avoid circular import
PROTOCOL_MIN = (0, 54, 0)
PROTOCOL_MAX = (0, 199, 0)
PROTOCOL_MAX = (0, 99, 0)
+12 -41
View File
@@ -272,31 +272,16 @@ class Output(InputOutput):
def id(self):
return self.ref.id
@property
def is_pubkey_hash(self):
return 'pubkey_hash' in self.script.values
@property
def pubkey_hash(self):
return self.script.values['pubkey_hash']
@property
def is_script_hash(self):
return 'script_hash' in self.script.values
@property
def script_hash(self):
return self.script.values['script_hash']
@property
def has_address(self):
return self.is_pubkey_hash or self.is_script_hash
return 'pubkey_hash' in self.script.values
def get_address(self, ledger):
if self.is_pubkey_hash:
return ledger.hash160_to_address(self.pubkey_hash)
elif self.is_script_hash:
return ledger.hash160_to_script_address(self.script_hash)
return ledger.hash160_to_address(self.pubkey_hash)
def get_estimator(self, ledger):
return OutputEffectiveAmountEstimator(ledger, self)
@@ -305,10 +290,6 @@ class Output(InputOutput):
def pay_pubkey_hash(cls, amount, pubkey_hash):
return cls(amount, OutputScript.pay_pubkey_hash(pubkey_hash))
@classmethod
def pay_script_hash(cls, amount, pubkey_hash):
return cls(amount, OutputScript.pay_script_hash(pubkey_hash))
@classmethod
def deserialize_from(cls, stream):
return cls(
@@ -558,7 +539,6 @@ class Transaction:
height: int = -2, position: int = -1, julian_day: int = None) -> None:
self._raw = raw
self._raw_sans_segwit = None
self._raw_outputs = None
self.is_segwit_flag = 0
self.witnesses: List[bytes] = []
self.ref = TXRefMutable(self)
@@ -620,7 +600,6 @@ class Transaction:
def _reset(self):
self._raw = None
self._raw_sans_segwit = None
self._raw_outputs = None
self.ref.reset()
@property
@@ -714,7 +693,9 @@ class Transaction:
stream.write_compact_size(len(self._inputs))
for txin in self._inputs:
txin.serialize_to(stream)
self._serialize_outputs(stream)
stream.write_compact_size(len(self._outputs))
for txout in self._outputs:
txout.serialize_to(stream)
stream.write_uint32(self.locktime)
return stream.get_bytes()
@@ -728,19 +709,13 @@ class Transaction:
txin.serialize_to(stream, txin.txo_ref.txo.script.source)
else:
txin.serialize_to(stream, b'')
self._serialize_outputs(stream)
stream.write_compact_size(len(self._outputs))
for txout in self._outputs:
txout.serialize_to(stream)
stream.write_uint32(self.locktime)
stream.write_uint32(self.signature_hash_type(1)) # signature hash type: SIGHASH_ALL
return stream.get_bytes()
def _serialize_outputs(self, stream):
if self._raw_outputs is None:
self._raw_outputs = BCDataStream()
self._raw_outputs.write_compact_size(len(self._outputs))
for txout in self._outputs:
txout.serialize_to(self._raw_outputs)
stream.write(self._raw_outputs.get_bytes())
def _deserialize(self):
if self._raw is not None:
stream = BCDataStream(self._raw)
@@ -869,7 +844,6 @@ class Transaction:
return hash_type
async def sign(self, funding_accounts: Iterable['Account']):
self._reset()
ledger, wallet = self.ensure_all_have_same_ledger_and_wallet(funding_accounts)
for i, txi in enumerate(self._inputs):
assert txi.script is not None
@@ -925,18 +899,15 @@ class Transaction:
@classmethod
def support(cls, claim_name: str, claim_id: str, amount: int, holding_address: str,
funding_accounts: List['Account'], change_account: 'Account', signing_channel: Output = None,
comment: str = None):
funding_accounts: List['Account'], change_account: 'Account', signing_channel: Output = None):
ledger, _ = cls.ensure_all_have_same_ledger_and_wallet(funding_accounts, change_account)
if signing_channel is not None or comment is not None:
if signing_channel is not None:
support = Support()
if comment is not None:
support.comment = comment
support.emoji = '👍'
support_output = Output.pay_support_data_pubkey_hash(
amount, claim_name, claim_id, support, ledger.address_to_hash160(holding_address)
)
if signing_channel is not None:
support_output.sign(signing_channel, b'placeholder txid:nout')
support_output.sign(signing_channel, b'placeholder txid:nout')
else:
support_output = Output.pay_support_pubkey_hash(
amount, claim_name, claim_id, ledger.address_to_hash160(holding_address)
+1 -1
View File
@@ -35,7 +35,7 @@ class WalletServerPayer:
if not address or not amount:
continue
if not self.ledger.is_pubkey_address(address):
if not self.ledger.is_valid_address(address):
self._on_payment_controller.add_error(ServerPaymentInvalidAddressError(address))
continue
+1 -1
View File
@@ -64,7 +64,7 @@ async def checkcontrolling(daemon: Daemon, db: SQLDB):
if __name__ == '__main__':
if len(sys.argv) != 3:
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
+177
View File
@@ -0,0 +1,177 @@
import os
import time
import textwrap
import argparse
import asyncio
import logging
from concurrent.futures.process import ProcessPoolExecutor
from lbry.wallet.server.db.reader import search_to_bytes, initializer, _get_claims, interpolate
from lbry.wallet.ledger import MainNetLedger
log = logging.getLogger(__name__)
log.addHandler(logging.StreamHandler())
log.setLevel(logging.CRITICAL)
DEFAULT_ANY_TAGS = [
'blockchain',
'news',
'learning',
'technology',
'automotive',
'economics',
'food',
'science',
'art',
'nature'
]
COMMON_AND_RARE = [
'gaming',
'ufos'
]
COMMON_AND_RARE2 = [
'city fix',
'gaming'
]
RARE_ANY_TAGS = [
'city fix',
'ufos',
]
CITY_FIX = [
'city fix'
]
MATURE_TAGS = [
'porn',
'nsfw',
'mature',
'xxx'
]
ORDER_BY = [
[
"trending_global",
"trending_mixed",
],
[
"release_time"
],
[
"effective_amount"
]
]
def get_args(limit=20):
args = []
any_tags_combinations = [DEFAULT_ANY_TAGS, COMMON_AND_RARE, RARE_ANY_TAGS, COMMON_AND_RARE2, CITY_FIX, []]
not_tags_combinations = [MATURE_TAGS, []]
for no_fee in [False, True]:
for claim_type in [None, 'stream', 'channel']:
for no_totals in [True]:
for offset in [0, 100]:
for any_tags in any_tags_combinations:
for not_tags in not_tags_combinations:
for order_by in ORDER_BY:
kw = {
'order_by': order_by,
'offset': offset,
'limit': limit,
'no_totals': no_totals
}
if not_tags:
kw['not_tags'] = not_tags
if any_tags:
kw['any_tags'] = any_tags
if claim_type:
kw['claim_type'] = claim_type
if no_fee:
kw['fee_amount'] = 0
args.append(kw)
print(f"-- Trying {len(args)} argument combinations")
return args
def _search(kwargs):
start = time.perf_counter()
error = None
try:
search_to_bytes(kwargs)
except Exception as err:
error = str(err)
return time.perf_counter() - start, kwargs, error
async def search(executor, kwargs):
return await asyncio.get_running_loop().run_in_executor(
executor, _search, kwargs
)
async def main(db_path, max_query_time):
args = dict(initializer=initializer, initargs=(log, db_path, MainNetLedger, 0.25))
workers = max(os.cpu_count(), 4)
log.info(f"using {workers} reader processes")
query_executor = ProcessPoolExecutor(workers, **args)
tasks = [search(query_executor, constraints) for constraints in get_args()]
try:
results = await asyncio.gather(*tasks)
query_times = [
{
'sql': interpolate(*_get_claims("""
claimtrie.claim_hash as is_controlling,
claimtrie.last_take_over_height,
claim.claim_hash, claim.txo_hash,
claim.claims_in_channel,
claim.height, claim.creation_height,
claim.activation_height, claim.expiration_height,
claim.effective_amount, claim.support_amount,
claim.trending_group, claim.trending_mixed,
claim.trending_local, claim.trending_global,
claim.short_url, claim.canonical_url,
claim.channel_hash, channel.txo_hash AS channel_txo_hash,
channel.height AS channel_height, claim.signature_valid
""", **constraints)),
'duration': ts,
'error': error
}
for ts, constraints, error in results
]
errored = [query_info for query_info in query_times if query_info['error']]
errors = {str(query_info['error']): [] for query_info in errored}
for error in errored:
errors[str(error['error'])].append(error['sql'])
slow = [
query_info for query_info in query_times
if not query_info['error'] and query_info['duration'] > (max_query_time / 2.0)
]
fast = [
query_info for query_info in query_times
if not query_info['error'] and query_info['duration'] <= (max_query_time / 2.0)
]
print(f"-- {len(fast)} queries were fast")
slow.sort(key=lambda query_info: query_info['duration'], reverse=True)
print(f"-- Failing queries:")
for error in errors:
print(f"-- Failure: \"{error}\"")
for failing_query in errors[error]:
print(f"{textwrap.dedent(failing_query)};\n")
print()
print(f"-- Slow queries:")
for slow_query in slow:
print(f"-- Query took {slow_query['duration']}\n{textwrap.dedent(slow_query['sql'])};\n")
finally:
query_executor.shutdown()
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--db_path', dest='db_path', default=os.path.expanduser('~/claims.db'), type=str)
parser.add_argument('--max_time', dest='max_time', default=0.25, type=float)
args = parser.parse_args()
db_path = args.db_path
max_query_time = args.max_time
asyncio.run(main(db_path, max_query_time))
-25
View File
@@ -13,7 +13,6 @@ from lbry.extras.cli import set_kwargs, get_argument_parser
from lbry.extras.daemon.daemon import (
Daemon, jsonrpc_dumps_pretty, encode_pagination_doc
)
from tests.integration.other.test_comment_commands import MockedCommentServer
from lbry.extras.daemon.json_response_encoder import (
encode_tx_doc, encode_txo_doc, encode_account_doc, encode_file_doc,
encode_wallet_doc
@@ -67,10 +66,6 @@ class Examples(CommandTestCase):
async def asyncSetUp(self):
await super().asyncSetUp()
self.daemon.conf.comment_server = 'http://localhost:2903/api'
self.comment_server = MockedCommentServer(2903)
await self.comment_server.start()
self.addCleanup(self.comment_server.stop)
self.recorder = ExampleRecorder(self)
async def play(self):
@@ -365,26 +360,6 @@ class Examples(CommandTestCase):
await self.daemon.jsonrpc_comment_abandon(reply['comment_id'])
# collections
collection = await r(
'Create a collection of one stream',
'collection', 'create',
'--name=tom', '--bid=1.0',
f'--channel_id={channel_id}',
f'--claims={stream_id}'
)
await self.on_transaction_dict(collection)
await self.generate(1)
await self.on_transaction_dict(collection)
await r(
'List collections',
'collection', 'list',
'--resolve', '--resolve_claims=1',
)
# files
file_list_result = (await r(
+62
View File
@@ -0,0 +1,62 @@
import uvloop, asyncio, time, sys, logging
from concurrent.futures import ProcessPoolExecutor
from lbry.wallet.server.db import reader
from lbry.wallet.server.metrics import calculate_avg_percentiles
db_path = '../../../lbryconf/wallet-server/claims.db'
default_query_timout = 0.25
log = logging.getLogger(__name__)
log.addHandler(logging.StreamHandler())
async def run_times(executor, iterations, show=True):
start = time.perf_counter()
timings = await asyncio.gather(*(asyncio.get_running_loop().run_in_executor(
executor, reader.search_to_bytes, {
'no_totals': True,
'offset': 0,
'limit': 20,
'any_tags': [
'ufos', 'city fix'
],
'not_tags': [
'porn', 'mature', 'xxx', 'nsfw'
],
'order_by': [
'release_time'
]
}
) for _ in range(iterations)))
timings = [r[1]['execute_query'][0]['total'] for r in timings]
total = int((time.perf_counter() - start) * 100)
if show:
avg = sum(timings)/len(timings)
print(f"{iterations:4}: {total}ms total concurrent, {len(timings)*avg*1000:.3f}s total sequential (avg*runs)")
print(f" {total/len(timings):.1f}ms/query concurrent (total/runs)")
print(f" {avg:.1f}ms/query actual average (sum(queries)/runs)")
stats = calculate_avg_percentiles(timings)
print(f" min: {stats[1]}, 5%: {stats[2]}, 25%: {stats[3]}, 50%: {stats[4]}, 75%: {stats[5]}, 95%: {stats[6]}, max: {stats[7]}")
sys.stdout.write(' sample:')
for i, t in zip(range(10), timings[::-1]):
sys.stdout.write(f' {t}ms')
print(' ...\n' if len(timings) > 10 else '\n')
async def main():
executor = ProcessPoolExecutor(
4, initializer=reader.initializer, initargs=(log, db_path, 'mainnet', 1.0, True)
)
#await run_times(executor, 4, show=False)
#await run_times(executor, 1)
await run_times(executor, 2**3)
await run_times(executor, 2**5)
await run_times(executor, 2**7)
#await run_times(executor, 2**9)
#await run_times(executor, 2**11)
#await run_times(executor, 2**13)
executor.shutdown(True)
if __name__ == '__main__':
uvloop.install()
asyncio.run(main())
+273
View File
@@ -0,0 +1,273 @@
#!/usr/bin/env python
import asyncio
import json
import logging
import pickle
import signal
import sqlite3
import time
from os import path
from pprint import pprint
from urllib.parse import unquote
from aioupnp import upnp, fault as upnpfault
from aiohttp import web
from lbry.wallet.network import ClientSession
from lbry.schema.result import Outputs
from lbry.wallet.transaction import Transaction
from binascii import hexlify, unhexlify
from lbry.dht import node, peer
log = logging.getLogger("lbry")
log.addHandler(logging.StreamHandler())
log.setLevel(logging.INFO)
async def main():
data_dir = "/home/grin/code/lbry/sdk"
state_dir = data_dir + '/nodestate/'
loop = asyncio.get_event_loop()
try:
loop.add_signal_handler(signal.SIGINT, shutdown)
loop.add_signal_handler(signal.SIGTERM, shutdown)
except NotImplementedError:
pass # Not implemented on Windows
db = sqlite3.connect(data_dir + "/tracker.sqlite3")
db.execute('CREATE TABLE IF NOT EXISTS announce (local_id TEXT, hash TEXT, node_id TEXT, ip TEXT, port INT, timestamp INT)')
db.execute('CREATE UNIQUE INDEX IF NOT EXISTS node_id_hash_idx ON announce (node_id, hash)')
spv_host = 'spv13.lbry.com'
wallet_client = ClientSession(network=None, server=(spv_host, 50001))
await wallet_client.create_connection()
asyncio.create_task(run_web_api(loop, db, wallet_client))
num_nodes = 128
u = await upnp.UPnP.discover()
external_ip = await u.get_external_ip()
try:
nodes = await start_nodes(loop, num_nodes, external_ip, state_dir)
await asyncio.gather(*map(lambda n: n.started_listening.wait(), nodes), loop=loop)
print("joined")
queue = asyncio.Queue(maxsize=100*num_nodes)
for n in nodes:
asyncio.create_task(drain_events(n, queue))
while True:
(n, node_id, ip, method, args) = await queue.get()
local_node_id = bytes.hex(n.protocol.node_id)
if method != b'store':
# print(f"{local_node_id[:8]}: {method} from {bytes.hex(node_id)} ({ip})")
continue
if len(args)< 5:
print(f'malformed args to Store')
pprint(args)
continue
blob_hash, token, port, original_publisher_id, age = args[:5]
print(f"STORE to {local_node_id[:8]} from {bytes.hex(node_id)[:8]} ({ip}) for blob {bytes.hex(blob_hash)[:8]}")
try:
cur = db.cursor()
cur.execute(
'''
INSERT INTO announce (local_id, hash, node_id, ip, port, timestamp) VALUES (?,?,?,?,?,?)
ON CONFLICT (node_id, hash) DO UPDATE SET
local_id=excluded.local_id, ip=excluded.ip, port=excluded.port, timestamp=excluded.timestamp
''',
(local_node_id, bytes.hex(blob_hash), bytes.hex(node_id), ip, port, int(time.time()))
)
db.commit()
cur.close()
except sqlite3.Error as err:
print("failed sqlite insert", err)
finally:
print("shutting down")
for n in nodes:
node_id = bytes.hex(n.protocol.node_id)
n.stop()
# print(f'deleting upnp port mapping {n.protocol.udp_port}')
try:
await u.delete_port_mapping(n.protocol.udp_port, "UDP")
except upnpfault.UPnPError:
pass
state = n.get_state()
# keep existing rt if there is one
if len(state.routing_table_peers) == 0 and path.exists(state_dir + node_id):
with open(state_dir + node_id, 'rb') as f:
existing_state = pickle.load(f)
if len(existing_state.routing_table_peers) > 0:
state.routing_table_peers = existing_state.routing_table_peers
print(f'rt empty on save, but old rt was recovered ({len(state.routing_table_peers)} peers)')
with open(state_dir + node_id, 'wb') as f:
# pprint(state.routing_table_peers)
# pprint(state.datastore)
print(f'{node_id[:8]}: saved {len(state.routing_table_peers)} rt peers, {len(state.datastore)} in store')
pickle.dump(state, f)
await wallet_client.close()
db.close()
class ShutdownErr(BaseException):
pass
def shutdown():
print("got interrupt signal...")
raise ShutdownErr()
def make_node_id(i: int, n: int) -> str:
"""
split dht address space into N chunks and return the first id of the i'th chunk
make_node_id(0,n) returns 000...000 for any n
"""
if not 0 <= i < n:
raise ValueError("i must be between 0 (inclusive) and n (exclusive)")
bytes_in_id = 48
return "{0:0{1}x}".format(i * ((2**8)**bytes_in_id // n), bytes_in_id*2)
async def start_nodes(loop, num_nodes, external_ip, state_dir):
start_port = 4445
known_node_urls = [("lbrynet1.lbry.com", 4444), ("lbrynet2.lbry.com", 4444), ("lbrynet3.lbry.com", 4444)]
peer_manager = peer.PeerManager(loop)
nodes = []
for i in range(num_nodes):
node_id = make_node_id(i, num_nodes)
# pprint(node_id)
port = start_port + i
# await u.get_next_mapping(port, "UDP", "lbry dht tracker") # not necessary, i just opened ports in router
n = node.Node(loop, peer_manager, node_id=bytes.fromhex(node_id), external_ip=external_ip,
udp_port=port, internal_udp_port=port, peer_port=3333)
persisted_peers = []
if path.exists(state_dir + node_id):
with open(state_dir + node_id, 'rb') as f:
state = pickle.load(f)
# pprint(state.routing_table_peers)
# pprint(state.datastore)
print(f'{node_id[:8]}: loaded {len(state.routing_table_peers)} rt peers, {len(state.datastore)} in store')
n.load_state(state)
persisted_peers = state.routing_table_peers
# if len(persisted_peers) == 0 and len(state.datastore) > 0:
# peers_to_import = map(lambda p: (p[0], p[1], p[2], p[3]), n.get_state().datastore)
# persisted_peers.extend(peers_to_import)
# print(f'{node_id[:8]}: rt is empty but we recovered {len(state.datastore)} '
# f'peers from the datastore. {len(peers_to_import)} of those were recent enough to import')
n.start("0.0.0.0", known_node_urls, persisted_peers)
nodes.append(n)
return nodes
async def drain_events(n, q):
# print(f'drain started on {bytes.hex(n.protocol.node_id)[:8]}')
while True:
(node_id, ip, method, args) = await n.protocol.event_queue.get()
try:
q.put_nowait((n, node_id, ip, method, args))
except asyncio.QueueFull:
pass
async def run_web_api(loop, db, wallet_client):
try:
app = web.Application(loop=loop)
app['db'] = db
app['wallet_client'] = wallet_client
app.add_routes([
web.get('/', api_handler),
web.get('/seeds/hash/{hash}', seeds_handler),
web.get('/seeds/url/{url}', url_handler),
])
# server = web.Server(api_handler, loop=loop)
# runner = web.ServerRunner(server)
runner = web.AppRunner(app)
await runner.setup()
site = web.TCPSite(runner, 'localhost', 8080)
await site.start()
except Exception as err:
pprint(err)
await runner.cleanup()
async def seeds_handler(request):
blobhash = request.match_info['hash']
db = request.app['db']
try:
cur = db.cursor()
c = cur.execute("""
select count(distinct(node_id)) from announce where hash = ? and timestamp > strftime('%s','now','-1 day')
""", (blobhash,)).fetchone()[0]
cur.close()
return web.Response(text=json.dumps({'seeds': c})+"\n")
except Exception as err:
return web.Response(text=json.dumps({'error': err})+"\n")
async def url_handler(request):
url = unquote(request.match_info['url'])
log.warning(url)
db = request.app['db']
wallet_client = request.app['wallet_client']
try:
sd_hash = await get_sd_hash(wallet_client, url)
if sd_hash is None:
return web.Response(text=json.dumps({'error': 'Could not get sd hash for url', 'url': url})+"\n")
seeds = get_seeds(db, sd_hash)
return web.Response(text=json.dumps({'url': url, 'sd_hash': sd_hash, 'seeds': seeds})+"\n")
except Exception as err:
return web.Response(text=json.dumps({'error': err})+"\n")
def get_seeds(db, blobhash):
cur = db.cursor()
c = cur.execute(
"select count(distinct(node_id)) from announce where hash = ? and timestamp > strftime('%s','now','-1 day')",
(blobhash,)
).fetchone()[0]
cur.close()
return c
async def get_sd_hash(wallet_client, url):
try:
resolved_txos = Outputs.from_base64(await wallet_client.send_request('blockchain.claimtrie.resolve', [url]))
if not resolved_txos.txos:
return None
raw_txs = await wallet_client.send_request('blockchain.transaction.get_batch', [txid for (txid, height) in resolved_txos.txs])
txo_proto = resolved_txos.txos[0]
txid = txo_proto.tx_hash[::-1].hex()
raw_tx_hex, _ = raw_txs[txid]
txo = Transaction(bytes.fromhex(raw_tx_hex)).outputs[txo_proto.nout]
return txo.claim.stream.source.sd_hash
except Exception as err: # claim is not a stream, stream has no source, protobuf err, etc
if isinstance(err, asyncio.CancelledError):
raise err
log.exception("failed to get sd_hash")
return None
async def api_handler(request):
return web.Response(text="tracker OK")
if __name__ == "__main__":
try:
asyncio.run(main())
except ShutdownErr:
pass
+2 -4
View File
@@ -28,9 +28,8 @@ setup(
entry_points={
'console_scripts': [
'lbrynet=lbry.extras.cli:main',
'lbry-hub=lbry.wallet.server.cli:main',
'torba-server=lbry.wallet.server.cli:main',
'orchstr8=lbry.wallet.orchstr8.cli:main',
'lbry-hub-elastic-sync=lbry.wallet.server.db.elasticsearch.sync:run_elastic_sync'
],
},
install_requires=[
@@ -54,8 +53,7 @@ setup(
'coincurve==11.0.0',
'pbkdf2==1.3',
'attrs==18.2.0',
'pylru==1.1.0',
'elasticsearch==7.10.1'
'pylru==1.1.0'
] + PLYVEL,
classifiers=[
'Framework :: AsyncIO',
@@ -114,6 +114,15 @@ class BlockchainReorganizationTests(CommandTestCase):
client_reorg_block_hash = (await self.ledger.headers.hash(208)).decode()
self.assertEqual(client_reorg_block_hash, reorg_block_hash)
# verify the dropped claim is no longer returned by claim search
txos, _, _, _ = await self.ledger.claim_search([], name='hovercraft')
self.assertListEqual(txos, [])
# verify the claim published a block earlier wasn't also reverted
txos, _, _, _ = await self.ledger.claim_search([], name='still-valid')
self.assertEqual(1, len(txos))
self.assertEqual(207, txos[0].tx_ref.height)
# broadcast the claim in a different block
new_txid = await self.blockchain.sendrawtransaction(hexlify(broadcast_tx.raw).decode())
self.assertEqual(broadcast_tx.id, new_txid)
@@ -3,7 +3,6 @@ import tempfile
import logging
import asyncio
from binascii import unhexlify
from unittest import skip
from urllib.request import urlopen
from lbry.error import InsufficientFundsError
@@ -11,7 +10,6 @@ from lbry.extras.daemon.comment_client import verify
from lbry.extras.daemon.daemon import DEFAULT_PAGE_SIZE
from lbry.testcase import CommandTestCase
from lbry.wallet.orchstr8.node import SPVNode
from lbry.wallet.transaction import Transaction
from lbry.wallet.util import satoshis_to_coins as lbc
@@ -74,22 +72,9 @@ class ClaimSearchCommand(ClaimTestCase):
for claim, result in zip(claims, results):
self.assertEqual(
(claim['txid'], self.get_claim_id(claim)),
(result['txid'], result['claim_id']),
f"(expected {claim['outputs'][0]['name']}) != (got {result['name']})"
(result['txid'], result['claim_id'])
)
async def assertListsClaims(self, claims, **kwargs):
kwargs.setdefault('order_by', 'height')
results = await self.claim_list(**kwargs)
self.assertEqual(len(claims), len(results))
for claim, result in zip(claims, results):
self.assertEqual(
(claim['txid'], self.get_claim_id(claim)),
(result['txid'], result['claim_id']),
f"(expected {claim['outputs'][0]['name']}) != (got {result['name']})"
)
@skip("doesnt happen on ES...?")
async def test_disconnect_on_memory_error(self):
claim_ids = [
'0000000000000000000000000000000000000000',
@@ -109,18 +94,6 @@ class ClaimSearchCommand(ClaimTestCase):
with self.assertRaises(ConnectionResetError):
await self.claim_search(claim_ids=claim_ids)
async def test_claim_search_as_reader_server(self):
node2 = SPVNode(self.conductor.spv_module, node_number=2)
current_prefix = self.conductor.spv_node.server.bp.env.es_index_prefix
await node2.start(self.blockchain, extraconf={'ES_MODE': 'reader', 'ES_INDEX_PREFIX': current_prefix})
self.addCleanup(node2.stop)
self.ledger.network.config['default_servers'] = [(node2.hostname, node2.port)]
await self.ledger.stop()
await self.ledger.start()
channel2 = await self.channel_create('@abc', '0.1', allow_duplicate_name=True)
await asyncio.sleep(1) # fixme: find a way to block on the writer
await self.assertFindsClaims([channel2], name='@abc')
async def test_basic_claim_search(self):
await self.create_channel()
channel_txo = self.channel['outputs'][0]
@@ -161,7 +134,6 @@ class ClaimSearchCommand(ClaimTestCase):
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([], channel=f"@inexistent")
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=f"@abc#{self.channel_id}", valid_channel_signature=True)
@@ -185,24 +157,6 @@ class ClaimSearchCommand(ClaimTestCase):
# 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])
# resolve by claim ids
await self.assertFindsClaims([three, two], claim_ids=[self.get_claim_id(three), self.get_claim_id(two)])
await self.assertFindsClaims([three], claim_id=self.get_claim_id(three))
await self.assertFindsClaims([three], claim_id=self.get_claim_id(three), text='*')
async def test_source_filter(self):
channel = await self.channel_create('@abc')
no_source = await self.stream_create('no-source', data=None)
normal = await self.stream_create('normal', data=b'normal')
normal_repost = await self.stream_repost(self.get_claim_id(normal), 'normal-repost')
no_source_repost = await self.stream_repost(self.get_claim_id(no_source), 'no-source-repost')
channel_repost = await self.stream_repost(self.get_claim_id(channel), 'channel-repost')
await self.assertFindsClaims([channel_repost, no_source_repost, no_source, channel], has_no_source=True)
await self.assertListsClaims([no_source, channel], has_no_source=True)
await self.assertFindsClaims([channel_repost, normal_repost, normal, channel], has_source=True)
await self.assertListsClaims([channel_repost, no_source_repost, normal_repost, normal], has_source=True)
await self.assertFindsClaims([channel_repost, no_source_repost, normal_repost, normal, no_source, channel])
await self.assertListsClaims([channel_repost, no_source_repost, normal_repost, normal, no_source, channel])
async def test_pagination(self):
await self.create_channel()
@@ -398,70 +352,6 @@ class ClaimSearchCommand(ClaimTestCase):
limit_claims_per_channel=3, claim_type='stream'
)
async def test_no_duplicates(self):
await self.generate(10)
match = self.assertFindsClaims
claims = []
channels = []
first = await self.stream_create('original_claim0')
second = await self.stream_create('original_claim1')
for i in range(10):
repost_id = self.get_claim_id(second if i % 2 == 0 else first)
channel = await self.channel_create(f'@chan{i}', bid='0.001')
channels.append(channel)
claims.append(
await self.stream_repost(repost_id, f'claim{i}', bid='0.001', channel_id=self.get_claim_id(channel)))
await match([first, second] + channels,
remove_duplicates=True, order_by=['^height'])
await match(list(reversed(channels)) + [second, first],
remove_duplicates=True, order_by=['height'])
# the original claims doesn't show up, so we pick the oldest reposts
await match([channels[0], claims[0], channels[1], claims[1]] + channels[2:],
height='>218',
remove_duplicates=True, order_by=['^height'])
# limit claims per channel, invert order, oldest ones are still chosen
await match(channels[2:][::-1] + [claims[1], channels[1], claims[0], channels[0]],
height='>218', limit_claims_per_channel=1,
remove_duplicates=True, order_by=['height'])
async def test_limit_claims_per_channel_across_sorted_pages(self):
await self.generate(10)
match = self.assertFindsClaims
channel_id = self.get_claim_id(await self.channel_create('@chan0'))
claims = []
first = await self.stream_create('claim0', channel_id=channel_id)
second = await self.stream_create('claim1', channel_id=channel_id)
for i in range(2, 10):
some_chan = self.get_claim_id(await self.channel_create(f'@chan{i}', bid='0.001'))
claims.append(await self.stream_create(f'claim{i}', bid='0.001', channel_id=some_chan))
last = await self.stream_create('claim10', channel_id=channel_id)
await match(
[first, second, claims[0], claims[1]], page_size=4,
limit_claims_per_channel=3, claim_type='stream', order_by=['^height']
)
# second goes out
await match(
[first, claims[0], claims[1], claims[2]], page_size=4,
limit_claims_per_channel=1, claim_type='stream', order_by=['^height']
)
# second appears, from replacement queue
await match(
[second, claims[3], claims[4], claims[5]], page_size=4, page=2,
limit_claims_per_channel=1, claim_type='stream', order_by=['^height']
)
# last is unaffected, as the limit applies per page
await match(
[claims[6], claims[7], last], page_size=4, page=3,
limit_claims_per_channel=1, claim_type='stream', order_by=['^height']
)
# feature disabled on 0 or negative values
for limit in [None, 0, -1]:
await match(
[first, second] + claims + [last],
limit_claims_per_channel=limit, claim_type='stream', order_by=['^height']
)
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()
@@ -475,7 +365,6 @@ class ClaimSearchCommand(ClaimTestCase):
video = await self.stream_create('chrome', file_path=self.video_file_name)
image = await self.stream_create('blank-image', data=self.image_data, suffix='.png')
repost = await self.stream_repost(self.get_claim_id(image))
collection = await self.collection_create('a-collection', claims=[self.get_claim_id(video)])
channel = await self.channel_create()
unknown = self.sout(tx)
@@ -483,7 +372,6 @@ class ClaimSearchCommand(ClaimTestCase):
await self.assertFindsClaims([image, video, octet, unknown], claim_type='stream')
await self.assertFindsClaims([channel], claim_type='channel')
await self.assertFindsClaims([repost], claim_type='repost')
await self.assertFindsClaims([collection], claim_type='collection')
# stream_type
await self.assertFindsClaims([octet, unknown], stream_types=['binary'])
@@ -534,11 +422,10 @@ class ClaimSearchCommand(ClaimTestCase):
await self.assertFindsClaims([claim2], text='autobiography')
await self.assertFindsClaims([claim3], text='history')
await self.assertFindsClaims([claim4], text='conspiracy')
await self.assertFindsClaims([], text='conspiracy+history')
await self.assertFindsClaims([claim4, claim3], text='conspiracy|history')
await self.assertFindsClaims([claim1, claim4, claim2, claim3], text='documentary', order_by=[])
# todo: check why claim1 and claim2 order changed. used to be ...claim1, claim2...
await self.assertFindsClaims([claim4, claim2, claim1, claim3], text='satoshi', order_by=[])
await self.assertFindsClaims([], text='conspiracy AND history')
await self.assertFindsClaims([claim4, claim3], text='conspiracy OR history')
await self.assertFindsClaims([claim1, claim4, claim2, claim3], text='documentary')
await self.assertFindsClaims([claim4, claim1, claim2, claim3], text='satoshi')
claim2 = await self.stream_update(
self.get_claim_id(claim2), clear_tags=True, tags=['cloud'],
@@ -574,62 +461,6 @@ class TransactionCommands(ClaimTestCase):
class TransactionOutputCommands(ClaimTestCase):
async def test_support_with_comment(self):
channel = self.get_claim_id(await self.channel_create('@identity'))
stream = self.get_claim_id(await self.stream_create())
support = await self.support_create(stream, channel_id=channel, comment="nice!")
self.assertEqual(support['outputs'][0]['value']['comment'], "nice!")
r, = await self.txo_list(type='support')
self.assertEqual(r['txid'], support['txid'])
self.assertEqual(r['value']['comment'], "nice!")
await self.support_abandon(txid=support['txid'], nout=0, blocking=True)
support = await self.support_create(stream, comment="anonymously great!")
self.assertEqual(support['outputs'][0]['value']['comment'], "anonymously great!")
r, = await self.txo_list(type='support', is_not_spent=True)
self.assertEqual(r['txid'], support['txid'])
self.assertEqual(r['value']['comment'], "anonymously great!")
async def test_txo_list_resolve_supports(self):
channel = self.get_claim_id(await self.channel_create('@identity'))
stream = self.get_claim_id(await self.stream_create())
support = await self.support_create(stream, channel_id=channel)
r, = await self.txo_list(type='support')
self.assertEqual(r['txid'], support['txid'])
self.assertNotIn('name', r['signing_channel'])
r, = await self.txo_list(type='support', resolve=True)
self.assertIn('name', r['signing_channel'])
self.assertEqual(r['signing_channel']['name'], '@identity')
async def test_txo_list_by_channel_filtering(self):
channel_foo = self.get_claim_id(await self.channel_create('@foo'))
channel_bar = self.get_claim_id(await self.channel_create('@bar'))
stream_a = self.get_claim_id(await self.stream_create('a', channel_id=channel_foo))
stream_b = self.get_claim_id(await self.stream_create('b', channel_id=channel_foo))
stream_c = self.get_claim_id(await self.stream_create('c', channel_id=channel_bar))
stream_d = self.get_claim_id(await self.stream_create('d'))
support_c = await self.support_create(stream_c, '0.3', channel_id=channel_foo)
support_d = await self.support_create(stream_d, '0.3', channel_id=channel_bar)
r = await self.txo_list(type='stream')
self.assertEqual({stream_a, stream_b, stream_c, stream_d}, {c['claim_id'] for c in r})
r = await self.txo_list(type='stream', channel_id=channel_foo)
self.assertEqual({stream_a, stream_b}, {c['claim_id'] for c in r})
r = await self.txo_list(type='support', channel_id=channel_foo)
self.assertEqual({support_c['txid']}, {s['txid'] for s in r})
r = await self.txo_list(type='support', channel_id=channel_bar)
self.assertEqual({support_d['txid']}, {s['txid'] for s in r})
r = await self.txo_list(type='stream', channel_id=[channel_foo, channel_bar])
self.assertEqual({stream_a, stream_b, stream_c}, {c['claim_id'] for c in r})
r = await self.txo_list(type='stream', not_channel_id=channel_foo)
self.assertEqual({stream_c, stream_d}, {c['claim_id'] for c in r})
r = await self.txo_list(type='stream', not_channel_id=[channel_foo, channel_bar])
self.assertEqual({stream_d}, {c['claim_id'] for c in r})
async def test_txo_list_and_sum_filtering(self):
channel_id = self.get_claim_id(await self.channel_create())
self.assertEqual('1.0', lbc(await self.txo_sum(type='channel', is_not_spent=True)))
@@ -1032,22 +863,6 @@ class ClaimCommands(ClaimTestCase):
self.assertEqual('0.0', claims[0]['received_tips'])
self.assertEqual('0.0', claims[1]['received_tips'])
async def stream_update_and_wait(self, claim_id, **kwargs):
tx = await self.daemon.jsonrpc_stream_update(claim_id, **kwargs)
await self.ledger.wait(tx)
async def test_claim_list_pending_edits_ordering(self):
stream5_id = self.get_claim_id(await self.stream_create('five'))
stream4_id = self.get_claim_id(await self.stream_create('four'))
stream3_id = self.get_claim_id(await self.stream_create('three'))
stream2_id = self.get_claim_id(await self.stream_create('two'))
stream1_id = self.get_claim_id(await self.stream_create('one'))
await self.assertClaimList([stream1_id, stream2_id, stream3_id, stream4_id, stream5_id])
await self.stream_update_and_wait(stream4_id, title='foo')
await self.assertClaimList([stream4_id, stream1_id, stream2_id, stream3_id, stream5_id])
await self.stream_update_and_wait(stream3_id, title='foo')
await self.assertClaimList([stream4_id, stream3_id, stream1_id, stream2_id, stream5_id])
class ChannelCommands(CommandTestCase):
@@ -1401,6 +1216,9 @@ class StreamCommands(ClaimTestCase):
self.assertTrue(signed['outputs'][0]['is_channel_signature_valid'])
async def test_repost(self):
sql = self.conductor.spv_node.server.bp.sql
sql.execute(sql.TAG_INDEXES)
await self.channel_create('@goodies', '1.0')
tx = await self.stream_create('newstuff', '1.1', channel_name='@goodies', tags=['foo', 'gaming'])
claim_id = self.get_claim_id(tx)
@@ -1422,6 +1240,7 @@ class StreamCommands(ClaimTestCase):
self.assertItemCount(await self.daemon.jsonrpc_claim_search(all_tags=['foo'], claim_type=['stream', 'repost']), 2)
self.assertItemCount(await self.daemon.jsonrpc_claim_search(not_tags=['foo'], claim_type=['stream', 'repost']), 0)
# "common" / indexed tags work too
self.assertIn('gaming', sql.TAG_INDEXES) # if this breaks, next test doesn't make sense
self.assertItemCount(await self.daemon.jsonrpc_claim_search(any_tags=['gaming'], claim_type=['stream', 'repost']), 2)
self.assertItemCount(await self.daemon.jsonrpc_claim_search(all_tags=['gaming'], claim_type=['stream', 'repost']), 2)
self.assertItemCount(await self.daemon.jsonrpc_claim_search(not_tags=['gaming'], claim_type=['stream', 'repost']), 0)
@@ -1476,11 +1295,6 @@ class StreamCommands(ClaimTestCase):
self.assertEqual(1, blocked['channels'][0]['blocked'])
self.assertTrue(blocked['channels'][0]['channel']['short_url'].startswith('lbry://@filtering#'))
# same search, but details omitted by 'no_totals'
last_result = result
result = await self.out(self.daemon.jsonrpc_claim_search(name='bad_content', no_totals=True))
self.assertEqual(result['items'], last_result['items'])
# search inside channel containing filtered content
result = await self.out(self.daemon.jsonrpc_claim_search(channel='@some_channel'))
filtered = result['blocked']
@@ -1490,11 +1304,6 @@ class StreamCommands(ClaimTestCase):
self.assertEqual(1, filtered['channels'][0]['blocked'])
self.assertTrue(filtered['channels'][0]['channel']['short_url'].startswith('lbry://@filtering#'))
# same search, but details omitted by 'no_totals'
last_result = result
result = await self.out(self.daemon.jsonrpc_claim_search(channel='@some_channel', no_totals=True))
self.assertEqual(result['items'], last_result['items'])
# content was filtered by not_tag before censoring
result = await self.out(self.daemon.jsonrpc_claim_search(channel='@some_channel', not_tags=["good", "bad"]))
self.assertEqual(0, len(result['items']))
@@ -1548,13 +1357,6 @@ class StreamCommands(ClaimTestCase):
self.assertEqual(3, filtered['channels'][0]['blocked'])
self.assertTrue(filtered['channels'][0]['channel']['short_url'].startswith('lbry://@filtering#'))
# same search, but details omitted by 'no_totals'
last_result = result
result = await self.out(
self.daemon.jsonrpc_claim_search(any_tags=['bad-stuff'], order_by=['height'], no_totals=True)
)
self.assertEqual(result['items'], last_result['items'])
# filtered channel should still resolve
result = await self.resolve('lbry://@bad_channel')
self.assertEqual(bad_channel_id, result['claim_id'])
@@ -1999,6 +1801,9 @@ class StreamCommands(ClaimTestCase):
with self.assertRaisesRegex(Exception, "'bid' is a required argument for new publishes."):
await self.daemon.jsonrpc_publish('foo')
with self.assertRaisesRegex(Exception, "'file_path' is a required argument for new publishes."):
await self.daemon.jsonrpc_publish('foo', bid='1.0')
# successfully create stream
with tempfile.NamedTemporaryFile() as file:
file.write(b'hi')
@@ -2041,41 +1846,6 @@ class StreamCommands(ClaimTestCase):
self.assertEqual(claim['value']['languages'], ['uk-UA'])
self.assertEqual(claim['value']['tags'], ['anime'])
# publish a stream with no source
tx5 = await self.publish(
'future-release', bid='0.1', languages='uk-UA', tags=['Anime', 'anime ']
)
self.assertItemCount(await self.daemon.jsonrpc_file_list(), 2)
claim = await self.resolve('lbry://future-release')
self.assertEqual(claim['txid'], tx5['outputs'][0]['txid'])
self.assertNotIn('signing_channel', claim)
self.assertEqual(claim['value']['languages'], ['uk-UA'])
self.assertEqual(claim['value']['tags'], ['anime'])
self.assertNotIn('source', claim['value'])
# change metadata before the release
await self.publish(
'future-release', bid='0.1', tags=['Anime', 'anime ', 'psy-trance'], title='Psy will be over 9000!!!'
)
self.assertItemCount(await self.daemon.jsonrpc_file_list(), 2)
claim = await self.resolve('lbry://future-release')
self.assertEqual(claim['value']['tags'], ['anime', 'psy-trance'])
self.assertEqual(claim['value']['title'], 'Psy will be over 9000!!!')
self.assertNotIn('source', claim['value'])
# update the stream to have a source
tx6 = await self.publish(
'future-release', sd_hash='beef', file_hash='beef',
file_name='blah.mp3', tags=['something-else']
)
claim = await self.resolve('lbry://future-release')
self.assertEqual(claim['txid'], tx6['outputs'][0]['txid'])
self.assertEqual(claim['value']['tags'], ['something-else'])
self.assertEqual(claim['value']['source']['sd_hash'], 'beef')
self.assertEqual(claim['value']['source']['hash'], 'beef')
self.assertEqual(claim['value']['source']['name'], 'blah.mp3')
self.assertEqual(claim['value']['source']['media_type'], 'audio/mpeg')
class SupportCommands(CommandTestCase):
@@ -2163,14 +1933,10 @@ class SupportCommands(CommandTestCase):
self.assertTrue(txs[1]['support_info'][0]['is_tip'])
self.assertTrue(txs[1]['support_info'][0]['is_spent'])
async def test_signed_supports_with_no_change_txo_regression(self):
# reproduces a bug where transactions did not get properly signed
# if there was no change and just a single output
# lbrycrd returned 'the transaction was rejected by network rules.'
async def test_signed_supports(self):
channel_id = self.get_claim_id(await self.channel_create())
stream_id = self.get_claim_id(await self.stream_create())
tx = await self.support_create(stream_id, '7.967601', channel_id=channel_id)
self.assertEqual(len(tx['outputs']), 1) # must be one to reproduce bug
tx = await self.support_create(stream_id, '0.3', channel_id=channel_id)
self.assertTrue(tx['outputs'][0]['is_channel_signature_valid'])
@@ -2212,30 +1978,16 @@ class CollectionCommands(CommandTestCase):
tx = await self.collection_create('radjingles', claims=claim_ids, allow_duplicate_name=True)
claim_id2 = self.get_claim_id(tx)
self.assertItemCount(await self.daemon.jsonrpc_collection_list(), 2)
# with clear_claims
await self.collection_update(claim_id, clear_claims=True, claims=claim_ids[:2])
collections = await self.out(self.daemon.jsonrpc_collection_list())
self.assertEqual(len(collections['items']), 2)
self.assertNotIn('canonical_url', collections['items'][0])
resolved_collections = await self.out(self.daemon.jsonrpc_collection_list(resolve=True))
self.assertIn('canonical_url', resolved_collections['items'][0])
# with replace
await self.collection_update(claim_id, replace=True, claims=claim_ids[::-1][:2], tags=['cool'])
updated = await self.claim_search(claim_id=claim_id)
self.assertEqual(updated[0]['value']['tags'], ['cool'])
self.assertEqual(updated[0]['value']['claims'], claim_ids[::-1][:2])
await self.collection_update(claim_id, replace=True, claims=claim_ids[:4], languages=['en', 'pt-BR'])
updated = await self.resolve(f'radjingles:{claim_id}')
self.assertEqual(updated['value']['claims'], claim_ids[:4])
self.assertNotIn('tags', updated['value'])
self.assertEqual(updated['value']['languages'], ['en', 'pt-BR'])
self.assertEquals(len(collections['items']), 2)
await self.collection_abandon(claim_id)
self.assertItemCount(await self.daemon.jsonrpc_collection_list(), 1)
collections = await self.out(self.daemon.jsonrpc_collection_list(resolve_claims=2))
self.assertEqual(len(collections['items'][0]['claims']), 2)
self.assertEquals(len(collections['items'][0]['claims']), 2)
collections = await self.out(self.daemon.jsonrpc_collection_list(resolve_claims=10))
self.assertEqual(len(collections['items'][0]['claims']), 4)
+38 -61
View File
@@ -4,10 +4,8 @@ import lbry
from unittest.mock import Mock
from lbry.wallet.network import Network
from lbry.wallet.orchstr8 import Conductor
from lbry.wallet.orchstr8.node import SPVNode
from lbry.wallet.rpc import RPCSession
from lbry.wallet.server.udp import StatusServer
from lbry.testcase import IntegrationTestCase, AsyncioTestCase
@@ -24,7 +22,7 @@ class NetworkTests(IntegrationTestCase):
'genesis_hash': self.conductor.spv_node.coin_class.GENESIS_HASH,
'hash_function': 'sha256',
'hosts': {},
'protocol_max': '0.199.0',
'protocol_max': '0.99.0',
'protocol_min': '0.54.0',
'pruning': None,
'description': '',
@@ -34,22 +32,23 @@ class NetworkTests(IntegrationTestCase):
'server_version': lbry.__version__,
'trending_algorithm': 'zscore',
}, await self.ledger.network.get_server_features())
# await self.conductor.spv_node.stop()
await self.conductor.spv_node.stop()
payment_address, donation_address = await self.account.get_addresses(limit=2)
self.conductor.spv_node.server.env.payment_address = payment_address
self.conductor.spv_node.server.env.donation_address = donation_address
self.conductor.spv_node.server.env.description = 'Fastest server in the west.'
self.conductor.spv_node.server.env.daily_fee = '42'
from lbry.wallet.server.session import LBRYElectrumX
LBRYElectrumX.set_server_features(self.conductor.spv_node.server.env)
# await self.ledger.network.on_connected.first
await self.conductor.spv_node.start(
self.conductor.blockchain_node,
extraconf={
'DESCRIPTION': 'Fastest server in the west.',
'PAYMENT_ADDRESS': payment_address,
'DONATION_ADDRESS': donation_address,
'DAILY_FEE': '42'
}
)
await self.ledger.network.on_connected.first
self.assertDictEqual({
'genesis_hash': self.conductor.spv_node.coin_class.GENESIS_HASH,
'hash_function': 'sha256',
'hosts': {},
'protocol_max': '0.199.0',
'protocol_max': '0.99.0',
'protocol_min': '0.54.0',
'pruning': None,
'description': 'Fastest server in the west.',
@@ -66,20 +65,22 @@ class ReconnectTests(IntegrationTestCase):
async def test_multiple_servers(self):
# we have a secondary node that connects later, so
node2 = SPVNode(self.conductor.spv_module, node_number=2)
self.ledger.network.config['default_servers'].append((node2.hostname, node2.port))
await asyncio.wait_for(self.ledger.stop(), timeout=1)
await asyncio.wait_for(self.ledger.start(), timeout=1)
self.ledger.network.session_pool.new_connection_event.clear()
await node2.start(self.blockchain)
self.ledger.network.config['explicit_servers'].append((node2.hostname, node2.port))
self.ledger.network.config['explicit_servers'].reverse()
self.assertEqual(50002, self.ledger.network.client.server[1])
await self.ledger.stop()
await self.ledger.start()
# this is only to speed up the test as retrying would take 4+ seconds
for session in self.ledger.network.session_pool.sessions:
session.trigger_urgent_reconnect.set()
await asyncio.wait_for(self.ledger.network.session_pool.new_connection_event.wait(), timeout=1)
self.assertEqual(2, len(list(self.ledger.network.session_pool.available_sessions)))
self.assertTrue(self.ledger.network.is_connected)
self.assertEqual(50003, self.ledger.network.client.server[1])
switch_event = self.ledger.network.on_connected.first
await node2.stop(True)
self.assertFalse(self.ledger.network.is_connected)
await self.ledger.resolve([], ['derp'])
self.assertEqual(50002, self.ledger.network.client.server[1])
# secondary down, but primary is ok, do not switch! (switches trigger new on_connected events)
with self.assertRaises(asyncio.TimeoutError):
await asyncio.wait_for(switch_event, timeout=1)
async def test_direct_sync(self):
await self.ledger.stop()
@@ -97,13 +98,10 @@ class ReconnectTests(IntegrationTestCase):
async def test_connection_drop_still_receives_events_after_reconnected(self):
address1 = await self.account.receiving.get_or_create_usable_address()
# disconnect and send a new tx, should reconnect and get it
self.ledger.network.client.transport.close()
self.ledger.network.client.connection_lost(Exception())
self.assertFalse(self.ledger.network.is_connected)
await self.ledger.resolve([], 'derp')
sendtxid = await self.blockchain.send_to_address(address1, 1.1337)
# await self.ledger.resolve([], 'derp')
# self.assertTrue(self.ledger.network.is_connected)
await asyncio.wait_for(self.on_transaction_id(sendtxid), 10.0) # mempool
await asyncio.wait_for(self.on_transaction_id(sendtxid), 1.0) # mempool
await self.blockchain.generate(1)
await self.on_transaction_id(sendtxid) # confirmed
self.assertLess(self.ledger.network.client.response_time, 1) # response time properly set lower, we are fine
@@ -125,7 +123,7 @@ class ReconnectTests(IntegrationTestCase):
await self.blockchain.generate(1)
# (this is just so the test doesn't hang forever if it doesn't reconnect)
if not self.ledger.network.is_connected:
await asyncio.wait_for(self.ledger.network.on_connected.first, timeout=10.0)
await asyncio.wait_for(self.ledger.network.on_connected.first, timeout=1.0)
# omg, the burned cable still works! torba is fire proof!
await self.ledger.network.get_transaction(sendtxid)
@@ -138,34 +136,15 @@ class ReconnectTests(IntegrationTestCase):
await self.ledger.network.on_connected.first
self.assertTrue(self.ledger.network.is_connected)
# async def test_online_but_still_unavailable(self):
# # Edge case. See issue #2445 for context
# self.assertIsNotNone(self.ledger.network.session_pool.fastest_session)
# for session in self.ledger.network.session_pool.sessions:
# session.response_time = None
# self.assertIsNone(self.ledger.network.session_pool.fastest_session)
class UDPServerFailDiscoveryTest(AsyncioTestCase):
async def test_wallet_connects_despite_lack_of_udp(self):
conductor = Conductor()
conductor.spv_node.udp_port = '0'
await conductor.start_blockchain()
self.addCleanup(conductor.stop_blockchain)
await conductor.start_spv()
self.addCleanup(conductor.stop_spv)
self.assertFalse(conductor.spv_node.server.bp.status_server.is_running)
await asyncio.wait_for(conductor.start_wallet(), timeout=5)
self.addCleanup(conductor.stop_wallet)
self.assertTrue(conductor.wallet_node.ledger.network.is_connected)
async def test_online_but_still_unavailable(self):
# Edge case. See issue #2445 for context
self.assertIsNotNone(self.ledger.network.session_pool.fastest_session)
for session in self.ledger.network.session_pool.sessions:
session.response_time = None
self.assertIsNone(self.ledger.network.session_pool.fastest_session)
class ServerPickingTestCase(AsyncioTestCase):
async def _make_udp_server(self, port):
s = StatusServer()
await s.start(0, b'\x00' * 32, '127.0.0.1', port)
self.addCleanup(s.stop)
async def _make_fake_server(self, latency=1.0, port=1):
# local fake server with artificial latency
@@ -177,7 +156,6 @@ class ServerPickingTestCase(AsyncioTestCase):
return {'height': 1}
server = await self.loop.create_server(lambda: FakeSession(), host='127.0.0.1', port=port)
self.addCleanup(server.close)
await self._make_udp_server(port)
return '127.0.0.1', port
async def _make_bad_server(self, port=42420):
@@ -186,10 +164,9 @@ class ServerPickingTestCase(AsyncioTestCase):
writer.write(await reader.read())
server = await asyncio.start_server(echo, host='127.0.0.1', port=port)
self.addCleanup(server.close)
await self._make_udp_server(port)
return '127.0.0.1', port
async def _test_pick_fastest(self):
async def test_pick_fastest(self):
ledger = Mock(config={
'default_servers': [
# fast but unhealthy, should be discarded
@@ -205,8 +182,8 @@ class ServerPickingTestCase(AsyncioTestCase):
network = Network(ledger)
self.addCleanup(network.stop)
await network.start()
await asyncio.wait_for(network.on_connected.first, timeout=10)
asyncio.ensure_future(network.start())
await asyncio.wait_for(network.on_connected.first, timeout=1)
self.assertTrue(network.is_connected)
self.assertTupleEqual(network.client.server, ('127.0.0.1', 1337))
self.assertTrue(all([not session.is_closing() for session in network.session_pool.available_sessions]))
@@ -11,9 +11,7 @@ class PurchaseCommandTests(CommandTestCase):
await super().asyncSetUp()
self.merchant_address = await self.blockchain.get_raw_change_address()
async def priced_stream(
self, name='stream', price: Optional[str] = '0.2', currency='LBC', mine=False
) -> Transaction:
async def priced_stream(self, name='stream', price: Optional[str] = '2.0', currency='LBC') -> Transaction:
kwargs = {}
if price and currency:
kwargs = {
@@ -21,8 +19,6 @@ class PurchaseCommandTests(CommandTestCase):
'fee_currency': currency,
'fee_address': self.merchant_address
}
if not mine:
kwargs['claim_address'] = self.merchant_address
file_path = self.create_upload_file(data=b'high value content')
tx = await self.daemon.jsonrpc_stream_create(
name, '0.01', file_path=file_path, **kwargs
@@ -44,7 +40,7 @@ class PurchaseCommandTests(CommandTestCase):
await self.account.release_all_outputs()
buyer_balance = await self.account.get_balance()
merchant_balance = lbc_to_dewies(await self.blockchain.get_balance())
merchant_balance = lbc_to_dewies(str(await self.blockchain.get_balance()))
pre_purchase_count = (await self.daemon.jsonrpc_purchase_list())['total_items']
purchase = await operation()
stream_txo, purchase_txo = stream.outputs[0], purchase.outputs[0]
@@ -60,9 +56,7 @@ class PurchaseCommandTests(CommandTestCase):
self.assertEqual(
await self.account.get_balance(), buyer_balance - (purchase.input_sum-purchase.outputs[2].amount))
self.assertEqual(
str(float(await self.blockchain.get_balance())),
dewies_to_lbc(merchant_balance + purchase_txo.amount)
)
str(await self.blockchain.get_balance()), dewies_to_lbc(merchant_balance + purchase_txo.amount))
purchases = await self.daemon.jsonrpc_purchase_list()
self.assertEqual(purchases['total_items'], pre_purchase_count+1)
@@ -123,13 +117,6 @@ class PurchaseCommandTests(CommandTestCase):
abc_stream = await self.priced_stream('abc')
await self.assertStreamPurchased(abc_stream, lambda: self.daemon.jsonrpc_purchase_create(url='lbry://abc'))
# purchase without valid exchange rate fails
erm = self.daemon.component_manager.get_component('exchange_rate_manager')
for feed in erm.market_feeds:
feed.last_check -= 10_000
with self.assertRaisesRegex(Exception, "Unable to convert 50 from USD to LBC"):
await self.daemon.jsonrpc_purchase_create(claim_id, allow_duplicate_purchase=True)
async def test_purchase_and_transaction_list(self):
self.assertItemCount(await self.daemon.jsonrpc_purchase_list(), 0)
self.assertItemCount(await self.daemon.jsonrpc_transaction_list(), 1)
@@ -186,13 +173,7 @@ class PurchaseCommandTests(CommandTestCase):
await self.generate(1)
await self.ledger.wait(purchase)
# confirm that available and reserved take into account purchase received
self.assertEqual(await self.account.get_detailed_balance(), {
'total': 1099789300,
'available': 1098789300,
'reserved': 1000000,
'reserved_subtotals': {'claims': 1000000, 'supports': 0, 'tips': 0}
})
await self.assertBalance(self.account, '10.987893')
self.assertItemCount(await self.daemon.jsonrpc_utxo_list(), 2)
spend = await self.daemon.jsonrpc_wallet_send('10.5', address2)
@@ -201,12 +182,3 @@ class PurchaseCommandTests(CommandTestCase):
await self.ledger.wait(spend)
await self.assertBalance(self.account, '0.487695')
self.assertItemCount(await self.daemon.jsonrpc_utxo_list(), 1)
async def test_owner_not_required_purchase_own_content(self):
await self.priced_stream(mine=True)
# check that `get` doesn't purchase own claim
balance = await self.account.get_balance()
response = await self.daemon.jsonrpc_get('lbry://stream')
self.assertIsNone(response.content_fee)
self.assertEqual(await self.account.get_balance(), balance)
self.assertItemCount(await self.daemon.jsonrpc_purchase_list(), 0)
@@ -43,32 +43,18 @@ class WalletCommands(CommandTestCase):
)
async def test_wallet_reconnect(self):
status = await self.daemon.jsonrpc_status()
self.assertEqual(len(status['wallet']['servers']), 1)
self.assertEqual(status['wallet']['servers'][0]['port'], 50002)
await self.conductor.spv_node.stop(True)
self.conductor.spv_node.port = 54320
await self.conductor.spv_node.start(self.conductor.blockchain_node)
status = await self.daemon.jsonrpc_status()
self.assertEqual(len(status['wallet']['servers']), 0)
self.assertEqual(len(status['wallet']['servers']), 1)
self.assertEqual(status['wallet']['servers'][0]['port'], 50002)
self.daemon.jsonrpc_settings_set('lbryum_servers', ['localhost:54320'])
await self.daemon.jsonrpc_wallet_reconnect()
status = await self.daemon.jsonrpc_status()
self.assertEqual(len(status['wallet']['servers']), 1)
self.assertEqual(status['wallet']['servers'][0]['port'], 54320)
async def test_sending_to_scripthash_address(self):
self.assertEqual(await self.blockchain.get_balance(), '95.99973580')
await self.assertBalance(self.account, '10.0')
p2sh_address1 = await self.blockchain.get_new_address(self.blockchain.P2SH_SEGWIT_ADDRESS)
tx = await self.account_send('2.0', p2sh_address1)
self.assertEqual(tx['outputs'][0]['address'], p2sh_address1)
self.assertEqual(await self.blockchain.get_balance(), '98.99973580') # +1 lbc for confirm block
await self.assertBalance(self.account, '7.999877')
await self.wallet_send('3.0', p2sh_address1)
self.assertEqual(await self.blockchain.get_balance(), '102.99973580') # +1 lbc for confirm block
await self.assertBalance(self.account, '4.999754')
async def test_balance_caching(self):
account2 = await self.daemon.jsonrpc_account_create("Tip-er")
address2 = await self.daemon.jsonrpc_address_unused(account2.id)
@@ -88,7 +74,7 @@ class WalletCommands(CommandTestCase):
}
self.assertIsNone(ledger._balance_cache.get(self.account.id))
query_count += 2
query_count += 6
self.assertEqual(await wallet_balance(), expected)
self.assertEqual(self.ledger.db.db.query_count, query_count)
self.assertEqual(dict_values_to_lbc(ledger._balance_cache.get(self.account.id))['total'], '10.0')
@@ -112,7 +98,7 @@ class WalletCommands(CommandTestCase):
# on_transaction event reset balance cache
query_count = self.ledger.db.db.query_count
self.assertEqual(await wallet_balance(), expected)
query_count += 1 # only one of the accounts changed
query_count += 3 # only one of the accounts changed
self.assertEqual(dict_values_to_lbc(ledger._balance_cache.get(self.account.id))['total'], '9.979893')
self.assertEqual(dict_values_to_lbc(ledger._balance_cache.get(account2.id))['total'], '10.0')
self.assertEqual(self.ledger.db.db.query_count, query_count)
@@ -4,8 +4,6 @@ import lbry
import lbry.wallet
from lbry.error import ServerPaymentFeeAboveMaxAllowedError
from lbry.wallet.network import ClientSession
from lbry.wallet.server.db.elasticsearch.sync import run as run_sync, make_es_index
from lbry.wallet.server.session import LBRYElectrumX
from lbry.testcase import IntegrationTestCase, CommandTestCase
from lbry.wallet.orchstr8.node import SPVNode
@@ -14,6 +12,9 @@ class TestSessions(IntegrationTestCase):
"""
Tests that server cleans up stale connections after session timeout and client times out too.
"""
LEDGER = lbry.wallet
async def test_session_bloat_from_socket_timeout(self):
await self.conductor.stop_spv()
await self.ledger.stop()
@@ -45,7 +46,7 @@ class TestSessions(IntegrationTestCase):
class TestUsagePayment(CommandTestCase):
async def _test_single_server_payment(self):
async def test_single_server_payment(self):
wallet_pay_service = self.daemon.component_manager.get_component('wallet_server_payments')
wallet_pay_service.payment_period = 1
# only starts with a positive max key fee
@@ -67,125 +68,21 @@ class TestUsagePayment(CommandTestCase):
self.addCleanup(node.stop)
self.daemon.jsonrpc_settings_set('lbryum_servers', [f"{node.hostname}:{node.port}"])
await self.daemon.jsonrpc_wallet_reconnect()
LBRYElectrumX.set_server_features(node.server.env)
features = await self.ledger.network.get_server_features()
self.assertEqual(features["payment_address"], address)
self.assertEqual(features["daily_fee"], "1.1")
with self.assertRaises(ServerPaymentFeeAboveMaxAllowedError):
await asyncio.wait_for(wallet_pay_service.on_payment.first, timeout=30)
node.server.env.daily_fee = "1.0"
node.server.env.payment_address = address
LBRYElectrumX.set_server_features(node.server.env)
# self.daemon.jsonrpc_settings_set('lbryum_servers', [f"{node.hostname}:{node.port}"])
await asyncio.wait_for(wallet_pay_service.on_payment.first, timeout=8)
await node.stop(False)
await node.start(self.blockchain, extraconf={"PAYMENT_ADDRESS": address, "DAILY_FEE": "1.0"})
self.daemon.jsonrpc_settings_set('lbryum_servers', [f"{node.hostname}:{node.port}"])
await self.daemon.jsonrpc_wallet_reconnect()
features = await self.ledger.network.get_server_features()
self.assertEqual(features["payment_address"], address)
self.assertEqual(features["daily_fee"], "1.0")
tx = await asyncio.wait_for(wallet_pay_service.on_payment.first, timeout=30)
tx = await asyncio.wait_for(wallet_pay_service.on_payment.first, timeout=8)
self.assertIsNotNone(await self.blockchain.get_raw_transaction(tx.id)) # verify its broadcasted
self.assertEqual(tx.outputs[0].amount, 100000000)
self.assertEqual(tx.outputs[0].get_address(self.ledger), address)
class TestESSync(CommandTestCase):
async def test_es_sync_utility(self):
for i in range(10):
await self.stream_create(f"stream{i}", bid='0.001')
await self.generate(1)
self.assertEqual(10, len(await self.claim_search(order_by=['height'])))
db = self.conductor.spv_node.server.db
await db.search_index.delete_index()
db.search_index.clear_caches()
self.assertEqual(0, len(await self.claim_search(order_by=['height'])))
await db.search_index.stop()
self.assertTrue(await make_es_index(db.search_index))
async def resync():
await db.search_index.start()
db.search_index.clear_caches()
await run_sync(db.sql._db_path, 1, 0, 0, index_name=db.search_index.index)
self.assertEqual(10, len(await self.claim_search(order_by=['height'])))
await resync()
# this time we will test a migration from unversioned to v1
await db.search_index.sync_client.indices.delete_template(db.search_index.index)
await db.search_index.stop()
self.assertTrue(await make_es_index(db.search_index))
await db.search_index.start()
await resync()
class TestHubDiscovery(CommandTestCase):
async def test_hub_discovery(self):
us_final_node = SPVNode(self.conductor.spv_module, node_number=2)
await us_final_node.start(self.blockchain, extraconf={"COUNTRY": "US"})
self.addCleanup(us_final_node.stop)
final_node_host = f"{us_final_node.hostname}:{us_final_node.port}"
kp_final_node = SPVNode(self.conductor.spv_module, node_number=3)
await kp_final_node.start(self.blockchain, extraconf={"COUNTRY": "KP"})
self.addCleanup(kp_final_node.stop)
kp_final_node_host = f"{kp_final_node.hostname}:{kp_final_node.port}"
relay_node = SPVNode(self.conductor.spv_module, node_number=4)
await relay_node.start(self.blockchain, extraconf={
"COUNTRY": "FR",
"PEER_HUBS": ",".join([kp_final_node_host, final_node_host])
})
relay_node_host = f"{relay_node.hostname}:{relay_node.port}"
self.addCleanup(relay_node.stop)
self.assertEqual(list(self.daemon.conf.known_hubs), [])
self.assertEqual(
self.daemon.ledger.network.client.server_address_and_port,
('127.0.0.1', 50002)
)
# connect to relay hub which will tell us about the final hubs
self.daemon.jsonrpc_settings_set('lbryum_servers', [relay_node_host])
await self.daemon.jsonrpc_wallet_reconnect()
self.assertEqual(
self.daemon.conf.known_hubs.filter(), {
(relay_node.hostname, relay_node.port): {"country": "FR"},
(us_final_node.hostname, us_final_node.port): {}, # discovered from relay but not contacted yet
(kp_final_node.hostname, kp_final_node.port): {}, # discovered from relay but not contacted yet
}
)
self.assertEqual(
self.daemon.ledger.network.client.server_address_and_port, ('127.0.0.1', relay_node.port)
)
# use known_hubs to connect to final US hub
self.daemon.jsonrpc_settings_clear('lbryum_servers')
self.daemon.conf.jurisdiction = "US"
await self.daemon.jsonrpc_wallet_reconnect()
self.assertEqual(
self.daemon.conf.known_hubs.filter(), {
(relay_node.hostname, relay_node.port): {"country": "FR"},
(us_final_node.hostname, us_final_node.port): {"country": "US"},
(kp_final_node.hostname, kp_final_node.port): {"country": "KP"},
}
)
self.assertEqual(
self.daemon.ledger.network.client.server_address_and_port, ('127.0.0.1', us_final_node.port)
)
# connection to KP jurisdiction
self.daemon.conf.jurisdiction = "KP"
await self.daemon.jsonrpc_wallet_reconnect()
self.assertEqual(
self.daemon.ledger.network.client.server_address_and_port, ('127.0.0.1', kp_final_node.port)
)
kp_final_node.server.session_mgr._notify_peer('127.0.0.1:9988')
await self.daemon.ledger.network.on_hub.first
await asyncio.sleep(0.5) # wait for above event to be processed by other listeners
self.assertEqual(
self.daemon.conf.known_hubs.filter(), {
(relay_node.hostname, relay_node.port): {"country": "FR"},
(us_final_node.hostname, us_final_node.port): {"country": "US"},
(kp_final_node.hostname, kp_final_node.port): {"country": "KP"},
('127.0.0.1', 9988): {}
}
)
@@ -9,10 +9,6 @@ from lbry.wallet import Transaction
class FileCommands(CommandTestCase):
def __init__(self, *a, **kw):
super().__init__(*a, **kw)
self.skip_libtorrent = False
async def initialize_torrent(self, tx_to_update=None):
if not hasattr(self, 'seeder_session'):
self.seeder_session = TorrentSession(self.loop, None)
@@ -221,20 +217,6 @@ class FileCommands(CommandTestCase):
file_list = (await self.daemon.jsonrpc_file_list())['items']
self.assertEqual(file_list[0].stream_claim_info.claim.stream.description, claim.stream.description)
async def test_sourceless_content(self):
# claim has no source, then it has one
tx = await self.stream_create('foo', '0.01', data=None)
claim_id = self.get_claim_id(tx)
await self.daemon.jsonrpc_file_delete(claim_name='foo')
response = await self.out(self.daemon.jsonrpc_get('lbry://foo'))
self.assertIn('error', response)
self.assertIn('nothing to download', response['error'])
# source is set (there isn't a way to clear the source field, so we stop here for now)
await self.stream_update(claim_id, data=b'surpriiiiiiiise')
response = await self.out(self.daemon.jsonrpc_get('lbry://foo'))
self.assertNotIn('error', response)
self.assertItemCount(await self.daemon.jsonrpc_file_list(), 1)
async def test_file_list_paginated_output(self):
await self.create_streams_in_range(0, 20)
@@ -372,8 +354,7 @@ class FileCommands(CommandTestCase):
# FAIL: beyond available balance
await self.stream_create(
'expensive', '0.01', data=b'pay me if you can',
fee_currency='LBC', fee_amount='11.0',
fee_address=target_address, claim_address=target_address
fee_currency='LBC', fee_amount='11.0', fee_address=target_address
)
await self.daemon.jsonrpc_file_delete(claim_name='expensive')
response = await self.out(self.daemon.jsonrpc_get('lbry://expensive'))
@@ -383,8 +364,7 @@ class FileCommands(CommandTestCase):
# FAIL: beyond maximum key fee
await self.stream_create(
'maxkey', '0.01', data=b'no pay me, no',
fee_currency='LBC', fee_amount='111.0',
fee_address=target_address, claim_address=target_address
fee_currency='LBC', fee_amount='111.0', fee_address=target_address
)
await self.daemon.jsonrpc_file_delete(claim_name='maxkey')
response = await self.out(self.daemon.jsonrpc_get('lbry://maxkey'))
@@ -396,8 +376,7 @@ class FileCommands(CommandTestCase):
# PASS: purchase is successful
await self.stream_create(
'icanpay', '0.01', data=b'I got the power!',
fee_currency='LBC', fee_amount='1.0',
fee_address=target_address, claim_address=target_address
fee_currency='LBC', fee_amount='1.0', fee_address=target_address
)
await self.daemon.jsonrpc_file_delete(claim_name='icanpay')
await self.assertBalance(self.account, '9.925679')
@@ -410,12 +389,11 @@ class FileCommands(CommandTestCase):
await asyncio.wait_for(self.wait_files_to_complete(), timeout=1)
# check that the fee was received
starting_balance = float(await self.blockchain.get_balance())
starting_balance = await self.blockchain.get_balance()
await self.generate(1)
block_reward_and_claim_fee = 2.0
self.assertEqual(
float(await self.blockchain.get_balance()),
starting_balance + block_reward_and_claim_fee
await self.blockchain.get_balance(), starting_balance + block_reward_and_claim_fee
)
# restart the daemon and make sure the fee is still there
@@ -449,8 +427,7 @@ class FileCommands(CommandTestCase):
await self.stream_create(
'somename', '0.5', data=b'Yes, please',
fee_currency='LBC', fee_amount='1.0',
fee_address=target_address, claim_address=target_address
fee_currency='LBC', fee_amount='1.0', fee_address=target_address
)
self.assertTrue(await self.daemon.jsonrpc_file_delete(claim_name='somename'))
# Assert the fee and bid are subtracted
@@ -464,11 +441,11 @@ class FileCommands(CommandTestCase):
self.assertItemCount(await self.daemon.jsonrpc_file_list(), 1)
# Assert the transaction is recorded to the blockchain
starting_balance = float(await self.blockchain.get_balance())
starting_balance = await self.blockchain.get_balance()
await self.generate(1)
block_reward_and_claim_fee = 2.0
self.assertEqual(
float(await self.blockchain.get_balance()), starting_balance + block_reward_and_claim_fee
await self.blockchain.get_balance(), starting_balance + block_reward_and_claim_fee
)
async def test_null_fee(self):
+3 -5
View File
@@ -7,8 +7,7 @@ from lbry.extras import cli
from lbry.extras.daemon.components import (
DATABASE_COMPONENT, BLOB_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT,
HASH_ANNOUNCER_COMPONENT, FILE_MANAGER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT,
UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, WALLET_SERVER_PAYMENTS_COMPONENT,
LIBTORRENT_COMPONENT
UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, WALLET_SERVER_PAYMENTS_COMPONENT
)
from lbry.extras.daemon.daemon import Daemon
@@ -23,8 +22,7 @@ class CLIIntegrationTest(AsyncioTestCase):
conf.components_to_skip = (
DATABASE_COMPONENT, BLOB_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT,
HASH_ANNOUNCER_COMPONENT, FILE_MANAGER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT,
UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, WALLET_SERVER_PAYMENTS_COMPONENT,
LIBTORRENT_COMPONENT
UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, WALLET_SERVER_PAYMENTS_COMPONENT
)
Daemon.component_attributes = {}
self.daemon = Daemon(conf)
@@ -36,4 +34,4 @@ class CLIIntegrationTest(AsyncioTestCase):
with contextlib.redirect_stdout(actual_output):
cli.main(["--api", "localhost:5299", "status"])
actual_output = actual_output.getvalue()
self.assertIn("is_running", actual_output)
self.assertIn("connection_status", actual_output)
@@ -2,7 +2,6 @@ import re
import time
import typing
from math import ceil
import secrets
from aiohttp import web
@@ -51,7 +50,7 @@ class MockedCommentServer:
self.server = None
self.comments = []
self.reacts = {}
self.index = 0
self.comment_id = 0
self.react_id = 0
@classmethod
@@ -67,15 +66,14 @@ class MockedCommentServer:
return schema
def create_comment(self, claim_id=None, parent_id=None, channel_name=None, channel_id=None, **kwargs):
comment_id = secrets.token_hex(64)
comment_id = self.comment_id
channel_url = 'lbry://' + channel_name + '#' + channel_id if channel_id else None
if parent_id:
parent_comment = list(filter(lambda c: c['comment_id'] == parent_id, self.comments))[0]
claim_id = parent_comment['claim_id']
claim_id = self.comments[self.get_comment_id(parent_id)]['claim_id']
comment = self._create_comment(
comment_id=comment_id,
comment_id=str(comment_id),
channel_name=channel_name,
channel_id=channel_id,
channel_url=channel_url,
@@ -85,14 +83,15 @@ class MockedCommentServer:
**kwargs
)
self.comments.append(comment)
self.comment_id += 1
return self.clean(comment)
def abandon_comment(self, comment_id: str, channel_id: str, **kwargs):
def abandon_comment(self, comment_id: int, channel_id: str, **kwargs):
deleted = False
index = self.get_index_for_comment_id(comment_id)
comment_id = self.get_comment_id(comment_id)
try:
if index >= 0:
self.comments.pop(index)
if self.comments[comment_id]['channel_id'] == channel_id:
self.comments.pop(comment_id)
deleted = True
finally:
return {
@@ -101,41 +100,42 @@ class MockedCommentServer:
}
}
def edit_comment(self, comment_id: str, comment: str, channel_id: str,
def edit_comment(self, comment_id: typing.Union[str, int], comment: str, channel_id: str,
channel_name: str, signature: str, signing_ts: str) -> dict:
edited = False
if self.credentials_are_valid(channel_id, channel_name, signature, signing_ts) \
and self.is_valid_body(comment):
index = self.get_index_for_comment_id(comment_id)
if self.comments[index]['channel_id'] == channel_id:
self.comments[index].update({
comment_id = self.get_comment_id(comment_id)
if self.comments[comment_id]['channel_id'] == channel_id:
self.comments[comment_id].update({
'comment': comment,
'signature': signature,
'signing_ts': signing_ts
})
edited = True
return self.comments[index] if edited else None
return self.comments[comment_id] if edited else None
def hide_comment(self, comment_id: str, signing_ts: str, signature: str):
def hide_comment(self, comment_id: typing.Union[int, str], signing_ts: str, signature: str):
comment_id = self.get_comment_id(comment_id)
if self.is_signable(signature, signing_ts):
self.comments[self.get_index_for_comment_id(comment_id)]['is_hidden'] = True
self.comments[comment_id]['is_hidden'] = True
return True
return False
def pin_comment(
self,
comment_id: str,
comment_id: typing.Union[int, str],
channel_name: str, channel_id: str, remove: bool,
signing_ts: str, signature: str
):
index = self.get_index_for_comment_id(comment_id)
comment_id = self.get_comment_id(comment_id)
if self.is_signable(signature, signing_ts):
if remove:
self.comments[index]['is_pinned'] = False
self.comments[comment_id]['is_pinned'] = False
else:
self.comments[index]['is_pinned'] = True
return self.comments[index]
self.comments[comment_id]['is_pinned'] = True
return self.comments[comment_id]
return False
def hide_comments(self, pieces: list):
@@ -164,15 +164,15 @@ class MockedCommentServer:
'has_hidden_comments': bool(list(filter(lambda x: x['is_hidden'], self.comments)))
}
def get_comment_channel_by_id(self, comment_id: str, **kwargs):
comment = self.comments[self.get_index_for_comment_id(comment_id)]
def get_comment_channel_by_id(self, comment_id: int, **kwargs):
comment = self.comments[self.get_comment_id(comment_id)]
return {
'channel_id': comment['channel_id'],
'channel_name': comment['channel_name'],
}
def get_comments_by_id(self, comment_ids: list):
comments = [self.comments[self.get_index_for_comment_id(cid)] for cid in comment_ids]
comments = [self.comments[self.get_comment_id(cid)] for cid in comment_ids]
return {
'page': 1,
'page_size': len(comment_ids),
@@ -331,18 +331,17 @@ class MockedCommentServer:
return 0 < len(comment) <= 2000
def is_valid_comment_id(self, comment_id: typing.Union[int, str]) -> bool:
if isinstance(comment_id, str):
return True
if isinstance(comment_id, str) and comment_id.isalnum():
comment_id = int(comment_id)
if isinstance(comment_id, int):
return 0 <= comment_id < len(self.comments)
return False
def get_comment_for_id(self, cid: str) -> dict:
return list(filter(lambda c: c['comment_id'] == cid, self.comments))[0]
def get_index_for_comment_id(self, value: str):
for i, dic in enumerate(self.comments):
if dic['comment_id'] == value:
return i
return -1
def get_comment_id(self, cid: typing.Union[int, str, any]) -> int:
if not self.is_valid_comment_id(cid):
raise ValueError('Comment ID is Invalid')
return cid if isinstance(cid, int) else int(cid)
@staticmethod
def claim_id_is_valid(claim_id: str) -> bool:
@@ -385,6 +384,7 @@ class MockedCommentServer:
(parent_id is None or self.is_valid_comment_id(parent_id))
class CommentCommands(CommandTestCase):
async def asyncSetUp(self):
@@ -412,7 +412,7 @@ class CommentCommands(CommandTestCase):
self.assertEqual(stream['claim_id'], comments[0]['claim_id'])
channel2 = (await self.channel_create('@BuffettJimmy'))['outputs'][0]
comment2 = await self.daemon.jsonrpc_comment_create(
await self.daemon.jsonrpc_comment_create(
claim_id=stream['claim_id'],
channel_name=channel2['name'],
comment='Let\'s all go to Margaritaville',
@@ -712,8 +712,7 @@ class CommentCommands(CommandTestCase):
claim_id=claim_id,
channel_id=bee['claim_id']
)
first_comment_id = first_comment['comment_id']
second_comment_id = second_comment['comment_id']
all_comments = [second_comment, first_comment]
comment_list = await self.daemon.jsonrpc_comment_list(claim_id)
self.assertEqual(
{'items', 'page', 'page_size', 'has_hidden_comments', 'total_items', 'total_pages'},
@@ -722,29 +721,29 @@ class CommentCommands(CommandTestCase):
self.assertEqual(comment_list['total_items'], 2)
bee_like_reaction = await self.daemon.jsonrpc_comment_react(
comment_ids=first_comment_id,
comment_ids=first_comment['comment_id'],
channel_id=bee['claim_id'],
channel_name=bee['name'],
react_type='like',
)
moth_like_reaction = await self.daemon.jsonrpc_comment_react(
comment_ids=first_comment_id,
comment_ids=first_comment['comment_id'],
channel_id=moth['claim_id'],
channel_name=moth['name'],
react_type='like',
)
reactions = await self.daemon.jsonrpc_comment_react_list(
comment_ids=first_comment_id,
comment_ids=first_comment['comment_id'],
channel_id=moth['claim_id'],
channel_name=moth['name'],
)
# {'my_reactions': {'0': {'like': 1}}, 'others_reactions': {'0': {'like': 1}}}
self.assertEqual(reactions['my_reactions'][first_comment_id]['like'], 1)
self.assertEqual(reactions['others_reactions'][first_comment_id]['like'], 1)
self.assertEqual(reactions['my_reactions']['0']['like'], 1)
self.assertEqual(reactions['others_reactions']['0']['like'], 1)
bee_dislike_reaction = await self.daemon.jsonrpc_comment_react(
comment_ids=first_comment_id,
comment_ids=first_comment['comment_id'],
channel_id=bee['claim_id'],
channel_name=bee['name'],
react_type='dislike',
@@ -752,30 +751,30 @@ class CommentCommands(CommandTestCase):
)
reactions_after_bee_dislikes = await self.daemon.jsonrpc_comment_react_list(
comment_ids=first_comment_id,
comment_ids=first_comment['comment_id'],
channel_id=moth['claim_id'],
channel_name=moth['name'],
)
# {'my_reactions': {'0': {'like': 1, 'dislike', 0}}, 'others_reactions': {'0': {'like': 0, 'dislike': 1}}}
self.assertEqual(reactions_after_bee_dislikes['my_reactions'][first_comment_id]['like'], 1)
self.assertEqual(reactions_after_bee_dislikes['my_reactions'][first_comment_id]['dislike'], 0)
self.assertEqual(reactions_after_bee_dislikes['others_reactions'][first_comment_id]['dislike'], 1)
self.assertEqual(reactions_after_bee_dislikes['others_reactions'][first_comment_id]['like'], 0)
self.assertEqual(reactions_after_bee_dislikes['my_reactions']['0']['like'], 1)
self.assertEqual(reactions_after_bee_dislikes['my_reactions']['0']['dislike'], 0)
self.assertEqual(reactions_after_bee_dislikes['others_reactions']['0']['dislike'], 1)
self.assertEqual(reactions_after_bee_dislikes['others_reactions']['0']['like'], 0)
only_likes_after_bee_dislikes = await self.daemon.jsonrpc_comment_react_list(
comment_ids=first_comment_id,
comment_ids=first_comment['comment_id'],
channel_id=moth['claim_id'],
channel_name=moth['name'],
react_types='like',
)
self.assertEqual(only_likes_after_bee_dislikes['my_reactions'][first_comment_id]['like'], 1)
self.assertEqual(only_likes_after_bee_dislikes['my_reactions'][first_comment_id]['dislike'], 0)
self.assertEqual(only_likes_after_bee_dislikes['others_reactions'][first_comment_id]['dislike'], 0)
self.assertEqual(only_likes_after_bee_dislikes['others_reactions'][first_comment_id]['like'], 0)
self.assertEqual(only_likes_after_bee_dislikes['my_reactions']['0']['like'], 1)
self.assertEqual(only_likes_after_bee_dislikes['my_reactions']['0']['dislike'], 0)
self.assertEqual(only_likes_after_bee_dislikes['others_reactions']['0']['dislike'], 0)
self.assertEqual(only_likes_after_bee_dislikes['others_reactions']['0']['like'], 0)
bee_un_dislike_reaction = await self.daemon.jsonrpc_comment_react(
comment_ids=first_comment_id,
comment_ids=first_comment['comment_id'],
channel_id=bee['claim_id'],
channel_name=bee['name'],
remove=True,
@@ -783,30 +782,30 @@ class CommentCommands(CommandTestCase):
)
reactions_after_bee_absconds = await self.daemon.jsonrpc_comment_react_list(
comment_ids=first_comment_id,
comment_ids=first_comment['comment_id'],
channel_id=moth['claim_id'],
channel_name=moth['name'],
)
self.assertEqual(reactions_after_bee_absconds['my_reactions'][first_comment_id]['like'], 1)
self.assertNotIn('dislike', reactions_after_bee_absconds['my_reactions'][first_comment_id])
self.assertEqual(reactions_after_bee_absconds['others_reactions'][first_comment_id]['like'], 0)
self.assertNotIn('dislike', reactions_after_bee_absconds['others_reactions'][first_comment_id])
self.assertEqual(reactions_after_bee_absconds['my_reactions']['0']['like'], 1)
self.assertNotIn('dislike', reactions_after_bee_absconds['my_reactions']['0'])
self.assertEqual(reactions_after_bee_absconds['others_reactions']['0']['like'], 0)
self.assertNotIn('dislike', reactions_after_bee_absconds['others_reactions']['0'])
bee_reacts_to_both_comments = await self.daemon.jsonrpc_comment_react(
comment_ids=first_comment_id + ',' + second_comment_id,
comment_ids=first_comment['comment_id'] + ',' + second_comment['comment_id'],
channel_id=bee['claim_id'],
channel_name=bee['name'],
react_type='frozen_tom',
)
reactions_after_double_frozen_tom = await self.daemon.jsonrpc_comment_react_list(
comment_ids=first_comment_id + ',' + second_comment_id,
comment_ids=first_comment['comment_id'] + ',' + second_comment['comment_id'],
channel_id=moth['claim_id'],
channel_name=moth['name'],
)
self.assertEqual(reactions_after_double_frozen_tom['my_reactions'][first_comment_id]['like'], 1)
self.assertNotIn('dislike', reactions_after_double_frozen_tom['my_reactions'][first_comment_id])
self.assertEqual(reactions_after_double_frozen_tom['others_reactions'][first_comment_id]['frozen_tom'], 1)
self.assertEqual(reactions_after_double_frozen_tom['others_reactions'][second_comment_id]['frozen_tom'], 1)
self.assertEqual(reactions_after_double_frozen_tom['my_reactions']['0']['like'], 1)
self.assertNotIn('dislike', reactions_after_double_frozen_tom['my_reactions']['0'])
self.assertEqual(reactions_after_double_frozen_tom['others_reactions']['0']['frozen_tom'], 1)
self.assertEqual(reactions_after_double_frozen_tom['others_reactions']['1']['frozen_tom'], 1)
@@ -1,12 +1,12 @@
import asyncio
import logging
from decimal import Decimal
from lbry.testcase import AsyncioTestCase
from lbry.extras.daemon.exchange_rate_manager import ExchangeRate, ExchangeRateManager, FEEDS, MarketFeed
from lbry.extras.daemon.exchange_rate_manager import ExchangeRate, ExchangeRateManager, FEEDS
class TestExchangeRateManager(AsyncioTestCase):
async def test_exchange_rate_manager(self):
# TODO: re-enable cryptonator.com
# TODO: this uses real exchange rate feeds... update to use mocks
manager = ExchangeRateManager(FEEDS)
manager.start()
self.addCleanup(manager.stop)
@@ -14,32 +14,9 @@ class TestExchangeRateManager(AsyncioTestCase):
self.assertFalse(feed.is_online)
self.assertIsNone(feed.rate)
await manager.wait()
failures = set()
for feed in manager.market_feeds:
if feed.is_online:
self.assertIsInstance(feed.rate, ExchangeRate)
else:
failures.add(feed.name)
self.assertFalse(feed.has_rate)
self.assertLessEqual(len(failures), 1, f"feed failures: {failures}. Please check exchange rate feeds!")
lbc = manager.convert_currency('USD', 'LBC', Decimal('1.0'))
self.assertGreaterEqual(lbc, 2.0)
self.assertLessEqual(lbc, 60.0)
lbc = manager.convert_currency('BTC', 'LBC', Decimal('0.01'))
self.assertGreaterEqual(lbc, 1_000)
self.assertLessEqual(lbc, 20_000)
async def test_it_handles_feed_being_offline(self):
class FakeFeed(MarketFeed):
name = "fake"
url = "http://impossi.bru"
manager = ExchangeRateManager((FakeFeed,))
manager.start()
self.addCleanup(manager.stop)
for feed in manager.market_feeds:
self.assertFalse(feed.is_online)
self.assertIsNone(feed.rate)
await asyncio.wait_for(manager.wait(), 2)
for feed in manager.market_feeds:
self.assertFalse(feed.is_online)
self.assertFalse(feed.has_rate)
self.assertTrue(feed.is_online)
self.assertIsInstance(feed.rate, ExchangeRate)
lbc = manager.convert_currency('USD', 'LBC', Decimal('0.01'))
self.assertGreaterEqual(lbc, 0.01)
self.assertLessEqual(lbc, 10.0)
@@ -15,7 +15,7 @@ class AddressManagement(CommandTestCase):
class SettingsManagement(CommandTestCase):
async def test_settings(self):
self.assertEqual(self.daemon.jsonrpc_settings_get()['lbryum_servers'][0], ('localhost', 50002))
self.assertEqual(self.daemon.jsonrpc_settings_get()['lbryum_servers'][0], ('127.0.0.1', 50001))
setting = self.daemon.jsonrpc_settings_set('lbryum_servers', ['server:50001'])
self.assertEqual(setting['lbryum_servers'][0], ('server', 50001))
-1
View File
@@ -11,7 +11,6 @@ from lbry.extras.daemon.storage import SQLiteStorage
class TestNodePingQueueDiscover(AsyncioTestCase):
TIMEOUT = None # not supported as it advances time
async def test_ping_queue_discover(self):
loop = asyncio.get_event_loop()
loop.set_debug(False)
+25 -26
View File
@@ -10,8 +10,8 @@ class PeerTest(AsyncioTestCase):
self.loop = asyncio.get_event_loop()
self.peer_manager = PeerManager(self.loop)
self.node_ids = [generate_id(), generate_id(), generate_id()]
self.first_contact = make_kademlia_peer(self.node_ids[1], '1.0.0.1', udp_port=1024)
self.second_contact = make_kademlia_peer(self.node_ids[0], '1.0.0.2', udp_port=1024)
self.first_contact = make_kademlia_peer(self.node_ids[1], '1.0.0.1', udp_port=1000)
self.second_contact = make_kademlia_peer(self.node_ids[0], '1.0.0.2', udp_port=1000)
def test_peer_is_good_unknown_peer(self):
# Scenario: peer replied, but caller doesn't know the node_id.
@@ -25,37 +25,36 @@ class PeerTest(AsyncioTestCase):
def test_make_contact_error_cases(self):
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '1.2.3.4', 100000)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '1.2.3.4.5', 1024)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], 'this is not an ip', 1024)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '1.2.3.4.5', 1000)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], 'this is not an ip', 1000)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '1.2.3.4', -1000)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '1.2.3.4', 0)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '1.2.3.4', 1023)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '1.2.3.4', 70000)
self.assertRaises(ValueError, make_kademlia_peer, b'not valid node id', '1.2.3.4', 1024)
self.assertRaises(ValueError, make_kademlia_peer, b'not valid node id', '1.2.3.4', 1000)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '0.0.0.0', 1024)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '10.0.0.1', 1024)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '100.64.0.1', 1024)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '127.0.0.1', 1024)
self.assertIsNotNone(make_kademlia_peer(self.node_ids[1], '127.0.0.1', 1024, allow_localhost=True))
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '192.168.0.1', 1024)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '172.16.0.1', 1024)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '169.254.1.1', 1024)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '192.0.0.2', 1024)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '192.0.2.2', 1024)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '192.88.99.2', 1024)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '198.18.1.1', 1024)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '198.51.100.2', 1024)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '198.51.100.2', 1024)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '203.0.113.4', 1024)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '0.0.0.0', 1000)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '10.0.0.1', 1000)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '100.64.0.1', 1000)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '127.0.0.1', 1000)
self.assertIsNotNone(make_kademlia_peer(self.node_ids[1], '127.0.0.1', 1000, allow_localhost=True))
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '192.168.0.1', 1000)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '172.16.0.1', 1000)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '169.254.1.1', 1000)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '192.0.0.2', 1000)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '192.0.2.2', 1000)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '192.88.99.2', 1000)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '198.18.1.1', 1000)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '198.51.100.2', 1000)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '198.51.100.2', 1000)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '203.0.113.4', 1000)
for i in range(32):
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], f"{224 + i}.0.0.0", 1024)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '255.255.255.255', 1024)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], f"{224 + i}.0.0.0", 1000)
self.assertRaises(ValueError, make_kademlia_peer, self.node_ids[1], '255.255.255.255', 1000)
self.assertRaises(
ValueError, make_kademlia_peer, self.node_ids[1], 'beee:eeee:eeee:eeee:eeee:eeee:eeee:eeef', 1024
ValueError, make_kademlia_peer, self.node_ids[1], 'beee:eeee:eeee:eeee:eeee:eeee:eeee:eeef', 1000
)
self.assertRaises(
ValueError, make_kademlia_peer, self.node_ids[1], '2001:db8::ff00:42:8329', 1024
ValueError, make_kademlia_peer, self.node_ids[1], '2001:db8::ff00:42:8329', 1000
)
def test_is_valid_ipv4(self):
@@ -80,7 +79,7 @@ class PeerTest(AsyncioTestCase):
def test_boolean(self):
self.assertNotEqual(self.first_contact, self.second_contact)
self.assertEqual(
self.second_contact, make_kademlia_peer(self.node_ids[0], '1.0.0.2', udp_port=1024)
self.second_contact, make_kademlia_peer(self.node_ids[0], '1.0.0.2', udp_port=1000)
)
def test_compact_ip(self):
@@ -1,19 +1,11 @@
import unittest
from aiohttp import ClientSession
from aiohttp.test_utils import make_mocked_request as request
from aiohttp.web import HTTPForbidden
from lbry.testcase import AsyncioTestCase
from lbry.conf import Config
from lbry.extras.daemon.security import is_request_allowed as allowed, ensure_request_allowed as ensure
from lbry.extras.daemon.components import (
DATABASE_COMPONENT, BLOB_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT,
HASH_ANNOUNCER_COMPONENT, FILE_MANAGER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT,
UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, WALLET_SERVER_PAYMENTS_COMPONENT,
LIBTORRENT_COMPONENT
)
from lbry.extras.daemon.daemon import Daemon
class TestAllowedOrigin(unittest.TestCase):
@@ -59,38 +51,3 @@ class TestAllowedOrigin(unittest.TestCase):
ensure(request('GET', '/', headers={'Origin': 'hackers.com'}), conf)
self.assertIn("'hackers.com' are not allowed", log.output[0])
self.assertIn("'allowed_origin' limits requests to: 'localhost'", log.output[0])
class TestAccessHeaders(AsyncioTestCase):
async def asyncSetUp(self):
conf = Config(allowed_origin='localhost')
conf.data_dir = '/tmp'
conf.share_usage_data = False
conf.api = 'localhost:5299'
conf.components_to_skip = (
DATABASE_COMPONENT, BLOB_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT,
HASH_ANNOUNCER_COMPONENT, FILE_MANAGER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT,
UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, WALLET_SERVER_PAYMENTS_COMPONENT,
LIBTORRENT_COMPONENT
)
Daemon.component_attributes = {}
self.daemon = Daemon(conf)
await self.daemon.start()
self.addCleanup(self.daemon.stop)
async def test_headers(self):
async with ClientSession() as session:
# OPTIONS
async with session.options('http://localhost:5299') as resp:
self.assertEqual(resp.headers['Access-Control-Allow-Origin'], 'localhost')
self.assertEqual(resp.headers['Access-Control-Allow-Methods'], 'localhost')
self.assertEqual(resp.headers['Access-Control-Allow-Headers'], 'localhost')
# GET
status = {'method': 'status', 'params': []}
async with session.get('http://localhost:5299/lbryapi', json=status) as resp:
self.assertEqual(resp.headers['Access-Control-Allow-Origin'], 'localhost')
self.assertEqual(resp.headers['Access-Control-Allow-Methods'], 'localhost')
self.assertEqual(resp.headers['Access-Control-Allow-Headers'], 'localhost')
@@ -4,8 +4,9 @@ from time import time
from lbry.schema.claim import Claim
from lbry.extras.daemon.exchange_rate_manager import (
ExchangeRate, ExchangeRateManager, CurrencyConversionError,
BittrexUSDFeed, BittrexBTCFeed,
CoinExBTCFeed
LBRYFeed, LBRYBTCFeed,
CryptonatorFeed, CryptonatorBTCFeed,
BittrexFeed,
)
from lbry.testcase import AsyncioTestCase, FakeExchangeRateManager, get_fake_exchange_rate_manager
from lbry.error import InvalidExchangeRateResponseError
@@ -25,25 +26,111 @@ class ExchangeRateTests(AsyncioTestCase):
fee.address = "bRcHraa8bYJZL7vkh5sNmGwPDERFUjGPP9"
manager = get_fake_exchange_rate_manager()
result = manager.convert_currency(fee.currency, "LBC", fee.amount)
self.assertEqual(20.0, result)
self.assertEqual(60.0, result)
def test_missing_feed(self):
fee = Claim().stream.fee
fee.usd = Decimal(1.0)
fee.address = "bRcHraa8bYJZL7vkh5sNmGwPDERFUjGPP9"
manager = FakeExchangeRateManager([BittrexBTCFeed()], {'BTCLBC': 1.0})
manager = FakeExchangeRateManager([LBRYFeed()], {'BTCLBC': 1.0})
with self.assertRaises(CurrencyConversionError):
manager.convert_currency(fee.currency, "LBC", fee.amount)
def test_bittrex_feed_response(self):
feed = BittrexBTCFeed()
def test_lbry_feed_response(self):
feed = LBRYFeed()
out = feed.get_rate_from_response({
"symbol": "LBC-BTC",
"lastTradeRate": "0.00000323",
"bidRate": "0.00000322",
"askRate": "0.00000327"
'data': {
'fresh': 0, 'lbc_usd': 0.05863062523378918,
'lbc_btc': 5.065289549855739e-05, 'btc_usd': 1157.498
},
'success': True,
'error': None
})
self.assertEqual(1.0 / 0.00000323, out)
self.assertEqual(1.0 / 5.065289549855739e-05, out)
with self.assertRaises(InvalidExchangeRateResponseError):
feed.get_rate_from_response({})
with self.assertRaises(InvalidExchangeRateResponseError):
feed.get_rate_from_response({
"success": True,
"result": []
})
def test_lbry_btc_feed_response(self):
feed = LBRYBTCFeed()
out = feed.get_rate_from_response({
'data': {
'fresh': 0, 'lbc_usd': 0.05863062523378918,
'lbc_btc': 5.065289549855739e-05, 'btc_usd': 1157.498
},
'success': True,
'error': None
})
self.assertEqual(1.0 / 1157.498, out)
with self.assertRaises(InvalidExchangeRateResponseError):
feed.get_rate_from_response({})
with self.assertRaises(InvalidExchangeRateResponseError):
feed.get_rate_from_response({
"success": True,
"result": {}
})
def test_cryptonator_lbc_feed_response(self):
feed = CryptonatorFeed()
out = feed.get_rate_from_response({
'ticker': {
'base': 'BTC', 'target': 'LBC', 'price': 23657.44026496,
'volume': '', 'change': -5.59806916,
},
'timestamp': 1507470422,
'success': True,
'error': ""
})
self.assertEqual(23_657.44026496, out)
with self.assertRaises(InvalidExchangeRateResponseError):
feed.get_rate_from_response({})
with self.assertRaises(InvalidExchangeRateResponseError):
feed.get_rate_from_response({
"success": True,
"ticker": {}
})
def test_cryptonator_btc_feed_response(self):
feed = CryptonatorBTCFeed()
out = feed.get_rate_from_response({
'ticker': {
'base': 'BTC', 'target': 'LBC', 'price': 0.00022123,
'volume': '', 'change': -0.00000259,
},
'timestamp': 1507471141,
'success': True,
'error': ''
})
self.assertEqual(0.00022123, out)
with self.assertRaises(InvalidExchangeRateResponseError):
feed.get_rate_from_response({})
with self.assertRaises(InvalidExchangeRateResponseError):
feed.get_rate_from_response({
"success": True,
"ticker": {}
})
def test_bittrex_feed_response(self):
feed = BittrexFeed()
out = feed.get_rate_from_response({
"success": True,
"message": "",
"result": [
{
'Id': 6902471, 'TimeStamp': '2017-02-27T23:41:52.213', 'Quantity': 56.12611239,
"Price": 0.00001621, "Total": 0.00090980, "FillType": "PARTIAL_FILL", "OrderType": "SELL"
},
{
"Id": 6902403, "TimeStamp": "2017-02-27t23:31:40.463", "Quantity": 430.99988180,
"Price": 0.00001592, "Total": 0.00686151, "FillType": "PARTIAL_FILL", "OrderType": "SELL"
}
]
})
self.assertEqual(1.0 / ((0.00090980+0.00686151) / (56.12611239+430.99988180)), out)
with self.assertRaises(InvalidExchangeRateResponseError):
feed.get_rate_from_response({})
with self.assertRaises(InvalidExchangeRateResponseError):
@@ -53,7 +140,7 @@ class ExchangeRateTests(AsyncioTestCase):
})
class BadMarketFeed(BittrexUSDFeed):
class BadMarketFeed(LBRYFeed):
def get_response(self):
raise InvalidExchangeRateResponseError(self.name, 'bad stuff')
@@ -64,20 +151,5 @@ class ExchangeRateManagerTests(AsyncioTestCase):
async def test_get_rate_failure_retrieved(self):
manager = ExchangeRateManager([BadMarketFeed])
manager.start()
await manager.wait()
for feed in manager.market_feeds: # no rate but it tried
self.assertFalse(feed.has_rate)
self.assertTrue(feed.event.is_set())
await asyncio.sleep(1)
self.addCleanup(manager.stop)
async def test_median_rate_used(self):
manager = ExchangeRateManager([BittrexBTCFeed, CoinExBTCFeed])
for feed in manager.market_feeds:
feed.last_check = time()
bittrex, coinex = manager.market_feeds
bittrex.rate = ExchangeRate(bittrex.market, 1.0, time())
coinex.rate = ExchangeRate(coinex.market, 2.0, time())
coinex.rate = ExchangeRate(coinex.market, 3.0, time())
self.assertEqual(14.0, manager.convert_currency("BTC", "LBC", Decimal(7.0)))
coinex.rate.spot = 4.0
self.assertEqual(17.5, manager.convert_currency("BTC", "LBC", Decimal(7.0)))
+2 -22
View File
@@ -43,36 +43,19 @@ class TestReflector(AsyncioTestCase):
self.stream_manager.config.reflect_streams = False
self.stream = await self.stream_manager.create(file_path)
async def _test_reflect_stream(self, response_chunk_size=50, partial_needs=False):
reflector = ReflectorServer(self.server_blob_manager, response_chunk_size=response_chunk_size,
partial_needs=partial_needs)
async def _test_reflect_stream(self, response_chunk_size):
reflector = ReflectorServer(self.server_blob_manager, response_chunk_size=response_chunk_size)
reflector.start_server(5566, '127.0.0.1')
if partial_needs:
server_blob = self.server_blob_manager.get_blob(self.stream.sd_hash)
client_blob = self.blob_manager.get_blob(self.stream.sd_hash)
with client_blob.reader_context() as handle:
server_blob.set_length(client_blob.get_length())
writer = server_blob.get_blob_writer('nobody', 0)
writer.write(handle.read())
self.server_blob_manager.blob_completed(server_blob)
await reflector.started_listening.wait()
self.addCleanup(reflector.stop_server)
self.assertEqual(0, self.stream.reflector_progress)
sent = await self.stream.upload_to_reflector('127.0.0.1', 5566)
self.assertEqual(100, self.stream.reflector_progress)
if partial_needs:
self.assertFalse(self.stream.is_fully_reflected)
send_more = await self.stream.upload_to_reflector('127.0.0.1', 5566)
self.assertGreater(len(send_more), 0)
sent.extend(send_more)
sent.append(self.stream.sd_hash)
self.assertSetEqual(
set(sent),
set(map(lambda b: b.blob_hash,
self.stream.descriptor.blobs[:-1] + [self.blob_manager.get_blob(self.stream.sd_hash)]))
)
send_more = await self.stream.upload_to_reflector('127.0.0.1', 5566)
self.assertEqual(len(send_more), 0)
self.assertTrue(self.stream.is_fully_reflected)
server_sd_blob = self.server_blob_manager.get_blob(self.stream.sd_hash)
self.assertTrue(server_sd_blob.get_is_verified())
@@ -88,9 +71,6 @@ class TestReflector(AsyncioTestCase):
async def test_reflect_stream(self):
return await asyncio.wait_for(self._test_reflect_stream(response_chunk_size=50), 3, loop=self.loop)
async def test_reflect_stream_but_reflector_changes_its_mind(self):
return await asyncio.wait_for(self._test_reflect_stream(partial_needs=True), 3, loop=self.loop)
async def test_reflect_stream_small_response_chunks(self):
return await asyncio.wait_for(self._test_reflect_stream(response_chunk_size=30), 3, loop=self.loop)
-55
View File
@@ -47,26 +47,6 @@ class ConfigurationTests(unittest.TestCase):
c.persisted = {}
self.assertEqual(c.test_str, 'the default')
def test_is_set(self):
c = TestConfig()
self.assertEqual(c.test_str, 'the default')
self.assertFalse(TestConfig.test_str.is_set(c))
c.test_str = 'new value'
self.assertEqual(c.test_str, 'new value')
self.assertTrue(TestConfig.test_str.is_set(c))
def test_is_set_to_default(self):
c = TestConfig()
self.assertEqual(TestConfig.test_str.default, 'the default')
self.assertFalse(TestConfig.test_str.is_set(c))
self.assertFalse(TestConfig.test_str.is_set_to_default(c))
c.test_str = 'new value'
self.assertTrue(TestConfig.test_str.is_set(c))
self.assertFalse(TestConfig.test_str.is_set_to_default(c))
c.test_str = 'the default'
self.assertTrue(TestConfig.test_str.is_set(c))
self.assertTrue(TestConfig.test_str.is_set_to_default(c))
def test_arguments(self):
parser = argparse.ArgumentParser()
TestConfig.contribute_to_argparse(parser)
@@ -275,38 +255,3 @@ class ConfigurationTests(unittest.TestCase):
args = parser.parse_args(['--string-choice', 'c'])
c = TestConfig.create_from_arguments(args)
self.assertEqual("c", c.string_choice)
def test_known_hubs_list(self):
with tempfile.TemporaryDirectory() as temp_dir:
hubs = Config(config=os.path.join(temp_dir, 'settings.yml'), wallet_dir=temp_dir).known_hubs
self.assertEqual(hubs.serialized, {})
self.assertEqual(list(hubs), [])
self.assertFalse(hubs)
hubs.set('new.hub.io:99', {'jurisdiction': 'us'})
self.assertTrue(hubs)
self.assertFalse(hubs.exists)
hubs.save()
self.assertTrue(hubs.exists)
hubs = Config(config=os.path.join(temp_dir, 'settings.yml'), wallet_dir=temp_dir).known_hubs
self.assertEqual(list(hubs), [('new.hub.io', 99)])
self.assertEqual(hubs.serialized, {'new.hub.io:99': {'jurisdiction': 'us'}})
hubs.set('any.hub.io:99', {})
hubs.set('oth.hub.io:99', {'jurisdiction': 'other'})
self.assertEqual(list(hubs), [('new.hub.io', 99), ('any.hub.io', 99), ('oth.hub.io', 99)])
self.assertEqual(hubs.filter(), {
('new.hub.io', 99): {'jurisdiction': 'us'},
('oth.hub.io', 99): {'jurisdiction': 'other'},
('any.hub.io', 99): {}
})
self.assertEqual(hubs.filter(foo="bar"), {})
self.assertEqual(hubs.filter(jurisdiction="us"), {
('new.hub.io', 99): {'jurisdiction': 'us'}
})
self.assertEqual(hubs.filter(jurisdiction="us", match_none=True), {
('new.hub.io', 99): {'jurisdiction': 'us'},
('any.hub.io', 99): {}
})
+2 -7
View File
@@ -8,16 +8,12 @@ from typing import List, Tuple
from lbry.wallet.constants import COIN, NULL_HASH32
from lbry.schema.claim import Claim
from lbry.schema.result import Censor
from lbry.wallet.server.db import writer
from lbry.wallet.server.db import reader, writer
from lbry.wallet.server.coin import LBCRegTest
from lbry.wallet.server.db.trending import zscore
from lbry.wallet.server.db.canonical import FindShortestID
from lbry.wallet.server.block_processor import Timer
from lbry.wallet.transaction import Transaction, Input, Output
try:
import reader
except:
from . import reader
def get_output(amount=COIN, pubkey_hash=NULL_HASH32):
@@ -35,7 +31,7 @@ def get_tx():
def search(**constraints) -> List:
return reader.search_claims(Censor(Censor.SEARCH), **constraints)
return reader.search_claims(Censor(), **constraints)
def censored_search(**constraints) -> Tuple[List, Censor]:
@@ -557,7 +553,6 @@ class TestTrending(TestSQLDB):
self.advance(zscore.TRENDING_WINDOW * 2, [self.get_support(problematic, 500000000)])
@unittest.skip("filtering/blocking is applied during ES sync, this needs to be ported to integration test")
class TestContentBlocking(TestSQLDB):
def test_blocking_and_filtering(self):
Loaded 100 of 102 files, more files were not shown because too many files have changed in this diff. Show more