Compare commits
281
Commits
fix_order2
...
v0.97.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73d35bc985 | ||
|
|
2a8ccb065b | ||
|
|
8f04a50ce1 | ||
|
|
888aa5586b | ||
|
|
99f56f5d22 | ||
|
|
ad6281090d | ||
|
|
f0d334d3e2 | ||
|
|
5f829b048f | ||
|
|
1a961e66ff | ||
|
|
fdb0e22656 | ||
|
|
132ee1915f | ||
|
|
44bf4f3c8f | ||
|
|
6237767d5a | ||
|
|
dec9d96417 | ||
|
|
b167c87267 | ||
|
|
2280fe8e8e | ||
|
|
575d6dcd2d | ||
|
|
f729490c6b | ||
|
|
b32124cdd6 | ||
|
|
3d4321ee38 | ||
|
|
85034b382e | ||
|
|
77a51d1ad4 | ||
|
|
33e0cdc2d7 | ||
|
|
6519faa2fe | ||
|
|
5e3a234cbe | ||
|
|
e54c31d2d5 | ||
|
|
66c0537251 | ||
|
|
ac58516593 | ||
|
|
c3da6322b5 | ||
|
|
3d241500cf | ||
|
|
ded8224f66 | ||
|
|
f8814881a1 | ||
|
|
cc2852cd48 | ||
|
|
467637a9eb | ||
|
|
3cfc292d84 | ||
|
|
6acf94a810 | ||
|
|
31367fb4c4 | ||
|
|
12d6074e3b | ||
|
|
ff30386051 | ||
|
|
601f99ac16 | ||
|
|
87fe5c6101 | ||
|
|
68399ca31c | ||
|
|
2a6d7fd80f | ||
|
|
4725f510d8 | ||
|
|
be0ba22222 | ||
|
|
c8781392be | ||
|
|
b97164fcfb | ||
|
|
0dfb92281b | ||
|
|
4fe80c40da | ||
|
|
f0fac5115a | ||
|
|
46dd389d0d | ||
|
|
1e28e21ab5 | ||
|
|
7832c62c5d | ||
|
|
d025ee9dbe | ||
|
|
a9a9cb4319 | ||
|
|
aa727cb9b1 | ||
|
|
b8c9a99f20 | ||
|
|
aff995b0d0 | ||
|
|
2cc7e5dfdc | ||
|
|
5235a150b1 | ||
|
|
c6372ea9de | ||
|
|
7df4cc44c4 | ||
|
|
d47cf40544 | ||
|
|
7f5d88e95c | ||
|
|
d09663c066 | ||
|
|
ef97c9b69f | ||
|
|
d855e6c8b1 | ||
|
|
cd66f7eb43 | ||
|
|
6a35a7ba4c | ||
|
|
a3e146dc68 | ||
|
|
b81305a4a9 | ||
|
|
73884b34bc | ||
|
|
6166a34db2 | ||
|
|
6fa7da4b1c | ||
|
|
c3e426c491 | ||
|
|
21e023f0db | ||
|
|
063be001b3 | ||
|
|
5dff02e8bc | ||
|
|
60a59407d8 | ||
|
|
20a5aecfca | ||
|
|
c2e7b5a67d | ||
|
|
8f32303d07 | ||
|
|
891b1e7782 | ||
|
|
f26394fd3b | ||
|
|
4d83d42b4c | ||
|
|
57f1108df2 | ||
|
|
2641a9abe5 | ||
|
|
6b193ab350 | ||
|
|
b1bb37511c | ||
|
|
319187d6d6 | ||
|
|
02eb789f84 | ||
|
|
5a9338a27f | ||
|
|
eb6924277f | ||
|
|
325419404d | ||
|
|
bd8f371fd5 | ||
|
|
1783ff2845 | ||
|
|
d388527ffa | ||
|
|
19494088bd | ||
|
|
920dad524a | ||
|
|
ec89bcac8e | ||
|
|
a916c1f4ad | ||
|
|
a9a0ac92d7 | ||
|
|
da8a8bd1ef | ||
|
|
d9c746891d | ||
|
|
67817005b5 | ||
|
|
24d11de5a7 | ||
|
|
9251c87323 | ||
|
|
e12fab90d1 | ||
|
|
0a194b5b01 | ||
|
|
8d028adc53 | ||
|
|
dfca15395e | ||
|
|
e21f2362fe | ||
|
|
1ce328e8a9 | ||
|
|
038a5f999f | ||
|
|
5d3704c7ea | ||
|
|
87037c06c9 | ||
|
|
dd412c0f50 | ||
|
|
bf44befff6 | ||
|
|
e61874bb6f | ||
|
|
1e5331768f | ||
|
|
ec9a3a4f7c | ||
|
|
e439a3a8dc | ||
|
|
19f70d7a11 | ||
|
|
afe7ed5b05 | ||
|
|
d4bf004d74 | ||
|
|
e4d06a088b | ||
|
|
0929088b12 | ||
|
|
7b4838fc9b | ||
|
|
0cf9533248 | ||
|
|
84ff0b8a9f | ||
|
|
d467dcfeaf | ||
|
|
8e68ba4751 | ||
|
|
0f2a85ba9f | ||
|
|
7674a0a91e | ||
|
|
5bc1a66572 | ||
|
|
9b56067213 | ||
|
|
9a9df2fc3c | ||
|
|
9989d8d1d4 | ||
|
|
f9471f297e | ||
|
|
146b693e4a | ||
|
|
7295b7e329 | ||
|
|
e2441ea3e7 | ||
|
|
119e51912e | ||
|
|
dd950f5b0d | ||
|
|
78a9bad1e1 | ||
|
|
0c6eaf5484 | ||
|
|
1010068ddb | ||
|
|
82eec3d8d7 | ||
|
|
ee7b37d3f3 | ||
|
|
143d82d242 | ||
|
|
8b91b38855 | ||
|
|
1098f0d2a3 | ||
|
|
ab53cec022 | ||
|
|
6f5f8e5648 | ||
|
|
edfd707c22 | ||
|
|
1870f30af8 | ||
|
|
90106f5f08 | ||
|
|
9924b7b438 | ||
|
|
aa37faab0a | ||
|
|
dc10f8ce72 | ||
|
|
996686c1da | ||
|
|
488785d013 | ||
|
|
3abdc01230 | ||
|
|
8da04a584f | ||
|
|
27cc61d45e | ||
|
|
7371c30064 | ||
|
|
140d163895 | ||
|
|
dc33bdc1dc | ||
|
|
74df4fab83 | ||
|
|
1e5cd3d7a1 | ||
|
|
a54e9b64aa | ||
|
|
74660704e3 | ||
|
|
7439893a2a | ||
|
|
e27e49e9dc | ||
|
|
34ed729c59 | ||
|
|
adaeeca3fd | ||
|
|
dac75563d3 | ||
|
|
cbc76adcaa | ||
|
|
69a9cb383d | ||
|
|
4343073c00 | ||
|
|
fe60d4be88 | ||
|
|
ae337807f5 | ||
|
|
9ae30ac08e | ||
|
|
62fa85c0a4 | ||
|
|
7bb873dad9 | ||
|
|
5f6c1c14cb | ||
|
|
d43189ad33 | ||
|
|
fcad76fc51 | ||
|
|
97e6e1684e | ||
|
|
67a0d3e926 | ||
|
|
183fb9f9ff | ||
|
|
9815ddef1f | ||
|
|
f6d0847453 | ||
|
|
b0b9f0d65f | ||
|
|
0cec80f676 | ||
|
|
48c64143e3 | ||
|
|
a8712422bc | ||
|
|
97f65bd283 | ||
|
|
fd3c1c50f1 | ||
|
|
b153e4bb9f | ||
|
|
db9856a8db | ||
|
|
75ecea265d | ||
|
|
be8751cb73 | ||
|
|
fb25ecb4a1 | ||
|
|
f1cb7d27ac | ||
|
|
dee494e12f | ||
|
|
b13a121915 | ||
|
|
7486ee9537 | ||
|
|
4a20ccc28e | ||
|
|
f80dd2b307 | ||
|
|
b208cf6d32 | ||
|
|
39e78ff17e | ||
|
|
a8177ea7fe | ||
|
|
bedcfc154b | ||
|
|
4c38b4aa3c | ||
|
|
f6cfe266e0 | ||
|
|
4905e65f14 | ||
|
|
ccb250b410 | ||
|
|
aca57ffc62 | ||
|
|
7f375f42d8 | ||
|
|
eedcc2034d | ||
|
|
24c9a167d7 | ||
|
|
909df8ef1f | ||
|
|
3b27cb3671 | ||
|
|
3fe0db4a7d | ||
|
|
8b55814ab2 | ||
|
|
575e471553 | ||
|
|
0f5f1aebed | ||
|
|
50e17eb1ab | ||
|
|
158cc2f660 | ||
|
|
1066a31acd | ||
|
|
1f9d0f4582 | ||
|
|
a6d65233f1 | ||
|
|
eff2fe7a1b | ||
|
|
20efdc70b3 | ||
|
|
f0d8fb8f1a | ||
|
|
f7a380e9b7 | ||
|
|
e9c7cf6f63 | ||
|
|
68f1661452 | ||
|
|
36fd1b91ae | ||
|
|
a4ec430ac0 | ||
|
|
519614b2fd | ||
|
|
bf0118c8ef | ||
|
|
a4db0820bc | ||
|
|
ee7528413e | ||
|
|
7952fc8324 | ||
|
|
652773d2cf | ||
|
|
2a17787242 | ||
|
|
0a53ad5721 | ||
|
|
6da6bdc863 | ||
|
|
42ad2bb83f | ||
|
|
f309a65cb4 | ||
|
|
77e19ab1a4 | ||
|
|
1a996b6ef3 | ||
|
|
b882f1a010 | ||
|
|
82a030e6ff | ||
|
|
0758b85179 | ||
|
|
ab3d9bd080 | ||
|
|
8ff813f689 | ||
|
|
88ae72c0d3 | ||
|
|
312aa4be26 | ||
|
|
cbb06fce9d | ||
|
|
f259e497c4 | ||
|
|
dd4172ac66 | ||
|
|
66029e60d3 | ||
|
|
364f484f04 | ||
|
|
9dd5159414 | ||
|
|
13e38d6fd8 | ||
|
|
10dcb64715 | ||
|
|
7551b51e7d | ||
|
|
adb418aafc | ||
|
|
270da80d64 | ||
|
|
b2027cfd66 | ||
|
|
7f1f4eeac6 | ||
|
|
7a7446c8bd | ||
|
|
ddbae294e6 | ||
|
|
8c71b744f3 | ||
|
|
479b5d31a9 | ||
|
|
4cbf4230e8 | ||
|
|
6a610187e0 | ||
|
|
eb2a4aebba |
No files matched your search
@@ -0,0 +1,67 @@
|
||||
# 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
|
||||
@@ -22,10 +22,9 @@ jobs:
|
||||
with:
|
||||
python-version: '3.7'
|
||||
- run: make install tools
|
||||
- working-directory: lbry
|
||||
env:
|
||||
- env:
|
||||
HOME: /tmp
|
||||
run: coverage run -p --source=lbry -m unittest discover -vv tests.unit
|
||||
run: make test-unit-coverage
|
||||
|
||||
tests-integration:
|
||||
name: "tests / integration"
|
||||
@@ -37,6 +36,17 @@ 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:
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
# 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 }}
|
||||
+14
-5
@@ -1,5 +1,11 @@
|
||||
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:
|
||||
@@ -41,13 +47,14 @@ test:datanetwork-integration:
|
||||
stage: test
|
||||
script:
|
||||
- pip install tox-travis
|
||||
- tox -e datanetwork --recreate
|
||||
- ELASTIC_HOST=elasticsearch tox -e datanetwork --recreate
|
||||
|
||||
test:blockchain-integration:
|
||||
stage: test
|
||||
script:
|
||||
- curl "http://elasticsearch:9200/_cat/health"
|
||||
- pip install tox-travis
|
||||
- tox -e blockchain
|
||||
- ELASTIC_HOST=elasticsearch tox -e blockchain
|
||||
|
||||
test:other-integration:
|
||||
stage: test
|
||||
@@ -55,13 +62,13 @@ test:other-integration:
|
||||
- apt-get update
|
||||
- apt-get install -y --no-install-recommends ffmpeg
|
||||
- pip install tox-travis
|
||||
- tox -e other
|
||||
- ELASTIC_HOST=elasticsearch tox -e other
|
||||
|
||||
test:json-api:
|
||||
stage: test
|
||||
script:
|
||||
- make install tools
|
||||
- HOME=/tmp coverage run -p --source=lbry scripts/generate_json_api.py
|
||||
- ELASTIC_HOST=elasticsearch HOME=/tmp coverage run -p --source=lbry scripts/generate_json_api.py
|
||||
|
||||
|
||||
|
||||
@@ -121,9 +128,11 @@ build:windows:
|
||||
GIT_DEPTH: 5
|
||||
before_script:
|
||||
- ./docker/install_choco.ps1
|
||||
- choco install -y --x86 python3 7zip checksum
|
||||
- choco install -y --x64 python --version=3.7.9
|
||||
- choco install -y 7zip checksum
|
||||
- python --version # | findstr /B "Python 3\.7\." # dont upgrade python on every run. just make sure we're on the right Python
|
||||
- pip --version # | findstr /E '\(python 3\.7\)'
|
||||
- python -c "import sys;print(f'{str(64 if sys.maxsize > 2**32 else 32)} bit python\n{sys.platform}')"
|
||||
- pip install virtualenv pywin32
|
||||
- virtualenv venv
|
||||
- venv/Scripts/activate.ps1
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.PHONY: install tools lint test idea
|
||||
.PHONY: install tools lint test test-unit test-unit-coverage test-integration idea
|
||||
|
||||
install:
|
||||
pip install https://s3.amazonaws.com/files.lbry.io/python_libtorrent-1.2.4-py3-none-any.whl
|
||||
@@ -16,7 +16,15 @@ lint:
|
||||
pylint --rcfile=setup.cfg lbry
|
||||
#mypy --ignore-missing-imports lbry
|
||||
|
||||
test:
|
||||
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:
|
||||
tox
|
||||
|
||||
idea:
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# 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
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM ubuntu:19.10
|
||||
FROM debian:10-slim
|
||||
|
||||
ARG user=lbry
|
||||
ARG db_dir=/database
|
||||
@@ -13,7 +13,9 @@ RUN apt-get update && \
|
||||
wget \
|
||||
tar unzip \
|
||||
build-essential \
|
||||
python3 \
|
||||
pkg-config \
|
||||
libleveldb-dev \
|
||||
python3.7 \
|
||||
python3-dev \
|
||||
python3-pip \
|
||||
python3-wheel \
|
||||
|
||||
@@ -1,36 +1,45 @@
|
||||
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
|
||||
- "50005:50005" # websocket port
|
||||
#- "2112:2112" # uncomment to enable prometheus
|
||||
- "2112:2112" # uncomment to enable prometheus
|
||||
volumes:
|
||||
- "wallet_server:/database"
|
||||
environment:
|
||||
# Curently not snapshot provided
|
||||
# - SNAPSHOT_URL=${WALLET_SERVER_SNAPSHOT_URL-https://lbry.com/snapshot/wallet}
|
||||
- DAEMON_URL=http://lbry:lbry@lbrycrd:9245
|
||||
- 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
|
||||
@@ -20,4 +20,6 @@ if [[ -n "$SNAPSHOT_URL" ]] && [[ ! -f /database/claims.db ]]; then
|
||||
rm "$filename"
|
||||
fi
|
||||
|
||||
/home/lbry/.local/bin/torba-server "$@"
|
||||
/home/lbry/.local/bin/lbry-hub-elastic-sync /database/claims.db
|
||||
echo 'starting server'
|
||||
/home/lbry/.local/bin/lbry-hub "$@"
|
||||
+327
-153
@@ -46,7 +46,7 @@
|
||||
{
|
||||
"name": "wallet_id",
|
||||
"type": "str",
|
||||
"description": "wallet to check for claim purchase reciepts",
|
||||
"description": "wallet to check for claim purchase receipts",
|
||||
"is_required": false
|
||||
}
|
||||
],
|
||||
@@ -54,10 +54,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Get a file",
|
||||
"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}"
|
||||
"curl": "curl -d'{\"method\": \"get\", \"params\": {\"uri\": \"astream#bcd03a6bc9ab0f5694a13410d862af81f735499d\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet get astream#bcd03a6bc9ab0f5694a13410d862af81f735499d",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"get\", \"params\": {\"uri\": \"astream#bcd03a6bc9ab0f5694a13410d862af81f735499d\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"added_on\": 1619186574,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 4,\n \"content_fee\": null,\n \"download_directory\": \"/tmp/tmp3yjc8ttn\",\n \"download_path\": \"/tmp/tmp3yjc8ttn/tmp12xihy6s\",\n \"file_name\": \"tmp12xihy6s\",\n \"height\": 214,\n \"is_fully_reflected\": false,\n \"key\": \"6153d7a516ff43d69f858f7353fc9a39\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp12xihy6s\",\n \"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"7b9ad271e84e82c5b04d07f7914ae915de8f297bf94d9f7490a2bffc9ea4be37:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"0175132284c9e57ffb6ce03c5283c634bf66c2155c29355d45feccaadb918ace380beac35a09dc3df2c22c5a5ee688d37af34904d5354ddeefe50206e3467c9559895cbf61b6e319a44256bf87b52a2ad7720244cf0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d703132786968793673180b22186170706c69636174696f6e2f6f637465742d73747265616d3230f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"purchase_receipt\": null,\n \"reflector_progress\": 0,\n \"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"5811a98af0070bbe1d55e78b9eccf809c0b3e334b0f4daf8b5832b0f2361e6940547f97da8768a8663a35607460d814a\",\n \"stream_name\": \"tmp12xihy6s\",\n \"streaming_url\": \"http://localhost:5280/stream/f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"suggested_file_name\": \"tmp12xihy6s\",\n \"timestamp\": 1619186595,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"7b9ad271e84e82c5b04d07f7914ae915de8f297bf94d9f7490a2bffc9ea4be37\",\n \"uploading_to_reflector\": false,\n \"written_bytes\": 11\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -83,6 +83,18 @@
|
||||
"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",
|
||||
@@ -191,6 +203,12 @@
|
||||
"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",
|
||||
@@ -250,10 +268,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Publish a file",
|
||||
"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}"
|
||||
"curl": "curl -d'{\"method\": \"publish\", \"params\": {\"name\": \"a-new-stream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpqedr4hf_\", \"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/tmpqedr4hf_",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"publish\", \"params\": {\"name\": \"a-new-stream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpqedr4hf_\", \"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\": \"01000000012bb08a103ff362cdf211bf509a3a315369d42e8dd89fdbe043e3b3a17fb63145010000006a473044022076b7b102c80e4063523944b71575ad015f69ab44758b49e9674d112aa7d8e65e02203179a6488f9ccd64d640ff14c49d80ccb5ccf10cbda4b01173ac3a01ab4e387e01210214d28c7227f0b3eef47cb2b5704bde364b40747f97b9d7edf806da068aaaabd2ffffffff0200e1f50500000000bfb50c612d6e65772d73747265616d4c94000a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d70716564723468665f180b22186170706c69636174696f6e2f6f637465742d73747265616d3230d4d0e089925b0a7f5ab287cf39ff511ef380b0fb7e04b62d72964bb416baf4211e713dab967e600aa2a39f4b5c9f88da6d7576a9141b195fe77318659029c07b32b2de8df7820e5c9e88ac54826311000000001976a9143c14aa564481f9d0f771e740377fc0ed17791e7788ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mztSRbjwzK9k7BUDXWybL8ZJs2KYQAq6hP\",\n \"amount\": \"3.941448\",\n \"confirmations\": 3,\n \"height\": 217,\n \"nout\": 1,\n \"timestamp\": 1619186595,\n \"txid\": \"4531b67fa1b3e343e0db9fd88d2ed46953313a9a50bf11f2cd62f33f108ab02b\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mhzEwHxzVtn29ZSiSGWrCvNkS8tvxULAPx\",\n \"amount\": \"1.0\",\n \"claim_id\": \"3750860c465d9b7b30f197e01b1d767bf2f6427c\",\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#3750860c465d9b7b30f197e01b1d767bf2f6427c\",\n \"timestamp\": null,\n \"txid\": \"0819ba64123cf83ea748a21ee6e5f72a133766fe1745598796d86c268e2c33c8\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpqedr4hf_\",\n \"sd_hash\": \"d4d0e089925b0a7f5ab287cf39ff511ef380b0fb7e04b62d72964bb416baf4211e713dab967e600aa2a39f4b5c9f88da\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mkzdbRHazFEn4s2w2MVvGqSQoMuprZPxDo\",\n \"amount\": \"2.917341\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"0819ba64123cf83ea748a21ee6e5f72a133766fe1745598796d86c268e2c33c8\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.024107\",\n \"total_input\": \"3.941448\",\n \"total_output\": \"3.917341\",\n \"txid\": \"0819ba64123cf83ea748a21ee6e5f72a133766fe1745598796d86c268e2c33c8\"\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -270,7 +288,7 @@
|
||||
{
|
||||
"name": "wallet_id",
|
||||
"type": "str",
|
||||
"description": "wallet to check for claim purchase reciepts",
|
||||
"description": "wallet to check for claim purchase receipts",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
@@ -314,10 +332,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Resolve a claim",
|
||||
"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}"
|
||||
"curl": "curl -d'{\"method\": \"resolve\", \"params\": {\"urls\": [\"astream#bcd03a6bc9ab0f5694a13410d862af81f735499d\"], \"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#bcd03a6bc9ab0f5694a13410d862af81f735499d",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"resolve\", \"params\": {\"urls\": [\"astream#bcd03a6bc9ab0f5694a13410d862af81f735499d\"], \"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#bcd03a6bc9ab0f5694a13410d862af81f735499d\": {\n \"address\": \"mmpTpyBuV9vuZ56V3fj2yGXG76JEN8SDBm\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#5/astream#b\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\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\": 1619186595,\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#bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"short_url\": \"lbry://astream#b\",\n \"signing_channel\": {\n \"address\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#5\",\n \"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\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\": 1619186594,\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#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"short_url\": \"lbry://@channel#5\",\n \"timestamp\": 1619186594,\n \"txid\": \"7dcba7746fc307b5c4112dea445c1c91098a7444b4c3b07542c18a77987a0923\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004b1f16e5b66fbb724cd8967de626e1113083a5d2f391b52fe9896d30aeb374155c8c660dc268195bc2feb2925ce3f4dc2d547bacc43955465ddf94adce214f50d\",\n \"public_key_id\": \"mpgQaTWRWYphbxv94VZsSgW91YK55FZEov\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1619186595,\n \"txid\": \"7b9ad271e84e82c5b04d07f7914ae915de8f297bf94d9f7490a2bffc9ea4be37\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp12xihy6s\",\n \"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -339,7 +357,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 \"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}"
|
||||
"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\": \"4PfwRLRLRYVBzAH9BztZYLG9kWdaBF3rd9248ACo1ft7L7TMa4ohEijLmXDXn2bnBs\",\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\": \"dc9c04cc674a7123a0ac3dfbf2b03838664490c0fa9845fc2a5bfb5eb7a25a19\",\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.94.1\",\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.0034657910000532866,\n \"port\": 50002\n }\n ]\n },\n \"wallet_server_payments\": {\n \"max_fee\": \"0.0\",\n \"running\": false\n }\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -361,7 +379,7 @@
|
||||
"curl": "curl -d'{\"method\": \"version\", \"params\": {}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet version",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"version\", \"params\": {}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"build\": \"dev\",\n \"desktop\": \"GNOME\",\n \"distro\": {\n \"codename\": \"xenial\",\n \"id\": \"ubuntu\",\n \"like\": \"debian\",\n \"version\": \"16.04\",\n \"version_parts\": {\n \"build_number\": \"\",\n \"major\": \"16\",\n \"minor\": \"04\"\n }\n },\n \"lbrynet_version\": \"0.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}"
|
||||
"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.94.1\",\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.9\",\n \"version\": \"0.94.1\"\n }\n}"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -415,10 +433,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Add an account from seed",
|
||||
"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}"
|
||||
"curl": "curl -d'{\"method\": \"account_add\", \"params\": {\"account_name\": \"new account\", \"seed\": \"alley cattle pig switch demise guide use thing monkey club setup post\", \"single_key\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account add \"new account\" --seed=\"alley cattle pig switch demise guide use thing monkey club setup post\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_add\", \"params\": {\"account_name\": \"new account\", \"seed\": \"alley cattle pig switch demise guide use thing monkey club setup post\", \"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\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1619186562,\n \"name\": \"new account\",\n \"private_key\": \"tprv8ZgxMBicQKsPeDp4m3ZSg72s4LFLVLxoStasxmbm5egbdCpMk1YANTw52EhZiTZ831vgdcuuwD6EhfPhvEHn1t9BtpBR74sJCQ2TEhaXMK6\",\n \"public_key\": \"tpubD6NzVbkrYhZ4XgqrehE35WgydMmGeg9i2CBfFHe4VvUzTh58NQMkYxYwCPvo6CEy8b8qo8cq2rdfPk42qNYLk7cWLpDkiXJnvr9zHZ9KqGD\",\n \"seed\": \"alley cattle pig switch demise guide use thing monkey club setup post\"\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -456,9 +474,9 @@
|
||||
},
|
||||
{
|
||||
"title": "Get balance for specific account by id",
|
||||
"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()",
|
||||
"curl": "curl -d'{\"method\": \"account_balance\", \"params\": {\"account_id\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account balance \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_balance\", \"params\": {\"account_id\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\"}}).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}"
|
||||
}
|
||||
]
|
||||
@@ -493,7 +511,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\": \"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}"
|
||||
"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\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1619186562,\n \"name\": \"generated account\",\n \"private_key\": \"tprv8ZgxMBicQKsPeDp4m3ZSg72s4LFLVLxoStasxmbm5egbdCpMk1YANTw52EhZiTZ831vgdcuuwD6EhfPhvEHn1t9BtpBR74sJCQ2TEhaXMK6\",\n \"public_key\": \"tpubD6NzVbkrYhZ4XgqrehE35WgydMmGeg9i2CBfFHe4VvUzTh58NQMkYxYwCPvo6CEy8b8qo8cq2rdfPk42qNYLk7cWLpDkiXJnvr9zHZ9KqGD\",\n \"seed\": \"alley cattle pig switch demise guide use thing monkey club setup post\"\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -548,24 +566,24 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Transfer 2 LBC from default account to specific account",
|
||||
"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}"
|
||||
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"to_account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\", \"amount\": \"2.0\", \"everything\": false, \"broadcast\": true}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account fund --to_account=\"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\" --amount=2.0 --broadcast",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"to_account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\", \"amount\": \"2.0\", \"everything\": false, \"broadcast\": true}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000140b6a1a9e9d645fdc13d610f5ea726f6f3632d573d710fd9fd653b7bf26e7b7c000000006b483045022100d98c7aee6bf787a8baab3ad7dda342cbb3a40f97b0e3f7acb8d5ec6d8cdf46330220500ffb8e927c309f8c27eb16a2a63990f393501b54f7993198efb8fe5b8b03560121030b674794d96c8f25504064a3fa083612eeaa9725611c65882f6c09124b9fd90effffffff0200c2eb0b000000001976a9141d34f625de59642aee534ce63fbeff7c629ecc3888ac90d7ae2f000000001976a914d2ba6ed7df0d95eccf902d5e4057e5e49e32343488ac00000000\",\n \"inputs\": [\n {\n \"address\": \"moncvibtkcp8X8EEAaA5Qx5vNGcBJPsZbM\",\n \"amount\": \"10.0\",\n \"confirmations\": 6,\n \"height\": 201,\n \"nout\": 0,\n \"timestamp\": 1619186593,\n \"txid\": \"7c7b6ef27b3b65fdd90f713d572d63f3f626a75e0f613dc1fd45d6e9a9a1b640\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"miBPLSvKJAiYtorvP4R3Z9bCBmbyVzCpZV\",\n \"amount\": \"2.0\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"036c2f7d8df7fe3cbac6cfeea4a2ef1d79cbb7113aa5417ed7b7371ccd2289ca\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mzjBXvqaeQQUHpxocqhqtdRStrmpW4Ho45\",\n \"amount\": \"7.999876\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"036c2f7d8df7fe3cbac6cfeea4a2ef1d79cbb7113aa5417ed7b7371ccd2289ca\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000124\",\n \"total_input\": \"10.0\",\n \"total_output\": \"9.999876\",\n \"txid\": \"036c2f7d8df7fe3cbac6cfeea4a2ef1d79cbb7113aa5417ed7b7371ccd2289ca\"\n }\n}"
|
||||
},
|
||||
{
|
||||
"title": "Spread LBC between multiple addresses",
|
||||
"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}"
|
||||
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"to_account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\", \"from_account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\", \"amount\": \"1.5\", \"everything\": false, \"outputs\": 2, \"broadcast\": true}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account fund --to_account=\"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\" --from_account=\"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\" --amount=1.5 --outputs=2 --broadcast",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"to_account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\", \"from_account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\", \"amount\": \"1.5\", \"everything\": false, \"outputs\": 2, \"broadcast\": true}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001ca8922cd1c37b7d77e41a53a11b7cb791defa2a4eecfc6ba3cfef78d7d2f6c03000000006b483045022100c90c3a19f2df1bf1804182b956ac026c49a3ae5c5b4683e752d0b0f790a2ffcc02201585e4a89be8d9a8a89390955f52652981b5334d773dddf4b532b1c0cf5c10ef012102cd0bfe93207b243de0c9e94c14acb266d2c0e8cbd9cd8e5bc392b9ea854a7525ffffffff03c0687804000000001976a914dcd3b9091b6c5476b0c3ca5e2a1ce803d9690f1688acc0687804000000001976a914dcd3b9091b6c5476b0c3ca5e2a1ce803d9690f1688ac6cb9fa02000000001976a914ab9a29a2d32193a63d1bdae31881e80dce7c72b388ac00000000\",\n \"inputs\": [\n {\n \"address\": \"miBPLSvKJAiYtorvP4R3Z9bCBmbyVzCpZV\",\n \"amount\": \"2.0\",\n \"confirmations\": 1,\n \"height\": 207,\n \"nout\": 0,\n \"timestamp\": 1619186594,\n \"txid\": \"036c2f7d8df7fe3cbac6cfeea4a2ef1d79cbb7113aa5417ed7b7371ccd2289ca\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"n1eab1nmWNhEa1MYfpgGdNVm89VZFz3ohV\",\n \"amount\": \"0.75\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"8447a8af18cbf5d3aeca38f5be588bba648de68669b4990a5e689243a0c72676\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"n1eab1nmWNhEa1MYfpgGdNVm89VZFz3ohV\",\n \"amount\": \"0.75\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"8447a8af18cbf5d3aeca38f5be588bba648de68669b4990a5e689243a0c72676\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mwAJXGL1Aw4U5BRnTYjKiZKHHUkLbxJwTs\",\n \"amount\": \"0.499859\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 2,\n \"timestamp\": null,\n \"txid\": \"8447a8af18cbf5d3aeca38f5be588bba648de68669b4990a5e689243a0c72676\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000141\",\n \"total_input\": \"2.0\",\n \"total_output\": \"1.999859\",\n \"txid\": \"8447a8af18cbf5d3aeca38f5be588bba648de68669b4990a5e689243a0c72676\"\n }\n}"
|
||||
},
|
||||
{
|
||||
"title": "Transfer all LBC to a specified account",
|
||||
"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}"
|
||||
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"from_account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\", \"everything\": true, \"broadcast\": true}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account fund --from_account=\"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\" --everything --broadcast",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"from_account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\", \"everything\": true, \"broadcast\": true}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000037626c7a04392685e0a99b46986e68d64ba8b58bef538caaed3f5cb18afa84784000000006b483045022100cc8ab1133f9aa023984758dc6028daabbe9898fab43db8e7a7f03cd98b7a52a102207679d5b8825642dbf7e04e8cc7adab6c16859470815cf9e7b8546e294c0a248d0121031a0a1bb2d064d4b10274f214f972b78e12d7f024568e0cb478a1e6738bbe826dffffffff7626c7a04392685e0a99b46986e68d64ba8b58bef538caaed3f5cb18afa84784010000006b48304502210085c8b09788fdf20a1d7662d6281f2d3a13a16bafda968bb5aaa090329f2524af02205a18a3ffcd85d0887b88a01b41c9e530b7f5c1d4644b37adc764cda8cb66747a0121031a0a1bb2d064d4b10274f214f972b78e12d7f024568e0cb478a1e6738bbe826dffffffff7626c7a04392685e0a99b46986e68d64ba8b58bef538caaed3f5cb18afa84784020000006a47304402203ac347806d77cba6bb1cdc3f79638a4f254f9e2bdbc42d348d52de859487c5e502204af387abc826923a9033b674ecef4a712cbe7f7b29fa531188600543271a98eb0121037a661ea7428fcd9c1ad331f049646bfbf17f210ba0ce9c27e16b17ddef5c72d0ffffffff015027eb0b000000001976a9140953009b4f066787a0aa01eb98f8fbf233feacb788ac00000000\",\n \"inputs\": [\n {\n \"address\": \"n1eab1nmWNhEa1MYfpgGdNVm89VZFz3ohV\",\n \"amount\": \"0.75\",\n \"confirmations\": 1,\n \"height\": 208,\n \"nout\": 0,\n \"timestamp\": 1619186594,\n \"txid\": \"8447a8af18cbf5d3aeca38f5be588bba648de68669b4990a5e689243a0c72676\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"n1eab1nmWNhEa1MYfpgGdNVm89VZFz3ohV\",\n \"amount\": \"0.75\",\n \"confirmations\": 1,\n \"height\": 208,\n \"nout\": 1,\n \"timestamp\": 1619186594,\n \"txid\": \"8447a8af18cbf5d3aeca38f5be588bba648de68669b4990a5e689243a0c72676\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mwAJXGL1Aw4U5BRnTYjKiZKHHUkLbxJwTs\",\n \"amount\": \"0.499859\",\n \"confirmations\": 1,\n \"height\": 208,\n \"nout\": 2,\n \"timestamp\": 1619186594,\n \"txid\": \"8447a8af18cbf5d3aeca38f5be588bba648de68669b4990a5e689243a0c72676\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mgNFotMcVkNSmVwGpZHi6dACpVsMKBgFZB\",\n \"amount\": \"1.999604\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"7f05265b44c16aefef52bdca98f8a51f1cc7c10c6ea58114a6040b5c1af3d7ee\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000255\",\n \"total_input\": \"1.999859\",\n \"total_output\": \"1.999604\",\n \"txid\": \"7f05265b44c16aefef52bdca98f8a51f1cc7c10c6ea58114a6040b5c1af3d7ee\"\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -623,7 +641,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\": \"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}"
|
||||
"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\": \"mkPwiscpsmDM8ECQrLYS3vnq16MaXsTZVD\",\n \"is_default\": true,\n \"ledger\": \"lbc_regtest\",\n \"name\": \"Account #mkPwiscpsmDM8ECQrLYS3vnq16MaXsTZVD\",\n \"public_key\": \"tpubD6NzVbkrYhZ4We9GS84h1j7L9Xs5T2QcCqABCJqEAMAXeBXqsR1FUwZXjLpMuGUtr3VLB95No1ax4HevXK2MwUZ39FSKkGMDWs4PL7kiSp1\",\n \"satoshis\": 1000000000\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -668,10 +686,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Remove an account",
|
||||
"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}"
|
||||
"curl": "curl -d'{\"method\": \"account_remove\", \"params\": {\"account_id\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account remove mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_remove\", \"params\": {\"account_id\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\"}}).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\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1619186562,\n \"name\": \"generated account\",\n \"private_key\": \"tprv8ZgxMBicQKsPeDp4m3ZSg72s4LFLVLxoStasxmbm5egbdCpMk1YANTw52EhZiTZ831vgdcuuwD6EhfPhvEHn1t9BtpBR74sJCQ2TEhaXMK6\",\n \"public_key\": \"tpubD6NzVbkrYhZ4XgqrehE35WgydMmGeg9i2CBfFHe4VvUzTh58NQMkYxYwCPvo6CEy8b8qo8cq2rdfPk42qNYLk7cWLpDkiXJnvr9zHZ9KqGD\",\n \"seed\": \"alley cattle pig switch demise guide use thing monkey club setup post\"\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -764,10 +782,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Modify maximum number of times a change address can be reused",
|
||||
"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}"
|
||||
"curl": "curl -d'{\"method\": \"account_set\", \"params\": {\"account_id\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\", \"default\": false, \"change_max_uses\": 10}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet account set mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs --change_max_uses=10",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_set\", \"params\": {\"account_id\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\", \"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\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1619186562,\n \"name\": \"new account\",\n \"private_key\": \"tprv8ZgxMBicQKsPeDp4m3ZSg72s4LFLVLxoStasxmbm5egbdCpMk1YANTw52EhZiTZ831vgdcuuwD6EhfPhvEHn1t9BtpBR74sJCQ2TEhaXMK6\",\n \"public_key\": \"tpubD6NzVbkrYhZ4XgqrehE35WgydMmGeg9i2CBfFHe4VvUzTh58NQMkYxYwCPvo6CEy8b8qo8cq2rdfPk42qNYLk7cWLpDkiXJnvr9zHZ9KqGD\",\n \"seed\": \"alley cattle pig switch demise guide use thing monkey club setup post\"\n }\n}"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -803,9 +821,9 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Check if address is mine",
|
||||
"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()",
|
||||
"curl": "curl -d'{\"method\": \"address_is_mine\", \"params\": {\"address\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet address is_mine mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_is_mine\", \"params\": {\"address\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": true\n}"
|
||||
}
|
||||
]
|
||||
@@ -852,14 +870,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\": \"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
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mfmhc92HaRe3va3ebMqfkjACWE7Efg7WQo\",\n \"pubkey\": \"tpubDA9GDAntyJu4osD8fGNsDznW1DxdJz31FNzUUgq4F5Aamjn2PRv3CFKWHwg8pLTprfRkNZaZDeUDgDsBfiY7Q8ZjgjEApjnenkZyJ2KideH\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mgbap1vfAiBNVKqUUT7W5xnxmrjsbU3fQk\",\n \"pubkey\": \"tpubDA9GDAntyJu4JHowiMKECSVPkkntXycNgaLidDnum3oF5pgvEq7PaRoyqK7Ls9xtPHfyVLVuQu9YGJ4Gd1CrtZaSispuLPgjpvDzDA41wy3\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"miBPLSvKJAiYtorvP4R3Z9bCBmbyVzCpZV\",\n \"pubkey\": \"tpubDA9GDAntyJu4R9T8QWqc7PvQs7AU9wKyG6xyct6WN1huKHPZjmvVh1wbFKuCc2yLjXP1qQ188rLS87tvqXPutEz71stE6E14Ux3F3DpsVVH\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mjebtHKV24PApa9fR5mQ8gSCAits93Ecb4\",\n \"pubkey\": \"tpubDA9GDAntyJu4KfYLGfo16i1S39nfrDVVe3tAbNuXfzftkSRbASzo9UT1X9j8oGLRfTjnUQF1rGP3FnSQUDfEweRqiZUXhv6WDVDRUHRGoWu\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mm3VT4W1vwPRrPQqCTZytyeVnzbUkmWyTA\",\n \"pubkey\": \"tpubDA9GDAntyJu4N1hoLeYF6TuJuAnv9aZE6k4pAhwgm6hDaFzzMxSSTYMLed637xt7QAMhmB7iVpjn9d55kgmp3z4KKuEooYQeAaqVwJVSqLz\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mmKWdxNhFhFAXNsGTy2tVRwhbpkijgK2bm\",\n \"pubkey\": \"tpubDA9GDAntyJu4PsNjmu5LaSbS7DtcdGC7mjF9NH3Jyu2UrR8FxZK8PErhJHg3cskG7D6GUgLmLJ6LaEnVFFS3WCdnU2gT54YXW9BBtGQQHb6\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mnDP2uk38XSLorT95aqq9N5gy8bf3Wjt9y\",\n \"pubkey\": \"tpubDA9GDAntyJu4dQDNMhay8bq1f5QyCXzL8SQLj11i1pbg1pbrgUUFoJcAbCS56eqe6Xqs3CPKW4DTkir1HJ64uriFBT4xw9FA1unJKFKpGSx\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"moSi1CqRyZzfkLgT1kkrtHS6oYChRvJxqd\",\n \"pubkey\": \"tpubDA9GDAntyJu4mDpFcwkSwF4Hyvn5VSWp2bskbKd9iNqDwdNLbwkzxLwQGF1JArVWEEwk2xV76BXa1hk1nQMQmPd1Ab6tcJPpfKhY8pFZXMX\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mr2s4EoTgVBE4r9JLkwAHDnFX3uGvgufW6\",\n \"pubkey\": \"tpubDA9GDAntyJu4FQqtS3XjPowNGLHcBXgaFZVwwVZa8uK1cFk2mhG4ZbSWQszY7REB1wiauhsbFNU5e8TfpQWChL1uwmoxkW35ytVmWFXfSMG\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"msJmZvJqs2e8C23hovmZKeVdCkitGxbrru\",\n \"pubkey\": \"tpubDA9GDAntyJu4hBpsMFjvMc9AawthJSRgKTRjX5aJ96VS81xaha6fURbWbaJ1d9sTpBk43JQB6oxcaRRBdSkz83s3YVVx6Rxs4B3xp4fpXQV\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"msMFJbadB5dzHvz5oWscZUKvQYEYPk7Ncd\",\n \"pubkey\": \"tpubDA9GDAntyJu4ENuarHFHHvkPf1MQKFyXtS18GUuqFeAmqgmYkWvboJpbm9dZnTFUu1WN3YeyyNMRDVmpU81ad9j18SjGFVXq9rvDyktKDDb\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mt6JggawxBTj1GrZ5DcDHFgmvkDtmBtw8P\",\n \"pubkey\": \"tpubDA9GDAntyJu4rGaqwnidtFkzNjDdbeZxtaVhXWXSkzAgsf5fmcXuFuMAtSHApnmpnawbcjQpLzJzoY9BBJmhXHV8ZTv7iUQTVmQHKzspkZr\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mtESjA4yH9XhMV1TTRPDahQcswXGokjJEQ\",\n \"pubkey\": \"tpubDA9GDAntyJu4kGNiwQwsfXo9MQiNv4zvppZMZG5rJsRuU9yuy5hdbkkyNTYEAPdDfW27WfC1yWd2mtMiUsWkhKk6xGouuZzFwQSepqdFj4m\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mtSMa8yjkyumAEpuu27w5mBKDvtV8WuwUS\",\n \"pubkey\": \"tpubDA9GDAntyJu4bDz5PUjqeS6vDQGgFZ67ttpxoeAh8FMsHmgYXe5MEUHDLmVtSmdjxqzpLsCkLc9efBvVn1qqzuSFV5gffcEHjWD3QmjoAMS\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mu3Fgd4fLSMmPdBG8M7pMDM9mVgqBsNa2P\",\n \"pubkey\": \"tpubDA9GDAntyJu4ZYzCJS7DcSKHDiEwRLUSG5VkfS5fubFz3fQnrZ32LMAK1fVG6xucP5GLdEtaPtFXmbVd7kzLp5j2viUfWJ8n7HHX9e3rFMS\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"muTdW8b65cWxqTbCnrGyxEMwfNXX1ZYuoa\",\n \"pubkey\": \"tpubDA9GDAntyJu54zEFL428ce3vX5ehsYh4AEaXi3GRtwyLftHLfwJisf7Q1JyQehhw77Q1xvgy4qrc7CSNxn8aBM8xikmNpUwFNSzdUEQyUQ8\",\n \"Line truncated
|
||||
},
|
||||
{
|
||||
"title": "List addresses in specified account",
|
||||
"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
|
||||
"curl": "curl -d'{\"method\": \"address_list\", \"params\": {\"account_id\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet address list --account_id=\"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_list\", \"params\": {\"account_id\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mfmhc92HaRe3va3ebMqfkjACWE7Efg7WQo\",\n \"pubkey\": \"tpubDA9GDAntyJu4osD8fGNsDznW1DxdJz31FNzUUgq4F5Aamjn2PRv3CFKWHwg8pLTprfRkNZaZDeUDgDsBfiY7Q8ZjgjEApjnenkZyJ2KideH\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mgbap1vfAiBNVKqUUT7W5xnxmrjsbU3fQk\",\n \"pubkey\": \"tpubDA9GDAntyJu4JHowiMKECSVPkkntXycNgaLidDnum3oF5pgvEq7PaRoyqK7Ls9xtPHfyVLVuQu9YGJ4Gd1CrtZaSispuLPgjpvDzDA41wy3\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"miBPLSvKJAiYtorvP4R3Z9bCBmbyVzCpZV\",\n \"pubkey\": \"tpubDA9GDAntyJu4R9T8QWqc7PvQs7AU9wKyG6xyct6WN1huKHPZjmvVh1wbFKuCc2yLjXP1qQ188rLS87tvqXPutEz71stE6E14Ux3F3DpsVVH\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mjebtHKV24PApa9fR5mQ8gSCAits93Ecb4\",\n \"pubkey\": \"tpubDA9GDAntyJu4KfYLGfo16i1S39nfrDVVe3tAbNuXfzftkSRbASzo9UT1X9j8oGLRfTjnUQF1rGP3FnSQUDfEweRqiZUXhv6WDVDRUHRGoWu\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mm3VT4W1vwPRrPQqCTZytyeVnzbUkmWyTA\",\n \"pubkey\": \"tpubDA9GDAntyJu4N1hoLeYF6TuJuAnv9aZE6k4pAhwgm6hDaFzzMxSSTYMLed637xt7QAMhmB7iVpjn9d55kgmp3z4KKuEooYQeAaqVwJVSqLz\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mmKWdxNhFhFAXNsGTy2tVRwhbpkijgK2bm\",\n \"pubkey\": \"tpubDA9GDAntyJu4PsNjmu5LaSbS7DtcdGC7mjF9NH3Jyu2UrR8FxZK8PErhJHg3cskG7D6GUgLmLJ6LaEnVFFS3WCdnU2gT54YXW9BBtGQQHb6\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mnDP2uk38XSLorT95aqq9N5gy8bf3Wjt9y\",\n \"pubkey\": \"tpubDA9GDAntyJu4dQDNMhay8bq1f5QyCXzL8SQLj11i1pbg1pbrgUUFoJcAbCS56eqe6Xqs3CPKW4DTkir1HJ64uriFBT4xw9FA1unJKFKpGSx\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"moSi1CqRyZzfkLgT1kkrtHS6oYChRvJxqd\",\n \"pubkey\": \"tpubDA9GDAntyJu4mDpFcwkSwF4Hyvn5VSWp2bskbKd9iNqDwdNLbwkzxLwQGF1JArVWEEwk2xV76BXa1hk1nQMQmPd1Ab6tcJPpfKhY8pFZXMX\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mr2s4EoTgVBE4r9JLkwAHDnFX3uGvgufW6\",\n \"pubkey\": \"tpubDA9GDAntyJu4FQqtS3XjPowNGLHcBXgaFZVwwVZa8uK1cFk2mhG4ZbSWQszY7REB1wiauhsbFNU5e8TfpQWChL1uwmoxkW35ytVmWFXfSMG\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"msJmZvJqs2e8C23hovmZKeVdCkitGxbrru\",\n \"pubkey\": \"tpubDA9GDAntyJu4hBpsMFjvMc9AawthJSRgKTRjX5aJ96VS81xaha6fURbWbaJ1d9sTpBk43JQB6oxcaRRBdSkz83s3YVVx6Rxs4B3xp4fpXQV\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"msMFJbadB5dzHvz5oWscZUKvQYEYPk7Ncd\",\n \"pubkey\": \"tpubDA9GDAntyJu4ENuarHFHHvkPf1MQKFyXtS18GUuqFeAmqgmYkWvboJpbm9dZnTFUu1WN3YeyyNMRDVmpU81ad9j18SjGFVXq9rvDyktKDDb\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mt6JggawxBTj1GrZ5DcDHFgmvkDtmBtw8P\",\n \"pubkey\": \"tpubDA9GDAntyJu4rGaqwnidtFkzNjDdbeZxtaVhXWXSkzAgsf5fmcXuFuMAtSHApnmpnawbcjQpLzJzoY9BBJmhXHV8ZTv7iUQTVmQHKzspkZr\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mtESjA4yH9XhMV1TTRPDahQcswXGokjJEQ\",\n \"pubkey\": \"tpubDA9GDAntyJu4kGNiwQwsfXo9MQiNv4zvppZMZG5rJsRuU9yuy5hdbkkyNTYEAPdDfW27WfC1yWd2mtMiUsWkhKk6xGouuZzFwQSepqdFj4m\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mtSMa8yjkyumAEpuu27w5mBKDvtV8WuwUS\",\n \"pubkey\": \"tpubDA9GDAntyJu4bDz5PUjqeS6vDQGgFZ67ttpxoeAh8FMsHmgYXe5MEUHDLmVtSmdjxqzpLsCkLc9efBvVn1qqzuSFV5gffcEHjWD3QmjoAMS\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"mu3Fgd4fLSMmPdBG8M7pMDM9mVgqBsNa2P\",\n \"pubkey\": \"tpubDA9GDAntyJu4ZYzCJS7DcSKHDiEwRLUSG5VkfS5fubFz3fQnrZ32LMAK1fVG6xucP5GLdEtaPtFXmbVd7kzLp5j2viUfWJ8n7HHX9e3rFMS\",\n \"used_times\": 0\n },\n {\n \"account\": \"mhiYjatt6yjzN75xTigQa2hkN69FLRZnNs\",\n \"address\": \"muTdW8b65cWxqTbCnrGyxEMwfNXX1ZYuoa\",\n \"pubkey\": \"tpubDA9GDAntyJu54zEFL428ce3vX5ehsYh4AEaXi3GRtwyLftHLfwJisf7Q1JyQehhw77Q1xvgy4qrc7CSNxn8aBM8xikmNpUwFNSzdUEQyUQ8\",\n \"Line truncated
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -887,7 +905,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\": \"mvW5fF65d8WiGavNWjJcuQ6uRoa4AsSmLZ\"\n}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\"\n}"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -937,10 +955,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Delete a blob",
|
||||
"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}"
|
||||
"curl": "curl -d'{\"method\": \"blob_delete\", \"params\": {\"blob_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet blob delete f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"blob_delete\", \"params\": {\"blob_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": \"Deleted f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\"\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1018,7 +1036,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 \"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}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"3e9c701f71aa9df9dc13e18a1a2d96a0c8f834a4218a3c2cddea815e6bccd3ddf3b96ae3aa0e338cd797b781596a1584\",\n \"8433ac4f1eef3d06976ab7ed852be501ecbbee9c4901e72469183e17a08a1f70d2e994d226bf7c9f570c93fffb42ddb4\",\n \"66615b1c95f4f88df25f1f1a243ec7129d283a6df60a21640a3022f686d2d89f0a5b0757aaeb885d7ac06febe8d07a04\"\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 4,\n \"total_pages\": 1\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1099,10 +1117,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Abandon a channel claim",
|
||||
"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}"
|
||||
"curl": "curl -d'{\"method\": \"channel_abandon\", \"params\": {\"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\", \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet channel abandon 5c15c266bf34c683523ce06cfb7fe5c984221375",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_abandon\", \"params\": {\"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\", \"preview\": false, \"blocking\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000123097a98778ac14275b0c3b444748a09911c5c44ea2d11c4b507c36f74a7cb7d000000006b4830450221008cdfde561c68c5bc509bf87206794b930c8e51ad147e1dc40025cf929d04d32d02206923e395f867551cf8273aa98497cd8339da18e1b81e04b07e4fefa89f932a730121032c31a47c0f8bc4a0c8565f56f796f3cca09b86524b74dea8c16715240134ab1fffffffff0134b7f505000000001976a91425783ce606316d3bac10802a371e229c1363246888ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\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#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"timestamp\": 1619186594,\n \"txid\": \"7dcba7746fc307b5c4112dea445c1c91098a7444b4c3b07542c18a77987a0923\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004b1f16e5b66fbb724cd8967de626e1113083a5d2f391b52fe9896d30aeb374155c8c660dc268195bc2feb2925ce3f4dc2d547bacc43955465ddf94adce214f50d\",\n \"public_key_id\": \"mpgQaTWRWYphbxv94VZsSgW91YK55FZEov\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"miw5LRgpz1FvHDgCLQT3hMoKD5bwSRSK9M\",\n \"amount\": \"0.999893\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"17c121e283ad21ec0c0bd05b59007ff9abd789cc736377336327aa73d34b4a62\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000107\",\n \"total_input\": \"1.0\",\n \"total_output\": \"0.999893\",\n \"txid\": \"17c121e283ad21ec0c0bd05b59007ff9abd789cc736377336327aa73d34b4a62\"\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1232,14 +1250,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\": \"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}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001ca8922cd1c37b7d77e41a53a11b7cb791defa2a4eecfc6ba3cfef78d7d2f6c03010000006b48304502210094ac6bbd1833b430dadb4f835843e8895d7420cb0c8146ac3037f55b0b668ebc02202a178a2c108fef944f28b71fc71c1f8f76403bcfec8a208a41361a809be333b5012103335f36c7b695d71f35a4345aa590f2b3f1efaec93eda106a6fcf083a89877a85ffffffff0200e1f5050000000084b508406368616e6e656c4c5d00125a0a583056301006072a8648ce3d020106052b8104000a03420004b1f16e5b66fbb724cd8967de626e1113083a5d2f391b52fe9896d30aeb374155c8c660dc268195bc2feb2925ce3f4dc2d547bacc43955465ddf94adce214f50d6d7576a9149fcb81549737993f898614438f3dcddefe43ba5388acc462a029000000001976a914cc111fc1cabd8cda886b054333a7239bf339ab5188ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mzjBXvqaeQQUHpxocqhqtdRStrmpW4Ho45\",\n \"amount\": \"7.999876\",\n \"confirmations\": 2,\n \"height\": 207,\n \"nout\": 1,\n \"timestamp\": 1619186594,\n \"txid\": \"036c2f7d8df7fe3cbac6cfeea4a2ef1d79cbb7113aa5417ed7b7371ccd2289ca\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\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#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"timestamp\": null,\n \"txid\": \"3df903b234ce20a7061eb0e2381daf0f81edc8bcc630cc59cbcd86653032950d\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004b1f16e5b66fbb724cd8967de626e1113083a5d2f391b52fe9896d30aeb374155c8c660dc268195bc2feb2925ce3f4dc2d547bacc43955465ddf94adce214f50d\",\n \"public_key_id\": \"mpgQaTWRWYphbxv94VZsSgW91YK55FZEov\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mz7xezDeGSCCwsT1RAV6VSnZvx1Y48GWBz\",\n \"amount\": \"6.983769\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"3df903b234ce20a7061eb0e2381daf0f81edc8bcc630cc59cbcd86653032950d\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.016107\",\n \"total_input\": \"7.999876\",\n \"total_output\": \"7.983769\",\n \"txid\": \"3df903b234ce20a7061eb0e2381daf0f81edc8bcc630cc59cbcd86653032950d\"\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\": \"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}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000123097a98778ac14275b0c3b444748a09911c5c44ea2d11c4b507c36f74a7cb7d010000006b483045022100c4562df8bef779b2f494ef275f2dff0e6b5034e1b1b354fa4aadd0999c50633c0220671886610ed3b99c1e78836b1696ae39150a8a680e7ecbc2e6b72cce95ad25790121025a25bd09226e9bfd30e70205841bbe4588502ced799970bcfc5c32b19f10710affffffff0200e1f50500000000fd5001b50b406269676368616e6e656c4d25010012ab010a583056301006072a8648ce3d020106052b8104000a0342000403a4c9063ae880abb9e7a4f2b0f31b33aa0f2eb00432d0fc3dc6263a0cc4f03f4e8762f2b0549d6e433e28754ff9b9aa86f66fc4779d8ad4392430ea18e86e23121663726561746f7240736d616c6c6d656469612e636f6d1a15687474703a2f2f736d616c6c6d656469612e636f6d22202a1e687474703a2f2f736d616c6c6d656469612e636f6d2f6c6f676f2e6a7067420b426967204368616e6e656c4a1e41206368616e6e656c2077697468206c6f7473206f6620766964656f732e52202a1e687474703a2f2f736d616c6c6d656469612e636f6d2f6c6f676f2e6a70675a056d757369635a0361727462050883011820620308ab016a0208206a0908e9011a044b6979766d7576a914755f01af82d2a8dd32fc3dfde402e9ecb6b8107588ace221d305000000001976a9148f28c757d1d8d84faa35f1af1c1c3c52bc1efba288ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mh5rVtpeDVSih7YixfMP6SQoQ8re4iy8gX\",\n \"amount\": \"1.9993355\",\n \"confirmations\": 1,\n \"height\": 210,\n \"nout\": 1,\n \"timestamp\": 1619186594,\n \"txid\": \"7dcba7746fc307b5c4112dea445c1c91098a7444b4c3b07542c18a77987a0923\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mrDZAfto9XzQP3SjvshVZL4vcsTfSXvLje\",\n \"amount\": \"1.0\",\n \"claim_id\": \"87d1232c6284d36467b41ebe8c8b3d2dfdce01ce\",\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#87d1232c6284d36467b41ebe8c8b3d2dfdce01ce\",\n \"timestamp\": null,\n \"txid\": \"b29b6120bc093923071239eda52c6387f143fcc0c913e15b1fcacd44e2bf202b\",\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\": \"3056301006072a8648ce3d020106052b8104000a0342000403a4c9063ae880abb9e7a4f2b0f31b33aa0f2eb00432d0fc3dc6263a0cc4f03f4e8762f2b0549d6e433e28754ff9b9aa86f66fc4779d8ad4392430ea18e86e23\",\n \"public_key_id\": \"mizH8bDDSiitsoUdZc4wycocXccrY3j4Vi\",\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\": \"mtZumqabuzJQ9UMvtN5a58XCcrBBCPL1BD\",\n \"amount\": \"0.9772285\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"b29b6120bc093923071239eda52c6387f143fcc0c913e15b1fcacd44e2bf202b\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.022107\",\n \"total_input\": \"1.9993355\",\n \"total_output\": \"1.9772285\",\n \"txid\": \"b29b6120bc093923071239eda52c6387f143fcc0c913e15b1fcacd44e2bf202b\"\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1361,17 +1379,55 @@
|
||||
"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\": \"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}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\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#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"timestamp\": 1619186594,\n \"txid\": \"3df903b234ce20a7061eb0e2381daf0f81edc8bcc630cc59cbcd86653032950d\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004b1f16e5b66fbb724cd8967de626e1113083a5d2f391b52fe9896d30aeb374155c8c660dc268195bc2feb2925ce3f4dc2d547bacc43955465ddf94adce214f50d\",\n \"public_key_id\": \"mpgQaTWRWYphbxv94VZsSgW91YK55FZEov\"\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\": \"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}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\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#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"timestamp\": 1619186594,\n \"txid\": \"3df903b234ce20a7061eb0e2381daf0f81edc8bcc630cc59cbcd86653032950d\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004b1f16e5b66fbb724cd8967de626e1113083a5d2f391b52fe9896d30aeb374155c8c660dc268195bc2feb2925ce3f4dc2d547bacc43955465ddf94adce214f50d\",\n \"public_key_id\": \"mpgQaTWRWYphbxv94VZsSgW91YK55FZEov\"\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.",
|
||||
@@ -1525,10 +1581,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Update a channel claim",
|
||||
"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}"
|
||||
"curl": "curl -d'{\"method\": \"channel_update\", \"params\": {\"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\", \"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 5c15c266bf34c683523ce06cfb7fe5c984221375 --title=\"New Channel\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_update\", \"params\": {\"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\", \"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\": \"01000000020d9532306586cdcb59cc30c6bcc8ed810faf1d38e2b01e06a720ce34b203f93d000000006a473044022025740699e7c92648b58019fd6b1d7a78285195bfafeb115f4b5a5e485d1df4de02203f8fc26159454b07e5580ff0b9be8ba8f9aecfd5b1573c00b707b41193b8e1980121032c31a47c0f8bc4a0c8565f56f796f3cca09b86524b74dea8c16715240134ab1fffffffffeed7f31a5c0b04a61481a56e0cc1c71c1fa5f898cabd52efef6ac1445b26057f000000006b483045022100d26d8fa7ff5e1be2f486278c059a6e6c3fb9a002ff14059cd0aa96d3a34e48880220108d5900346d266eae1a6091e0d6e34de4a9f18bdbdced164450a98c5fc975920121035e9a676a6c96274e2da7647804cf7f567df88f4db16aea223caf0d201526df65ffffffff0200e1f50500000000a6b708406368616e6e656c1475132284c9e57ffb6ce03c5283c634bf66c2155c4c6a00125a0a583056301006072a8648ce3d020106052b8104000a03420004b1f16e5b66fbb724cd8967de626e1113083a5d2f391b52fe9896d30aeb374155c8c660dc268195bc2feb2925ce3f4dc2d547bacc43955465ddf94adce214f50d420b4e6577204368616e6e656c6d6d76a9149fcb81549737993f898614438f3dcddefe43ba5388ac6ebeea0b000000001976a914113103aeb6cd62f58efa54a0d0b51dba991e49c888ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\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#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"timestamp\": 1619186594,\n \"txid\": \"3df903b234ce20a7061eb0e2381daf0f81edc8bcc630cc59cbcd86653032950d\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004b1f16e5b66fbb724cd8967de626e1113083a5d2f391b52fe9896d30aeb374155c8c660dc268195bc2feb2925ce3f4dc2d547bacc43955465ddf94adce214f50d\",\n \"public_key_id\": \"mpgQaTWRWYphbxv94VZsSgW91YK55FZEov\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mgNFotMcVkNSmVwGpZHi6dACpVsMKBgFZB\",\n \"amount\": \"1.999604\",\n \"confirmations\": 1,\n \"height\": 209,\n \"nout\": 0,\n \"timestamp\": 1619186594,\n \"txid\": \"7f05265b44c16aefef52bdca98f8a51f1cc7c10c6ea58114a6040b5c1af3d7ee\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\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#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"timestamp\": null,\n \"txid\": \"7dcba7746fc307b5c4112dea445c1c91098a7444b4c3b07542c18a77987a0923\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004b1f16e5b66fbb724cd8967de626e1113083a5d2f391b52fe9896d30aeb374155c8c660dc268195bc2feb2925ce3f4dc2d547bacc43955465ddf94adce214f50d\",\n \"public_key_id\": \"mpgQaTWRWYphbxv94VZsSgW91YK55FZEov\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mh5rVtpeDVSih7YixfMP6SQoQ8re4iy8gX\",\n \"amount\": \"1.9993355\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"7dcba7746fc307b5c4112dea445c1c91098a7444b4c3b07542c18a77987a0923\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.0002685\",\n \"total_input\": \"2.999604\",\n \"total_output\": \"2.9993355\",\n \"txid\": \"7dcba7746fc307b5c4112dea445c1c91098a7444b4c3b07542c18a77987a0923\"\n }\n}"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1583,6 +1639,18 @@
|
||||
"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",
|
||||
@@ -1616,7 +1684,7 @@
|
||||
{
|
||||
"name": "include_received_tips",
|
||||
"type": "bool",
|
||||
"description": "calculate the amount of tips recieved for claim outputs",
|
||||
"description": "calculate the amount of tips received for claim outputs",
|
||||
"is_required": false
|
||||
}
|
||||
],
|
||||
@@ -1624,17 +1692,17 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "List all your claims",
|
||||
"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/",
|
||||
"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/",
|
||||
"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\": [], \"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}"
|
||||
"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\": \"mmpTpyBuV9vuZ56V3fj2yGXG76JEN8SDBm\",\n \"amount\": \"1.0\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\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#bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"signing_channel\": {\n \"address\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\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#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"timestamp\": 1619186594,\n \"txid\": \"7dcba7746fc307b5c4112dea445c1c91098a7444b4c3b07542c18a77987a0923\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004b1f16e5b66fbb724cd8967de626e1113083a5d2f391b52fe9896d30aeb374155c8c660dc268195bc2feb2925ce3f4dc2d547bacc43955465ddf94adce214f50d\",\n \"public_key_id\": \"mpgQaTWRWYphbxv94VZsSgW91YK55FZEov\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1619186595,\n \"txid\": \"7b9ad271e84e82c5b04d07f7914ae915de8f297bf94d9f7490a2bffc9ea4be37\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp12xihy6s\",\n \"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\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#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"timestamp\": 1619186594,\n \"txid\": \"7dcba7746fc307b5c4112dea445c1c91098a7444b4c3b07542c18a77987a0923\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004b1f16e5b66fbb724cd8967de626e1113083a5d2f391b52fe9896d30aeb374155c8c660dc268195bc2feb2925ce3f4dc2d547bacc43955465ddf94adce214f50d\",\n \"public_key_id\": \"mpgQaTWRWYphbxv94VZsSgW91YK55FZEov\",\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\": [], \"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\": [], \"has_source\": false, \"has_no_source\": false, \"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\": [], \"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}"
|
||||
"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\": \"mmpTpyBuV9vuZ56V3fj2yGXG76JEN8SDBm\",\n \"amount\": \"1.0\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\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#bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"signing_channel\": {\n \"address\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\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#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"timestamp\": 1619186594,\n \"txid\": \"7dcba7746fc307b5c4112dea445c1c91098a7444b4c3b07542c18a77987a0923\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004b1f16e5b66fbb724cd8967de626e1113083a5d2f391b52fe9896d30aeb374155c8c660dc268195bc2feb2925ce3f4dc2d547bacc43955465ddf94adce214f50d\",\n \"public_key_id\": \"mpgQaTWRWYphbxv94VZsSgW91YK55FZEov\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1619186595,\n \"txid\": \"7b9ad271e84e82c5b04d07f7914ae915de8f297bf94d9f7490a2bffc9ea4be37\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp12xihy6s\",\n \"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\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#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"timestamp\": 1619186594,\n \"txid\": \"7dcba7746fc307b5c4112dea445c1c91098a7444b4c3b07542c18a77987a0923\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004b1f16e5b66fbb724cd8967de626e1113083a5d2f391b52fe9896d30aeb374155c8c660dc268195bc2feb2925ce3f4dc2d547bacc43955465ddf94adce214f50d\",\n \"public_key_id\": \"mpgQaTWRWYphbxv94VZsSgW91YK55FZEov\",\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}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1831,7 +1899,7 @@
|
||||
{
|
||||
"name": "claim_type",
|
||||
"type": "str",
|
||||
"description": "filter by 'channel', 'stream' or 'unknown'",
|
||||
"description": "filter by 'channel', 'stream', 'repost' or 'collection'",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
@@ -1945,7 +2013,7 @@
|
||||
{
|
||||
"name": "wallet_id",
|
||||
"type": "str",
|
||||
"description": "wallet to check for claim purchase reciepts",
|
||||
"description": "wallet to check for claim purchase receipts",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
@@ -1960,6 +2028,18 @@
|
||||
"description": "lookup and include a boolean indicating if claim being resolved is yours",
|
||||
"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",
|
||||
@@ -1971,17 +2051,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\": [], \"include_purchase_receipt\": false, \"include_is_my_output\": 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\": [], \"no_totals\": false, \"include_purchase_receipt\": false, \"include_is_my_output\": false, \"has_source\": false, \"has_no_source\": 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\": [], \"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}"
|
||||
"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, \"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\": \"mmpTpyBuV9vuZ56V3fj2yGXG76JEN8SDBm\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#5/astream#b\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\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\": 1619186595,\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#bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"short_url\": \"lbry://astream#b\",\n \"signing_channel\": {\n \"address\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#5\",\n \"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\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\": 1619186594,\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#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"short_url\": \"lbry://@channel#5\",\n \"timestamp\": 1619186594,\n \"txid\": \"7dcba7746fc307b5c4112dea445c1c91098a7444b4c3b07542c18a77987a0923\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004b1f16e5b66fbb724cd8967de626e1113083a5d2f391b52fe9896d30aeb374155c8c660dc268195bc2feb2925ce3f4dc2d547bacc43955465ddf94adce214f50d\",\n \"public_key_id\": \"mpgQaTWRWYphbxv94VZsSgW91YK55FZEov\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1619186595,\n \"txid\": \"7b9ad271e84e82c5b04d07f7914ae915de8f297bf94d9f7490a2bffc9ea4be37\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp12xihy6s\",\n \"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\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\": [], \"include_purchase_receipt\": false, \"include_is_my_output\": 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\": [], \"no_totals\": false, \"include_purchase_receipt\": false, \"include_is_my_output\": false, \"has_source\": false, \"has_no_source\": 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\": [], \"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}"
|
||||
"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, \"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\": \"mmpTpyBuV9vuZ56V3fj2yGXG76JEN8SDBm\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#5/astream#b\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\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\": 1619186595,\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#bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"short_url\": \"lbry://astream#b\",\n \"signing_channel\": {\n \"address\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#5\",\n \"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\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\": 1619186594,\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#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"short_url\": \"lbry://@channel#5\",\n \"timestamp\": 1619186594,\n \"txid\": \"7dcba7746fc307b5c4112dea445c1c91098a7444b4c3b07542c18a77987a0923\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004b1f16e5b66fbb724cd8967de626e1113083a5d2f391b52fe9896d30aeb374155c8c660dc268195bc2feb2925ce3f4dc2d547bacc43955465ddf94adce214f50d\",\n \"public_key_id\": \"mpgQaTWRWYphbxv94VZsSgW91YK55FZEov\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1619186595,\n \"txid\": \"7b9ad271e84e82c5b04d07f7914ae915de8f297bf94d9f7490a2bffc9ea4be37\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp12xihy6s\",\n \"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\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}"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2060,7 +2140,7 @@
|
||||
"name": "claims",
|
||||
"type": "list",
|
||||
"description": "claim ids to be included in the collection",
|
||||
"is_required": true
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "allow_duplicate_name",
|
||||
@@ -2110,6 +2190,24 @@
|
||||
"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",
|
||||
@@ -2148,12 +2246,26 @@
|
||||
}
|
||||
],
|
||||
"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": []
|
||||
"examples": [
|
||||
{
|
||||
"title": "Create a collection of one stream",
|
||||
"curl": "curl -d'{\"method\": \"collection_create\", \"params\": {\"name\": \"tom\", \"bid\": \"1.0\", \"claims\": [\"bcd03a6bc9ab0f5694a13410d862af81f735499d\"], \"allow_duplicate_name\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\", \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet collection create --name=tom --bid=1.0 --channel_id=5c15c266bf34c683523ce06cfb7fe5c984221375 --claims=bcd03a6bc9ab0f5694a13410d862af81f735499d",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"collection_create\", \"params\": {\"name\": \"tom\", \"bid\": \"1.0\", \"claims\": [\"bcd03a6bc9ab0f5694a13410d862af81f735499d\"], \"allow_duplicate_name\": false, \"tags\": [], \"languages\": [], \"locations\": [], \"channel_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\", \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001daef8df5dd59c4ef2e5b64332013dabc2ef12ba695cbe481e6cf15211fdd1bfd010000006a47304402204aa8d205ac5000d87b6c4040cb20efb23a97d6f7d590ab4f96c2b32c4214f3f8022074f7e20dc877e683fce13b8fddb84dd3083093b014b8ad0b02aa6a4557f57c2c012102bbf7a3d450aede8d5f60a6889a8e1b66e5f22d7079944623d779d19e2b270973ffffffff0200e1f5050000000091b503746f6d4c6f0175132284c9e57ffb6ce03c5283c634bf66c2155c256e3b7258258dac89ac426b7e6634a8ce11544475ef77194abd183a9de6bb75539bfa416b69f85e5191fca61dfabaac8766ba96f47718d7ab581e06344b26ef1a1812160a149d4935f781af62d81034a194560fabc96b3ad0bc6d7576a91442d128bf839fcc82c9596282d0cdd3bcd5170ee588ac202c7e17000000001976a914d47a9b5eb4d22ce83b0717df98b9022ecd15f36488ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mqsLA2uT7pBfhzPBEQPrXiHtXpMtys7jRb\",\n \"amount\": \"4.947555\",\n \"confirmations\": 2,\n \"height\": 215,\n \"nout\": 1,\n \"timestamp\": 1619186595,\n \"txid\": \"fd1bdd1f2115cfe681e4cb95a62bf12ebcda132033645b2eefc459ddf58defda\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mmcFTMBvn5a1YdH1hWZaQzYbXY8n1ULESS\",\n \"amount\": \"1.0\",\n \"claim_id\": \"1ce582bac00e1fc80e05e2f2357adf2f2b4673c6\",\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#1ce582bac00e1fc80e05e2f2357adf2f2b4673c6\",\n \"signing_channel\": {\n \"address\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\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#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"timestamp\": 1619186594,\n \"txid\": \"7dcba7746fc307b5c4112dea445c1c91098a7444b4c3b07542c18a77987a0923\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004b1f16e5b66fbb724cd8967de626e1113083a5d2f391b52fe9896d30aeb374155c8c660dc268195bc2feb2925ce3f4dc2d547bacc43955465ddf94adce214f50d\",\n \"public_key_id\": \"mpgQaTWRWYphbxv94VZsSgW91YK55FZEov\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": null,\n \"txid\": \"4531b67fa1b3e343e0db9fd88d2ed46953313a9a50bf11f2cd62f33f108ab02b\",\n \"type\": \"claim\",\n \"value\": {\n \"claims\": [\n \"bcd03a6bc9ab0f5694a13410d862af81f735499d\"\n ]\n },\n \"value_type\": \"collection\"\n },\n {\n \"address\": \"mztSRbjwzK9k7BUDXWybL8ZJs2KYQAq6hP\",\n \"amount\": \"3.941448\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"4531b67fa1b3e343e0db9fd88d2ed46953313a9a50bf11f2cd62f33f108ab02b\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.006107\",\n \"total_input\": \"4.947555\",\n \"total_output\": \"4.941448\",\n \"txid\": \"4531b67fa1b3e343e0db9fd88d2ed46953313a9a50bf11f2cd62f33f108ab02b\"\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"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",
|
||||
@@ -2186,7 +2298,15 @@
|
||||
}
|
||||
],
|
||||
"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": []
|
||||
"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\": \"mmcFTMBvn5a1YdH1hWZaQzYbXY8n1ULESS\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#5/tom#1\",\n \"claim_id\": \"1ce582bac00e1fc80e05e2f2357adf2f2b4673c6\",\n \"claim_op\": \"create\",\n \"claims\": [\n {\n \"address\": \"mmpTpyBuV9vuZ56V3fj2yGXG76JEN8SDBm\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#5/astream#b\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\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\": 1619186595,\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#bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"short_url\": \"lbry://astream#b\",\n \"signing_channel\": {\n \"address\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#5\",\n \"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\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\": 1619186594,\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#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"short_url\": \"lbry://@channel#5\",\n \"timestamp\": 1619186594,\n \"txid\": \"7dcba7746fc307b5c4112dea445c1c91098a7444b4c3b07542c18a77987a0923\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004b1f16e5b66fbb724cd8967de626e1113083a5d2f391b52fe9896d30aeb374155c8c660dc268195bc2feb2925ce3f4dc2d547bacc43955465ddf94adce214f50d\",\n \"public_key_id\": \"mpgQaTWRWYphbxv94VZsSgW91YK55FZEov\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1619186595,\n \"txid\": \"7b9ad271e84e82c5b04d07f7914ae915de8f297bf94d9f7490a2bffc9ea4be37\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp12xihy6s\",\n \"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\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\": 1619186595,\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
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "collection_resolve",
|
||||
@@ -2332,12 +2452,6 @@
|
||||
"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",
|
||||
@@ -2386,10 +2500,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Abandon a comment",
|
||||
"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}"
|
||||
"curl": "curl -d'{\"method\": \"comment_abandon\", \"params\": {\"comment_id\": \"5fc8a6d6a65cf68be2bab52f65762eb3c7855570d01754ffb4543eff988d97c6230740cf2e541ca07f31bb6b79e5d01b32d077ec63a6b193d16b8bbf05423030\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet comment abandon 5fc8a6d6a65cf68be2bab52f65762eb3c7855570d01754ffb4543eff988d97c6230740cf2e541ca07f31bb6b79e5d01b32d077ec63a6b193d16b8bbf05423030",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_abandon\", \"params\": {\"comment_id\": \"5fc8a6d6a65cf68be2bab52f65762eb3c7855570d01754ffb4543eff988d97c6230740cf2e541ca07f31bb6b79e5d01b32d077ec63a6b193d16b8bbf05423030\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"5fc8a6d6a65cf68be2bab52f65762eb3c7855570d01754ffb4543eff988d97c6230740cf2e541ca07f31bb6b79e5d01b32d077ec63a6b193d16b8bbf05423030\": {\n \"abandoned\": true\n }\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -2444,17 +2558,17 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Posting a comment as your channel",
|
||||
"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}"
|
||||
"curl": "curl -d'{\"method\": \"comment_create\", \"params\": {\"comment\": \"Thank you Based God\", \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\", \"channel_name\": \"@channel\", \"channel_account_id\": []}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet comment create --comment=\"Thank you Based God\" --channel_name=@channel --claim_id=bcd03a6bc9ab0f5694a13410d862af81f735499d",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_create\", \"params\": {\"comment\": \"Thank you Based God\", \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\", \"channel_name\": \"@channel\", \"channel_account_id\": []}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"channel_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"comment\": \"Thank you Based God\",\n \"comment_id\": \"5fc8a6d6a65cf68be2bab52f65762eb3c7855570d01754ffb4543eff988d97c6230740cf2e541ca07f31bb6b79e5d01b32d077ec63a6b193d16b8bbf05423030\",\n \"is_claim_signature_valid\": true,\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"signature\": \"cb6d31df7a9e7bb181cc3fec3843eb90e7e7ccd8d7afd8a718ef9be602135d574ff3e39246b84663c057b7146035df7efe54fbbe3b3d18be2b6e8c3317d98de4\",\n \"signing_ts\": \"1619186572\",\n \"timestamp\": \"1619186572\"\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\", \"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}"
|
||||
"curl": "curl -d'{\"method\": \"comment_create\", \"params\": {\"comment\": \"I have photographic evidence confirming Sasquatch exists\", \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\", \"parent_id\": \"5fc8a6d6a65cf68be2bab52f65762eb3c7855570d01754ffb4543eff988d97c6230740cf2e541ca07f31bb6b79e5d01b32d077ec63a6b193d16b8bbf05423030\", \"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=5fc8a6d6a65cf68be2bab52f65762eb3c7855570d01754ffb4543eff988d97c6230740cf2e541ca07f31bb6b79e5d01b32d077ec63a6b193d16b8bbf05423030 --claim_id=bcd03a6bc9ab0f5694a13410d862af81f735499d",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_create\", \"params\": {\"comment\": \"I have photographic evidence confirming Sasquatch exists\", \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\", \"parent_id\": \"5fc8a6d6a65cf68be2bab52f65762eb3c7855570d01754ffb4543eff988d97c6230740cf2e541ca07f31bb6b79e5d01b32d077ec63a6b193d16b8bbf05423030\", \"channel_name\": \"@channel\", \"channel_account_id\": []}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"channel_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"comment\": \"I have photographic evidence confirming Sasquatch exists\",\n \"comment_id\": \"44906b7921edca7d32b3dbfd092adc9a33cd14ab0e87ba5b8be0ccc45dd3a89bd6c294118ca81278bc20269d9c0aca27f6c7b9126e6ad0d97eb64df89ecc91cf\",\n \"is_claim_signature_valid\": true,\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"parent_id\": \"5fc8a6d6a65cf68be2bab52f65762eb3c7855570d01754ffb4543eff988d97c6230740cf2e541ca07f31bb6b79e5d01b32d077ec63a6b193d16b8bbf05423030\",\n \"signature\": \"775f999681b9b20f7eb9f60a72ce64e63b2cb552fb25c2eabdfafd35d7bef13ae2d51ab35debfe84411b110bd09a4a8104bd191fb2bfa1eedb6e882fa484af4a\",\n \"signing_ts\": \"1619186572\",\n \"timestamp\": \"1619186572\"\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -2541,17 +2655,17 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "List all comments on a claim",
|
||||
"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}"
|
||||
"curl": "curl -d'{\"method\": \"comment_list\", \"params\": {\"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\", \"include_replies\": true, \"skip_validation\": false, \"is_channel_signature_valid\": false, \"visible\": false, \"hidden\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet comment list bcd03a6bc9ab0f5694a13410d862af81f735499d --include_replies",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_list\", \"params\": {\"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\", \"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\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"comment\": \"I have photographic evidence confirming Sasquatch exists\",\n \"comment_id\": \"44906b7921edca7d32b3dbfd092adc9a33cd14ab0e87ba5b8be0ccc45dd3a89bd6c294118ca81278bc20269d9c0aca27f6c7b9126e6ad0d97eb64df89ecc91cf\",\n \"is_channel_signature_valid\": true,\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"parent_id\": \"5fc8a6d6a65cf68be2bab52f65762eb3c7855570d01754ffb4543eff988d97c6230740cf2e541ca07f31bb6b79e5d01b32d077ec63a6b193d16b8bbf05423030\",\n \"signature\": \"775f999681b9b20f7eb9f60a72ce64e63b2cb552fb25c2eabdfafd35d7bef13ae2d51ab35debfe84411b110bd09a4a8104bd191fb2bfa1eedb6e882fa484af4a\",\n \"signing_ts\": \"1619186572\",\n \"timestamp\": \"1619186572\"\n },\n {\n \"channel_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"comment\": \"Thank you Based God\",\n \"comment_id\": \"5fc8a6d6a65cf68be2bab52f65762eb3c7855570d01754ffb4543eff988d97c6230740cf2e541ca07f31bb6b79e5d01b32d077ec63a6b193d16b8bbf05423030\",\n \"is_channel_signature_valid\": true,\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"signature\": \"cb6d31df7a9e7bb181cc3fec3843eb90e7e7ccd8d7afd8a718ef9be602135d574ff3e39246b84663c057b7146035df7efe54fbbe3b3d18be2b6e8c3317d98de4\",\n \"signing_ts\": \"1619186572\",\n \"timestamp\": \"1619186572\"\n }\n ],\n \"page\": 1,\n \"page_size\": 50,\n \"total_items\": 2,\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\": \"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}"
|
||||
"curl": "curl -d'{\"method\": \"comment_list\", \"params\": {\"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\", \"parent_id\": \"5fc8a6d6a65cf68be2bab52f65762eb3c7855570d01754ffb4543eff988d97c6230740cf2e541ca07f31bb6b79e5d01b32d077ec63a6b193d16b8bbf05423030\", \"include_replies\": false, \"skip_validation\": false, \"is_channel_signature_valid\": false, \"visible\": false, \"hidden\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet comment list bcd03a6bc9ab0f5694a13410d862af81f735499d --parent_id=5fc8a6d6a65cf68be2bab52f65762eb3c7855570d01754ffb4543eff988d97c6230740cf2e541ca07f31bb6b79e5d01b32d077ec63a6b193d16b8bbf05423030",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_list\", \"params\": {\"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\", \"parent_id\": \"5fc8a6d6a65cf68be2bab52f65762eb3c7855570d01754ffb4543eff988d97c6230740cf2e541ca07f31bb6b79e5d01b32d077ec63a6b193d16b8bbf05423030\", \"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\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"comment\": \"I have photographic evidence confirming Sasquatch exists\",\n \"comment_id\": \"44906b7921edca7d32b3dbfd092adc9a33cd14ab0e87ba5b8be0ccc45dd3a89bd6c294118ca81278bc20269d9c0aca27f6c7b9126e6ad0d97eb64df89ecc91cf\",\n \"is_channel_signature_valid\": true,\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"parent_id\": \"5fc8a6d6a65cf68be2bab52f65762eb3c7855570d01754ffb4543eff988d97c6230740cf2e541ca07f31bb6b79e5d01b32d077ec63a6b193d16b8bbf05423030\",\n \"signature\": \"775f999681b9b20f7eb9f60a72ce64e63b2cb552fb25c2eabdfafd35d7bef13ae2d51ab35debfe84411b110bd09a4a8104bd191fb2bfa1eedb6e882fa484af4a\",\n \"signing_ts\": \"1619186572\",\n \"timestamp\": \"1619186572\"\n },\n {\n \"channel_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"comment\": \"Thank you Based God\",\n \"comment_id\": \"5fc8a6d6a65cf68be2bab52f65762eb3c7855570d01754ffb4543eff988d97c6230740cf2e541ca07f31bb6b79e5d01b32d077ec63a6b193d16b8bbf05423030\",\n \"is_channel_signature_valid\": true,\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"signature\": \"cb6d31df7a9e7bb181cc3fec3843eb90e7e7ccd8d7afd8a718ef9be602135d574ff3e39246b84663c057b7146035df7efe54fbbe3b3d18be2b6e8c3317d98de4\",\n \"signing_ts\": \"1619186572\",\n \"timestamp\": \"1619186572\"\n }\n ],\n \"page\": 1,\n \"page_size\": 50,\n \"total_items\": 2,\n \"total_pages\": 1\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -2720,10 +2834,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\": \"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}"
|
||||
"curl": "curl -d'{\"method\": \"comment_update\", \"params\": {\"comment\": \"Where there was once sasquatch, there is not\", \"comment_id\": \"5fc8a6d6a65cf68be2bab52f65762eb3c7855570d01754ffb4543eff988d97c6230740cf2e541ca07f31bb6b79e5d01b32d077ec63a6b193d16b8bbf05423030\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet comment update Where there was once sasquatch, there is not --comment_id=5fc8a6d6a65cf68be2bab52f65762eb3c7855570d01754ffb4543eff988d97c6230740cf2e541ca07f31bb6b79e5d01b32d077ec63a6b193d16b8bbf05423030",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"comment_update\", \"params\": {\"comment\": \"Where there was once sasquatch, there is not\", \"comment_id\": \"5fc8a6d6a65cf68be2bab52f65762eb3c7855570d01754ffb4543eff988d97c6230740cf2e541ca07f31bb6b79e5d01b32d077ec63a6b193d16b8bbf05423030\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"channel_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"channel_name\": \"@channel\",\n \"channel_url\": \"lbry://@channel#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"comment\": \"Where there was once sasquatch, there is not\",\n \"comment_id\": \"5fc8a6d6a65cf68be2bab52f65762eb3c7855570d01754ffb4543eff988d97c6230740cf2e541ca07f31bb6b79e5d01b32d077ec63a6b193d16b8bbf05423030\",\n \"is_hidden\": false,\n \"is_pinned\": false,\n \"parent_id\": null,\n \"signature\": \"b37359c9301ab871acf14a0327b6151b89f639c2490134006687bcee4bd4c627b25ce2a520973a769cd32fa3cbbe43323ce23a9a1141dc768c992d146c5ca1d1\",\n \"signing_ts\": \"1619186573\",\n \"timestamp\": \"1619186572\"\n }\n}"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2813,9 +2927,9 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Delete a file",
|
||||
"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()",
|
||||
"curl": "curl -d'{\"method\": \"file_delete\", \"params\": {\"delete_from_download_dir\": false, \"delete_all\": false, \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet file delete --claim_id=\"bcd03a6bc9ab0f5694a13410d862af81f735499d\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_delete\", \"params\": {\"delete_from_download_dir\": false, \"delete_all\": false, \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": true\n}"
|
||||
}
|
||||
]
|
||||
@@ -2976,14 +3090,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\": \"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
|
||||
"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\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\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\": \"6153d7a516ff43d69f858f7353fc9a39\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp12xihy6s\",\n \"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"7b9ad271e84e82c5b04d07f7914ae915de8f297bf94d9f7490a2bffc9ea4be37:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"0175132284c9e57ffb6ce03c5283c634bf66c2155c29355d45feccaadb918ace380beac35a09dc3df2c22c5a5ee688d37af34904d5354ddeefe50206e3467c9559895cbf61b6e319a44256bf87b52a2ad7720244cf0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d703132786968793673180b22186170706c69636174696f6e2f6f637465742d73747265616d3230f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"purchase_receipt\": null,\n \"reflector_progress\": 100,\n \"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"5811a98af0070bbe1d55e78b9eccf809c0b3e334b0f4daf8b5832b0f2361e6940547f97da8768a8663a35607460d814a\",\n \"stream_name\": \"tmp12xihy6s\",\n \"streaming_url\": \"http://localhost:5280/stream/f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"suggested_file_name\": \"tmp12xihy6s\",\n \"timestamp\": null,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"7b9ad271e84e82c5b04d07f7914ae915de8f297bf94d9f7490a2bffc9ea4be37\",\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\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"30a49013449a01baf6c5a15adca029bbd3cb8487\",\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\": \"0ac74e9ad025a7b43c7088801dbcad53\",\n \"metadata\": {\n \"author\": \"Picaso\",\n \"description\": \"A blank PNG that is 5x7.\",\n \"fee\": {\n \"address\": \"mi9HPZePTMpu83NpAQwTqJkfPbSgLZhFPU\",\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\": \"1619186570\",\n \"source\": {\n \"hash\": \"6c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545\",\n \"media_type\": \"image/png\",\n \"name\": \"tmpie38oo39.png\",\n \"sd_hash\": \"66615b1c95f4f88df25f1f1a243ec7129d283a6df60a21640a3022f686d2d89f0a5b0757aaeb885d7ac06febe8d07a04\",\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\": \"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}"
|
||||
"curl": "curl -d'{\"method\": \"file_list\", \"params\": {\"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\", \"reverse\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet file list --claim_id=\"bcd03a6bc9ab0f5694a13410d862af81f735499d\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_list\", \"params\": {\"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\", \"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\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\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\": \"6153d7a516ff43d69f858f7353fc9a39\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp12xihy6s\",\n \"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"7b9ad271e84e82c5b04d07f7914ae915de8f297bf94d9f7490a2bffc9ea4be37:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"0175132284c9e57ffb6ce03c5283c634bf66c2155c29355d45feccaadb918ace380beac35a09dc3df2c22c5a5ee688d37af34904d5354ddeefe50206e3467c9559895cbf61b6e319a44256bf87b52a2ad7720244cf0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d703132786968793673180b22186170706c69636174696f6e2f6f637465742d73747265616d3230f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"purchase_receipt\": null,\n \"reflector_progress\": 100,\n \"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"5811a98af0070bbe1d55e78b9eccf809c0b3e334b0f4daf8b5832b0f2361e6940547f97da8768a8663a35607460d814a\",\n \"stream_name\": \"tmp12xihy6s\",\n \"streaming_url\": \"http://localhost:5280/stream/f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"suggested_file_name\": \"tmp12xihy6s\",\n \"timestamp\": 1619186595,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"7b9ad271e84e82c5b04d07f7914ae915de8f297bf94d9f7490a2bffc9ea4be37\",\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}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -3100,10 +3214,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Save a file to the downloads directory",
|
||||
"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}"
|
||||
"curl": "curl -d'{\"method\": \"file_save\", \"params\": {\"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\"}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet file save --sd_hash=\"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_save\", \"params\": {\"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\"}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"added_on\": 1619186574,\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 4,\n \"content_fee\": null,\n \"download_directory\": \"/tmp/tmp3yjc8ttn\",\n \"download_path\": \"/tmp/tmp3yjc8ttn/tmp12xihy6s_1\",\n \"file_name\": \"tmp12xihy6s_1\",\n \"height\": 214,\n \"is_fully_reflected\": false,\n \"key\": \"6153d7a516ff43d69f858f7353fc9a39\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp12xihy6s\",\n \"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"7b9ad271e84e82c5b04d07f7914ae915de8f297bf94d9f7490a2bffc9ea4be37:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"0175132284c9e57ffb6ce03c5283c634bf66c2155c29355d45feccaadb918ace380beac35a09dc3df2c22c5a5ee688d37af34904d5354ddeefe50206e3467c9559895cbf61b6e319a44256bf87b52a2ad7720244cf0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d703132786968793673180b22186170706c69636174696f6e2f6f637465742d73747265616d3230f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"purchase_receipt\": null,\n \"reflector_progress\": 0,\n \"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"5811a98af0070bbe1d55e78b9eccf809c0b3e334b0f4daf8b5832b0f2361e6940547f97da8768a8663a35607460d814a\",\n \"stream_name\": \"tmp12xihy6s\",\n \"streaming_url\": \"http://localhost:5280/stream/f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"suggested_file_name\": \"tmp12xihy6s\",\n \"timestamp\": 1619186595,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"7b9ad271e84e82c5b04d07f7914ae915de8f297bf94d9f7490a2bffc9ea4be37\",\n \"uploading_to_reflector\": false,\n \"written_bytes\": 11\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -3384,7 +3498,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\": \"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}"
|
||||
"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/lex/.local/share/lbry/lbrynet/daemon_settings.yml\",\n \"data_dir\": \"/tmp/tmp3yjc8ttn\",\n \"download_dir\": \"/tmp/tmp3yjc8ttn\",\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/tmp3yjc8ttn\",\n \"wallets\": [\n \"default_wallet\"\n ]\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -3459,10 +3573,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Abandon a stream claim",
|
||||
"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}"
|
||||
"curl": "curl -d'{\"method\": \"stream_abandon\", \"params\": {\"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\", \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet stream abandon bcd03a6bc9ab0f5694a13410d862af81f735499d",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_abandon\", \"params\": {\"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\", \"preview\": false, \"blocking\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000137bea49efcbfa290749f4df97b298fde15e94a91f7074db0c5824ee871d29a7b000000006a47304402203412da1fa2b96cc1191e36deab1bad5e822ec9cb4f88e9267632e87dd5dd4bf7022031daa32521dcf4f69d0ba71261dd33f7e97fbfe0f3dfa29eb9704f0c8e94bab6012103a0f9331ba7bb5ec620354ccaf4579e1195929316a8a03269f0389e6aa40e103dffffffff0134b7f505000000001976a9148ce9b7e1af3519b3ac3d6fc6dd79e8b2fb82f2a688ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mmpTpyBuV9vuZ56V3fj2yGXG76JEN8SDBm\",\n \"amount\": \"1.0\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\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#bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"timestamp\": 1619186595,\n \"txid\": \"7b9ad271e84e82c5b04d07f7914ae915de8f297bf94d9f7490a2bffc9ea4be37\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp12xihy6s\",\n \"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mtN2swZj3Wynoe9L6R82xxk7xaTWs5N6kb\",\n \"amount\": \"0.999893\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"6021f8bfa24e637732164e17f2272ced687f4b1256a9cc6ff5715bda6a71e42c\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000107\",\n \"total_input\": \"1.0\",\n \"total_output\": \"0.999893\",\n \"txid\": \"6021f8bfa24e637732164e17f2272ced687f4b1256a9cc6ff5715bda6a71e42c\"\n }\n}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -3500,7 +3614,19 @@
|
||||
"name": "file_path",
|
||||
"type": "str",
|
||||
"description": "path to file to be associated with name.",
|
||||
"is_required": true
|
||||
"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",
|
||||
@@ -3616,6 +3742,12 @@
|
||||
"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",
|
||||
@@ -3675,17 +3807,17 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Create a stream claim without metadata",
|
||||
"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}"
|
||||
"curl": "curl -d'{\"method\": \"stream_create\", \"params\": {\"name\": \"astream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmp12xihy6s\", \"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/tmp12xihy6s",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_create\", \"params\": {\"name\": \"astream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmp12xihy6s\", \"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\": \"01000000010d9532306586cdcb59cc30c6bcc8ed810faf1d38e2b01e06a720ce34b203f93d010000006b483045022100b3aec529900a8019a269482d77b7da0cd65170365839702814db3e724b93f0b50220298b277f4c06ca9f1192523284880f73e4ef67b30b3a266efa7dc94e538a1fb5012103784172862f04b1e6c2c6973ad24461b7f1a5afb65814b7d3eefb434c7dad0792ffffffff0200e1f50500000000bab5076173747265616d4c94000a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d703132786968793673180b22186170706c69636174696f6e2f6f637465742d73747265616d3230f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea6d7576a91445207a9e9642daffd510f3394e2275ffecb3dfa288ac38fb9423000000001976a914e17fa7172490e99ae32889b75416ab97a7934c9b88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mz7xezDeGSCCwsT1RAV6VSnZvx1Y48GWBz\",\n \"amount\": \"6.983769\",\n \"confirmations\": 4,\n \"height\": 209,\n \"nout\": 1,\n \"timestamp\": 1619186594,\n \"txid\": \"3df903b234ce20a7061eb0e2381daf0f81edc8bcc630cc59cbcd86653032950d\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mmpTpyBuV9vuZ56V3fj2yGXG76JEN8SDBm\",\n \"amount\": \"1.0\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\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#bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"timestamp\": null,\n \"txid\": \"f79f820a535343bd3f0ced251687a17e412bd900e51bf0669dec67df85f6dbba\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp12xihy6s\",\n \"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"n25HFgSFcDw1unkj8wTi2tVq6LB3hpd3DX\",\n \"amount\": \"5.969662\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"f79f820a535343bd3f0ced251687a17e412bd900e51bf0669dec67df85f6dbba\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.014107\",\n \"total_input\": \"6.983769\",\n \"total_output\": \"6.969662\",\n \"txid\": \"f79f820a535343bd3f0ced251687a17e412bd900e51bf0669dec67df85f6dbba\"\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/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
|
||||
"curl": "curl -d'{\"method\": \"stream_create\", \"params\": {\"name\": \"blank-image\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpie38oo39.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\": 1619186570, \"channel_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\", \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet stream create blank-image 1.0 /tmp/tmpie38oo39.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=1619186570 --channel_id=\"5c15c266bf34c683523ce06cfb7fe5c984221375\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_create\", \"params\": {\"name\": \"blank-image\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpie38oo39.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\": 1619186570, \"channel_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\", \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001badbf685df67ec9d66f01be500d92b417ea1871625ed0c3fbd4353530a829ff7010000006b4830450221009e4c32407bee4da0c778760a72b2bf7886304a7353791b46f1c988c2b1af1b8b0220135bb6146bf859fa673047c369ed69b0ea8afda19bbf966e4f3bc6e634eada4d0121030e089bbbe50c6d7ccd1fed871a8a122110790d52807de6ca8c62c62a1132160cffffffff0200e1f50500000000fddc01b50b626c616e6b2d696d6167654db1010175132284c9e57ffb6ce03c5283c634bf66c2155c6a58b698a1aa43f0e8a6c902011194d0f2e3f1ac4fe0cab54c3d690845f73bfcaeff030384ab3ba2372a57e58daf5579d0a39eb55964fae5a823c3e5e69b357b0ae6010a82010a306c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545120f746d70696533386f6f33392e706e6718632209696d6167652f706e67323066615b1c95f4f88df25f1f1a243ec7129d283a6df60a21640a3022f686d2d89f0a5b0757aaeb885d7ac06febe8d07a04120650696361736f1a0d5075626c696320446f6d61696e2218687474703a2f2f7075626c69632d646f6d61696e2e6f7267288aa78b84063222080112196f1ccf2a77c401281744e1ee1b91bb59fde2b1982051d1686f188087a70e520408051007420b426c616e6b20496d6167654a184120626c616e6b20504e472074686174206973203578372e52252a23687474703a2f2f736d616c6c6d656469612e636f6d2f7468756d626e61696c2e6a70675a05626c616e6b5a03617274620208016a1308ec0112024e481a0a4d616e636865737465726d7576a9141ccf2a77c401281744e1ee1b91bb59fde2b1982088acac5e7d1d000000001976a914718bd3897a6f10f3e7ef8dd0521654677826a57b88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"n25HFgSFcDw1unkj8wTi2tVq6LB3hpd3DX\",\n \"amount\": \"5.969662\",\n \"confirmations\": 2,\n \"height\": 213,\n \"nout\": 1,\n \"timestamp\": 1619186595,\n \"txid\": \"f79f820a535343bd3f0ced251687a17e412bd900e51bf0669dec67df85f6dbba\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mi9HPZePTMpu83NpAQwTqJkfPbSgLZhFPU\",\n \"amount\": \"1.0\",\n \"claim_id\": \"30a49013449a01baf6c5a15adca029bbd3cb8487\",\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#30a49013449a01baf6c5a15adca029bbd3cb8487\",\n \"signing_channel\": {\n \"address\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\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#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"timestamp\": 1619186594,\n \"txid\": \"7dcba7746fc307b5c4112dea445c1c91098a7444b4c3b07542c18a77987a0923\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004b1f16e5b66fbb724cd8967de626e1113083a5d2f391b52fe9896d30aeb374155c8c660dc268195bc2feb2925ce3f4dc2d547bacc43955465ddf94adce214f50d\",\n \"public_key_id\": \"mpgQaTWRWYphbxv94VZsSgW91YK55FZEov\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": null,\n \"txid\": \"fd1bdd1f2115cfe681e4cb95a62bf12ebcda132033645b2eefc459ddf58defda\",\n \"type\": \"claim\",\n \"value\": {\n \"author\": \"Picaso\",\n \"description\": \"A blank PNG that is 5x7.\",\n \"fee\": {\n \"address\": \"mi9HPZePTMpu83NpAQwTqJkfPbSgLZhFPU\",\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\": \"1619186570\",\n \"source\": {\n \"hash\": \"6c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545\",\n \"media_type\": \"image/png\",\n \"name\": \"tmpie38oo39.png\",\n \"sd_hash\": \"66615b1c95f4f88df25f1f1a243ec7129d283a6df60a21640a3022f686d2d89f0a5b0757aaeb885d7ac06febe8d07a04\",\n \"size\": \"99\"\n },\n \"stream_type\": \"image\",\n \"tags\": [\n \"blank\",\n \"art\"\n ],\n \"thuLine truncated
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -3755,14 +3887,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\": \"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}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mmpTpyBuV9vuZ56V3fj2yGXG76JEN8SDBm\",\n \"amount\": \"1.0\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\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#bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"signing_channel\": {\n \"address\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\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#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"timestamp\": 1619186594,\n \"txid\": \"7dcba7746fc307b5c4112dea445c1c91098a7444b4c3b07542c18a77987a0923\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004b1f16e5b66fbb724cd8967de626e1113083a5d2f391b52fe9896d30aeb374155c8c660dc268195bc2feb2925ce3f4dc2d547bacc43955465ddf94adce214f50d\",\n \"public_key_id\": \"mpgQaTWRWYphbxv94VZsSgW91YK55FZEov\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1619186595,\n \"txid\": \"7b9ad271e84e82c5b04d07f7914ae915de8f297bf94d9f7490a2bffc9ea4be37\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp12xihy6s\",\n \"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mmpTpyBuV9vuZ56V3fj2yGXG76JEN8SDBm\",\n \"amount\": \"1.0\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\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#bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"timestamp\": 1619186595,\n \"txid\": \"f79f820a535343bd3f0ced251687a17e412bd900e51bf0669dec67df85f6dbba\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp12xihy6s\",\n \"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\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\": \"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}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mmpTpyBuV9vuZ56V3fj2yGXG76JEN8SDBm\",\n \"amount\": \"1.0\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\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#bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"signing_channel\": {\n \"address\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\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#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"timestamp\": 1619186594,\n \"txid\": \"7dcba7746fc307b5c4112dea445c1c91098a7444b4c3b07542c18a77987a0923\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004b1f16e5b66fbb724cd8967de626e1113083a5d2f391b52fe9896d30aeb374155c8c660dc268195bc2feb2925ce3f4dc2d547bacc43955465ddf94adce214f50d\",\n \"public_key_id\": \"mpgQaTWRWYphbxv94VZsSgW91YK55FZEov\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1619186595,\n \"txid\": \"7b9ad271e84e82c5b04d07f7914ae915de8f297bf94d9f7490a2bffc9ea4be37\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp12xihy6s\",\n \"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mmpTpyBuV9vuZ56V3fj2yGXG76JEN8SDBm\",\n \"amount\": \"1.0\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\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#bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"timestamp\": 1619186595,\n \"txid\": \"f79f820a535343bd3f0ced251687a17e412bd900e51bf0669dec67df85f6dbba\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp12xihy6s\",\n \"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\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}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -4024,6 +4156,12 @@
|
||||
"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",
|
||||
@@ -4095,10 +4233,10 @@
|
||||
"examples": [
|
||||
{
|
||||
"title": "Update a stream claim to add channel",
|
||||
"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
|
||||
"curl": "curl -d'{\"method\": \"stream_update\", \"params\": {\"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\", \"validate_file\": false, \"optimize_file\": false, \"clear_fee\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"channel_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\", \"clear_channel\": false, \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false, \"replace\": false}}' http://localhost:5279/",
|
||||
"lbrynet": "lbrynet stream update bcd03a6bc9ab0f5694a13410d862af81f735499d --channel_id=\"5c15c266bf34c683523ce06cfb7fe5c984221375\"",
|
||||
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_update\", \"params\": {\"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\", \"validate_file\": false, \"optimize_file\": false, \"clear_fee\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"channel_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\", \"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\": \"0100000002badbf685df67ec9d66f01be500d92b417ea1871625ed0c3fbd4353530a829ff7000000006a47304402202f8600123db5731f4702cddf0f8f56aba57555b124ce30c6282475c3fdfb0a150220286c133895326dcc9a0f3ea1cda7bbaa2c5ab24d802e1a28ecfea296408ddb4f012103a0f9331ba7bb5ec620354ccaf4579e1195929316a8a03269f0389e6aa40e103dffffffff2b20bfe244cdca1f5be113c9c0fc43f187632ca5ed391207233909bc20619bb2010000006a47304402206828757a2a417405079bd345bdd495e6b2a4937cb7f20d5c1b22626bc28d8475022004ee827093b6c2a091aeda2493d0ab47283dcd78d765bbfcb4b8b454e88e711e0121038564fc7ee856388d69c509f057b6aa7d7d9b341ebccb7d6452bc0adb0c6d50e7ffffffff0200e1f50500000000fd2301b7076173747265616d149d4935f781af62d81034a194560fabc96b3ad0bc4ce80175132284c9e57ffb6ce03c5283c634bf66c2155c29355d45feccaadb918ace380beac35a09dc3df2c22c5a5ee688d37af34904d5354ddeefe50206e3467c9559895cbf61b6e319a44256bf87b52a2ad7720244cf0a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d703132786968793673180b22186170706c69636174696f6e2f6f637465742d73747265616d3230f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea6d6d76a91445207a9e9642daffd510f3394e2275ffecb3dfa288ac32a0d205000000001976a914eb1c5433f3da0f37cd32430383e5614e02e412ca88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mmpTpyBuV9vuZ56V3fj2yGXG76JEN8SDBm\",\n \"amount\": \"1.0\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\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#bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"timestamp\": 1619186595,\n \"txid\": \"f79f820a535343bd3f0ced251687a17e412bd900e51bf0669dec67df85f6dbba\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp12xihy6s\",\n \"sd_hash\": \"f4f9e85899fd81833288ae98c314521b6a19336063c981bb8aec8ef948e2fbc787aed892943bfa5ca48e066e5a7b26ea\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mtZumqabuzJQ9UMvtN5a58XCcrBBCPL1BD\",\n \"amount\": \"0.9772285\",\n \"confirmations\": 3,\n \"height\": 211,\n \"nout\": 1,\n \"timestamp\": 1619186594,\n \"txid\": \"b29b6120bc093923071239eda52c6387f143fcc0c913e15b1fcacd44e2bf202b\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mmpTpyBuV9vuZ56V3fj2yGXG76JEN8SDBm\",\n \"amount\": \"1.0\",\n \"claim_id\": \"bcd03a6bc9ab0f5694a13410d862af81f735499d\",\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#bcd03a6bc9ab0f5694a13410d862af81f735499d\",\n \"signing_channel\": {\n \"address\": \"mv5sXLuaYTqALHhPNerS1KCR9DBnhLV2HR\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5c15c266bf34c683523ce06cfb7fe5c984221375\",\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#5c15c266bf34c683523ce06cfb7fe5c984221375\",\n \"timestamp\": 1619186594,\n \"txid\": \"7dcba7746fc307b5c4112dea445c1c91098a7444b4c3b07542c18a77987a0923\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a03420004b1f16e5b66fbb724cd8967de626e1113083a5d2f391b52fe9896d30aeb374155c8c660dc268195bc2feb2925ce3f4dc2d547bacc43955465ddf94adce214f50d\",\n \"public_key_id\": \"mpgQaTWRWYphbxv94VZsSgW91YK55FZEov\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": null,\n \"txid\": \"7b9ad271e84e82c5b04d07f7914ae915de8f297bf94d9f7490a2bffc9ea4be37\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n Line truncated
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -4474,7 +4612,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\": \"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}"
|
||||
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"abandon_info\": [],\n \"claim_info\": [],\n \"confirmations\": 1,\n \"date\": \"2021-04-23 10:03\",\n \"fee\": \"-0.000124\",\n \"purchase_info\": [],\n \"support_info\": [],\n \"timestamp\": 1619186594,\n \"txid\": \"036c2f7d8df7fe3cbac6cfeea4a2ef1d79cbb7113aa5417ed7b7371ccd2289ca\",\n \"update_info\": [],\n \"value\": \"0.0\"\n },\n {\n \"abandon_info\": [],\n \"claim_info\": [],\n \"confirmations\": 7,\n \"date\": \"2021-04-23 10:03\",\n \"fee\": \"0.0\",\n \"purchase_info\": [],\n \"support_info\": [],\n \"timestamp\": 1619186593,\n \"txid\": \"7c7b6ef27b3b65fdd90f713d572d63f3f626a75e0f613dc1fd45d6e9a9a1b640\",\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}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -4525,6 +4663,12 @@
|
||||
"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",
|
||||
@@ -4582,7 +4726,7 @@
|
||||
{
|
||||
"name": "include_received_tips",
|
||||
"type": "bool",
|
||||
"description": "calculate the amount of tips recieved for claim outputs",
|
||||
"description": "calculate the amount of tips received for claim outputs",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
@@ -4659,6 +4803,18 @@
|
||||
"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",
|
||||
@@ -4775,6 +4931,12 @@
|
||||
"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",
|
||||
@@ -4867,6 +5029,18 @@
|
||||
"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
@@ -1,2 +1,2 @@
|
||||
__version__ = "0.86.1"
|
||||
__version__ = "0.97.0"
|
||||
version = tuple(map(int, __version__.split('.'))) # pylint: disable=invalid-name
|
||||
@@ -2,7 +2,7 @@ import os
|
||||
import typing
|
||||
import asyncio
|
||||
import logging
|
||||
from lbry.utils import LRUCache
|
||||
from lbry.utils import LRUCacheWithMetrics
|
||||
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 LRUCache(
|
||||
self.decrypted_blob_lru_cache = None if not self.config.blob_lru_cache_size else LRUCacheWithMetrics(
|
||||
self.config.blob_lru_cache_size)
|
||||
self.connection_manager = ConnectionManager(loop)
|
||||
|
||||
|
||||
+1
-1
@@ -638,7 +638,7 @@ class Config(CLIConfig):
|
||||
"Strategy to use when selecting UTXOs for a transaction",
|
||||
STRATEGIES, "standard")
|
||||
|
||||
transaction_cache_size = Integer("Transaction cache size", 100_000)
|
||||
transaction_cache_size = Integer("Transaction cache size", 2 ** 17)
|
||||
save_resolved_claims = Toggle(
|
||||
"Save content claims to the database when they are resolved to keep file_list up to date, "
|
||||
"only disable this if file_x commands are not needed", True
|
||||
|
||||
+3
-22
@@ -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
|
||||
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,28 +20,9 @@ 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)
|
||||
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
|
||||
return _is_valid_public_ipv4(address, allow_localhost)
|
||||
|
||||
|
||||
class PeerManager:
|
||||
|
||||
@@ -132,7 +132,7 @@ class AnalyticsManager:
|
||||
async def run(self):
|
||||
while True:
|
||||
if self.enabled:
|
||||
self.external_ip = await utils.get_external_ip()
|
||||
self.external_ip, _ = await utils.get_external_ip(self.conf.lbryum_servers)
|
||||
await self._send_heartbeat()
|
||||
await asyncio.sleep(1800)
|
||||
|
||||
|
||||
@@ -26,42 +26,45 @@ def is_comment_signed_by_channel(comment: dict, channel: Output, sign_comment_id
|
||||
if isinstance(channel, Output):
|
||||
try:
|
||||
signing_field = comment['comment_id'] if sign_comment_id else comment['comment']
|
||||
pieces = [
|
||||
comment['signing_ts'].encode(),
|
||||
cid2hash(comment['channel_id']),
|
||||
signing_field.encode()
|
||||
]
|
||||
return Output.is_signature_valid(
|
||||
get_encoded_signature(comment['signature']),
|
||||
sha256(b''.join(pieces)),
|
||||
channel.claim.channel.public_key_bytes
|
||||
)
|
||||
return verify(channel, signing_field.encode(), comment, cid2hash(comment['channel_id']))
|
||||
except KeyError:
|
||||
pass
|
||||
return False
|
||||
|
||||
|
||||
def verify(channel, data, signature, channel_hash=None):
|
||||
pieces = [
|
||||
signature['signing_ts'].encode(),
|
||||
channel_hash or channel.claim_hash,
|
||||
data
|
||||
]
|
||||
return Output.is_signature_valid(
|
||||
get_encoded_signature(signature['signature']),
|
||||
sha256(b''.join(pieces)),
|
||||
channel.claim.channel.public_key_bytes
|
||||
)
|
||||
|
||||
|
||||
def sign_comment(comment: dict, channel: Output, sign_comment_id=False):
|
||||
timestamp = str(int(time.time()))
|
||||
signing_field = comment['comment_id'] if sign_comment_id else comment['comment']
|
||||
pieces = [timestamp.encode(), channel.claim_hash, signing_field.encode()]
|
||||
comment.update(sign(channel, signing_field.encode()))
|
||||
|
||||
|
||||
def sign(channel, data):
|
||||
timestamp = str(int(time.time()))
|
||||
pieces = [timestamp.encode(), channel.claim_hash, data]
|
||||
digest = sha256(b''.join(pieces))
|
||||
signature = channel.private_key.sign_digest_deterministic(digest, hashfunc=hashlib.sha256)
|
||||
comment.update({
|
||||
return {
|
||||
'signature': binascii.hexlify(signature).decode(),
|
||||
'signing_ts': timestamp
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
def sign_reaction(reaction: dict, channel: Output):
|
||||
timestamp = str(int(time.time()))
|
||||
signing_field = reaction['channel_name']
|
||||
pieces = [timestamp.encode(), channel.claim_hash, signing_field.encode()]
|
||||
digest = sha256(b''.join(pieces))
|
||||
signature = channel.private_key.sign_digest_deterministic(digest, hashfunc=hashlib.sha256)
|
||||
reaction.update({
|
||||
'signature': binascii.hexlify(signature).decode(),
|
||||
'signing_ts': timestamp
|
||||
})
|
||||
reaction.update(sign(channel, signing_field.encode()))
|
||||
|
||||
|
||||
async def jsonrpc_post(url: str, method: str, params: dict = None, **kwargs) -> any:
|
||||
params = params or {}
|
||||
|
||||
@@ -119,13 +119,14 @@ class WalletComponent(Component):
|
||||
async def get_status(self):
|
||||
if self.wallet_manager is None:
|
||||
return
|
||||
session_pool = self.wallet_manager.ledger.network.session_pool
|
||||
sessions = session_pool.sessions
|
||||
is_connected = self.wallet_manager.ledger.network.is_connected
|
||||
sessions = []
|
||||
connected = None
|
||||
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]}"
|
||||
if is_connected:
|
||||
addr, port = self.wallet_manager.ledger.network.client.server
|
||||
connected = f"{addr}:{port}"
|
||||
sessions.append(self.wallet_manager.ledger.network.client)
|
||||
|
||||
result = {
|
||||
'connected': connected,
|
||||
'connected_features': self.wallet_manager.ledger.network.server_features,
|
||||
@@ -137,8 +138,8 @@ class WalletComponent(Component):
|
||||
'availability': session.available,
|
||||
} for session in sessions
|
||||
],
|
||||
'known_servers': len(sessions),
|
||||
'available_servers': len(list(session_pool.available_sessions))
|
||||
'known_servers': len(self.wallet_manager.ledger.network.config['default_servers']),
|
||||
'available_servers': 1 if is_connected else 0
|
||||
}
|
||||
|
||||
if self.wallet_manager.ledger.network.remote_height:
|
||||
@@ -274,7 +275,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()
|
||||
external_ip, _ = await utils.get_external_ip(self.conf.lbryum_servers)
|
||||
if not external_ip:
|
||||
log.warning("failed to get external ip")
|
||||
|
||||
@@ -328,7 +329,7 @@ class HashAnnouncerComponent(Component):
|
||||
|
||||
class FileManagerComponent(Component):
|
||||
component_name = FILE_MANAGER_COMPONENT
|
||||
depends_on = [BLOB_COMPONENT, DATABASE_COMPONENT, WALLET_COMPONENT, LIBTORRENT_COMPONENT]
|
||||
depends_on = [BLOB_COMPONENT, DATABASE_COMPONENT, WALLET_COMPONENT]
|
||||
|
||||
def __init__(self, component_manager):
|
||||
super().__init__(component_manager)
|
||||
@@ -351,7 +352,10 @@ 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
|
||||
torrent = self.component_manager.get_component(LIBTORRENT_COMPONENT) if TorrentSession else None
|
||||
try:
|
||||
torrent = self.component_manager.get_component(LIBTORRENT_COMPONENT) if TorrentSession else None
|
||||
except NameError:
|
||||
torrent = None
|
||||
log.info('Starting the file manager')
|
||||
loop = asyncio.get_event_loop()
|
||||
self.file_manager = FileManager(
|
||||
@@ -360,7 +364,7 @@ class FileManagerComponent(Component):
|
||||
self.file_manager.source_managers['stream'] = StreamManager(
|
||||
loop, self.conf, blob_manager, wallet, storage, node,
|
||||
)
|
||||
if TorrentSession:
|
||||
if TorrentSession and LIBTORRENT_COMPONENT not in self.conf.components_to_skip:
|
||||
self.file_manager.source_managers['torrent'] = TorrentManager(
|
||||
loop, self.conf, torrent, storage, self.component_manager.analytics_manager
|
||||
)
|
||||
@@ -472,7 +476,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()
|
||||
external_ip, _ = await utils.get_external_ip(self.conf.lbryum_servers)
|
||||
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:
|
||||
@@ -530,13 +534,15 @@ 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.external_ip, _ = await utils.get_external_ip(self.conf.lbryum_servers)
|
||||
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
|
||||
@@ -545,9 +551,9 @@ class UPnPComponent(Component):
|
||||
else:
|
||||
log.error("failed to setup upnp")
|
||||
if not self.external_ip:
|
||||
self.external_ip = await utils.get_external_ip()
|
||||
self.external_ip, probed_url = await utils.get_external_ip(self.conf.lbryum_servers)
|
||||
if self.external_ip:
|
||||
log.info("detected external ip using lbry.com fallback")
|
||||
log.info("detected external ip using %s fallback", probed_url)
|
||||
if self.component_manager.analytics_manager:
|
||||
self.component_manager.loop.create_task(
|
||||
self.component_manager.analytics_manager.send_upnp_setup_success_fail(
|
||||
|
||||
+154
-99
@@ -21,6 +21,7 @@ import base58
|
||||
from aiohttp import web
|
||||
from prometheus_client import generate_latest as prom_generate_latest, Gauge, Histogram, Counter
|
||||
from google.protobuf.message import DecodeError
|
||||
|
||||
from lbry.wallet import (
|
||||
Wallet, ENCRYPT_ON_DISK, SingleKey, HierarchicalDeterministic,
|
||||
Transaction, Output, Input, Account, database
|
||||
@@ -118,13 +119,6 @@ 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
|
||||
@@ -338,13 +332,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()
|
||||
@@ -357,9 +351,6 @@ 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)
|
||||
@@ -464,31 +455,10 @@ 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()
|
||||
@@ -548,10 +518,6 @@ 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()
|
||||
@@ -574,6 +540,17 @@ 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()
|
||||
@@ -594,8 +571,16 @@ 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'
|
||||
)
|
||||
|
||||
@@ -935,10 +920,6 @@ 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 = {
|
||||
@@ -946,10 +927,6 @@ 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:
|
||||
@@ -998,7 +975,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 reciepts
|
||||
--wallet_id=<wallet_id> : (str) wallet to check for claim purchase receipts
|
||||
--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
|
||||
@@ -1111,7 +1088,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 reciepts
|
||||
--wallet_id=<wallet_id> : (str) wallet to check for claim purchase receipts
|
||||
|
||||
Returns: {File}
|
||||
"""
|
||||
@@ -1579,7 +1556,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, reserved_subtotals=True, read_only=True
|
||||
confirmations=confirmations, read_only=True
|
||||
)
|
||||
return dict_values_to_lbc(balance)
|
||||
|
||||
@@ -2277,7 +2254,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>]
|
||||
[--page=<page>] [--page_size=<page_size>]
|
||||
[--has_source | --has_no_source] [--page=<page>] [--page_size=<page_size>]
|
||||
[--resolve] [--order_by=<order_by>] [--no_totals] [--include_received_tips]
|
||||
|
||||
Options:
|
||||
@@ -2288,13 +2265,15 @@ 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 recieved for claim outputs
|
||||
--include_received_tips : (bool) calculate the amount of tips received for claim outputs
|
||||
|
||||
Returns: {Paginated[Output]}
|
||||
"""
|
||||
@@ -2371,8 +2350,9 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||
[--not_languages=<not_languages>...]
|
||||
[--any_locations=<any_locations>...] [--all_locations=<all_locations>...]
|
||||
[--not_locations=<not_locations>...]
|
||||
[--order_by=<order_by>...] [--page=<page>] [--page_size=<page_size>]
|
||||
[--order_by=<order_by>...] [--no_totals] [--page=<page>] [--page_size=<page_size>]
|
||||
[--wallet_id=<wallet_id>] [--include_purchase_receipt] [--include_is_my_output]
|
||||
[--has_source | --has_no_source]
|
||||
[--new_sdk_server=<new_sdk_server>]
|
||||
|
||||
Options:
|
||||
@@ -2450,7 +2430,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' or 'unknown'
|
||||
--claim_type=<claim_type> : (str) filter by 'channel', 'stream', 'repost' or 'collection'
|
||||
--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
|
||||
@@ -2476,11 +2456,13 @@ 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 reciepts
|
||||
--wallet_id=<wallet_id> : (str) wallet to check for claim purchase receipts
|
||||
--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
|
||||
--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]}
|
||||
@@ -2492,6 +2474,8 @@ 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)
|
||||
@@ -2788,6 +2772,39 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||
|
||||
return tx
|
||||
|
||||
@requires(WALLET_COMPONENT)
|
||||
async def jsonrpc_channel_sign(
|
||||
self, channel_name=None, channel_id=None, hexdata=None, channel_account_id=None, wallet_id=None):
|
||||
"""
|
||||
Signs data using the specified channel signing key.
|
||||
|
||||
Usage:
|
||||
channel_sign [<channel_name> | --channel_name=<channel_name>]
|
||||
[<channel_id> | --channel_id=<channel_id>] [<hexdata> | --hexdata=<hexdata>]
|
||||
[--channel_account_id=<channel_account_id>...] [--wallet_id=<wallet_id>]
|
||||
|
||||
Options:
|
||||
--channel_name=<channel_name> : (str) name of channel used to sign (or use channel id)
|
||||
--channel_id=<channel_id> : (str) claim id of channel used to sign (or use channel name)
|
||||
--hexdata=<hexdata> : (str) data to sign, encoded as hexadecimal
|
||||
--channel_account_id=<channel_account_id>: (str) one or more account ids for accounts to look in
|
||||
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,
|
||||
}
|
||||
"""
|
||||
wallet = self.wallet_manager.get_wallet_or_default(wallet_id)
|
||||
assert not wallet.is_locked, "Cannot spend funds with locked wallet, unlock first."
|
||||
signing_channel = await self.get_channel_or_error(
|
||||
wallet, channel_account_id, channel_id, channel_name, for_signing=True
|
||||
)
|
||||
return comment_client.sign(signing_channel, unhexlify(hexdata))
|
||||
|
||||
@requires(WALLET_COMPONENT)
|
||||
async def jsonrpc_channel_abandon(
|
||||
self, claim_id=None, txid=None, nout=None, account_id=None, wallet_id=None,
|
||||
@@ -2872,7 +2889,7 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||
Returns: {Paginated[Output]}
|
||||
"""
|
||||
kwargs['type'] = 'channel'
|
||||
if 'is_spent' not in kwargs:
|
||||
if 'is_spent' not in kwargs or not kwargs['is_spent']:
|
||||
kwargs['is_not_spent'] = True
|
||||
return self.jsonrpc_txo_list(*args, **kwargs)
|
||||
|
||||
@@ -2981,13 +2998,13 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||
|
||||
Usage:
|
||||
publish (<name> | --name=<name>) [--bid=<bid>] [--file_path=<file_path>]
|
||||
[--validate_file] [--optimize_file]
|
||||
[--file_name=<file_name>] [--file_hash=<file_hash>] [--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>]
|
||||
[--channel_id=<channel_id> | --channel_name=<channel_name>]
|
||||
[--sd_hash=<sd_hash>] [--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>...]
|
||||
@@ -2997,6 +3014,8 @@ 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
|
||||
@@ -3059,6 +3078,7 @@ 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
|
||||
@@ -3085,8 +3105,6 @@ 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."
|
||||
@@ -3170,7 +3188,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, allow_duplicate_name=False,
|
||||
self, name, bid, file_path=None, 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):
|
||||
@@ -3178,15 +3196,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>)
|
||||
[--validate_file] [--optimize_file]
|
||||
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]
|
||||
[--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>]
|
||||
[--channel_id=<channel_id> | --channel_name=<channel_name>]
|
||||
[--sd_hash=<sd_hash>] [--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>...]
|
||||
@@ -3196,6 +3214,8 @@ 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
|
||||
@@ -3260,13 +3280,14 @@ 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
|
||||
@@ -3292,20 +3313,24 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||
f"Use --allow-duplicate-name flag to override."
|
||||
)
|
||||
|
||||
file_path, spec = await self._video_file_analyzer.verify_or_repair(
|
||||
validate_file, optimize_file, file_path, ignore_non_video=True
|
||||
)
|
||||
kwargs.update(spec)
|
||||
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)
|
||||
|
||||
claim = Claim()
|
||||
claim.stream.update(file_path=file_path, sd_hash='0' * 96, **kwargs)
|
||||
if file_path is not None:
|
||||
claim.stream.update(file_path=file_path, sd_hash='0' * 96, **kwargs)
|
||||
else:
|
||||
claim.stream.update(**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:
|
||||
if not preview and file_path is not None:
|
||||
file_stream = await self.file_manager.create_stream(file_path)
|
||||
claim.stream.source.sd_hash = file_stream.sd_hash
|
||||
new_txo.script.generate()
|
||||
@@ -3321,7 +3346,8 @@ 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)
|
||||
)])
|
||||
await self.storage.save_content_claim(file_stream.stream_hash, new_txo.id)
|
||||
if file_path is not None:
|
||||
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'))
|
||||
@@ -3351,7 +3377,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>]
|
||||
[--channel_id=<channel_id> | --channel_name=<channel_name> | --clear_channel]
|
||||
[--sd_hash=<sd_hash>] [--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>...]
|
||||
@@ -3430,6 +3456,7 @@ 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
|
||||
@@ -3501,9 +3528,10 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||
|
||||
if replace:
|
||||
claim = Claim()
|
||||
claim.stream.message.source.CopyFrom(
|
||||
old_txo.claim.stream.message.source
|
||||
)
|
||||
if old_txo.claim.stream.has_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)
|
||||
@@ -3674,14 +3702,16 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||
|
||||
Usage:
|
||||
collection_create (<name> | --name=<name>) (<bid> | --bid=<bid>)
|
||||
(<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]
|
||||
(--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]
|
||||
|
||||
Options:
|
||||
--name=<name> : (str) name of the collection
|
||||
@@ -3732,6 +3762,10 @@ 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
|
||||
@@ -3795,7 +3829,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>] [--new_signing_key]
|
||||
[--claim_address=<claim_address>]
|
||||
[--funding_account_ids=<funding_account_ids>...]
|
||||
[--preview] [--blocking] [--replace]
|
||||
|
||||
@@ -3853,7 +3887,6 @@ 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
|
||||
@@ -3917,8 +3950,6 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||
)
|
||||
new_txo = tx.outputs[0]
|
||||
|
||||
new_txo.script.generate()
|
||||
|
||||
if channel:
|
||||
new_txo.sign(channel)
|
||||
await tx.sign(funding_accounts)
|
||||
@@ -3956,15 +3987,18 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||
return await self.jsonrpc_stream_abandon(*args, **kwargs)
|
||||
|
||||
@requires(WALLET_COMPONENT)
|
||||
def jsonrpc_collection_list(self, resolve_claims=0, account_id=None, wallet_id=None, page=None, page_size=None):
|
||||
def jsonrpc_collection_list(
|
||||
self, resolve_claims=0, resolve=False, account_id=None,
|
||||
wallet_id=None, page=None, page_size=None):
|
||||
"""
|
||||
List my collection claims.
|
||||
|
||||
Usage:
|
||||
collection_list [--resolve_claims=<resolve_claims>] [<account_id> | --account_id=<account_id>]
|
||||
collection_list [--resolve_claims=<resolve_claims>] [--resolve] [<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
|
||||
@@ -3981,7 +4015,10 @@ 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_claims=resolve_claims)
|
||||
return paginate_rows(
|
||||
collections, collection_count, page, page_size,
|
||||
resolve=resolve, 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):
|
||||
@@ -4313,8 +4350,10 @@ 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, name=None, reposted_claim_id=None,
|
||||
claim_id=None, channel_id=None, not_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):
|
||||
@@ -4322,6 +4361,10 @@ 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
|
||||
@@ -4336,6 +4379,7 @@ 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)
|
||||
@@ -4350,9 +4394,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>...] [--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>...] [--not_channel_id=<not_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]]
|
||||
]
|
||||
@@ -4366,6 +4410,7 @@ 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
|
||||
@@ -4380,7 +4425,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 recieved for claim outputs
|
||||
--include_received_tips : (bool) calculate the amount of tips received 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
|
||||
@@ -4419,15 +4464,15 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||
|
||||
@requires(WALLET_COMPONENT)
|
||||
async def jsonrpc_txo_spend(
|
||||
self, account_id=None, wallet_id=None, batch_size=500,
|
||||
self, account_id=None, wallet_id=None, batch_size=100,
|
||||
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>...] [--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>...] [--not_channel_id=<not_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]
|
||||
|
||||
@@ -4437,6 +4482,7 @@ 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
|
||||
@@ -4457,7 +4503,10 @@ 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,
|
||||
**self._constrain_txo_from_kwargs({}, is_not_spent=True, is_my_output=True, **kwargs)
|
||||
no_tx=True, no_channel_info=True,
|
||||
**self._constrain_txo_from_kwargs(
|
||||
{}, is_not_spent=True, is_my_output=True, **kwargs
|
||||
)
|
||||
)
|
||||
txs = []
|
||||
while txos:
|
||||
@@ -4481,6 +4530,7 @@ 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 |
|
||||
@@ -4494,6 +4544,8 @@ 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,
|
||||
@@ -4528,6 +4580,7 @@ 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]]
|
||||
]
|
||||
@@ -4542,6 +4595,8 @@ 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,
|
||||
|
||||
@@ -2,6 +2,7 @@ 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
|
||||
@@ -58,9 +59,12 @@ class MarketFeed:
|
||||
raise NotImplementedError()
|
||||
|
||||
async def get_response(self):
|
||||
async with aiohttp_request('get', self.url, params=self.params, timeout=self.request_timeout) as response:
|
||||
async with aiohttp_request(
|
||||
'get', self.url, params=self.params,
|
||||
timeout=self.request_timeout, headers={"User-Agent": "lbrynet"}
|
||||
) as response:
|
||||
try:
|
||||
self._last_response = await response.json()
|
||||
self._last_response = await response.json(content_type=None)
|
||||
except ContentTypeError as e:
|
||||
self._last_response = {}
|
||||
log.warning("Could not parse exchange rate response from %s: %s", self.name, e.message)
|
||||
@@ -104,70 +108,115 @@ class MarketFeed:
|
||||
self.event.clear()
|
||||
|
||||
|
||||
class BittrexFeed(MarketFeed):
|
||||
class BaseBittrexFeed(MarketFeed):
|
||||
name = "Bittrex"
|
||||
market = "BTCLBC"
|
||||
url = "https://bittrex.com/api/v1.1/public/getmarkethistory"
|
||||
params = {'market': 'BTC-LBC', 'count': 50}
|
||||
market = None
|
||||
url = None
|
||||
fee = 0.0025
|
||||
|
||||
def get_rate_from_response(self, json_response):
|
||||
if 'result' not in json_response:
|
||||
if 'lastTradeRate' not in json_response:
|
||||
raise InvalidExchangeRateResponseError(self.name, 'result not found')
|
||||
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)
|
||||
return 1.0 / float(json_response['lastTradeRate'])
|
||||
|
||||
|
||||
class LBRYFeed(MarketFeed):
|
||||
name = "lbry.com"
|
||||
class BittrexBTCFeed(BaseBittrexFeed):
|
||||
market = "BTCLBC"
|
||||
url = "https://api.lbry.com/lbc/exchange_rate"
|
||||
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 BaseCryptonatorFeed(MarketFeed):
|
||||
name = "Cryptonator"
|
||||
market = None
|
||||
url = None
|
||||
|
||||
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']['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:
|
||||
if 'ticker' not in json_response or 'price' not in json_response['ticker']:
|
||||
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"
|
||||
class CryptonatorBTCFeed(BaseCryptonatorFeed):
|
||||
market = "BTCLBC"
|
||||
url = "https://api.cryptonator.com/api/ticker/btc-lbc"
|
||||
|
||||
|
||||
class CryptonatorUSDFeed(BaseCryptonatorFeed):
|
||||
market = "USDLBC"
|
||||
url = "https://api.cryptonator.com/api/ticker/usd-lbc"
|
||||
|
||||
|
||||
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'])
|
||||
|
||||
|
||||
class HotbitBTCFeed(BaseHotbitFeed):
|
||||
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"}
|
||||
|
||||
def get_rate_from_response(self, json_response):
|
||||
if len(json_response) != 1 or 'trade_price' not in json_response[0]:
|
||||
raise InvalidExchangeRateResponseError(self.name, 'result not found')
|
||||
return 1.0 / float(json_response[0]['trade_price'])
|
||||
|
||||
|
||||
FEEDS: Iterable[Type[MarketFeed]] = (
|
||||
LBRYFeed,
|
||||
LBRYBTCFeed,
|
||||
BittrexFeed,
|
||||
# CryptonatorFeed,
|
||||
# CryptonatorBTCFeed,
|
||||
BittrexBTCFeed,
|
||||
BittrexUSDFeed,
|
||||
CryptonatorBTCFeed,
|
||||
CryptonatorUSDFeed,
|
||||
CoinExBTCFeed,
|
||||
CoinExUSDFeed,
|
||||
HotbitBTCFeed,
|
||||
HotbitUSDFeed,
|
||||
UPbitBTCFeed,
|
||||
)
|
||||
|
||||
|
||||
@@ -191,20 +240,23 @@ class ExchangeRateManager:
|
||||
source.stop()
|
||||
|
||||
def convert_currency(self, from_currency, to_currency, amount):
|
||||
rates = [market.rate for market in self.market_feeds]
|
||||
log.debug("Converting %f %s to %s, rates: %s", amount, from_currency, to_currency, rates)
|
||||
log.debug(
|
||||
"Converting %f %s to %s, rates: %s",
|
||||
amount, from_currency, to_currency,
|
||||
[market.rate for market in self.market_feeds]
|
||||
)
|
||||
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)):
|
||||
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)
|
||||
rates.append(market.rate.spot)
|
||||
|
||||
if rates:
|
||||
return round(amount * Decimal(median(rates)), 8)
|
||||
|
||||
raise CurrencyConversionError(
|
||||
f'Unable to convert {amount} from {from_currency} to {to_currency}')
|
||||
|
||||
|
||||
@@ -85,8 +85,11 @@ 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),
|
||||
resolve_timeout
|
||||
self.wallet_manager.ledger.resolve(
|
||||
wallet.accounts, [uri],
|
||||
include_purchase_receipt=True,
|
||||
include_is_my_output=True
|
||||
), resolve_timeout
|
||||
)
|
||||
except asyncio.TimeoutError:
|
||||
raise ResolveTimeoutError(uri)
|
||||
@@ -114,9 +117,11 @@ 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)
|
||||
else:
|
||||
elif claim.stream.source.sd_hash:
|
||||
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
|
||||
@@ -170,7 +175,14 @@ class FileManager:
|
||||
# pay fee
|
||||
####################
|
||||
|
||||
if not to_replace and txo.has_price and not txo.purchase_receipt:
|
||||
needs_purchasing = (
|
||||
not to_replace and
|
||||
not txo.is_my_output and
|
||||
txo.has_price and
|
||||
not txo.purchase_receipt
|
||||
)
|
||||
|
||||
if needs_purchasing:
|
||||
payment = await self.wallet_manager.create_purchase_transaction(
|
||||
wallet.accounts, txo, exchange_rate_manager
|
||||
)
|
||||
|
||||
+37
-1
@@ -1,14 +1,44 @@
|
||||
import time
|
||||
import logging
|
||||
import asyncio
|
||||
import asyncio.tasks
|
||||
from aiohttp import web
|
||||
from prometheus_client import generate_latest as prom_generate_latest
|
||||
from prometheus_client import Counter, Histogram, Gauge
|
||||
|
||||
|
||||
PROBES_IN_FLIGHT = Counter("probes_in_flight", "Number of loop probes in flight", namespace='asyncio')
|
||||
PROBES_FINISHED = Counter("probes_finished", "Number of finished loop probes", namespace='asyncio')
|
||||
PROBE_TIMES = Histogram("probe_times", "Loop probe times", namespace='asyncio')
|
||||
TASK_COUNT = Gauge("running_tasks", "Number of running tasks", namespace='asyncio')
|
||||
|
||||
|
||||
def get_loop_metrics(delay=1):
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
def callback(started):
|
||||
PROBE_TIMES.observe(time.perf_counter() - started - delay)
|
||||
PROBES_FINISHED.inc()
|
||||
|
||||
async def monitor_loop_responsiveness():
|
||||
while True:
|
||||
now = time.perf_counter()
|
||||
loop.call_later(delay, callback, now)
|
||||
PROBES_IN_FLIGHT.inc()
|
||||
TASK_COUNT.set(len(asyncio.tasks._all_tasks))
|
||||
await asyncio.sleep(delay)
|
||||
|
||||
return loop.create_task(monitor_loop_responsiveness())
|
||||
|
||||
|
||||
class PrometheusServer:
|
||||
def __init__(self, logger=None):
|
||||
self.runner = None
|
||||
self.logger = logger or logging.getLogger(__name__)
|
||||
self._monitor_loop_task = None
|
||||
|
||||
async def start(self, interface: str, port: int):
|
||||
self.logger.info("start prometheus metrics")
|
||||
prom_app = web.Application()
|
||||
prom_app.router.add_get('/metrics', self.handle_metrics_get_request)
|
||||
self.runner = web.AppRunner(prom_app)
|
||||
@@ -16,7 +46,10 @@ class PrometheusServer:
|
||||
|
||||
metrics_site = web.TCPSite(self.runner, interface, port, shutdown_timeout=.5)
|
||||
await metrics_site.start()
|
||||
self.logger.info('metrics server listening on %s:%i', *metrics_site._server.sockets[0].getsockname()[:2])
|
||||
self.logger.info(
|
||||
'prometheus metrics server listening on %s:%i', *metrics_site._server.sockets[0].getsockname()[:2]
|
||||
)
|
||||
self._monitor_loop_task = get_loop_metrics()
|
||||
|
||||
async def handle_metrics_get_request(self, request: web.Request):
|
||||
try:
|
||||
@@ -29,4 +62,7 @@ class PrometheusServer:
|
||||
raise
|
||||
|
||||
async def stop(self):
|
||||
if self._monitor_loop_task and not self._monitor_loop_task.done():
|
||||
self._monitor_loop_task.cancel()
|
||||
self._monitor_loop_task = None
|
||||
await self.runner.cleanup()
|
||||
@@ -303,6 +303,10 @@ 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)
|
||||
|
||||
@@ -46,8 +46,8 @@ types_map = {
|
||||
'.ksh': ('text/plain', 'document'),
|
||||
'.latex': ('application/x-latex', 'binary'),
|
||||
'.m1v': ('video/mpeg', 'video'),
|
||||
'.m3u': ('application/vnd.apple.mpegurl', 'audio'),
|
||||
'.m3u8': ('application/vnd.apple.mpegurl', 'video'),
|
||||
'.m3u': ('application/x-mpegurl', 'audio'),
|
||||
'.m3u8': ('application/x-mpegurl', 'video'),
|
||||
'.man': ('application/x-troff-man', 'document'),
|
||||
'.markdown': ('text/markdown', 'document'),
|
||||
'.md': ('text/markdown', 'document'),
|
||||
@@ -66,6 +66,7 @@ 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'),
|
||||
@@ -119,6 +120,7 @@ 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'),
|
||||
|
||||
+34
-45
@@ -13,57 +13,45 @@ NOT_FOUND = ErrorMessage.Code.Name(ErrorMessage.NOT_FOUND)
|
||||
BLOCKED = ErrorMessage.Code.Name(ErrorMessage.BLOCKED)
|
||||
|
||||
|
||||
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
|
||||
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']
|
||||
|
||||
|
||||
class Censor:
|
||||
|
||||
__slots__ = 'streams', 'channels', 'limit_claims_per_channel', 'censored', 'claims_in_channel', 'total'
|
||||
NOT_CENSORED = 0
|
||||
SEARCH = 1
|
||||
RESOLVE = 2
|
||||
|
||||
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
|
||||
__slots__ = 'censor_type', 'censored'
|
||||
|
||||
def __init__(self, censor_type):
|
||||
self.censor_type = censor_type
|
||||
self.censored = {}
|
||||
self.claims_in_channel = {}
|
||||
self.total = 0
|
||||
|
||||
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)]
|
||||
|
||||
def censor(self, row) -> bool:
|
||||
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
|
||||
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
|
||||
|
||||
def to_message(self, outputs: OutputsMessage, extra_txo_rows):
|
||||
outputs.blocked_total = self.total
|
||||
def to_message(self, outputs: OutputsMessage, extra_txo_rows: dict):
|
||||
for censoring_channel_hash, count in self.censored.items():
|
||||
blocked = outputs.blocked.add()
|
||||
blocked.count = count
|
||||
set_reference(blocked.channel, censoring_channel_hash, extra_txo_rows)
|
||||
blocked.count = len(count)
|
||||
set_reference(blocked.channel, extra_txo_rows.get(censoring_channel_hash))
|
||||
outputs.blocked_total += len(count)
|
||||
|
||||
|
||||
class Outputs:
|
||||
@@ -168,6 +156,7 @@ 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:
|
||||
@@ -176,12 +165,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:
|
||||
for row in extra_txo_rows.values():
|
||||
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_txo_rows):
|
||||
def row_to_message(cls, txo, txo_message, extra_row_dict: dict):
|
||||
if isinstance(txo, Exception):
|
||||
txo_message.error.text = txo.args[0]
|
||||
if isinstance(txo, ValueError):
|
||||
@@ -190,7 +179,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, txo.censor_hash, extra_txo_rows)
|
||||
set_reference(txo_message.error.blocked.channel, extra_row_dict.get(txo.censor_hash))
|
||||
return
|
||||
txo_message.tx_hash = txo['txo_hash'][:32]
|
||||
txo_message.nout, = struct.unpack('<I', txo['txo_hash'][32:])
|
||||
@@ -213,5 +202,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, txo['channel_hash'], extra_txo_rows)
|
||||
set_reference(txo_message.claim.repost, txo['reposted_claim_hash'], extra_txo_rows)
|
||||
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']))
|
||||
@@ -55,6 +55,14 @@ 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:
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -40,7 +40,7 @@ class StreamDownloader:
|
||||
async def cached_read_blob(blob_info: 'BlobInfo') -> bytes:
|
||||
return await self.read_blob(blob_info, 2)
|
||||
|
||||
if self.blob_manager.decrypted_blob_lru_cache:
|
||||
if self.blob_manager.decrypted_blob_lru_cache is not None:
|
||||
cached_read_blob = lru_cache_concurrent(override_lru_cache=self.blob_manager.decrypted_blob_lru_cache)(
|
||||
cached_read_blob
|
||||
)
|
||||
|
||||
@@ -354,20 +354,19 @@ class ManagedStream(ManagedDownloadSource):
|
||||
self.reflector_progress = int((i + 1) / len(we_have) * 100)
|
||||
except (asyncio.TimeoutError, ValueError):
|
||||
return sent
|
||||
except ConnectionRefusedError:
|
||||
except ConnectionError:
|
||||
return sent
|
||||
except (OSError, Exception) as err:
|
||||
if isinstance(err, asyncio.CancelledError):
|
||||
log.warning("stopped uploading %s#%s to reflector", self.claim_name, self.claim_id)
|
||||
raise err
|
||||
if isinstance(err, OSError):
|
||||
elif isinstance(err, OSError):
|
||||
log.warning(
|
||||
"stopped uploading %s#%s to reflector because blobs were deleted or moved", self.claim_name,
|
||||
self.claim_id
|
||||
)
|
||||
else:
|
||||
log.exception("unexpected error reflecting %s#%s", self.claim_name, self.claim_id)
|
||||
raise asyncio.CancelledError()
|
||||
return sent
|
||||
finally:
|
||||
if protocol.transport:
|
||||
protocol.transport.close()
|
||||
|
||||
@@ -160,13 +160,13 @@ class StreamManager(SourceManager):
|
||||
|
||||
async def reflect_streams(self):
|
||||
try:
|
||||
return await self._reflact_streams()
|
||||
return await self._reflect_streams()
|
||||
except asyncio.CancelledError:
|
||||
raise
|
||||
except Exception:
|
||||
log.exception("reflector task encountered an unexpected error!")
|
||||
|
||||
async def _reflact_streams(self):
|
||||
async def _reflect_streams(self):
|
||||
# todo: those debug statements are temporary for #2987 - remove them if its closed
|
||||
while True:
|
||||
if self.config.reflect_streams and self.config.reflector_servers:
|
||||
|
||||
+22
-8
@@ -23,12 +23,13 @@ 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
|
||||
DHT_COMPONENT,
|
||||
HASH_ANNOUNCER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT,
|
||||
UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, LIBTORRENT_COMPONENT
|
||||
)
|
||||
from lbry.extras.daemon.componentmanager import ComponentManager
|
||||
from lbry.extras.daemon.exchange_rate_manager import (
|
||||
ExchangeRateManager, ExchangeRate, LBRYFeed, LBRYBTCFeed
|
||||
ExchangeRateManager, ExchangeRate, BittrexBTCFeed, BittrexUSDFeed
|
||||
)
|
||||
from lbry.extras.daemon.storage import SQLiteStorage
|
||||
from lbry.blob.blob_manager import BlobManager
|
||||
@@ -83,6 +84,7 @@ class AsyncioTestCase(unittest.TestCase):
|
||||
# https://bugs.python.org/issue32972
|
||||
|
||||
LOOP_SLOW_CALLBACK_DURATION = 0.2
|
||||
TIMEOUT = 120.0
|
||||
|
||||
maxDiff = None
|
||||
|
||||
@@ -136,6 +138,8 @@ 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):
|
||||
@@ -188,6 +192,12 @@ 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):
|
||||
|
||||
@@ -281,8 +291,8 @@ class FakeExchangeRateManager(ExchangeRateManager):
|
||||
|
||||
def get_fake_exchange_rate_manager(rates=None):
|
||||
return FakeExchangeRateManager(
|
||||
[LBRYFeed(), LBRYBTCFeed()],
|
||||
rates or {'BTCLBC': 3.0, 'USDBTC': 2.0}
|
||||
[BittrexBTCFeed(), BittrexUSDFeed()],
|
||||
rates or {'BTCLBC': 3.0, 'USDLBC': 2.0}
|
||||
)
|
||||
|
||||
|
||||
@@ -320,6 +330,7 @@ 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()
|
||||
@@ -395,6 +406,8 @@ 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)
|
||||
wallet_node.manager.config = conf
|
||||
|
||||
def wallet_maker(component_manager):
|
||||
@@ -406,7 +419,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, 'USDBTC': 2.0
|
||||
'BTCLBC': 1.0, 'USDLBC': 2.0
|
||||
})
|
||||
))
|
||||
await daemon.initialize()
|
||||
@@ -435,8 +448,9 @@ 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 self.ledger.on_header.where(self.blockchain.is_expected_block)
|
||||
await prepare # no guarantee that it didn't happen already, so start waiting from before calling generate
|
||||
|
||||
async def blockchain_claim_name(self, name: str, value: str, amount: str, confirm=True):
|
||||
txid = await self.blockchain._cli_cmnd('claimname', name, value, amount)
|
||||
@@ -476,7 +490,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:
|
||||
if file_path is None and data is not 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
|
||||
|
||||
+186
-15
@@ -20,8 +20,11 @@ import pkg_resources
|
||||
|
||||
import certifi
|
||||
import aiohttp
|
||||
from prometheus_client import Counter
|
||||
from prometheus_client.registry import REGISTRY
|
||||
from lbry.schema.claim import Claim
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -102,10 +105,6 @@ 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)])
|
||||
|
||||
@@ -189,6 +188,8 @@ 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,18 +204,44 @@ async def resolve_host(url: str, port: int, proto: str) -> str:
|
||||
))[0][4][0]
|
||||
|
||||
|
||||
class LRUCache:
|
||||
class LRUCacheWithMetrics:
|
||||
__slots__ = [
|
||||
'capacity',
|
||||
'cache'
|
||||
'cache',
|
||||
'_track_metrics',
|
||||
'hits',
|
||||
'misses'
|
||||
]
|
||||
|
||||
def __init__(self, capacity):
|
||||
def __init__(self, capacity: int, metric_name: typing.Optional[str] = None, namespace: str = "daemon_cache"):
|
||||
self.capacity = capacity
|
||||
self.cache = collections.OrderedDict()
|
||||
if metric_name is None:
|
||||
self._track_metrics = False
|
||||
self.hits = self.misses = None
|
||||
else:
|
||||
self._track_metrics = True
|
||||
try:
|
||||
self.hits = Counter(
|
||||
f"{metric_name}_cache_hit_count", "Number of cache hits", namespace=namespace
|
||||
)
|
||||
self.misses = Counter(
|
||||
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)
|
||||
self._track_metrics = False
|
||||
self.hits = self.misses = None
|
||||
|
||||
def get(self, key):
|
||||
value = self.cache.pop(key)
|
||||
def get(self, key, default=None):
|
||||
try:
|
||||
value = self.cache.pop(key)
|
||||
if self._track_metrics:
|
||||
self.hits.inc()
|
||||
except KeyError:
|
||||
if self._track_metrics:
|
||||
self.misses.inc()
|
||||
return default
|
||||
self.cache[key] = value
|
||||
return value
|
||||
|
||||
@@ -226,16 +253,94 @@ class LRUCache:
|
||||
self.cache.popitem(last=False)
|
||||
self.cache[key] = value
|
||||
|
||||
def clear(self):
|
||||
self.cache.clear()
|
||||
|
||||
def pop(self, key):
|
||||
return self.cache.pop(key)
|
||||
|
||||
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
|
||||
|
||||
|
||||
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 clear(self):
|
||||
self.cache.clear()
|
||||
|
||||
def pop(self, key):
|
||||
return self.cache.pop(key)
|
||||
|
||||
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()
|
||||
|
||||
|
||||
def lru_cache_concurrent(cache_size: typing.Optional[int] = None,
|
||||
override_lru_cache: typing.Optional[LRUCache] = None):
|
||||
override_lru_cache: typing.Optional[LRUCacheWithMetrics] = None):
|
||||
if not cache_size and override_lru_cache is None:
|
||||
raise ValueError("invalid cache size")
|
||||
concurrent_cache = {}
|
||||
lru_cache = override_lru_cache or LRUCache(cache_size)
|
||||
lru_cache = override_lru_cache if override_lru_cache is not None else LRUCacheWithMetrics(cache_size)
|
||||
|
||||
def wrapper(async_fn):
|
||||
|
||||
@@ -266,18 +371,84 @@ 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, ssl=get_ssl_context(), **kwargs) as response:
|
||||
async with session.request(method, url, **kwargs) as response:
|
||||
yield response
|
||||
|
||||
|
||||
async def get_external_ip() -> typing.Optional[str]: # used if upnp is disabled or non-functioning
|
||||
# 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):
|
||||
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
|
||||
|
||||
|
||||
async def fallback_get_external_ip(): # used if spv servers can't be used for ip detection
|
||||
try:
|
||||
async with aiohttp_request("get", "https://api.lbry.com/ip") as resp:
|
||||
response = await resp.json()
|
||||
if response['success']:
|
||||
return response['data']['ip']
|
||||
return response['data']['ip'], None
|
||||
except Exception:
|
||||
return
|
||||
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
|
||||
|
||||
|
||||
def is_running_from_bundle():
|
||||
|
||||
+9
-31
@@ -5,7 +5,6 @@ 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
|
||||
@@ -16,7 +15,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, CLAIM_TYPES, TXO_TYPES
|
||||
from .constants import COIN, TXO_TYPES
|
||||
from .transaction import Transaction, Input, Output
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
@@ -566,35 +565,14 @@ class Account:
|
||||
if gap_changed:
|
||||
self.wallet.save()
|
||||
|
||||
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
|
||||
}
|
||||
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
|
||||
)
|
||||
|
||||
def get_transaction_history(self, read_only=False, **constraints):
|
||||
return self.ledger.get_transaction_history(
|
||||
|
||||
+102
-34
@@ -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' or 'KIVY_BUILD' in os.environ:
|
||||
if platform.system() == 'Windows' or ({'ANDROID_ARGUMENT', 'KIVY_BUILD'} & os.environ.keys()):
|
||||
from concurrent.futures.thread import ThreadPoolExecutor as ReaderExecutorClass # pylint: disable=reimported
|
||||
else:
|
||||
from concurrent.futures.process import ProcessPoolExecutor as ReaderExecutorClass
|
||||
@@ -124,6 +124,7 @@ class AIOSQLite:
|
||||
|
||||
def __checkpoint_and_close(conn: sqlite3.Connection):
|
||||
conn.execute("PRAGMA WAL_CHECKPOINT(FULL);")
|
||||
log.info("DB checkpoint finished.")
|
||||
conn.close()
|
||||
await asyncio.get_event_loop().run_in_executor(
|
||||
self.writer_executor, __checkpoint_and_close, self.writer_connection)
|
||||
@@ -386,14 +387,31 @@ def interpolate(sql, values):
|
||||
return sql
|
||||
|
||||
|
||||
def constrain_single_or_list(constraints, column, value, convert=lambda x: x):
|
||||
def constrain_single_or_list(constraints, column, value, convert=lambda x: x, negate=False):
|
||||
if value is not None:
|
||||
if isinstance(value, list):
|
||||
value = [convert(v) for v in value]
|
||||
if len(value) == 1:
|
||||
constraints[column] = value[0]
|
||||
if negate:
|
||||
constraints[f"{column}__or"] = {
|
||||
f"{column}__is_null": True,
|
||||
f"{column}__not": value[0]
|
||||
}
|
||||
else:
|
||||
constraints[column] = value[0]
|
||||
elif len(value) > 1:
|
||||
constraints[f"{column}__in"] = value
|
||||
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)
|
||||
}
|
||||
else:
|
||||
constraints[column] = convert(value)
|
||||
return constraints
|
||||
@@ -428,9 +446,13 @@ 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;')
|
||||
await self.db.execute(self.CREATE_VERSION_TABLE)
|
||||
await self.db.execute("INSERT INTO version VALUES (?)", (self.SCHEMA_VERSION,))
|
||||
await self.db.executescript(self.CREATE_TABLES_QUERY)
|
||||
@@ -574,7 +596,7 @@ def get_and_reserve_spendable_utxos(transaction: sqlite3.Connection, accounts: L
|
||||
|
||||
class Database(SQLiteMixin):
|
||||
|
||||
SCHEMA_VERSION = "1.4"
|
||||
SCHEMA_VERSION = "1.6"
|
||||
|
||||
PRAGMAS = """
|
||||
pragma journal_mode=WAL;
|
||||
@@ -628,6 +650,7 @@ 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
|
||||
@@ -672,7 +695,8 @@ class Database(SQLiteMixin):
|
||||
'address': txo.get_address(self.ledger),
|
||||
'position': txo.position,
|
||||
'amount': txo.amount,
|
||||
'script': sqlite3.Binary(txo.script.source)
|
||||
'script': sqlite3.Binary(txo.script.source),
|
||||
'has_source': False,
|
||||
}
|
||||
if txo.is_claim:
|
||||
if txo.can_decode_claim:
|
||||
@@ -680,12 +704,18 @@ 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
|
||||
@@ -944,16 +974,18 @@ 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, read_only=False, **constraints):
|
||||
async def get_txos(self, wallet=None, no_tx=False, no_channel_info=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, raw, tx.height, tx.position as tx_position, tx.is_verified, "
|
||||
"tx.txid, 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 = ""
|
||||
@@ -992,7 +1024,7 @@ class Database(SQLiteMixin):
|
||||
|
||||
if 'order_by' not in constraints or constraints['order_by'] == 'height':
|
||||
constraints['order_by'] = [
|
||||
"tx.height=0 DESC", "tx.height DESC", "tx.position DESC", "txo.position"
|
||||
"tx.height in (0, -1) DESC", "tx.height DESC", "tx.position DESC", "txo.position"
|
||||
]
|
||||
elif constraints.get('order_by', None) == 'none':
|
||||
del constraints['order_by']
|
||||
@@ -1031,32 +1063,33 @@ class Database(SQLiteMixin):
|
||||
txo.received_tips = row['received_tips']
|
||||
txos.append(txo)
|
||||
|
||||
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
|
||||
))
|
||||
}
|
||||
if not no_channel_info:
|
||||
channel_ids = set()
|
||||
for txo in txos:
|
||||
if txo.is_claim and txo.can_decode_claim:
|
||||
txo.channel = channels.get(txo.claim.signing_channel_id, None)
|
||||
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)
|
||||
|
||||
return txos
|
||||
|
||||
@@ -1118,6 +1151,41 @@ 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)",
|
||||
|
||||
+83
-72
@@ -10,11 +10,11 @@ from collections import defaultdict
|
||||
from binascii import hexlify, unhexlify
|
||||
from typing import Dict, Tuple, Type, Iterable, List, Optional, DefaultDict, NamedTuple
|
||||
|
||||
import pylru
|
||||
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 .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 = pylru.lrucache(self.config.get("tx_cache_size", 10_000))
|
||||
self._tx_cache = LRUCacheWithMetrics(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 = pylru.lrucache(100000)
|
||||
self._balance_cache = LRUCacheWithMetrics(2 ** 15)
|
||||
|
||||
@classmethod
|
||||
def get_id(cls):
|
||||
@@ -231,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()
|
||||
utxos = await account.get_utxos(no_tx=True, no_channel_info=True)
|
||||
for utxo in utxos:
|
||||
estimators.append(utxo.get_estimator(self))
|
||||
return estimators
|
||||
@@ -415,6 +415,7 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
"Blockchain Reorganization: attempting rewind to height %s from starting height %s",
|
||||
height, height+rewound
|
||||
)
|
||||
self._tx_cache.clear()
|
||||
|
||||
else:
|
||||
raise IndexError(f"headers.connect() returned negative number ({added})")
|
||||
@@ -513,10 +514,8 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
)
|
||||
return True
|
||||
|
||||
synced_txs = []
|
||||
to_request = {}
|
||||
pending_synced_history = {}
|
||||
updated_cached_items = {}
|
||||
already_synced = set()
|
||||
|
||||
already_synced_offset = 0
|
||||
@@ -526,10 +525,6 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
already_synced.add((txid, remote_height))
|
||||
already_synced_offset += 1
|
||||
continue
|
||||
cache_item = self._tx_cache.get(txid)
|
||||
if cache_item is None:
|
||||
cache_item = TransactionCacheItem()
|
||||
self._tx_cache[txid] = cache_item
|
||||
|
||||
tx_indexes = {}
|
||||
|
||||
@@ -537,29 +532,16 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
tx_indexes[txid] = i
|
||||
if (txid, remote_height) in already_synced:
|
||||
continue
|
||||
cache_item = self._tx_cache.get(txid)
|
||||
cache_item.pending_verifications += 1
|
||||
updated_cached_items[txid] = cache_item
|
||||
|
||||
assert cache_item is not None, 'cache item is none'
|
||||
# tx = cache_item.tx
|
||||
# if cache_item.tx is not None and \
|
||||
# cache_item.tx.height >= remote_height and \
|
||||
# (cache_item.tx.is_verified or remote_height < 1):
|
||||
# synced_txs.append(cache_item.tx) # cached tx is already up-to-date
|
||||
# pending_synced_history[i] = f'{tx.id}:{tx.height}:'
|
||||
# continue
|
||||
to_request[i] = (txid, remote_height)
|
||||
|
||||
log.debug(
|
||||
"request %i transactions, %i/%i for %s are already synced", len(to_request), len(synced_txs),
|
||||
"request %i transactions, %i/%i for %s are already synced", len(to_request), len(already_synced),
|
||||
len(remote_history), address
|
||||
)
|
||||
remote_history_txids = set(txid for txid, _ in remote_history)
|
||||
remote_history_txids = {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}:"
|
||||
synced_txs.append(tx)
|
||||
if len(synced_txs) >= 100:
|
||||
if len(pending_synced_history) % 100 == 0:
|
||||
log.info("Syncing address %s: %d/%d", address, len(pending_synced_history), len(to_request))
|
||||
log.info("Sync finished for address %s: %d/%d", address, len(pending_synced_history), len(to_request))
|
||||
|
||||
@@ -572,19 +554,7 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
if f"{txid}:{height}:" != pending_synced_history[i]:
|
||||
log.warning("history mismatch: %s vs %s", remote_history[remote_i], pending_synced_history[i])
|
||||
synced_history += pending_synced_history[i]
|
||||
await self.db.save_transaction_io_batch(
|
||||
synced_txs, address, self.address_to_hash160(address), synced_history
|
||||
)
|
||||
while synced_txs:
|
||||
self._on_transaction_controller.add(TransactionEvent(address, synced_txs.pop()))
|
||||
|
||||
cache_size = self.config.get("tx_cache_size", 10_000)
|
||||
for txid, cache_item in updated_cached_items.items():
|
||||
cache_item.pending_verifications -= 1
|
||||
if cache_item.pending_verifications < 0:
|
||||
log.warning("config value tx cache size %i needs to be increased", cache_size)
|
||||
cache_item.pending_verifications = 0
|
||||
|
||||
await self.db.set_address_history(address, synced_history)
|
||||
|
||||
if address_manager is None:
|
||||
address_manager = await self.get_address_manager_for_address(address)
|
||||
@@ -592,13 +562,6 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
if address_manager is not None:
|
||||
await address_manager.ensure_address_gap()
|
||||
|
||||
for txid, cache_item in updated_cached_items.items():
|
||||
if self._tx_cache.get(txid) is not cache_item:
|
||||
log.warning("tx cache corrupted while syncing %s, reattempt sync=%s", address, reattempt_update)
|
||||
if reattempt_update:
|
||||
return await self.update_history(address, remote_status, address_manager, False)
|
||||
return False
|
||||
|
||||
local_status, local_history = \
|
||||
await self.get_local_status_and_history(address, synced_history)
|
||||
|
||||
@@ -632,12 +595,6 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
|
||||
async def maybe_verify_transaction(self, tx, remote_height, merkle=None):
|
||||
tx.height = remote_height
|
||||
cached = self._tx_cache.get(tx.id)
|
||||
if not cached:
|
||||
# cache txs looked up by transaction_show too
|
||||
cached = TransactionCacheItem()
|
||||
self._tx_cache[tx.id] = cached
|
||||
cached.tx = tx
|
||||
if 0 < remote_height < len(self.headers):
|
||||
# can't be tx.pending_verifications == 1 because we have to handle the transaction_show case
|
||||
if not merkle:
|
||||
@@ -648,39 +605,65 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
header = await self.headers.get(remote_height)
|
||||
tx.position = merkle['pos']
|
||||
tx.is_verified = merkle_root == header['merkle_root']
|
||||
return tx
|
||||
|
||||
async def request_transactions(self, to_request: Tuple[Tuple[str, int], ...]):
|
||||
async def request_transactions(self, to_request: Tuple[Tuple[str, int], ...], cached=False):
|
||||
batches = [[]]
|
||||
remote_heights = {}
|
||||
cache_hits = set()
|
||||
|
||||
for txid, height in sorted(to_request, key=lambda x: x[1]):
|
||||
if cached:
|
||||
cached_tx = self._tx_cache.get(txid)
|
||||
if cached_tx is not None:
|
||||
if cached_tx.tx is not None and cached_tx.tx.is_verified:
|
||||
cache_hits.add(txid)
|
||||
continue
|
||||
else:
|
||||
self._tx_cache[txid] = TransactionCacheItem()
|
||||
remote_heights[txid] = height
|
||||
if len(batches[-1]) == 100:
|
||||
batches.append([])
|
||||
batches[-1].append(txid)
|
||||
if not batches[-1]:
|
||||
batches.pop()
|
||||
if cached and cache_hits:
|
||||
yield {txid: self._tx_cache[txid].tx for txid in cache_hits}
|
||||
|
||||
for batch in batches:
|
||||
async for tx in self._single_batch(batch, remote_heights):
|
||||
yield tx
|
||||
txs = await self._single_batch(batch, remote_heights)
|
||||
if cached:
|
||||
for txid, tx in txs.items():
|
||||
self._tx_cache[txid].tx = tx
|
||||
yield txs
|
||||
|
||||
async def request_synced_transactions(self, to_request, remote_history, address):
|
||||
pending_sync = []
|
||||
async for tx in self.request_transactions(((txid, height) for txid, height in to_request.values())):
|
||||
pending_sync.append(asyncio.ensure_future(self._sync(tx, remote_history)))
|
||||
yield tx
|
||||
await asyncio.gather(*pending_sync)
|
||||
async for txs in self.request_transactions(((txid, height) for txid, height in to_request.values())):
|
||||
for tx in txs.values():
|
||||
yield tx
|
||||
await self._sync_and_save_batch(address, remote_history, txs)
|
||||
|
||||
async def _single_batch(self, batch, remote_heights):
|
||||
batch_result = await self.network.retriable_call(self.network.get_transaction_batch, batch)
|
||||
heights = {remote_heights[txid] for txid in batch}
|
||||
unrestriced = 0 < min(heights) < max(heights) < max(self.headers.checkpoints or [0])
|
||||
batch_result = await self.network.retriable_call(self.network.get_transaction_batch, batch, not unrestriced)
|
||||
txs = {}
|
||||
for txid, (raw, merkle) in batch_result.items():
|
||||
remote_height = remote_heights[txid]
|
||||
tx = Transaction(unhexlify(raw), height=remote_height)
|
||||
txs[tx.id] = tx
|
||||
await self.maybe_verify_transaction(tx, remote_height, merkle)
|
||||
yield tx
|
||||
return txs
|
||||
|
||||
async def _sync(self, tx, remote_history):
|
||||
async def _sync_and_save_batch(self, address, remote_history, pending_txs):
|
||||
await asyncio.gather(*(self._sync(tx, remote_history, pending_txs) for tx in pending_txs.values()))
|
||||
await self.db.save_transaction_io_batch(
|
||||
pending_txs.values(), address, self.address_to_hash160(address), ""
|
||||
)
|
||||
while pending_txs:
|
||||
self._on_transaction_controller.add(TransactionEvent(address, pending_txs.popitem()[1]))
|
||||
|
||||
async def _sync(self, tx, remote_history, pending_txs):
|
||||
check_db_for_txos = {}
|
||||
for txi in tx.inputs:
|
||||
if txi.txo_ref.txo is not None:
|
||||
@@ -688,9 +671,8 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
wanted_txid = txi.txo_ref.tx_ref.id
|
||||
if wanted_txid not in remote_history:
|
||||
continue
|
||||
if wanted_txid in self._tx_cache:
|
||||
await self._tx_cache[wanted_txid].has_tx.wait()
|
||||
txi.txo_ref = self._tx_cache[wanted_txid].tx.outputs[txi.txo_ref.position].ref
|
||||
if wanted_txid in pending_txs:
|
||||
txi.txo_ref = pending_txs[wanted_txid].outputs[txi.txo_ref.position].ref
|
||||
else:
|
||||
check_db_for_txos[txi] = txi.txo_ref.id
|
||||
|
||||
@@ -704,7 +686,11 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
if txi.txo_ref.id in referenced_txos:
|
||||
txi.txo_ref = referenced_txos[txi.txo_ref.id].ref
|
||||
else:
|
||||
log.warning("%s not on db, not on cache, but on remote history!", txi.txo_ref.id)
|
||||
tx_from_db = await self.db.get_transaction(txid=txi.txo_ref.tx_ref.id)
|
||||
if tx_from_db is None:
|
||||
log.warning("%s not on db, not on cache, but on remote history!", txi.txo_ref.id)
|
||||
else:
|
||||
txi.txo_ref = tx_from_db.outputs[txi.txo_ref.position].ref
|
||||
return tx
|
||||
|
||||
async def get_address_manager_for_address(self, address) -> Optional[AddressManager]:
|
||||
@@ -775,8 +761,8 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
outputs = Outputs.from_base64(encoded_outputs or b'') # TODO: why is the server returning None?
|
||||
txs: List[Transaction] = []
|
||||
if len(outputs.txs) > 0:
|
||||
async for tx in self.request_transactions(tuple(outputs.txs)):
|
||||
txs.append(tx)
|
||||
async for tx in self.request_transactions(tuple(outputs.txs), cached=True):
|
||||
txs.extend(tx.values())
|
||||
|
||||
_txos, blocked = outputs.inflate(txs)
|
||||
|
||||
@@ -951,6 +937,11 @@ 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]
|
||||
@@ -966,6 +957,23 @@ 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:
|
||||
@@ -1014,8 +1022,10 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
claims.append(None)
|
||||
return claims
|
||||
|
||||
async def get_collections(self, resolve_claims=0, **constraints):
|
||||
async def get_collections(self, resolve_claims=0, resolve=False, **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)
|
||||
@@ -1050,7 +1060,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)
|
||||
@@ -1161,7 +1171,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, reserved_subtotals=True)
|
||||
await account.get_detailed_balance(confirmations)
|
||||
for key, value in balance.items():
|
||||
if key == 'reserved_subtotals':
|
||||
for subkey, subvalue in value.items():
|
||||
@@ -1170,6 +1180,7 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
result[key] += value
|
||||
return result
|
||||
|
||||
|
||||
class TestNetLedger(Ledger):
|
||||
network_name = 'testnet'
|
||||
pubkey_address_prefix = bytes((111,))
|
||||
|
||||
+189
-177
@@ -1,26 +1,28 @@
|
||||
import logging
|
||||
import asyncio
|
||||
import json
|
||||
import socket
|
||||
import random
|
||||
from time import perf_counter
|
||||
from operator import itemgetter
|
||||
from collections import defaultdict
|
||||
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
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ClientSession(BaseClientSession):
|
||||
def __init__(self, *args, network, server, timeout=30, on_connect_callback=None, **kwargs):
|
||||
def __init__(self, *args, network: 'Network', server, timeout=30, **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
|
||||
@@ -28,8 +30,6 @@ 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):
|
||||
@@ -56,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", method, tuple(args), *self.server)
|
||||
log.debug("send %s%s to %s:%i (%i timeout)", method, tuple(args), self.server[0], self.server[1], self.timeout)
|
||||
try:
|
||||
if method == 'server.version':
|
||||
return await self.send_timed_server_version_request(args, self.timeout)
|
||||
@@ -67,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.info("timeout sending %s to %s:%i", method, *self.server)
|
||||
log.warning("timeout sending %s to %s:%i", method, *self.server)
|
||||
raise asyncio.TimeoutError
|
||||
if done:
|
||||
try:
|
||||
@@ -87,44 +87,12 @@ class ClientSession(BaseClientSession):
|
||||
self.synchronous_close()
|
||||
raise
|
||||
except asyncio.CancelledError:
|
||||
log.info("cancelled sending %s to %s:%i", method, *self.server)
|
||||
log.warning("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(
|
||||
@@ -134,6 +102,25 @@ 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()
|
||||
@@ -145,12 +132,14 @@ class ClientSession(BaseClientSession):
|
||||
controller.add(request.args)
|
||||
|
||||
def connection_lost(self, exc):
|
||||
log.debug("Connection lost: %s:%d", *self.server)
|
||||
log.warning("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)
|
||||
# self._on_disconnect_controller.add(True)
|
||||
if self.network:
|
||||
self.network.disconnect()
|
||||
|
||||
|
||||
class Network:
|
||||
@@ -160,10 +149,9 @@ 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)
|
||||
@@ -183,58 +171,176 @@ class Network:
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
async def switch_forever(self):
|
||||
while self.running:
|
||||
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)
|
||||
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
|
||||
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):
|
||||
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)
|
||||
if not self.running:
|
||||
self.running = True
|
||||
self.aiohttp_session = aiohttp.ClientSession()
|
||||
self.on_header.listen(self._update_remote_height)
|
||||
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
|
||||
await asyncio.gather(*(resolve_spv(server, port) for (server, port) in self.config['default_servers']))
|
||||
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['default_servers']))
|
||||
pongs = {}
|
||||
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)
|
||||
|
||||
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)
|
||||
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) in fastest_spvs:
|
||||
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
|
||||
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.info("subscribe to headers %s:%i", *client.server)
|
||||
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")
|
||||
|
||||
async def stop(self):
|
||||
if self.running:
|
||||
self.running = False
|
||||
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:
|
||||
await self.aiohttp_session.close()
|
||||
self._switch_task.cancel()
|
||||
self.session_pool.stop()
|
||||
self.aiohttp_session = None
|
||||
|
||||
@property
|
||||
def is_connected(self):
|
||||
return self.client and not self.client.is_closing()
|
||||
|
||||
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():
|
||||
def rpc(self, list_or_method, args, restricted=True, session: Optional[ClientSession] = None):
|
||||
if session or self.is_connected:
|
||||
session = session or self.client
|
||||
return session.send_request(list_or_method, args)
|
||||
else:
|
||||
self.session_pool.trigger_nodelay_connect()
|
||||
self._urgent_need_reconnect.set()
|
||||
raise ConnectionError("Attempting to send rpc request when connection is not available.")
|
||||
|
||||
async def retriable_call(self, function, *args, **kwargs):
|
||||
@@ -242,14 +348,15 @@ 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:
|
||||
pass
|
||||
log.warning("connection error")
|
||||
|
||||
raise asyncio.CancelledError() # if we got here, we are shutting down
|
||||
|
||||
def _update_remote_height(self, header_args):
|
||||
@@ -312,9 +419,6 @@ 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)
|
||||
|
||||
@@ -339,95 +443,3 @@ 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
|
||||
@@ -11,6 +11,7 @@ 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
|
||||
@@ -168,6 +169,7 @@ 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
|
||||
|
||||
@@ -182,10 +184,13 @@ 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
|
||||
'RPC_PORT': self.rpc_port,
|
||||
'ES_INDEX_PREFIX': uuid4().hex,
|
||||
'ES_MODE': 'writer',
|
||||
}
|
||||
if extraconf:
|
||||
conf.update(extraconf)
|
||||
@@ -197,6 +202,8 @@ class SPVNode:
|
||||
|
||||
async def stop(self, cleanup=True):
|
||||
try:
|
||||
await self.server.db.search_index.delete_index()
|
||||
await self.server.db.search_index.stop()
|
||||
await self.server.stop()
|
||||
finally:
|
||||
cleanup and self.cleanup()
|
||||
|
||||
@@ -108,9 +108,6 @@ class Response:
|
||||
|
||||
class CodeMessageError(Exception):
|
||||
|
||||
def __init__(self, code, message):
|
||||
super().__init__(code, message)
|
||||
|
||||
@property
|
||||
def code(self):
|
||||
return self.args[0]
|
||||
|
||||
@@ -32,10 +32,13 @@ 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
|
||||
|
||||
@@ -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,6 +185,7 @@ 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
|
||||
@@ -213,6 +214,8 @@ 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()
|
||||
@@ -221,10 +224,14 @@ 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]:
|
||||
@@ -279,7 +286,6 @@ 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:
|
||||
@@ -599,8 +605,7 @@ class BlockProcessor:
|
||||
# Key: b'h' + compressed_tx_hash + tx_idx + tx_num
|
||||
# Value: hashX
|
||||
prefix = b'h' + tx_hash[:4] + idx_packed
|
||||
candidates = {db_key: hashX for db_key, hashX
|
||||
in self.db.utxo_db.iterator(prefix=prefix)}
|
||||
candidates = dict(self.db.utxo_db.iterator(prefix=prefix))
|
||||
for hdb_key, hashX in candidates.items():
|
||||
tx_num_packed = hdb_key[-4:]
|
||||
if len(candidates) > 1:
|
||||
@@ -648,7 +653,11 @@ class BlockProcessor:
|
||||
self.reorg_count = 0
|
||||
else:
|
||||
blocks = self.prefetcher.get_prefetched_blocks()
|
||||
await self.check_and_advance_blocks(blocks)
|
||||
try:
|
||||
await self.check_and_advance_blocks(blocks)
|
||||
except Exception:
|
||||
self.logger.exception("error while processing txs")
|
||||
raise
|
||||
|
||||
async def _first_caught_up(self):
|
||||
self.logger.info(f'caught up to height {self.height}')
|
||||
@@ -682,9 +691,11 @@ 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()
|
||||
@@ -695,6 +706,7 @@ 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)
|
||||
@@ -714,7 +726,6 @@ class BlockProcessor:
|
||||
|
||||
|
||||
class Timer:
|
||||
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
self.total = 0
|
||||
@@ -777,15 +788,17 @@ class LBRYBlockProcessor(BlockProcessor):
|
||||
self.timer = Timer('BlockProcessor')
|
||||
|
||||
def advance_blocks(self, blocks):
|
||||
self.sql.begin()
|
||||
if self.sql:
|
||||
self.sql.begin()
|
||||
try:
|
||||
self.timer.run(super().advance_blocks, blocks)
|
||||
except:
|
||||
self.logger.exception(f'Error while advancing transaction in new block.')
|
||||
raise
|
||||
finally:
|
||||
self.sql.commit()
|
||||
if self.db.first_sync and self.height == self.daemon.cached_height():
|
||||
if self.sql:
|
||||
self.sql.commit()
|
||||
if self.sql and 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')
|
||||
@@ -794,22 +807,8 @@ class LBRYBlockProcessor(BlockProcessor):
|
||||
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')
|
||||
timer.run(self.sql.advance_txs, height, txs, header, self.daemon.cached_height(), forward_timer=True)
|
||||
if self.sql:
|
||||
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
|
||||
@@ -8,7 +8,7 @@ from lbry.wallet.server.server import Server
|
||||
|
||||
def get_argument_parser():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="torba-server"
|
||||
prog="lbry-hub"
|
||||
)
|
||||
parser.add_argument("spvserver", type=str, help="Python class path to SPV server implementation.",
|
||||
nargs="?", default="lbry.wallet.server.coin.LBC")
|
||||
@@ -27,6 +27,8 @@ def main():
|
||||
coin_class = get_coin_class(args.spvserver)
|
||||
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,11 +3,10 @@ import itertools
|
||||
import json
|
||||
import time
|
||||
from functools import wraps
|
||||
from pylru import lrucache
|
||||
|
||||
import aiohttp
|
||||
from prometheus_client import Gauge, Histogram
|
||||
|
||||
from lbry.utils import LRUCacheWithMetrics
|
||||
from lbry.wallet.rpc.jsonrpc import RPCError
|
||||
from lbry.wallet.server.util import hex_to_bytes, class_logger
|
||||
from lbry.wallet.rpc import JSONRPC
|
||||
@@ -55,8 +54,8 @@ class Daemon:
|
||||
self._height = None
|
||||
self.available_rpcs = {}
|
||||
self.connector = aiohttp.TCPConnector()
|
||||
self._block_hash_cache = lrucache(100000)
|
||||
self._block_cache = lrucache(10000)
|
||||
self._block_hash_cache = LRUCacheWithMetrics(100000)
|
||||
self._block_cache = LRUCacheWithMetrics(2 ** 16, metric_name='block', namespace=NAMESPACE)
|
||||
|
||||
async def close(self):
|
||||
if self.connector:
|
||||
@@ -250,8 +249,10 @@ class Daemon:
|
||||
|
||||
async def deserialised_block(self, hex_hash):
|
||||
"""Return the deserialised block with the given hex hash."""
|
||||
if not self._block_cache.get(hex_hash):
|
||||
self._block_cache[hex_hash] = await self._send_single('getblock', (hex_hash, True))
|
||||
if hex_hash not in self._block_cache:
|
||||
block = await self._send_single('getblock', (hex_hash, True))
|
||||
self._block_cache[hex_hash] = block
|
||||
return block
|
||||
return self._block_cache[hex_hash]
|
||||
|
||||
async def raw_blocks(self, hex_hashes):
|
||||
|
||||
@@ -15,7 +15,7 @@ class FindShortestID:
|
||||
|
||||
def finalize(self):
|
||||
if self.short_id:
|
||||
return '#'+self.short_id
|
||||
return ':'+self.short_id
|
||||
|
||||
@classmethod
|
||||
def factory(cls):
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
CLAIM_TYPES = {
|
||||
'stream': 1,
|
||||
'channel': 2,
|
||||
'repost': 3
|
||||
'repost': 3,
|
||||
'collection': 4,
|
||||
}
|
||||
|
||||
STREAM_TYPES = {
|
||||
@@ -10,7 +11,7 @@ STREAM_TYPES = {
|
||||
'image': 3,
|
||||
'document': 4,
|
||||
'binary': 5,
|
||||
'model': 6
|
||||
'model': 6,
|
||||
}
|
||||
|
||||
# 9/21/2020
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
from .search import SearchIndex
|
||||
@@ -0,0 +1,61 @@
|
||||
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'
|
||||
}
|
||||
@@ -0,0 +1,590 @@
|
||||
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 SearchIndex:
|
||||
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 start(self):
|
||||
if self.sync_client:
|
||||
return
|
||||
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)
|
||||
return res.get('acknowledged', False)
|
||||
|
||||
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.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:
|
||||
if 'limit_claims_per_channel' in kwargs:
|
||||
return await self.search_ahead(**kwargs), 0, 0
|
||||
else:
|
||||
result = (await self.search_client.search(
|
||||
expand_query(**kwargs), index=self.index,
|
||||
track_total_hits=False if kwargs.get('no_totals') else 10_000
|
||||
))['hits']
|
||||
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')
|
||||
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)
|
||||
reordered_hits = await self.__search_ahead(query, page_size, per_channel_per_page)
|
||||
cache_item.result = reordered_hits
|
||||
return list(await self.get_many(*(claim_id for claim_id, _ in reordered_hits[offset:(offset + page_size)])))
|
||||
|
||||
async def __search_ahead(self, query: dict, page_size: int, per_channel_per_page: int):
|
||||
search_hits = deque((await self.search_client.search(
|
||||
query, index=self.index, track_total_hits=False, _source_includes=['_id', 'channel_id']
|
||||
))['hits']['hits'])
|
||||
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 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:
|
||||
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]}})
|
||||
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
|
||||
@@ -0,0 +1,114 @@
|
||||
import argparse
|
||||
import asyncio
|
||||
import logging
|
||||
import os
|
||||
from collections import namedtuple
|
||||
from multiprocessing import Process
|
||||
|
||||
import apsw
|
||||
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
|
||||
|
||||
INDEX = 'claims'
|
||||
|
||||
|
||||
async def get_all(db, shard_num, shards_total, limit=0):
|
||||
logging.info("shard %d starting", shard_num)
|
||||
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
|
||||
|
||||
db.setexectrace(exec_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,
|
||||
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)
|
||||
if 0 < limit <= num:
|
||||
break
|
||||
|
||||
|
||||
async def consume(producer):
|
||||
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)
|
||||
finally:
|
||||
await es.close()
|
||||
|
||||
|
||||
async def make_es_index():
|
||||
env = Env(LBC)
|
||||
index = SearchIndex('', elastic_host=env.elastic_host, elastic_port=env.elastic_port)
|
||||
try:
|
||||
return await index.start()
|
||||
finally:
|
||||
index.stop()
|
||||
|
||||
|
||||
async def run(args, shard):
|
||||
def itsbusy(*_):
|
||||
logging.info("shard %d: db is busy, retry", shard)
|
||||
return True
|
||||
db = apsw.Connection(args.db_path, flags=apsw.SQLITE_OPEN_READONLY | apsw.SQLITE_OPEN_URI)
|
||||
db.setbusyhandler(itsbusy)
|
||||
db.cursor().execute('pragma journal_mode=wal;')
|
||||
db.cursor().execute('pragma temp_store=memory;')
|
||||
|
||||
producer = get_all(db.cursor(), shard, args.clients, limit=args.blocks)
|
||||
await asyncio.gather(*(consume(producer) for _ in range(min(8, args.clients))))
|
||||
|
||||
|
||||
def __run(args, shard):
|
||||
asyncio.run(run(args, 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()
|
||||
@@ -1,52 +0,0 @@
|
||||
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())
|
||||
+102
-33
@@ -1,11 +1,12 @@
|
||||
import os
|
||||
|
||||
import apsw
|
||||
from typing import Union, Tuple, Set, List
|
||||
from itertools import chain
|
||||
from decimal import Decimal
|
||||
from collections import namedtuple
|
||||
from multiprocessing import Manager
|
||||
from binascii import unhexlify
|
||||
from binascii import unhexlify, hexlify
|
||||
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,11 +16,10 @@ 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
|
||||
|
||||
@@ -47,14 +47,15 @@ class SQLDB:
|
||||
expiration_height integer not null,
|
||||
release_time integer not null,
|
||||
|
||||
short_url text not null, -- normalized#shortest-unique-claim_id
|
||||
canonical_url text, -- channel's-short_url/normalized#shortest-unique-claim_id-within-channel
|
||||
short_url text not null, -- normalized:shortest-unique-claim_id
|
||||
canonical_url text, -- channel's-short_url/normalized:shortest-unique-claim_id-within-channel
|
||||
|
||||
title text,
|
||||
author text,
|
||||
description text,
|
||||
|
||||
claim_type integer,
|
||||
has_source bool,
|
||||
reposted integer default 0,
|
||||
|
||||
-- streams
|
||||
@@ -134,6 +135,22 @@ 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);
|
||||
@@ -189,10 +206,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
|
||||
)
|
||||
|
||||
@@ -203,7 +220,6 @@ 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
|
||||
@@ -216,6 +232,7 @@ 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 = apsw.Connection(
|
||||
@@ -354,6 +371,7 @@ class SQLDB:
|
||||
'author': None,
|
||||
'duration': None,
|
||||
'claim_type': None,
|
||||
'has_source': False,
|
||||
'stream_type': None,
|
||||
'media_type': None,
|
||||
'release_time': None,
|
||||
@@ -371,6 +389,7 @@ 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
|
||||
@@ -393,6 +412,8 @@ class SQLDB:
|
||||
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)
|
||||
|
||||
@@ -417,21 +438,21 @@ class SQLDB:
|
||||
claims = self._upsertable_claims(txos, header)
|
||||
if claims:
|
||||
self.executemany("""
|
||||
INSERT OR IGNORE INTO claim (
|
||||
INSERT OR REPLACE INTO claim (
|
||||
claim_hash, claim_id, claim_name, normalized, txo_hash, tx_position, amount,
|
||||
claim_type, media_type, stream_type, timestamp, creation_timestamp,
|
||||
claim_type, media_type, stream_type, timestamp, creation_timestamp, has_source,
|
||||
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,
|
||||
:claim_type, :media_type, :stream_type, :timestamp, :timestamp, :has_source,
|
||||
: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,
|
||||
CASE WHEN :height >= 137181 THEN :height+2102400 ELSE :height+262974 END,
|
||||
:claim_name||COALESCE(
|
||||
(SELECT shortest_id(claim_id, :claim_id) FROM claim WHERE normalized = :normalized),
|
||||
'#'||substr(:claim_id, 1, 1)
|
||||
':'||substr(:claim_id, 1, 1)
|
||||
)
|
||||
)""", claims)
|
||||
|
||||
@@ -442,7 +463,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,
|
||||
timestamp=:timestamp, fee_amount=:fee_amount, fee_currency=:fee_currency, has_source=:has_source,
|
||||
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;
|
||||
@@ -526,6 +547,7 @@ 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:
|
||||
@@ -643,7 +665,7 @@ class SQLDB:
|
||||
WHERE other_claim.signature_valid = 1 AND
|
||||
other_claim.channel_hash = :channel_hash AND
|
||||
other_claim.normalized = claim.normalized),
|
||||
'#'||substr(claim_id, 1, 1)
|
||||
':'||substr(claim_id, 1, 1)
|
||||
)
|
||||
END
|
||||
WHERE claim_hash=:claim_hash;
|
||||
@@ -692,7 +714,7 @@ class SQLDB:
|
||||
claim_in_channel.channel_hash=claim.claim_hash
|
||||
)
|
||||
WHERE claim_hash = ?
|
||||
""", [(channel_hash,) for channel_hash in all_channel_keys.keys()])
|
||||
""", [(channel_hash,) for channel_hash in all_channel_keys])
|
||||
sub_timer.stop()
|
||||
|
||||
sub_timer = timer.add_timer('update blocked claims list')
|
||||
@@ -799,11 +821,56 @@ class SQLDB:
|
||||
f"SELECT claim_hash, normalized FROM claim WHERE expiration_height = {height}"
|
||||
)
|
||||
|
||||
def enqueue_changes(self):
|
||||
for claim in self.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,
|
||||
claim.*
|
||||
FROM claim LEFT JOIN claimtrie USING (claim_hash)
|
||||
WHERE claim.claim_hash in (SELECT claim_hash FROM changelog)
|
||||
"""):
|
||||
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 = set()
|
||||
delete_claim_hashes = self.pending_deletes
|
||||
insert_supports = []
|
||||
delete_support_txo_hashes = set()
|
||||
recalculate_claim_hashes = set() # added/deleted supports, added/updated claim
|
||||
@@ -872,28 +939,17 @@ 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):
|
||||
@@ -905,17 +961,30 @@ class LBRYLevelDB(LevelDB):
|
||||
for algorithm_name in self.env.trending_algorithms:
|
||||
if algorithm_name in TRENDING_ALGORITHMS:
|
||||
trending.append(TRENDING_ALGORITHMS[algorithm_name])
|
||||
self.sql = SQLDB(
|
||||
self, path,
|
||||
self.env.default('BLOCKING_CHANNEL_IDS', '').split(' '),
|
||||
self.env.default('FILTERING_CHANNEL_IDS', '').split(' '),
|
||||
trending
|
||||
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
|
||||
)
|
||||
|
||||
def close(self):
|
||||
super().close()
|
||||
self.sql.close()
|
||||
if self.sql:
|
||||
self.sql.close()
|
||||
|
||||
async def _open_dbs(self, *args, **kwargs):
|
||||
await self.search_index.start()
|
||||
await super()._open_dbs(*args, **kwargs)
|
||||
self.sql.open()
|
||||
if self.sql:
|
||||
self.sql.open()
|
||||
@@ -33,6 +33,8 @@ 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')
|
||||
@@ -53,10 +55,13 @@ 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')
|
||||
@@ -94,7 +99,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', 250)) / 1000.0
|
||||
self.database_query_timeout = float(self.integer('QUERY_TIMEOUT_MS', 3000)) / 1000.0
|
||||
|
||||
@classmethod
|
||||
def default(cls, envvar, default):
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
import asyncio
|
||||
import array
|
||||
import ast
|
||||
import base64
|
||||
import os
|
||||
import time
|
||||
import zlib
|
||||
import pylru
|
||||
import typing
|
||||
from typing import Optional, List, Tuple, Iterable
|
||||
from asyncio import sleep
|
||||
@@ -25,7 +25,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.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,6 +83,7 @@ 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')
|
||||
@@ -94,7 +95,7 @@ class LevelDB:
|
||||
self.headers_db = None
|
||||
self.tx_db = None
|
||||
|
||||
self._tx_and_merkle_cache = pylru.lrucache(100000)
|
||||
self._tx_and_merkle_cache = LRUCacheWithMetrics(2 ** 17, metric_name='tx_and_merkle', namespace="wallet_server")
|
||||
self.total_transactions = None
|
||||
|
||||
async def _read_tx_counts(self):
|
||||
@@ -136,9 +137,7 @@ class LevelDB:
|
||||
return
|
||||
|
||||
def get_headers():
|
||||
return [
|
||||
header for header in self.headers_db.iterator(prefix=HEADER_PREFIX, include_key=False)
|
||||
]
|
||||
return list(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}"
|
||||
@@ -441,6 +440,16 @@ 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
|
||||
@@ -467,7 +476,14 @@ class LevelDB:
|
||||
tx_height = bisect_right(self.tx_counts, tx_num)
|
||||
if tx_height > self.db_height:
|
||||
return None, tx_height
|
||||
return self.total_transactions[tx_num], 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
|
||||
|
||||
def _fs_transactions(self, txids: Iterable[str]):
|
||||
unpack_be_uint64 = util.unpack_be_uint64
|
||||
|
||||
@@ -210,6 +210,15 @@ 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:
|
||||
@@ -315,7 +324,7 @@ class MemPool:
|
||||
for prevout in tx.prevouts
|
||||
if prevout[0] not in all_hashes)
|
||||
utxos = await self.api.lookup_utxos(prevouts)
|
||||
utxo_map = {prevout: utxo for prevout, utxo in zip(prevouts, utxos)}
|
||||
utxo_map = dict(zip(prevouts, utxos))
|
||||
|
||||
return self._accept_transactions(tx_map, utxo_map, touched)
|
||||
|
||||
@@ -326,7 +335,7 @@ class MemPool:
|
||||
async def keep_synchronized(self, synchronized_event):
|
||||
"""Keep the mempool synchronized with the daemon."""
|
||||
await asyncio.wait([
|
||||
self._refresh_hashes(synchronized_event),
|
||||
self._mempool_loop(synchronized_event),
|
||||
# self._refresh_histogram(synchronized_event),
|
||||
self._logging(synchronized_event)
|
||||
])
|
||||
@@ -344,7 +353,7 @@ class MemPool:
|
||||
value += sum(v for h168, v in tx.out_pairs if h168 == hashX)
|
||||
return value
|
||||
|
||||
async def compact_fee_histogram(self):
|
||||
def compact_fee_histogram(self):
|
||||
"""Return a compact fee histogram of the current mempool."""
|
||||
return self.cached_compact_histogram
|
||||
|
||||
|
||||
@@ -94,6 +94,7 @@ 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
|
||||
@@ -110,11 +111,17 @@ 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.host, self.env.udp_port
|
||||
)
|
||||
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):
|
||||
|
||||
+63
-172
@@ -3,8 +3,6 @@ import ssl
|
||||
import math
|
||||
import time
|
||||
import json
|
||||
import zlib
|
||||
import pylru
|
||||
import base64
|
||||
import codecs
|
||||
import typing
|
||||
@@ -17,16 +15,17 @@ from asyncio import Event, sleep
|
||||
from collections import defaultdict
|
||||
from functools import partial
|
||||
|
||||
from binascii import hexlify, unhexlify
|
||||
from pylru import lrucache
|
||||
from binascii import hexlify
|
||||
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.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
|
||||
@@ -248,11 +247,12 @@ class SessionManager:
|
||||
async def _manage_servers(self):
|
||||
paused = False
|
||||
max_sessions = self.env.max_sessions
|
||||
low_watermark = max_sessions * 19 // 20
|
||||
low_watermark = int(max_sessions * 0.95)
|
||||
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}')
|
||||
@@ -261,6 +261,7 @@ 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
|
||||
@@ -573,6 +574,7 @@ 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([
|
||||
@@ -583,6 +585,7 @@ class SessionManager:
|
||||
])
|
||||
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()
|
||||
@@ -810,9 +813,6 @@ 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(10000)
|
||||
self.search_cache['resolve'] = lrucache(10000)
|
||||
|
||||
async def process_metrics(self):
|
||||
while self.running:
|
||||
@@ -826,22 +826,11 @@ 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, **args)
|
||||
self.query_executor = ThreadPoolExecutor(max_workers=1)
|
||||
else:
|
||||
self.query_executor = ProcessPoolExecutor(
|
||||
max_workers=self.env.max_query_workers or max(os.cpu_count(), 4), **args
|
||||
max_workers=self.env.max_query_workers or max(os.cpu_count(), 4)
|
||||
)
|
||||
if self.websocket is not None:
|
||||
await self.websocket.start()
|
||||
@@ -865,6 +854,7 @@ 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):
|
||||
@@ -893,7 +883,6 @@ 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,
|
||||
@@ -911,13 +900,15 @@ 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.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
|
||||
@@ -928,10 +919,10 @@ class LBRYElectrumX(SessionBase):
|
||||
for ver in (cls.PROTOCOL_MIN, cls.PROTOCOL_MAX)]
|
||||
|
||||
@classmethod
|
||||
def server_features(cls, env):
|
||||
def set_server_features(cls, env):
|
||||
"""Return the server features dictionary."""
|
||||
min_str, max_str = cls.protocol_min_max_strings()
|
||||
return {
|
||||
cls.cached_server_features.update({
|
||||
'hosts': env.hosts_dict(),
|
||||
'pruning': None,
|
||||
'server_version': cls.version,
|
||||
@@ -944,10 +935,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.server_features(self.env)
|
||||
return self.cached_server_features
|
||||
|
||||
@classmethod
|
||||
def server_version_args(cls):
|
||||
@@ -996,16 +987,6 @@ 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)
|
||||
@@ -1022,40 +1003,33 @@ 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, 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 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 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', reader.search_to_bytes, kwargs)
|
||||
return await self.run_and_cache_query('search', 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', reader.resolve_to_bytes, urls)
|
||||
return await self.run_and_cache_query('resolve', urls)
|
||||
finally:
|
||||
self.session_mgr.resolved_url_count_metric.inc(count)
|
||||
|
||||
@@ -1072,67 +1046,6 @@ 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.'''
|
||||
@@ -1143,16 +1056,6 @@ 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]
|
||||
@@ -1269,10 +1172,9 @@ 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)}')
|
||||
hashXes = [
|
||||
(self.address_to_hashX(address), address) for address in addresses
|
||||
return [
|
||||
await self.hashX_subscribe(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.
|
||||
@@ -1358,8 +1260,7 @@ class LBRYElectrumX(SessionBase):
|
||||
headers, count = self.db.read_headers(start_height, count)
|
||||
|
||||
if b64:
|
||||
compressobj = zlib.compressobj(wbits=-15, level=1, memLevel=9)
|
||||
headers = base64.b64encode(compressobj.compress(headers) + compressobj.flush()).decode()
|
||||
headers = self.db.encode_headers(start_height, count, headers)
|
||||
else:
|
||||
headers = headers.hex()
|
||||
result = {
|
||||
@@ -1468,7 +1369,8 @@ 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
|
||||
@@ -1478,8 +1380,7 @@ 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]
|
||||
@@ -1488,19 +1389,16 @@ 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:
|
||||
# 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}')
|
||||
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}')
|
||||
|
||||
self.protocol_tuple = ptuple
|
||||
return self.version, self.protocol_version_string()
|
||||
self.protocol_string = util.version_string(ptuple)
|
||||
return self.version, self.protocol_string
|
||||
|
||||
async def transaction_broadcast(self, raw_tx):
|
||||
"""Broadcast a raw transaction to the network.
|
||||
@@ -1550,15 +1448,14 @@ class LBRYElectrumX(SessionBase):
|
||||
else:
|
||||
batch_result[tx_hash] = [raw_tx, {'block_height': -1}]
|
||||
|
||||
def threaded_get_merkle():
|
||||
if needed_merkles:
|
||||
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
|
||||
}
|
||||
if needed_merkles:
|
||||
await asyncio.get_running_loop().run_in_executor(self.db.executor, threaded_get_merkle)
|
||||
await asyncio.sleep(0) # heavy call, give other tasks a chance
|
||||
|
||||
self.session_mgr.tx_replied_count_metric.inc(len(tx_hashes))
|
||||
return batch_result
|
||||
@@ -1613,26 +1510,20 @@ 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)
|
||||
@@ -0,0 +1,199 @@
|
||||
import asyncio
|
||||
import struct
|
||||
from time import perf_counter
|
||||
import logging
|
||||
from typing import Optional, Tuple, NamedTuple
|
||||
from lbry.utils import LRUCache
|
||||
# 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
|
||||
|
||||
|
||||
class SPVPing(NamedTuple):
|
||||
magic: int
|
||||
protocol_version: int
|
||||
pad_bytes: bytes
|
||||
|
||||
def encode(self):
|
||||
return struct.pack(b'!lB64s', *self)
|
||||
|
||||
@staticmethod
|
||||
def make(protocol_version=1) -> 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
|
||||
|
||||
|
||||
class SPVPong(NamedTuple):
|
||||
protocol_version: int
|
||||
flags: int
|
||||
height: int
|
||||
tip: bytes
|
||||
source_address_raw: bytes
|
||||
|
||||
def encode(self):
|
||||
return struct.pack(b'!BBl32s4s', *self)
|
||||
|
||||
@staticmethod
|
||||
def make(height: int, tip: bytes, flags: int, protocol_version: int = 1) -> bytes:
|
||||
# note: drops the last 4 bytes so the result can be cached and have addresses added to it as needed
|
||||
return SPVPong(protocol_version, flags, height, tip, b'\x00\x00\x00\x00').encode()[:38]
|
||||
|
||||
@classmethod
|
||||
def decode(cls, packet: bytes):
|
||||
return cls(*struct.unpack(b'!BBl32s4s', packet[:42]))
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
return (self.flags & 0b00000001) > 0
|
||||
|
||||
@property
|
||||
def ip_address(self) -> str:
|
||||
return ".".join(map(str, self.source_address_raw))
|
||||
|
||||
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()})"
|
||||
|
||||
|
||||
class SPVServerStatusProtocol(asyncio.DatagramProtocol):
|
||||
PROTOCOL_VERSION = 1
|
||||
|
||||
def __init__(self, height: int, tip: bytes, throttle_cache_size: int = 1024, throttle_reqs_per_sec: int = 10):
|
||||
super().__init__()
|
||||
self.transport: Optional[asyncio.transports.DatagramTransport] = None
|
||||
self._height = height
|
||||
self._tip = tip
|
||||
self._flags = 0
|
||||
self._cached_response = 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
|
||||
|
||||
def update_cached_response(self):
|
||||
self._cached_response = SPVPong.make(self._height, self._tip, self._flags, self.PROTOCOL_VERSION)
|
||||
|
||||
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._cached_response + bytes(int(b) for b in host.split("."))
|
||||
|
||||
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
|
||||
self.transport.sendto(self.make_pong(addr[0]), addr)
|
||||
# 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, interface: str, port: int):
|
||||
if self.is_running:
|
||||
return
|
||||
loop = asyncio.get_event_loop()
|
||||
self._protocol = SPVServerStatusProtocol(height, tip)
|
||||
interface = interface if interface.lower() != 'localhost' else '127.0.0.1'
|
||||
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):
|
||||
PROTOCOL_VERSION = 1
|
||||
|
||||
def __init__(self, responses: asyncio.Queue):
|
||||
super().__init__()
|
||||
self.transport: Optional[asyncio.transports.DatagramTransport] = None
|
||||
self.responses = responses
|
||||
self._ping_packet = SPVPing.make(self.PROTOCOL_VERSION)
|
||||
|
||||
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()
|
||||
@@ -384,7 +384,7 @@ class Output(InputOutput):
|
||||
@property
|
||||
def permanent_url(self) -> str:
|
||||
if self.script.is_claim_involved:
|
||||
return f"lbry://{self.claim_name}#{self.claim_id}"
|
||||
return f"lbry://{self.claim_name}:{self.claim_id}"
|
||||
raise ValueError('No claim associated.')
|
||||
|
||||
@property
|
||||
@@ -539,6 +539,7 @@ 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)
|
||||
@@ -600,6 +601,7 @@ class Transaction:
|
||||
def _reset(self):
|
||||
self._raw = None
|
||||
self._raw_sans_segwit = None
|
||||
self._raw_outputs = None
|
||||
self.ref.reset()
|
||||
|
||||
@property
|
||||
@@ -693,9 +695,7 @@ class Transaction:
|
||||
stream.write_compact_size(len(self._inputs))
|
||||
for txin in self._inputs:
|
||||
txin.serialize_to(stream)
|
||||
stream.write_compact_size(len(self._outputs))
|
||||
for txout in self._outputs:
|
||||
txout.serialize_to(stream)
|
||||
self._serialize_outputs(stream)
|
||||
stream.write_uint32(self.locktime)
|
||||
return stream.get_bytes()
|
||||
|
||||
@@ -709,13 +709,19 @@ class Transaction:
|
||||
txin.serialize_to(stream, txin.txo_ref.txo.script.source)
|
||||
else:
|
||||
txin.serialize_to(stream, b'')
|
||||
stream.write_compact_size(len(self._outputs))
|
||||
for txout in self._outputs:
|
||||
txout.serialize_to(stream)
|
||||
self._serialize_outputs(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)
|
||||
@@ -844,6 +850,7 @@ 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
|
||||
|
||||
@@ -64,7 +64,7 @@ async def checkcontrolling(daemon: Daemon, db: SQLDB):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if not len(sys.argv) == 3:
|
||||
if len(sys.argv) != 3:
|
||||
print("usage: <db_file_path> <lbrycrd_url>")
|
||||
sys.exit(1)
|
||||
db_path, lbrycrd_url = sys.argv[1:] # pylint: disable=W0632
|
||||
|
||||
@@ -1,177 +0,0 @@
|
||||
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))
|
||||
@@ -13,6 +13,7 @@ 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
|
||||
@@ -66,6 +67,10 @@ 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):
|
||||
@@ -360,6 +365,26 @@ 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(
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
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())
|
||||
@@ -28,8 +28,9 @@ setup(
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'lbrynet=lbry.extras.cli:main',
|
||||
'torba-server=lbry.wallet.server.cli:main',
|
||||
'lbry-hub=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=[
|
||||
@@ -53,7 +54,8 @@ setup(
|
||||
'coincurve==11.0.0',
|
||||
'pbkdf2==1.3',
|
||||
'attrs==18.2.0',
|
||||
'pylru==1.1.0'
|
||||
'pylru==1.1.0',
|
||||
'elasticsearch==7.10.1'
|
||||
] + PLYVEL,
|
||||
classifiers=[
|
||||
'Framework :: AsyncIO',
|
||||
|
||||
@@ -114,15 +114,6 @@ 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,12 +3,15 @@ import tempfile
|
||||
import logging
|
||||
import asyncio
|
||||
from binascii import unhexlify
|
||||
from unittest import skip
|
||||
from urllib.request import urlopen
|
||||
|
||||
from lbry.error import InsufficientFundsError
|
||||
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
|
||||
|
||||
@@ -71,9 +74,22 @@ class ClaimSearchCommand(ClaimTestCase):
|
||||
for claim, result in zip(claims, results):
|
||||
self.assertEqual(
|
||||
(claim['txid'], self.get_claim_id(claim)),
|
||||
(result['txid'], result['claim_id'])
|
||||
(result['txid'], result['claim_id']),
|
||||
f"(expected {claim['outputs'][0]['name']}) != (got {result['name']})"
|
||||
)
|
||||
|
||||
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',
|
||||
@@ -93,6 +109,18 @@ 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]
|
||||
@@ -132,10 +160,11 @@ class ClaimSearchCommand(ClaimTestCase):
|
||||
# three streams in channel, zero streams in abandoned channel
|
||||
claims = [three, two, signed]
|
||||
await self.assertFindsClaims(claims, channel_ids=[self.channel_id])
|
||||
await self.assertFindsClaims(claims, channel=f"@abc#{self.channel_id}")
|
||||
await self.assertFindsClaims(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)
|
||||
await self.assertFindsClaims([], channel=f"@abc:{self.channel_id}", valid_channel_signature=True)
|
||||
await self.assertFindsClaims([], channel_ids=[self.channel_id], valid_channel_signature=True)
|
||||
await self.assertFindsClaims([signed2], channel_ids=[channel_id2], valid_channel_signature=True)
|
||||
# pass `invalid_channel_signature=False` to catch a bug in argument processing
|
||||
@@ -156,6 +185,23 @@ 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')
|
||||
await self.assertFindsClaims([no_source_repost, no_source, channel], has_no_source=True)
|
||||
await self.assertListsClaims([no_source, channel], has_no_source=True)
|
||||
await self.assertFindsClaims([normal_repost, normal, channel], has_source=True)
|
||||
await self.assertListsClaims([no_source_repost, normal_repost, normal], has_source=True)
|
||||
await self.assertFindsClaims([no_source_repost, normal_repost, normal, no_source, channel])
|
||||
await self.assertListsClaims([no_source_repost, normal_repost, normal, no_source, channel])
|
||||
|
||||
async def test_pagination(self):
|
||||
await self.create_channel()
|
||||
@@ -351,6 +397,38 @@ class ClaimSearchCommand(ClaimTestCase):
|
||||
limit_claims_per_channel=3, claim_type='stream'
|
||||
)
|
||||
|
||||
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']
|
||||
)
|
||||
|
||||
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()
|
||||
@@ -364,6 +442,7 @@ 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)
|
||||
|
||||
@@ -371,6 +450,7 @@ 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'])
|
||||
@@ -421,10 +501,11 @@ 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 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')
|
||||
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=[])
|
||||
|
||||
claim2 = await self.stream_update(
|
||||
self.get_claim_id(claim2), clear_tags=True, tags=['cloud'],
|
||||
@@ -460,6 +541,47 @@ class TransactionCommands(ClaimTestCase):
|
||||
|
||||
class TransactionOutputCommands(ClaimTestCase):
|
||||
|
||||
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)))
|
||||
@@ -862,6 +984,22 @@ 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):
|
||||
|
||||
@@ -1004,6 +1142,18 @@ class ChannelCommands(CommandTestCase):
|
||||
self.assertItemCount(await self.daemon.jsonrpc_channel_list(account_id=self.account.id), 2)
|
||||
self.assertItemCount(await self.daemon.jsonrpc_channel_list(account_id=account2_id), 1)
|
||||
|
||||
async def test_sign_hex_encoded_data(self):
|
||||
data_to_sign = "CAFEBABE"
|
||||
# claim new name
|
||||
await self.channel_create('@someotherchan')
|
||||
channel_tx = await self.daemon.jsonrpc_channel_create('@signer', '0.1')
|
||||
await self.confirm_tx(channel_tx.id)
|
||||
channel = channel_tx.outputs[0]
|
||||
signature1 = await self.out(self.daemon.jsonrpc_channel_sign(channel_name='@signer', hexdata=data_to_sign))
|
||||
signature2 = await self.out(self.daemon.jsonrpc_channel_sign(channel_id=channel.claim_id, hexdata=data_to_sign))
|
||||
self.assertTrue(verify(channel, unhexlify(data_to_sign), signature1))
|
||||
self.assertTrue(verify(channel, unhexlify(data_to_sign), signature2))
|
||||
|
||||
async def test_channel_export_import_before_sending_channel(self):
|
||||
# export
|
||||
tx = await self.channel_create('@foo', '1.0')
|
||||
@@ -1280,7 +1430,12 @@ class StreamCommands(ClaimTestCase):
|
||||
self.assertEqual(1, blocked['total'])
|
||||
self.assertEqual(1, len(blocked['channels']))
|
||||
self.assertEqual(1, blocked['channels'][0]['blocked'])
|
||||
self.assertTrue(blocked['channels'][0]['channel']['short_url'].startswith('lbry://@filtering#'))
|
||||
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'))
|
||||
@@ -1289,7 +1444,12 @@ class StreamCommands(ClaimTestCase):
|
||||
self.assertEqual(1, filtered['total'])
|
||||
self.assertEqual(1, len(filtered['channels']))
|
||||
self.assertEqual(1, filtered['channels'][0]['blocked'])
|
||||
self.assertTrue(filtered['channels'][0]['channel']['short_url'].startswith('lbry://@filtering#'))
|
||||
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"]))
|
||||
@@ -1314,7 +1474,7 @@ class StreamCommands(ClaimTestCase):
|
||||
error = (await self.resolve('lbry://@some_channel/bad_content'))['error']
|
||||
self.assertEqual(error['name'], 'BLOCKED')
|
||||
self.assertTrue(error['text'].startswith("Resolve of 'lbry://@some_channel/bad_content' was censored"))
|
||||
self.assertTrue(error['censor']['short_url'].startswith('lbry://@blocking#'))
|
||||
self.assertTrue(error['censor']['short_url'].startswith('lbry://@blocking:'))
|
||||
|
||||
# a filtered/blocked channel impacts all content inside it
|
||||
bad_channel_id = self.get_claim_id(
|
||||
@@ -1342,7 +1502,14 @@ class StreamCommands(ClaimTestCase):
|
||||
self.assertEqual(3, filtered['total'])
|
||||
self.assertEqual(1, len(filtered['channels']))
|
||||
self.assertEqual(3, filtered['channels'][0]['blocked'])
|
||||
self.assertTrue(filtered['channels'][0]['channel']['short_url'].startswith('lbry://@filtering#'))
|
||||
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')
|
||||
@@ -1788,9 +1955,6 @@ 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')
|
||||
@@ -1833,6 +1997,41 @@ 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):
|
||||
|
||||
@@ -1920,10 +2119,14 @@ 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(self):
|
||||
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.'
|
||||
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, '0.3', channel_id=channel_id)
|
||||
tx = await self.support_create(stream_id, '7.967598', channel_id=channel_id)
|
||||
self.assertEqual(len(tx['outputs']), 1) # must be one to reproduce bug
|
||||
self.assertTrue(tx['outputs'][0]['is_channel_signature_valid'])
|
||||
|
||||
|
||||
@@ -1969,6 +2172,10 @@ class CollectionCommands(CommandTestCase):
|
||||
await self.collection_update(claim_id, clear_claims=True, claims=claim_ids[:2])
|
||||
collections = await self.out(self.daemon.jsonrpc_collection_list())
|
||||
self.assertEquals(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])
|
||||
|
||||
await self.collection_abandon(claim_id)
|
||||
self.assertItemCount(await self.daemon.jsonrpc_collection_list(), 1)
|
||||
|
||||
@@ -4,8 +4,10 @@ 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
|
||||
|
||||
|
||||
@@ -32,18 +34,17 @@ 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)
|
||||
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.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
|
||||
self.assertDictEqual({
|
||||
'genesis_hash': self.conductor.spv_node.coin_class.GENESIS_HASH,
|
||||
'hash_function': 'sha256',
|
||||
@@ -65,22 +66,20 @@ 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)
|
||||
# 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.ledger.network.config['default_servers'].append((node2.hostname, node2.port))
|
||||
self.ledger.network.config['default_servers'].reverse()
|
||||
self.assertEqual(50002, self.ledger.network.client.server[1])
|
||||
await self.ledger.stop()
|
||||
await self.ledger.start()
|
||||
|
||||
self.assertTrue(self.ledger.network.is_connected)
|
||||
switch_event = self.ledger.network.on_connected.first
|
||||
self.assertEqual(50003, self.ledger.network.client.server[1])
|
||||
await node2.stop(True)
|
||||
# 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)
|
||||
self.assertFalse(self.ledger.network.is_connected)
|
||||
await self.ledger.resolve([], ['derp'])
|
||||
self.assertEqual(50002, self.ledger.network.client.server[1])
|
||||
|
||||
async def test_direct_sync(self):
|
||||
await self.ledger.stop()
|
||||
@@ -98,10 +97,13 @@ 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.connection_lost(Exception())
|
||||
self.ledger.network.client.transport.close()
|
||||
self.assertFalse(self.ledger.network.is_connected)
|
||||
await self.ledger.resolve([], 'derp')
|
||||
sendtxid = await self.blockchain.send_to_address(address1, 1.1337)
|
||||
await asyncio.wait_for(self.on_transaction_id(sendtxid), 1.0) # mempool
|
||||
# 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 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
|
||||
@@ -123,7 +125,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=1.0)
|
||||
await asyncio.wait_for(self.ledger.network.on_connected.first, timeout=10.0)
|
||||
# omg, the burned cable still works! torba is fire proof!
|
||||
await self.ledger.network.get_transaction(sendtxid)
|
||||
|
||||
@@ -136,15 +138,34 @@ 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)
|
||||
# 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)
|
||||
|
||||
|
||||
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
|
||||
@@ -156,6 +177,7 @@ 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):
|
||||
@@ -164,9 +186,10 @@ 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
|
||||
@@ -182,8 +205,8 @@ class ServerPickingTestCase(AsyncioTestCase):
|
||||
|
||||
network = Network(ledger)
|
||||
self.addCleanup(network.stop)
|
||||
asyncio.ensure_future(network.start())
|
||||
await asyncio.wait_for(network.on_connected.first, timeout=1)
|
||||
await network.start()
|
||||
await asyncio.wait_for(network.on_connected.first, timeout=10)
|
||||
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,7 +11,9 @@ 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] = '2.0', currency='LBC') -> Transaction:
|
||||
async def priced_stream(
|
||||
self, name='stream', price: Optional[str] = '0.2', currency='LBC', mine=False
|
||||
) -> Transaction:
|
||||
kwargs = {}
|
||||
if price and currency:
|
||||
kwargs = {
|
||||
@@ -19,6 +21,8 @@ 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
|
||||
@@ -117,6 +121,13 @@ 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)
|
||||
@@ -173,7 +184,13 @@ class PurchaseCommandTests(CommandTestCase):
|
||||
await self.generate(1)
|
||||
await self.ledger.wait(purchase)
|
||||
|
||||
await self.assertBalance(self.account, '10.987893')
|
||||
# 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}
|
||||
})
|
||||
self.assertItemCount(await self.daemon.jsonrpc_utxo_list(), 2)
|
||||
|
||||
spend = await self.daemon.jsonrpc_wallet_send('10.5', address2)
|
||||
@@ -182,3 +199,12 @@ 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)
|
||||
@@ -132,8 +132,8 @@ class ResolveCommand(BaseResolveTestCase):
|
||||
channel_id = self.get_claim_id(
|
||||
await self.channel_create('@abc', '1.1', allow_duplicate_name=True))
|
||||
await self.assertResolvesToClaimId(f'@abc', channel_id)
|
||||
await self.assertResolvesToClaimId(f'@abc#{channel_id[:10]}', channel_id)
|
||||
await self.assertResolvesToClaimId(f'@abc#{channel_id}', channel_id)
|
||||
await self.assertResolvesToClaimId(f'@abc:{channel_id[:10]}', channel_id)
|
||||
await self.assertResolvesToClaimId(f'@abc:{channel_id}', channel_id)
|
||||
channel = (await self.claim_search(claim_id=channel_id))[0]
|
||||
await self.assertResolvesToClaimId(channel['short_url'], channel_id)
|
||||
await self.assertResolvesToClaimId(channel['canonical_url'], channel_id)
|
||||
@@ -182,7 +182,7 @@ class ResolveCommand(BaseResolveTestCase):
|
||||
response = await self.resolve('lbry://on-channel-claim')
|
||||
self.assertFalse(response['is_channel_signature_valid'])
|
||||
self.assertEqual({'channel_id': abandoned_channel_id}, response['signing_channel'])
|
||||
direct_uri = 'lbry://on-channel-claim#' + orphan_claim_id
|
||||
direct_uri = 'lbry://on-channel-claim:' + orphan_claim_id
|
||||
response = await self.resolve(direct_uri)
|
||||
self.assertFalse(response['is_channel_signature_valid'])
|
||||
self.assertEqual({'channel_id': abandoned_channel_id}, response['signing_channel'])
|
||||
|
||||
@@ -43,12 +43,14 @@ 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']), 1)
|
||||
self.assertEqual(status['wallet']['servers'][0]['port'], 50002)
|
||||
self.assertEqual(len(status['wallet']['servers']), 0)
|
||||
self.daemon.jsonrpc_settings_set('lbryum_servers', ['localhost:54320'])
|
||||
await self.daemon.jsonrpc_wallet_reconnect()
|
||||
status = await self.daemon.jsonrpc_status()
|
||||
@@ -74,7 +76,7 @@ class WalletCommands(CommandTestCase):
|
||||
}
|
||||
self.assertIsNone(ledger._balance_cache.get(self.account.id))
|
||||
|
||||
query_count += 6
|
||||
query_count += 2
|
||||
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')
|
||||
@@ -98,7 +100,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 += 3 # only one of the accounts changed
|
||||
query_count += 1 # 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,6 +4,7 @@ import lbry
|
||||
import lbry.wallet
|
||||
from lbry.error import ServerPaymentFeeAboveMaxAllowedError
|
||||
from lbry.wallet.network import ClientSession
|
||||
from lbry.wallet.server.session import LBRYElectrumX
|
||||
from lbry.testcase import IntegrationTestCase, CommandTestCase
|
||||
from lbry.wallet.orchstr8.node import SPVNode
|
||||
|
||||
@@ -46,7 +47,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
|
||||
@@ -68,21 +69,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=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 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 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=8)
|
||||
tx = await asyncio.wait_for(wallet_pay_service.on_payment.first, timeout=30)
|
||||
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)
|
||||
@@ -9,6 +9,10 @@ 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)
|
||||
@@ -217,6 +221,20 @@ 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)
|
||||
|
||||
@@ -354,7 +372,8 @@ 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
|
||||
fee_currency='LBC', fee_amount='11.0',
|
||||
fee_address=target_address, claim_address=target_address
|
||||
)
|
||||
await self.daemon.jsonrpc_file_delete(claim_name='expensive')
|
||||
response = await self.out(self.daemon.jsonrpc_get('lbry://expensive'))
|
||||
@@ -364,7 +383,8 @@ 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
|
||||
fee_currency='LBC', fee_amount='111.0',
|
||||
fee_address=target_address, claim_address=target_address
|
||||
)
|
||||
await self.daemon.jsonrpc_file_delete(claim_name='maxkey')
|
||||
response = await self.out(self.daemon.jsonrpc_get('lbry://maxkey'))
|
||||
@@ -376,7 +396,8 @@ 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
|
||||
fee_currency='LBC', fee_amount='1.0',
|
||||
fee_address=target_address, claim_address=target_address
|
||||
)
|
||||
await self.daemon.jsonrpc_file_delete(claim_name='icanpay')
|
||||
await self.assertBalance(self.account, '9.925679')
|
||||
@@ -427,7 +448,8 @@ 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
|
||||
fee_currency='LBC', fee_amount='1.0',
|
||||
fee_address=target_address, claim_address=target_address
|
||||
)
|
||||
self.assertTrue(await self.daemon.jsonrpc_file_delete(claim_name='somename'))
|
||||
# Assert the fee and bid are subtracted
|
||||
|
||||
@@ -7,7 +7,8 @@ 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
|
||||
UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, WALLET_SERVER_PAYMENTS_COMPONENT,
|
||||
LIBTORRENT_COMPONENT
|
||||
)
|
||||
from lbry.extras.daemon.daemon import Daemon
|
||||
|
||||
@@ -22,7 +23,8 @@ 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
|
||||
UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, WALLET_SERVER_PAYMENTS_COMPONENT,
|
||||
LIBTORRENT_COMPONENT
|
||||
)
|
||||
Daemon.component_attributes = {}
|
||||
self.daemon = Daemon(conf)
|
||||
@@ -34,4 +36,4 @@ class CLIIntegrationTest(AsyncioTestCase):
|
||||
with contextlib.redirect_stdout(actual_output):
|
||||
cli.main(["--api", "localhost:5299", "status"])
|
||||
actual_output = actual_output.getvalue()
|
||||
self.assertIn("connection_status", actual_output)
|
||||
self.assertIn("is_running", actual_output)
|
||||
@@ -2,6 +2,7 @@ import re
|
||||
import time
|
||||
import typing
|
||||
from math import ceil
|
||||
import secrets
|
||||
|
||||
from aiohttp import web
|
||||
|
||||
@@ -50,7 +51,7 @@ class MockedCommentServer:
|
||||
self.server = None
|
||||
self.comments = []
|
||||
self.reacts = {}
|
||||
self.comment_id = 0
|
||||
self.index = 0
|
||||
self.react_id = 0
|
||||
|
||||
@classmethod
|
||||
@@ -66,14 +67,15 @@ class MockedCommentServer:
|
||||
return schema
|
||||
|
||||
def create_comment(self, claim_id=None, parent_id=None, channel_name=None, channel_id=None, **kwargs):
|
||||
comment_id = self.comment_id
|
||||
comment_id = secrets.token_hex(64)
|
||||
channel_url = 'lbry://' + channel_name + '#' + channel_id if channel_id else None
|
||||
|
||||
if parent_id:
|
||||
claim_id = self.comments[self.get_comment_id(parent_id)]['claim_id']
|
||||
parent_comment = list(filter(lambda c: c['comment_id'] == parent_id, self.comments))[0]
|
||||
claim_id = parent_comment['claim_id']
|
||||
|
||||
comment = self._create_comment(
|
||||
comment_id=str(comment_id),
|
||||
comment_id=comment_id,
|
||||
channel_name=channel_name,
|
||||
channel_id=channel_id,
|
||||
channel_url=channel_url,
|
||||
@@ -83,15 +85,14 @@ class MockedCommentServer:
|
||||
**kwargs
|
||||
)
|
||||
self.comments.append(comment)
|
||||
self.comment_id += 1
|
||||
return self.clean(comment)
|
||||
|
||||
def abandon_comment(self, comment_id: int, channel_id: str, **kwargs):
|
||||
def abandon_comment(self, comment_id: str, channel_id: str, **kwargs):
|
||||
deleted = False
|
||||
comment_id = self.get_comment_id(comment_id)
|
||||
index = self.get_index_for_comment_id(comment_id)
|
||||
try:
|
||||
if self.comments[comment_id]['channel_id'] == channel_id:
|
||||
self.comments.pop(comment_id)
|
||||
if index >= 0:
|
||||
self.comments.pop(index)
|
||||
deleted = True
|
||||
finally:
|
||||
return {
|
||||
@@ -100,42 +101,41 @@ class MockedCommentServer:
|
||||
}
|
||||
}
|
||||
|
||||
def edit_comment(self, comment_id: typing.Union[str, int], comment: str, channel_id: str,
|
||||
def edit_comment(self, comment_id: str, 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):
|
||||
comment_id = self.get_comment_id(comment_id)
|
||||
if self.comments[comment_id]['channel_id'] == channel_id:
|
||||
self.comments[comment_id].update({
|
||||
index = self.get_index_for_comment_id(comment_id)
|
||||
if self.comments[index]['channel_id'] == channel_id:
|
||||
self.comments[index].update({
|
||||
'comment': comment,
|
||||
'signature': signature,
|
||||
'signing_ts': signing_ts
|
||||
})
|
||||
edited = True
|
||||
|
||||
return self.comments[comment_id] if edited else None
|
||||
return self.comments[index] if edited else None
|
||||
|
||||
def hide_comment(self, comment_id: typing.Union[int, str], signing_ts: str, signature: str):
|
||||
comment_id = self.get_comment_id(comment_id)
|
||||
def hide_comment(self, comment_id: str, signing_ts: str, signature: str):
|
||||
if self.is_signable(signature, signing_ts):
|
||||
self.comments[comment_id]['is_hidden'] = True
|
||||
self.comments[self.get_index_for_comment_id(comment_id)]['is_hidden'] = True
|
||||
return True
|
||||
return False
|
||||
|
||||
def pin_comment(
|
||||
self,
|
||||
comment_id: typing.Union[int, str],
|
||||
comment_id: str,
|
||||
channel_name: str, channel_id: str, remove: bool,
|
||||
signing_ts: str, signature: str
|
||||
):
|
||||
comment_id = self.get_comment_id(comment_id)
|
||||
index = self.get_index_for_comment_id(comment_id)
|
||||
if self.is_signable(signature, signing_ts):
|
||||
if remove:
|
||||
self.comments[comment_id]['is_pinned'] = False
|
||||
self.comments[index]['is_pinned'] = False
|
||||
else:
|
||||
self.comments[comment_id]['is_pinned'] = True
|
||||
return self.comments[comment_id]
|
||||
self.comments[index]['is_pinned'] = True
|
||||
return self.comments[index]
|
||||
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: int, **kwargs):
|
||||
comment = self.comments[self.get_comment_id(comment_id)]
|
||||
def get_comment_channel_by_id(self, comment_id: str, **kwargs):
|
||||
comment = self.comments[self.get_index_for_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_comment_id(cid)] for cid in comment_ids]
|
||||
comments = [self.comments[self.get_index_for_comment_id(cid)] for cid in comment_ids]
|
||||
return {
|
||||
'page': 1,
|
||||
'page_size': len(comment_ids),
|
||||
@@ -331,17 +331,18 @@ 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) and comment_id.isalnum():
|
||||
comment_id = int(comment_id)
|
||||
|
||||
if isinstance(comment_id, int):
|
||||
return 0 <= comment_id < len(self.comments)
|
||||
if isinstance(comment_id, str):
|
||||
return True
|
||||
return False
|
||||
|
||||
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)
|
||||
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
|
||||
|
||||
@staticmethod
|
||||
def claim_id_is_valid(claim_id: str) -> bool:
|
||||
@@ -384,7 +385,6 @@ 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]
|
||||
await self.daemon.jsonrpc_comment_create(
|
||||
comment2 = await self.daemon.jsonrpc_comment_create(
|
||||
claim_id=stream['claim_id'],
|
||||
channel_name=channel2['name'],
|
||||
comment='Let\'s all go to Margaritaville',
|
||||
@@ -712,7 +712,8 @@ class CommentCommands(CommandTestCase):
|
||||
claim_id=claim_id,
|
||||
channel_id=bee['claim_id']
|
||||
)
|
||||
all_comments = [second_comment, first_comment]
|
||||
first_comment_id = first_comment['comment_id']
|
||||
second_comment_id = second_comment['comment_id']
|
||||
comment_list = await self.daemon.jsonrpc_comment_list(claim_id)
|
||||
self.assertEqual(
|
||||
{'items', 'page', 'page_size', 'has_hidden_comments', 'total_items', 'total_pages'},
|
||||
@@ -721,29 +722,29 @@ class CommentCommands(CommandTestCase):
|
||||
self.assertEqual(comment_list['total_items'], 2)
|
||||
|
||||
bee_like_reaction = await self.daemon.jsonrpc_comment_react(
|
||||
comment_ids=first_comment['comment_id'],
|
||||
comment_ids=first_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['comment_id'],
|
||||
comment_ids=first_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['comment_id'],
|
||||
comment_ids=first_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']['0']['like'], 1)
|
||||
self.assertEqual(reactions['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)
|
||||
|
||||
bee_dislike_reaction = await self.daemon.jsonrpc_comment_react(
|
||||
comment_ids=first_comment['comment_id'],
|
||||
comment_ids=first_comment_id,
|
||||
channel_id=bee['claim_id'],
|
||||
channel_name=bee['name'],
|
||||
react_type='dislike',
|
||||
@@ -751,30 +752,30 @@ class CommentCommands(CommandTestCase):
|
||||
)
|
||||
|
||||
reactions_after_bee_dislikes = await self.daemon.jsonrpc_comment_react_list(
|
||||
comment_ids=first_comment['comment_id'],
|
||||
comment_ids=first_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']['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)
|
||||
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)
|
||||
|
||||
only_likes_after_bee_dislikes = await self.daemon.jsonrpc_comment_react_list(
|
||||
comment_ids=first_comment['comment_id'],
|
||||
comment_ids=first_comment_id,
|
||||
channel_id=moth['claim_id'],
|
||||
channel_name=moth['name'],
|
||||
react_types='like',
|
||||
)
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
bee_un_dislike_reaction = await self.daemon.jsonrpc_comment_react(
|
||||
comment_ids=first_comment['comment_id'],
|
||||
comment_ids=first_comment_id,
|
||||
channel_id=bee['claim_id'],
|
||||
channel_name=bee['name'],
|
||||
remove=True,
|
||||
@@ -782,30 +783,30 @@ class CommentCommands(CommandTestCase):
|
||||
)
|
||||
|
||||
reactions_after_bee_absconds = await self.daemon.jsonrpc_comment_react_list(
|
||||
comment_ids=first_comment['comment_id'],
|
||||
comment_ids=first_comment_id,
|
||||
channel_id=moth['claim_id'],
|
||||
channel_name=moth['name'],
|
||||
)
|
||||
|
||||
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'])
|
||||
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])
|
||||
|
||||
bee_reacts_to_both_comments = await self.daemon.jsonrpc_comment_react(
|
||||
comment_ids=first_comment['comment_id'] + ',' + second_comment['comment_id'],
|
||||
comment_ids=first_comment_id + ',' + second_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['comment_id'] + ',' + second_comment['comment_id'],
|
||||
comment_ids=first_comment_id + ',' + second_comment_id,
|
||||
channel_id=moth['claim_id'],
|
||||
channel_name=moth['name'],
|
||||
)
|
||||
|
||||
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)
|
||||
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)
|
||||
@@ -4,9 +4,7 @@ from lbry.extras.daemon.exchange_rate_manager import ExchangeRate, ExchangeRateM
|
||||
|
||||
|
||||
class TestExchangeRateManager(AsyncioTestCase):
|
||||
|
||||
async def test_exchange_rate_manager(self):
|
||||
# TODO: re-enable cryptonator.com
|
||||
manager = ExchangeRateManager(FEEDS)
|
||||
manager.start()
|
||||
self.addCleanup(manager.stop)
|
||||
@@ -17,6 +15,10 @@ class TestExchangeRateManager(AsyncioTestCase):
|
||||
for feed in manager.market_feeds:
|
||||
self.assertTrue(feed.is_online)
|
||||
self.assertIsInstance(feed.rate, ExchangeRate)
|
||||
lbc = manager.convert_currency('USD', 'LBC', Decimal('0.01'))
|
||||
self.assertGreaterEqual(lbc, 0.1)
|
||||
# print(f'{feed.name} - {feed.market} - {feed.rate.spot}')
|
||||
lbc = manager.convert_currency('USD', 'LBC', Decimal('1.0'))
|
||||
self.assertGreaterEqual(lbc, 2.0)
|
||||
self.assertLessEqual(lbc, 10.0)
|
||||
lbc = manager.convert_currency('BTC', 'LBC', Decimal('0.01'))
|
||||
self.assertGreaterEqual(lbc, 1_000)
|
||||
self.assertLessEqual(lbc, 4_000)
|
||||
@@ -11,6 +11,7 @@ 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)
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
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):
|
||||
@@ -51,3 +59,38 @@ 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,9 +4,9 @@ from time import time
|
||||
from lbry.schema.claim import Claim
|
||||
from lbry.extras.daemon.exchange_rate_manager import (
|
||||
ExchangeRate, ExchangeRateManager, CurrencyConversionError,
|
||||
LBRYFeed, LBRYBTCFeed,
|
||||
CryptonatorFeed, CryptonatorBTCFeed,
|
||||
BittrexFeed,
|
||||
CryptonatorUSDFeed, CryptonatorBTCFeed,
|
||||
BittrexUSDFeed, BittrexBTCFeed,
|
||||
CoinExBTCFeed
|
||||
)
|
||||
from lbry.testcase import AsyncioTestCase, FakeExchangeRateManager, get_fake_exchange_rate_manager
|
||||
from lbry.error import InvalidExchangeRateResponseError
|
||||
@@ -26,59 +26,21 @@ class ExchangeRateTests(AsyncioTestCase):
|
||||
fee.address = "bRcHraa8bYJZL7vkh5sNmGwPDERFUjGPP9"
|
||||
manager = get_fake_exchange_rate_manager()
|
||||
result = manager.convert_currency(fee.currency, "LBC", fee.amount)
|
||||
self.assertEqual(60.0, result)
|
||||
self.assertEqual(20.0, result)
|
||||
|
||||
def test_missing_feed(self):
|
||||
fee = Claim().stream.fee
|
||||
fee.usd = Decimal(1.0)
|
||||
fee.address = "bRcHraa8bYJZL7vkh5sNmGwPDERFUjGPP9"
|
||||
manager = FakeExchangeRateManager([LBRYFeed()], {'BTCLBC': 1.0})
|
||||
manager = FakeExchangeRateManager([BittrexBTCFeed()], {'BTCLBC': 1.0})
|
||||
with self.assertRaises(CurrencyConversionError):
|
||||
manager.convert_currency(fee.currency, "LBC", fee.amount)
|
||||
|
||||
def test_lbry_feed_response(self):
|
||||
feed = LBRYFeed()
|
||||
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 / 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()
|
||||
feed = CryptonatorUSDFeed()
|
||||
out = feed.get_rate_from_response({
|
||||
'ticker': {
|
||||
'base': 'BTC', 'target': 'LBC', 'price': 23657.44026496,
|
||||
'base': 'USD', 'target': 'LBC', 'price': 23657.44026496,
|
||||
'volume': '', 'change': -5.59806916,
|
||||
},
|
||||
'timestamp': 1507470422,
|
||||
@@ -115,22 +77,14 @@ class ExchangeRateTests(AsyncioTestCase):
|
||||
})
|
||||
|
||||
def test_bittrex_feed_response(self):
|
||||
feed = BittrexFeed()
|
||||
feed = BittrexBTCFeed()
|
||||
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"
|
||||
}
|
||||
]
|
||||
"symbol": "LBC-BTC",
|
||||
"lastTradeRate": "0.00000323",
|
||||
"bidRate": "0.00000322",
|
||||
"askRate": "0.00000327"
|
||||
})
|
||||
self.assertEqual(1.0 / ((0.00090980+0.00686151) / (56.12611239+430.99988180)), out)
|
||||
self.assertEqual(1.0 / 0.00000323, out)
|
||||
with self.assertRaises(InvalidExchangeRateResponseError):
|
||||
feed.get_rate_from_response({})
|
||||
with self.assertRaises(InvalidExchangeRateResponseError):
|
||||
@@ -140,7 +94,7 @@ class ExchangeRateTests(AsyncioTestCase):
|
||||
})
|
||||
|
||||
|
||||
class BadMarketFeed(LBRYFeed):
|
||||
class BadMarketFeed(BittrexUSDFeed):
|
||||
|
||||
def get_response(self):
|
||||
raise InvalidExchangeRateResponseError(self.name, 'bad stuff')
|
||||
@@ -153,3 +107,15 @@ class ExchangeRateManagerTests(AsyncioTestCase):
|
||||
manager.start()
|
||||
await asyncio.sleep(1)
|
||||
self.addCleanup(manager.stop)
|
||||
|
||||
async def test_median_rate_used(self):
|
||||
manager = ExchangeRateManager([BittrexBTCFeed, CryptonatorBTCFeed, CoinExBTCFeed])
|
||||
for feed in manager.market_feeds:
|
||||
feed.last_check = time()
|
||||
bittrex, cryptonator, coinex = manager.market_feeds
|
||||
bittrex.rate = ExchangeRate(bittrex.market, 1.0, time())
|
||||
cryptonator.rate = ExchangeRate(cryptonator.market, 2.0, time())
|
||||
coinex.rate = ExchangeRate(coinex.market, 3.0, time())
|
||||
self.assertEqual(14.0, manager.convert_currency("BTC", "LBC", Decimal(7.0)))
|
||||
cryptonator.rate.spot = 4.0
|
||||
self.assertEqual(21.0, manager.convert_currency("BTC", "LBC", Decimal(7.0)))
|
||||
@@ -93,8 +93,7 @@ class TestReflector(AsyncioTestCase):
|
||||
await incoming.wait()
|
||||
stop.set()
|
||||
# this used to raise (and then propagate) a CancelledError
|
||||
with self.assertRaises(asyncio.CancelledError):
|
||||
await reflect_task
|
||||
self.assertListEqual(await reflect_task, [])
|
||||
self.assertFalse(self.stream.is_fully_reflected)
|
||||
self.assertFalse(self.server_blob_manager.get_blob(self.stream.sd_hash).get_is_verified())
|
||||
|
||||
@@ -114,8 +113,8 @@ class TestReflector(AsyncioTestCase):
|
||||
await incoming.wait()
|
||||
await not_incoming.wait()
|
||||
stop.set()
|
||||
with self.assertRaises(asyncio.CancelledError):
|
||||
await reflect_task
|
||||
sent = await reflect_task
|
||||
self.assertListEqual([self.stream.sd_hash], sent)
|
||||
self.assertTrue(self.server_blob_manager.get_blob(self.stream.sd_hash).get_is_verified())
|
||||
self.assertFalse(self.stream.is_fully_reflected)
|
||||
|
||||
@@ -137,8 +136,8 @@ class TestReflector(AsyncioTestCase):
|
||||
await incoming.wait()
|
||||
await not_incoming.wait()
|
||||
stop.set()
|
||||
with self.assertRaises(asyncio.CancelledError):
|
||||
await reflect_task
|
||||
sent = await reflect_task
|
||||
self.assertListEqual([self.stream.sd_hash, self.stream.descriptor.blobs[0].blob_hash], sent)
|
||||
self.assertTrue(self.server_blob_manager.get_blob(self.stream.sd_hash).get_is_verified())
|
||||
self.assertTrue(self.server_blob_manager.get_blob(self.stream.descriptor.blobs[0].blob_hash).get_is_verified())
|
||||
self.assertFalse(self.stream.is_fully_reflected)
|
||||
@@ -160,9 +159,7 @@ class TestReflector(AsyncioTestCase):
|
||||
await not_incoming.wait()
|
||||
await incoming.wait()
|
||||
stop.set()
|
||||
with self.assertRaises(asyncio.CancelledError):
|
||||
await reflect_task
|
||||
# self.assertListEqual(await reflect_task, [self.stream.sd_hash])
|
||||
self.assertListEqual(await reflect_task, [self.stream.sd_hash])
|
||||
self.assertTrue(self.server_blob_manager.get_blob(self.stream.sd_hash).get_is_verified())
|
||||
self.assertFalse(
|
||||
self.server_blob_manager.get_blob(self.stream.descriptor.blobs[0].blob_hash).get_is_verified()
|
||||
@@ -187,8 +184,8 @@ class TestReflector(AsyncioTestCase):
|
||||
await incoming.wait()
|
||||
await self.stream_manager.delete(self.stream, delete_file=True)
|
||||
# this used to raise OSError when it can't read the deleted blob for the upload
|
||||
with self.assertRaises(asyncio.CancelledError):
|
||||
await reflect_task
|
||||
sent = await reflect_task
|
||||
self.assertListEqual([self.stream.sd_hash], sent)
|
||||
self.assertTrue(self.server_blob_manager.get_blob(self.stream.sd_hash).get_is_verified())
|
||||
self.assertFalse(
|
||||
self.server_blob_manager.get_blob(self.stream.descriptor.blobs[0].blob_hash).get_is_verified()
|
||||
|
||||
@@ -18,8 +18,7 @@ from lbry.schema.tags import clean_tags
|
||||
from lbry.schema.result import Outputs, Censor
|
||||
from lbry.wallet import Ledger, RegTestLedger
|
||||
|
||||
from .common import CLAIM_TYPES, STREAM_TYPES, COMMON_TAGS, INDEXED_LANGUAGES
|
||||
from .full_text_search import FTS_ORDER_BY
|
||||
from lbry.wallet.server.db.common import CLAIM_TYPES, STREAM_TYPES, COMMON_TAGS, INDEXED_LANGUAGES
|
||||
|
||||
|
||||
class SQLiteOperationalError(apsw.Error):
|
||||
@@ -53,7 +52,7 @@ SEARCH_PARAMS = {
|
||||
'any_locations', 'all_locations', 'not_locations',
|
||||
'any_languages', 'all_languages', 'not_languages',
|
||||
'is_controlling', 'limit', 'offset', 'order_by',
|
||||
'no_totals',
|
||||
'no_totals', 'has_source'
|
||||
} | INTEGER_PARAMS
|
||||
|
||||
|
||||
@@ -94,10 +93,10 @@ class ReaderState:
|
||||
self.db.setprogresshandler(interruptor, 100)
|
||||
|
||||
def get_resolve_censor(self) -> Censor:
|
||||
return Censor(self.blocked_streams, self.blocked_channels)
|
||||
return Censor(Censor.RESOLVE)
|
||||
|
||||
def get_search_censor(self, limit_claims_per_channel: int) -> Censor:
|
||||
return Censor(self.filtered_streams, self.filtered_channels, limit_claims_per_channel)
|
||||
return Censor(Censor.SEARCH)
|
||||
|
||||
|
||||
ctx: ContextVar[Optional[ReaderState]] = ContextVar('ctx')
|
||||
@@ -283,7 +282,7 @@ def claims_query(cols, for_count=False, **constraints) -> Tuple[str, Dict]:
|
||||
channel_ids = constraints.pop('channel_ids')
|
||||
if channel_ids:
|
||||
constraints['claim.channel_hash__in'] = {
|
||||
unhexlify(cid)[::-1] for cid in channel_ids
|
||||
unhexlify(cid)[::-1] for cid in channel_ids if cid
|
||||
}
|
||||
if 'not_channel_ids' in constraints:
|
||||
not_channel_ids = constraints.pop('not_channel_ids')
|
||||
@@ -342,12 +341,7 @@ 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)
|
||||
|
||||
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"
|
||||
select = f"SELECT {cols} FROM claim"
|
||||
if not for_count:
|
||||
select += " LEFT JOIN claimtrie USING (claim_hash)"
|
||||
return query(select, **constraints)
|
||||
@@ -372,7 +366,7 @@ def count_claims(**constraints) -> int:
|
||||
constraints.pop('offset', None)
|
||||
constraints.pop('limit', None)
|
||||
constraints.pop('order_by', None)
|
||||
count = select_claims(Censor(), 'count(*) as row_count', for_count=True, **constraints)
|
||||
count = select_claims(Censor(Censor.SEARCH), 'count(*) as row_count', for_count=True, **constraints)
|
||||
return count[0]['row_count']
|
||||
|
||||
|
||||
@@ -8,12 +8,16 @@ 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 reader, writer
|
||||
from lbry.wallet.server.db import 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):
|
||||
@@ -31,7 +35,7 @@ def get_tx():
|
||||
|
||||
|
||||
def search(**constraints) -> List:
|
||||
return reader.search_claims(Censor(), **constraints)
|
||||
return reader.search_claims(Censor(Censor.SEARCH), **constraints)
|
||||
|
||||
|
||||
def censored_search(**constraints) -> Tuple[List, Censor]:
|
||||
@@ -411,8 +415,8 @@ class TestClaimtrie(TestSQLDB):
|
||||
advance(1, [tx_chan_a])
|
||||
advance(2, [tx_chan_ab])
|
||||
(r_ab, r_a) = search(order_by=['creation_height'], limit=2)
|
||||
self.assertEqual("@foo#a", r_a['short_url'])
|
||||
self.assertEqual("@foo#ab", r_ab['short_url'])
|
||||
self.assertEqual("@foo:a", r_a['short_url'])
|
||||
self.assertEqual("@foo:ab", r_ab['short_url'])
|
||||
self.assertIsNone(r_a['canonical_url'])
|
||||
self.assertIsNone(r_ab['canonical_url'])
|
||||
self.assertEqual(0, r_a['claims_in_channel'])
|
||||
@@ -424,9 +428,9 @@ class TestClaimtrie(TestSQLDB):
|
||||
advance(3, [tx_a])
|
||||
advance(4, [tx_ab, tx_abc])
|
||||
(r_abc, r_ab, r_a) = search(order_by=['creation_height', 'tx_position'], limit=3)
|
||||
self.assertEqual("foo#a", r_a['short_url'])
|
||||
self.assertEqual("foo#ab", r_ab['short_url'])
|
||||
self.assertEqual("foo#abc", r_abc['short_url'])
|
||||
self.assertEqual("foo:a", r_a['short_url'])
|
||||
self.assertEqual("foo:ab", r_ab['short_url'])
|
||||
self.assertEqual("foo:abc", r_abc['short_url'])
|
||||
self.assertIsNone(r_a['canonical_url'])
|
||||
self.assertIsNone(r_ab['canonical_url'])
|
||||
self.assertIsNone(r_abc['canonical_url'])
|
||||
@@ -438,17 +442,17 @@ class TestClaimtrie(TestSQLDB):
|
||||
advance(6, [tx_a2])
|
||||
advance(7, [tx_ab2])
|
||||
(r_ab2, r_a2) = search(order_by=['creation_height'], limit=2)
|
||||
self.assertEqual(f"foo#{a2_claim.claim_id[:2]}", r_a2['short_url'])
|
||||
self.assertEqual(f"foo#{ab2_claim.claim_id[:4]}", r_ab2['short_url'])
|
||||
self.assertEqual("@foo#a/foo#a", r_a2['canonical_url'])
|
||||
self.assertEqual("@foo#a/foo#ab", r_ab2['canonical_url'])
|
||||
self.assertEqual(f"foo:{a2_claim.claim_id[:2]}", r_a2['short_url'])
|
||||
self.assertEqual(f"foo:{ab2_claim.claim_id[:4]}", r_ab2['short_url'])
|
||||
self.assertEqual("@foo:a/foo:a", r_a2['canonical_url'])
|
||||
self.assertEqual("@foo:a/foo:ab", r_ab2['canonical_url'])
|
||||
self.assertEqual(2, search(claim_id=txo_chan_a.claim_id, limit=1)[0]['claims_in_channel'])
|
||||
|
||||
# change channel public key, invaliding stream claim signatures
|
||||
advance(8, [self.get_channel_update(txo_chan_a, COIN, key=b'a')])
|
||||
(r_ab2, r_a2) = search(order_by=['creation_height'], limit=2)
|
||||
self.assertEqual(f"foo#{a2_claim.claim_id[:2]}", r_a2['short_url'])
|
||||
self.assertEqual(f"foo#{ab2_claim.claim_id[:4]}", r_ab2['short_url'])
|
||||
self.assertEqual(f"foo:{a2_claim.claim_id[:2]}", r_a2['short_url'])
|
||||
self.assertEqual(f"foo:{ab2_claim.claim_id[:4]}", r_ab2['short_url'])
|
||||
self.assertIsNone(r_a2['canonical_url'])
|
||||
self.assertIsNone(r_ab2['canonical_url'])
|
||||
self.assertEqual(0, search(claim_id=txo_chan_a.claim_id, limit=1)[0]['claims_in_channel'])
|
||||
@@ -457,18 +461,18 @@ class TestClaimtrie(TestSQLDB):
|
||||
channel_update = self.get_channel_update(txo_chan_a, COIN, key=b'c')
|
||||
advance(9, [channel_update])
|
||||
(r_ab2, r_a2) = search(order_by=['creation_height'], limit=2)
|
||||
self.assertEqual(f"foo#{a2_claim.claim_id[:2]}", r_a2['short_url'])
|
||||
self.assertEqual(f"foo#{ab2_claim.claim_id[:4]}", r_ab2['short_url'])
|
||||
self.assertEqual("@foo#a/foo#a", r_a2['canonical_url'])
|
||||
self.assertEqual("@foo#a/foo#ab", r_ab2['canonical_url'])
|
||||
self.assertEqual(f"foo:{a2_claim.claim_id[:2]}", r_a2['short_url'])
|
||||
self.assertEqual(f"foo:{ab2_claim.claim_id[:4]}", r_ab2['short_url'])
|
||||
self.assertEqual("@foo:a/foo:a", r_a2['canonical_url'])
|
||||
self.assertEqual("@foo:a/foo:ab", r_ab2['canonical_url'])
|
||||
self.assertEqual(2, search(claim_id=txo_chan_a.claim_id, limit=1)[0]['claims_in_channel'])
|
||||
self.assertEqual(0, search(claim_id=txo_chan_ab.claim_id, limit=1)[0]['claims_in_channel'])
|
||||
|
||||
# change channel of stream
|
||||
self.assertEqual("@foo#a/foo#ab", search(claim_id=ab2_claim.claim_id, limit=1)[0]['canonical_url'])
|
||||
self.assertEqual("@foo:a/foo:ab", search(claim_id=ab2_claim.claim_id, limit=1)[0]['canonical_url'])
|
||||
tx_ab2 = self.get_stream_update(tx_ab2, COIN, txo_chan_ab)
|
||||
advance(10, [tx_ab2])
|
||||
self.assertEqual("@foo#ab/foo#a", search(claim_id=ab2_claim.claim_id, limit=1)[0]['canonical_url'])
|
||||
self.assertEqual("@foo:ab/foo:a", search(claim_id=ab2_claim.claim_id, limit=1)[0]['canonical_url'])
|
||||
# TODO: currently there is a bug where stream leaving a channel does not update that channels claims count
|
||||
self.assertEqual(2, search(claim_id=txo_chan_a.claim_id, limit=1)[0]['claims_in_channel'])
|
||||
# TODO: after bug is fixed remove test above and add test below
|
||||
@@ -482,7 +486,7 @@ class TestClaimtrie(TestSQLDB):
|
||||
# delete channel, invaliding stream claim signatures
|
||||
advance(12, [self.get_abandon(channel_update)])
|
||||
(r_a2,) = search(order_by=['creation_height'], limit=1)
|
||||
self.assertEqual(f"foo#{a2_claim.claim_id[:2]}", r_a2['short_url'])
|
||||
self.assertEqual(f"foo:{a2_claim.claim_id[:2]}", r_a2['short_url'])
|
||||
self.assertIsNone(r_a2['canonical_url'])
|
||||
|
||||
def test_resolve_issue_2448(self):
|
||||
@@ -495,15 +499,15 @@ class TestClaimtrie(TestSQLDB):
|
||||
advance(1, [tx_chan_a])
|
||||
advance(2, [tx_chan_ab])
|
||||
|
||||
self.assertEqual(reader.resolve_url("@foo#a")['claim_hash'], txo_chan_a.claim_hash)
|
||||
self.assertEqual(reader.resolve_url("@foo#ab")['claim_hash'], txo_chan_ab.claim_hash)
|
||||
self.assertEqual(reader.resolve_url("@foo:a")['claim_hash'], txo_chan_a.claim_hash)
|
||||
self.assertEqual(reader.resolve_url("@foo:ab")['claim_hash'], txo_chan_ab.claim_hash)
|
||||
|
||||
# update increase last height change of channel
|
||||
advance(9, [self.get_channel_update(txo_chan_a, COIN, key=b'c')])
|
||||
|
||||
# make sure that activation_height is used instead of height (issue #2448)
|
||||
self.assertEqual(reader.resolve_url("@foo#a")['claim_hash'], txo_chan_a.claim_hash)
|
||||
self.assertEqual(reader.resolve_url("@foo#ab")['claim_hash'], txo_chan_ab.claim_hash)
|
||||
self.assertEqual(reader.resolve_url("@foo:a")['claim_hash'], txo_chan_a.claim_hash)
|
||||
self.assertEqual(reader.resolve_url("@foo:ab")['claim_hash'], txo_chan_ab.claim_hash)
|
||||
|
||||
def test_canonical_find_shortest_id(self):
|
||||
new_hash = 'abcdef0123456789beef'
|
||||
@@ -513,13 +517,13 @@ class TestClaimtrie(TestSQLDB):
|
||||
other3 = 'abcdef0123456789bee1'
|
||||
f = FindShortestID()
|
||||
f.step(other0, new_hash)
|
||||
self.assertEqual('#a', f.finalize())
|
||||
self.assertEqual(':a', f.finalize())
|
||||
f.step(other1, new_hash)
|
||||
self.assertEqual('#abc', f.finalize())
|
||||
self.assertEqual(':abc', f.finalize())
|
||||
f.step(other2, new_hash)
|
||||
self.assertEqual('#abcd', f.finalize())
|
||||
self.assertEqual(':abcd', f.finalize())
|
||||
f.step(other3, new_hash)
|
||||
self.assertEqual('#abcdef0123456789beef', f.finalize())
|
||||
self.assertEqual(':abcdef0123456789beef', f.finalize())
|
||||
|
||||
|
||||
class TestTrending(TestSQLDB):
|
||||
@@ -553,6 +557,7 @@ 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):
|
||||
|
||||
@@ -40,7 +40,7 @@ class MockNetwork:
|
||||
merkle = await self.get_merkle(tx_hash, known_height)
|
||||
return tx, merkle
|
||||
|
||||
async def get_transaction_batch(self, txids):
|
||||
async def get_transaction_batch(self, txids, restricted):
|
||||
return {
|
||||
txid: await self.get_transaction_and_merkle(txid)
|
||||
for txid in txids
|
||||
@@ -126,9 +126,7 @@ class TestSynchronization(LedgerTestCase):
|
||||
|
||||
self.ledger.network.get_history_called = []
|
||||
self.ledger.network.get_transaction_called = []
|
||||
self.assertFalse(self.ledger._tx_cache[txid1].tx.is_verified)
|
||||
self.assertFalse(self.ledger._tx_cache[txid2].tx.is_verified)
|
||||
self.assertFalse(self.ledger._tx_cache[txid3].tx.is_verified)
|
||||
self.assertEqual(0, len(self.ledger._tx_cache))
|
||||
await self.ledger.update_history(address, '')
|
||||
self.assertListEqual(self.ledger.network.get_history_called, [address])
|
||||
self.assertListEqual(self.ledger.network.get_transaction_called, [])
|
||||
|
||||
Reference in new issue
Block a user