Compare commits
| 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 | ||
|
|
21a2e67755 | ||
|
|
3b9e312615 | ||
|
|
26dab04c9e | ||
|
|
00713c0d11 | ||
|
|
751b5f3027 | ||
|
|
e8261b000e | ||
|
|
41ecb70297 | ||
|
|
09ee104b8c | ||
|
|
e3a4964787 | ||
|
|
9bf72910a4 | ||
|
|
ee39e20e6d | ||
|
|
399d6db6f6 | ||
|
|
0821ce44b5 | ||
|
|
ea279111c6 | ||
|
|
674ce02e58 | ||
|
|
8dfa2767ec | ||
|
|
20dad7f07f | ||
|
|
751cc4c44d | ||
|
|
2318e6d8e9 | ||
|
|
61b4a492c3 | ||
|
|
9db3d01e09 | ||
|
|
8da73ad3dd | ||
|
|
b8c16d8ac5 | ||
|
|
429c0951f3 | ||
|
|
74e103c791 | ||
|
|
f941950ee2 | ||
|
|
846df2eef1 | ||
|
|
34ed058c97 | ||
|
|
eae0290978 | ||
|
|
561368570e | ||
|
|
3467d1fed0 | ||
|
|
d02ff232e5 | ||
|
|
2d1c6a5402 | ||
|
|
eab3b65629 | ||
|
|
20b435732a | ||
|
|
929617273d | ||
|
|
2717bf7d49 | ||
|
|
5cd2ebc960 | ||
|
|
9b4afe9816 | ||
|
|
23bb5598d5 | ||
|
|
af1d7813e9 | ||
|
|
16c2e5a585 | ||
|
|
c02750edbd | ||
|
|
7204ddafec | ||
|
|
faeba9a7e4 | ||
|
|
190d238a1f | ||
|
|
715451b5fb | ||
|
|
87f1895405 | ||
|
|
923d817751 | ||
|
|
0728209b66 | ||
|
|
b8b9dcc2ee | ||
|
|
f35e879852 | ||
|
|
34f4f12eb9 | ||
|
|
fa63bf758d | ||
|
|
f6b396ae64 | ||
|
|
2c7fd58e34 | ||
|
|
982f2c9634 | ||
|
|
f2fd42b47a | ||
|
|
1b4ccad938 | ||
|
|
a9de1ce8e0 | ||
|
|
ac752d5ec2 | ||
|
|
632d8d02d2 | ||
|
|
48aeb26e02 | ||
|
|
1694af8b5e | ||
|
|
83bcab9cd2 | ||
|
|
bdc7f4b3f5 | ||
|
|
39202a3d79 | ||
|
|
912065a121 | ||
|
|
c8466afac2 |
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.84.0"
|
||||
__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(
|
||||
|
||||
+155
-100
@@ -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,
|
||||
@@ -5134,7 +5189,7 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||
|
||||
Usage:
|
||||
comment_create (<comment> | --comment=<comment>)
|
||||
(<claim_id> | --claim_id=<claim_id> | --parent_id=<parent_id>)
|
||||
(<claim_id> | --claim_id=<claim_id>) [--parent_id=<parent_id>]
|
||||
(--channel_id=<channel_id> | --channel_name=<channel_name>)
|
||||
[--channel_account_id=<channel_account_id>...] [--wallet_id=<wallet_id>]
|
||||
|
||||
|
||||
@@ -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']))
|
||||
+9
-8
@@ -6,7 +6,7 @@ from typing import NamedTuple, Tuple
|
||||
def _create_url_regex():
|
||||
# see https://spec.lbry.com/ and test_url.py
|
||||
invalid_names_regex = \
|
||||
r"[^=&#:$@%*?;\"/\\<>%{}|^~`\[\]" \
|
||||
r"[^=&#:$@%?;\"/\\<>%{}|^~`\[\]" \
|
||||
r"\u0000-\u0020\uD800-\uDFFF\uFFFE-\uFFFF]+"
|
||||
|
||||
def _named(name, regex):
|
||||
@@ -23,7 +23,6 @@ def _create_url_regex():
|
||||
_named(name+"_name", prefix + invalid_names_regex) +
|
||||
_oneof(
|
||||
_group('[:#]' + _named(name+"_claim_id", "[0-9a-f]{1,40}")),
|
||||
_group(r'\*' + _named(name+"_sequence", '[1-9][0-9]*')),
|
||||
_group(r'\$' + _named(name+"_amount_order", '[1-9][0-9]*'))
|
||||
) + '?'
|
||||
)
|
||||
@@ -50,19 +49,24 @@ def normalize_name(name):
|
||||
class PathSegment(NamedTuple):
|
||||
name: str
|
||||
claim_id: str = None
|
||||
sequence: int = None
|
||||
amount_order: int = None
|
||||
|
||||
@property
|
||||
def normalized(self):
|
||||
return normalize_name(self.name)
|
||||
|
||||
@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:
|
||||
q['claim_id'] = self.claim_id
|
||||
if self.sequence is not None:
|
||||
q['sequence'] = self.sequence
|
||||
if self.amount_order is not None:
|
||||
q['amount_order'] = self.amount_order
|
||||
return q
|
||||
@@ -70,8 +74,6 @@ class PathSegment(NamedTuple):
|
||||
def __str__(self):
|
||||
if self.claim_id is not None:
|
||||
return f"{self.name}:{self.claim_id}"
|
||||
elif self.sequence is not None:
|
||||
return f"{self.name}*{self.sequence}"
|
||||
elif self.amount_order is not None:
|
||||
return f"{self.name}${self.amount_order}"
|
||||
return self.name
|
||||
@@ -118,7 +120,6 @@ class URL(NamedTuple):
|
||||
segments[segment] = PathSegment(
|
||||
parts[f'{segment}_name'],
|
||||
parts[f'{segment}_claim_id'],
|
||||
parts[f'{segment}_sequence'],
|
||||
parts[f'{segment}_amount_order']
|
||||
)
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
+24
-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()
|
||||
@@ -340,6 +351,7 @@ class CommandTestCase(IntegrationTestCase):
|
||||
server_tmp_dir = tempfile.mkdtemp()
|
||||
self.addCleanup(shutil.rmtree, server_tmp_dir)
|
||||
self.server_config = Config()
|
||||
self.server_config.transaction_cache_size = 10000
|
||||
self.server_storage = SQLiteStorage(self.server_config, ':memory:')
|
||||
await self.server_storage.open()
|
||||
|
||||
@@ -389,10 +401,13 @@ class CommandTestCase(IntegrationTestCase):
|
||||
conf.fixed_peers = [('127.0.0.1', 5567)]
|
||||
conf.known_dht_nodes = []
|
||||
conf.blob_lru_cache_size = self.blob_lru_cache_size
|
||||
conf.transaction_cache_size = 10000
|
||||
conf.components_to_skip = [
|
||||
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):
|
||||
@@ -404,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()
|
||||
@@ -433,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)
|
||||
@@ -474,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(
|
||||
|
||||
@@ -740,4 +740,145 @@ HASHES = {
|
||||
738000: 'aebdf15b23eb7a37600f67d45bf6586b1d5bff3d5f3459adc2f6211ab3dd0bcb',
|
||||
739000: '3f5a894ac42f95f7d54ce25c42ea0baf1a05b2da0e9406978de0dc53484d8b04',
|
||||
740000: '55debc22f995d844eafa0a90296c9f4f433e2b7f38456fff45dd3c66cef04e37',
|
||||
741000: '927b47fc909b4b55c067bbd75d8638af1400fac076cb642e9500a747d849e458',
|
||||
742000: '97fa3d83eb94114496e418c118f549ebfb8f6d123d0b40a12ecb093239557646',
|
||||
743000: '482b66d8d5084703079c28e3ae69e5dee735f762d6fcf9743e75f04e139fd181',
|
||||
744000: 'f406890d5c70808a58fb14429bad812a3185bdb9dace1aa57de76663f92b5013',
|
||||
745000: '2bd0802cbb8aa4441a159104d39515a4ff6fc8dfe616bc83e88197847c78bcff',
|
||||
746000: '24d090a7b6359db3d5d714a69ddc9a6f2e8ff8f044b723220a8ba32df785fd54',
|
||||
747000: '07c4ce9ce5310ee472cf753ddb03c39c5fee6c910d491daffd38615205411633',
|
||||
748000: 'ea913798c0f09d0a27eae7c852954c2c88b8c3b7f23f8fba26b68a3952d0ffde',
|
||||
749000: '23f256adebfe35d49ba84ad49f3f71fc67f7745091c91f22e65f1cc2e23b8f2c',
|
||||
750000: '96db12ee3a295f3d5c56d244e6e7493f58c08d3427e379940e5d4f891a41ec26',
|
||||
751000: 'cedaf12415dac1314942e58ced80830b92fbfabc41f42a0b0f054f0672ef9822',
|
||||
752000: '293606bcd9fbbee5584724301b2cf86bb69204820023e1fb46c238ddfbc660ab',
|
||||
753000: 'f4d43cbb38b7d97919dedc0f5a6dc8007896c4f443b76f3e5693e25bc46760cf',
|
||||
754000: 'fcaad22fd815311280fe451086516375d1d9d92b2990c7c351407df5aa19011e',
|
||||
755000: 'b9276f10d1844cb5b0308766c8db960490ac34a73c4653d0a91202789a6ccb9b',
|
||||
756000: '2fe5581f1110c1c8dcea46cad647551bd6bd640cb37738d863e189bd8f368347',
|
||||
757000: 'b9d915f366f0b010429a52245b0fb02774157eb9fd8f66bce32dcd3acc71c2a1',
|
||||
758000: '62d1854fc15db56b5d0e05ceeb54c1297966bf9dc7f7a0a14b42c059fc485d1b',
|
||||
759000: 'f4ca9f69d16d092f4a0ea5102e6343b21204c4ea9cd9b22cddd77dbb5d68ade3',
|
||||
760000: 'df3bb86641330d8cc7f55a2fd0da28251219e95babe960a308b18e08a7d88fc8',
|
||||
761000: 'a93029475de4bc7569b6ae802d658cd91c84cc253772712a279f140a6c3b91b1',
|
||||
762000: '307e289dc6ec8bcd62ca8831e4159d5edd780f2fae55ba55dd446225450f46f8',
|
||||
763000: '293f73514abca24f374473bd0394179812952a04ea13dc60ef5ada5331fa274f',
|
||||
764000: 'dd8b082db9281e3d9bacf15d6b352fda186d2d2923c7731844d0d4764dd71db8',
|
||||
765000: '201239e562d2571bf47347b3522fff89632aecea3b2d8cef05151f88b2b0bcdb',
|
||||
766000: '4a55a538b51b5650979e64521998cd5c5ad055ba9f3ac0e3e2a28febc6cc2798',
|
||||
767000: '3916666f2adbb05ea98ec1961f9546b9afa0f6910ec95e42ce37267f2ae4f79c',
|
||||
768000: 'dc0ad881eedcb5fd4954238f462080d6e7636b058d481698ed1c077e0ce2207e',
|
||||
769000: 'eaf10a1e1ec6e129289b8479a05df03e0808f1f0946f1995de6524e9ebe7a461',
|
||||
770000: '7200c64f22e32de7f999583361c933680fc9a2ffcb9a5ab73d3076fd49ec7537',
|
||||
771000: 'd883111a2eeacff80ce31df35ab6c943805b9e48877b413fccf371e5dbfa7fb2',
|
||||
772000: '3977d3c60edb9c80c97bb2b759b1659cbb650ad2d3a6f61d2caec83f1b2ae84c',
|
||||
773000: '9c7175fb8646a1a82383b4c534fd01bcf92d65c43d87ae854d51a784b04dc77e',
|
||||
774000: 'e0e92485f86e5fffa87b3497424e43b02a37710517d9d3f272392e8cdc56e5e9',
|
||||
775000: '6395229113d3aa2105afbaeb8b59621a536fc61fe272314b2fc3bdda98dd66cc',
|
||||
776000: 'b4b00207328b5f032bd4f0b634f91323ff520ada8c8bfec241b23c8e4bfd5a4e',
|
||||
777000: '14cdc6f5f7b4bd5bad745dfe6fcd114e9194026412a2e1b3f345be2eef433d16',
|
||||
778000: 'd3cd7b68be504c32117b670d38d59d44b02dcf3d65811efc2ca5531d902623cc',
|
||||
779000: 'afcd220e4040cb5f92d4b38fc204e59822df2218f767f2c4b33597b238a35f77',
|
||||
780000: '78252a9cfc289a70192ed8dd3dddeb1b9a4f9b8eff9a5d0ac259b3254472cf68',
|
||||
781000: '02ebc3f17d947481a311b4771c254f1e002b6a9198d4a5258ce6c13165aadddc',
|
||||
782000: '8dd9f1f372ee6d688a0bcdc3b342c77804ba5a646a218be4bc2aa02d846206c0',
|
||||
783000: 'e46b0d02ec2ef488fae455665e107520e1bd2b4f35ca52af7ad8addd2f72fa73',
|
||||
784000: '9ee8a8de94231e3ae3a610b82fdbca48dc14d9b80791d20af6c365a31822df6f',
|
||||
785000: '21e1cc12def8173a50158b2833bd91a62140c61646f5e08aecaee3e6da20735e',
|
||||
786000: 'b3e659f84d73de42888cc0f2b69bae71dd5fa6756a437a4b21958b182faa316e',
|
||||
787000: 'a9be7ba00ea6a9ea6bd03d8412ec014ca7e8cda6bdc33382f165e702811b8836',
|
||||
788000: 'a4c14729f8a68c03f5a0ccd890ac6a92b39c143f1f752fe81ad051eb52d8dce0',
|
||||
789000: '5cf66d224e5645097efc9c3c0392b51c8ca8ea1295151921a7912a2f04ee1274',
|
||||
790000: '676769ade71c33bc102bce416e66eb2c6794b03d7b8f5a590c87c380da463775',
|
||||
791000: '0228e074451797bf6bfbc941bcafcbadc972d32e4e1e0c5da015513f65714217',
|
||||
792000: '0fa3d00a1f19c5ac060e10a410cf7cea18eac5f89018d79ce51ac3fc66bbb365',
|
||||
793000: '5f68d0868b424e32f5ce3d8e7d9f18979da7b831b8ef4e3974d62fb20ff53a97',
|
||||
794000: '34508c56423739c00a837801b654b07decb274d02b383eff396d23c4d64bc0e9',
|
||||
795000: '7f70910c855d1fd88cd7f9be8a3b94314ee408a31a2da6301404bf8deb07c12c',
|
||||
796000: 'b74ab8813b1d2a0967fea0e66597572e5f0b5a285e21f5150fcc9d5f757de130',
|
||||
797000: 'bba27b1491d907ab1baa456cb651dc5b071231b1b6ad27b62d351ca12c25dbfd',
|
||||
798000: 'e75dcb15b2fc91f02e75e600dde9f6f46c09672533bc82a5d6916c4a2cd8613a',
|
||||
799000: 'adf62c826a3e0b33af439a7881918ae4ce19c5fb2ca37d21243415f7d716aa65',
|
||||
800000: 'd8f0ca13a8c8a19c254a3a6ba15150a34711dca96f2d877162cc44aa2acfb268',
|
||||
801000: '2a8c7104c4040a2bc31913ae25e9361df5bac9477368c708f86c1ca640480887',
|
||||
802000: '1f3b09d3561c4a8a056b263289bd492dc6c0d604c3fa195935e735d1c0ddc40e',
|
||||
803000: '037769628c40a701fdb4b16d79084b8fbb319fde79770a7ac842f3cdc813099e',
|
||||
804000: 'a0c6a089e5fa1e3589ca282085fe7201a5705776d81b257ffd252b2947fa6428',
|
||||
805000: 'b2ac99bfc4a488e7b7624b31ee061991a6dd0881bb005cd13f3dd2e66a08fe19',
|
||||
806000: 'ffe63cb999a278280b80a667d2dcb60c40e43a53f733914d8bec808b694ebf83',
|
||||
807000: 'eddb09fc6c4869a59b520d0befb1fb6ac952333f3cc5de086539c85ea8558778',
|
||||
808000: '0f4fb3f9172e52897ea992d9f3a2024126c4d2e63e9888739f11fb1f5e4c1f46',
|
||||
809000: '9641dd720d23ced2f1cb6e5cf46ac4e547afb9f56263c4cf58e3b19d407cf401',
|
||||
810000: 'de6dc953acd7e5ef213b3aaf1c4a9ee1d5b756bfce5525ee105214647e243a85',
|
||||
811000: 'c52c83712ca12b24b2db1b4a575e7f352b1d560cbf702e121a03bdca9e8be23d',
|
||||
812000: '83143734bb965318a53a38a7e403dcdb3e3fadedb01ab12c370417fc2a0655c0',
|
||||
813000: 'e480deff10c5a84fc957e3aed936690e24b74dd08fa8858a8a953c2f7383b914',
|
||||
814000: '810d33afcee07b9abe16c6cdc3a041038daa131c476b0daf48a080007f08b490',
|
||||
815000: 'b4aeb9e16fddd27844b2d56bc2b221134039bb5642c9e9ba88372afbdeac3972',
|
||||
816000: '86e73b67aae3d248011b8f66ed414cb8a9ba4b2a3cf7e32773cfbff055d719b7',
|
||||
817000: '3ebb8b83752b48242016cb682f0f6bd14e15371bf1163a5933193eaa0edeb351',
|
||||
818000: '4d925e17f642f220bbf317d3d5355d2f41fbce325f190f8c3b32dc0b337d24d6',
|
||||
819000: 'b9cc126d620f6b99d90a00d35957b0e428aaaa7c986bc9e816a60e4334572961',
|
||||
820000: '9c2f8c142bed1f94dca29276f7c83958be8cfe11773bb9b56c808fbcf7d3b1f8',
|
||||
821000: 'e5509eb98895cfa12a8da5d54c1df3f52472ffcbdf707adbf84a4a9c5d356203',
|
||||
822000: '764aada4802ebfe4ef935ab50af06a4f83aa556c49fdde3d9e12e1abd230c16b',
|
||||
823000: '1dbd745c2e96a365d865f990d109137d32d42977f503af55d8c00b109d31d3c3',
|
||||
824000: '954304a0b0c8f549c3bffd5ff46b5b8f05b0f0fde2a36f24fd5af9d774fb3079',
|
||||
825000: '17808b14f2056c1a5d46cb7617e9de9be6a1a6084edbc1bdb778586467a72297',
|
||||
826000: '3ca1167d4cac8b187829b23001b438617c43704b42462c4eb001b0d434cb9651',
|
||||
827000: '246d1607245e4a202f420393ac2e30e9cbf5eb5570dc997073b897f6d8643023',
|
||||
828000: '1764730a8dc3e89d02d168ff6bb54e8c903820b74711af6ff27bd0c8545577e7',
|
||||
829000: 'd9f3ab0cd823c6305bd8b95a96188bb4f2ca90b4d66c5d12293e8b6192bac0f2',
|
||||
830000: 'd4ff51f0092b04aedf8d39937680d8e8309b1be21d36e7833ed36f8e30aad6ea',
|
||||
831000: '3e92e76721b962396dce52993fa7606552f0907b38f7b2bd7b21ada98c145f47',
|
||||
832000: 'df12fcdb4cbe53ba627ace6de898298de175f8671d3d90170732d110fcdc34b8',
|
||||
833000: '25167ff38ae4a5964b618cabe0a12d4de62ac7a4c47448cdb4499e09e108d5b9',
|
||||
834000: 'd31f5309ea179a1e386e835fc372e47dcda6871a3a239abfba50c4f368994f13',
|
||||
835000: 'aff7e8dd3e55ea807fcbe284014075f420b3a23f1b0eb47bacdc1c91d2899813',
|
||||
836000: '3b5ac6d64c470739bb17d1544a285affb40f2d33e92687e5ba7c5ac602e0d72a',
|
||||
837000: 'd5619cbfe4f27c55f2bf9351b4891636cf64fef88212a5eeeae7bd3de47fe0bd',
|
||||
838000: '1f9102a49c6ac470cb5d0050e5300b1443840d6d65719b835e3bea484aafb2ec',
|
||||
839000: '3f63e391f0fbc5787fbe4ace3bada3816261294ea1c6ee435001801023682f90',
|
||||
840000: '777894fd12bd0d6dee7bcde2995c68e55e7094e3122da38571e4b6c4304b75e0',
|
||||
841000: 'ceb0c598c788e25e43e25aa4beff5c7377035824844cf1675eaea537074df028',
|
||||
842000: '8661cf2065dc713d2ba043f0b81f0effcc940eeb3e91906a21ff22c210561dcd',
|
||||
843000: '0dc2766f90415009d0c86bedffee6ebcf58042eb08262c0c67c4e9ed86b2aec8',
|
||||
844000: '26d072da864cab268a12794977b04ec44fb69ef3978e2342e82225974dac54dd',
|
||||
845000: '95e93bb60be8d5f07a1f4d26290c914957a82fc9d26ae8a3f20082eda27406ff',
|
||||
846000: 'f1bdc39af7705e58ab8b6c31dc70dce1e115db1cfd8cc9b037949dfbec82a59a',
|
||||
847000: 'f5f10f06396ecf2765d8a081141d489737c1d8d57c281f28f57c4cb2f90db883',
|
||||
848000: '331b8ef08605bae8d749893af9ed54f0df4f07a5a002108a2a0aea82d0360979',
|
||||
849000: '75b5f6233ab9a1bbc3c8b2893e5b22a0aa98e7ea635261255dc3c281f67d2260',
|
||||
850000: '5d7e6fe83e0ea1910a54a00090704737671d6f44df4228e21440ad1fc15e595f',
|
||||
851000: '7822db25d3ff0f6695ee38bad91edf317b5c6611673d28f1d22053110bb558be',
|
||||
852000: '2f0effad83a3561fc1a2806a562786a641d9ddb18d16bb9308006e7d324a21e9',
|
||||
853000: 'f603b2eaff11d5296377d990651317d40a1b2599ad2c5250eab131090f4b9458',
|
||||
854000: '34d59b26a50f18a9f250736d0f2e69d28b7e196fbef9b8a26c6b0b75c16aa194',
|
||||
855000: '76dd1ffff3946c0878969886fcf177ce5ab5560df19ddf006f9bcb02ae3e4e4f',
|
||||
856000: '74ff0b6f64e9dd5802fec2aac1d3ae194d28b9264114adaf0a882b46c8c918fe',
|
||||
857000: '7b5badfa2e4f40aa597a504d7ebe83c3705a2c6169a8c168ce293db223bc2d32',
|
||||
858000: '2bb0767a0f72b20d45ecfc3e34517dbda16d85758e040cf0e147f4cbd0cc57ac',
|
||||
859000: '3d741b9c365a91ed76f85824b94d19ec19b608d232660840ba59c7aa4b2cb67f',
|
||||
860000: 'd481a5a117878c0e3acd1f5844e150fb30e617577947d9846b1d214d703b71b0',
|
||||
861000: '54033424e488a3f1ad6946d4a6d9acb48465d6b1dbe8e1c2504a54cc84d7cad4',
|
||||
862000: '464bc3820a8cc8844dc9e26c388009e9982c656d46ef4b4fd0a2cb0e4eea0aaa',
|
||||
863000: 'd1aa94be2174f66780c4f226b9da3f6712b0f37af8dec33360bea83ca261b342',
|
||||
864000: '8c16008f11de5bc395d88cd802514ff647450f1bc136724b9aaf2ccce10a494f',
|
||||
865000: '3dae86012e97a201e2e1a47c899001ac00f78dc108026ed7c4194858c6c6dd5a',
|
||||
866000: 'afe5b0ccab995e1a1fa25fbc24c1d4b1a92c43042d03395f8743dcd806e72fd8',
|
||||
867000: 'c83716ac171aa9ab0d414833db340fa30e82bfda6cc616d3038529caab9b5600',
|
||||
868000: '8c409fe03cd35ef2d8e366818788b40eaeb4c8f6ae91450d75f4a66ca5f69cad',
|
||||
869000: '1d47909ceba790b8e1ce2e9902ee2775ea99e58efdb95668f9803a8ccf95f286',
|
||||
870000: '9adf5da1476388f053aa42de636da169d1cf1c9652cdf7cd9ad4fb18a0eb3388',
|
||||
871000: '8ad57fb1e74bcba0b5614fbac003be2bb32275dd85b38f2d28a0585005a99cfc',
|
||||
872000: '84a32e92012a356106e9657da8dab1a5491ea588fc29d411c69b20680c666420',
|
||||
873000: 'adf5921bbbfaa43929f67e6a070975313b77b456e262c700a27be611fceb17ae',
|
||||
874000: '09eaa7c4b18c79a46a2895190333f72336826223d5c986849a06f5153f49f2a5',
|
||||
875000: '235d7e4f31966507312149ea4c5e294aa84c695cf840117f0ef5963be7a0bda1',
|
||||
876000: '9aa9cb806ccbec0475ac330b496c5b2edeba38ba3f1e13ddd54a01457634a288',
|
||||
877000: 'c1e7f9b2b20bb1c4c0deadbc786d31fdf36f262325342aa23d1a66e2846b22bc',
|
||||
878000: 'ee0d2b20ac28ce23ab38698a57c6beff14f12b7af9d027c05cc92f652695f46b',
|
||||
879000: '0eb0810f4b81d1845b0a88f05449408df2e45715c9210a656f45278c5fdf7956',
|
||||
880000: 'e7d613027e3b4ca38d09bbef07998b57db237c6d67f1e8ea50024d2e0d9a1a72',
|
||||
881000: '21af4d355d8756b8bf0369b2d79b5c824148ae069026ba5c14f9dd6b7555e1db',
|
||||
}
|
||||
+111
-38
@@ -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
|
||||
@@ -121,7 +121,13 @@ class AIOSQLite:
|
||||
if self._closing:
|
||||
return
|
||||
self._closing = True
|
||||
await asyncio.get_event_loop().run_in_executor(self.writer_executor, self.writer_connection.close)
|
||||
|
||||
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)
|
||||
self.writer_executor.shutdown(wait=True)
|
||||
self.reader_executor.shutdown(wait=True)
|
||||
self.read_ready.clear()
|
||||
@@ -154,7 +160,7 @@ class AIOSQLite:
|
||||
await self.read_ready.wait()
|
||||
still_waiting = True
|
||||
if self._closing:
|
||||
raise asyncio.CancelledError
|
||||
raise asyncio.CancelledError()
|
||||
return await asyncio.get_event_loop().run_in_executor(
|
||||
self.reader_executor, read_only_fn, sql, parameters
|
||||
)
|
||||
@@ -198,7 +204,7 @@ class AIOSQLite:
|
||||
try:
|
||||
async with self.write_lock:
|
||||
if self._closing:
|
||||
raise asyncio.CancelledError
|
||||
raise asyncio.CancelledError()
|
||||
return await asyncio.get_event_loop().run_in_executor(
|
||||
self.writer_executor, lambda: self.__run_transaction(fun, *args, **kwargs)
|
||||
)
|
||||
@@ -235,7 +241,7 @@ class AIOSQLite:
|
||||
try:
|
||||
async with self.write_lock:
|
||||
if self._closing:
|
||||
raise asyncio.CancelledError
|
||||
raise asyncio.CancelledError()
|
||||
return await asyncio.get_event_loop().run_in_executor(
|
||||
self.writer_executor, self.__run_transaction_with_foreign_keys_disabled, fun, args, kwargs
|
||||
)
|
||||
@@ -381,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
|
||||
@@ -423,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)
|
||||
@@ -569,7 +596,7 @@ def get_and_reserve_spendable_utxos(transaction: sqlite3.Connection, accounts: L
|
||||
|
||||
class Database(SQLiteMixin):
|
||||
|
||||
SCHEMA_VERSION = "1.3"
|
||||
SCHEMA_VERSION = "1.6"
|
||||
|
||||
PRAGMAS = """
|
||||
pragma journal_mode=WAL;
|
||||
@@ -623,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
|
||||
@@ -667,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:
|
||||
@@ -675,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
|
||||
@@ -939,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 = ""
|
||||
@@ -987,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']
|
||||
@@ -1026,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
|
||||
|
||||
@@ -1113,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)",
|
||||
|
||||
+142
-277
@@ -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
|
||||
@@ -123,7 +123,6 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
self.network: Network = self.config.get('network') or Network(self)
|
||||
self.network.on_header.listen(self.receive_header)
|
||||
self.network.on_status.listen(self.process_status_update)
|
||||
self.network.on_connected.listen(self.join_network)
|
||||
|
||||
self.accounts = []
|
||||
self.fee_per_byte: int = self.config.get('fee_per_byte', self.default_fee_per_byte)
|
||||
@@ -156,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", 100_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()
|
||||
@@ -168,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):
|
||||
@@ -232,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
|
||||
@@ -329,6 +328,8 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
await self.network.on_connected.first
|
||||
async with self._header_processing_lock:
|
||||
await self._update_tasks.add(self.initial_headers_sync())
|
||||
self.network.on_connected.listen(self.join_network)
|
||||
asyncio.ensure_future(self.join_network())
|
||||
await fully_synced
|
||||
await self.db.release_all_outputs()
|
||||
await asyncio.gather(*(a.maybe_migrate_certificates() for a in self.accounts))
|
||||
@@ -414,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})")
|
||||
@@ -512,11 +514,8 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
)
|
||||
return True
|
||||
|
||||
acquire_lock_tasks = []
|
||||
synced_txs = []
|
||||
to_request = {}
|
||||
pending_synced_history = {}
|
||||
updated_cached_items = {}
|
||||
already_synced = set()
|
||||
|
||||
already_synced_offset = 0
|
||||
@@ -526,17 +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
|
||||
|
||||
for txid, remote_height in remote_history[already_synced_offset:]:
|
||||
cache_item = self._tx_cache[txid]
|
||||
acquire_lock_tasks.append(asyncio.create_task(cache_item.lock.acquire()))
|
||||
|
||||
if acquire_lock_tasks:
|
||||
await asyncio.wait(acquire_lock_tasks)
|
||||
|
||||
tx_indexes = {}
|
||||
|
||||
@@ -544,29 +532,18 @@ 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'
|
||||
assert cache_item.lock.locked(), 'cache lock is not held?'
|
||||
# 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
|
||||
)
|
||||
requested_txes = await self._request_transaction_batch(to_request, len(remote_history), address)
|
||||
for tx in requested_txes:
|
||||
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(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))
|
||||
|
||||
assert len(pending_synced_history) == len(remote_history), \
|
||||
f"{len(pending_synced_history)} vs {len(remote_history)}"
|
||||
@@ -577,21 +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]
|
||||
|
||||
cache_size = self.config.get("tx_cache_size", 100_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
|
||||
try:
|
||||
cache_item.lock.release()
|
||||
except RuntimeError:
|
||||
log.warning("lock was already released?")
|
||||
|
||||
await self.db.save_transaction_io_batch(
|
||||
[], address, self.address_to_hash160(address), synced_history
|
||||
)
|
||||
await self.db.set_address_history(address, synced_history)
|
||||
|
||||
if address_manager is None:
|
||||
address_manager = await self.get_address_manager_for_address(address)
|
||||
@@ -599,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)
|
||||
|
||||
@@ -637,203 +593,105 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
log.debug("finished syncing transaction history for %s, %i known txs", address, len(local_history))
|
||||
return True
|
||||
|
||||
async def cache_transaction(self, txid, remote_height, check_local=True):
|
||||
cache_item = self._tx_cache.get(txid)
|
||||
if cache_item is None:
|
||||
cache_item = self._tx_cache[txid] = TransactionCacheItem()
|
||||
elif cache_item.tx is not None and \
|
||||
cache_item.tx.height >= remote_height and \
|
||||
(cache_item.tx.is_verified or remote_height < 1):
|
||||
return cache_item.tx # cached tx is already up-to-date
|
||||
|
||||
cache_item.pending_verifications += 1
|
||||
try:
|
||||
async with cache_item.lock:
|
||||
tx = cache_item.tx
|
||||
if tx is None and check_local:
|
||||
# check local db
|
||||
tx = cache_item.tx = await self.db.get_transaction(txid=txid)
|
||||
merkle = None
|
||||
if tx is None:
|
||||
# fetch from network
|
||||
_raw, merkle = await self.network.retriable_call(
|
||||
self.network.get_transaction_and_merkle, txid, remote_height
|
||||
)
|
||||
tx = Transaction(unhexlify(_raw), height=merkle['block_height'])
|
||||
cache_item.tx = tx # make sure it's saved before caching it
|
||||
tx.height = remote_height
|
||||
if merkle and 0 < remote_height < len(self.headers):
|
||||
merkle_root = self.get_root_of_merkle_tree(merkle['merkle'], merkle['pos'], tx.hash)
|
||||
header = await self.headers.get(remote_height)
|
||||
tx.position = merkle['pos']
|
||||
tx.is_verified = merkle_root == header['merkle_root']
|
||||
return tx
|
||||
finally:
|
||||
cache_item.pending_verifications -= 1
|
||||
|
||||
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) and cached.pending_verifications <= 1:
|
||||
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:
|
||||
merkle = await self.network.retriable_call(self.network.get_merkle, tx.id, remote_height)
|
||||
if 'merkle' not in merkle:
|
||||
return
|
||||
merkle_root = self.get_root_of_merkle_tree(merkle['merkle'], merkle['pos'], tx.hash)
|
||||
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_for_inflate(self, to_request: Tuple[Tuple[str, int], ...], session_override=None):
|
||||
header_cache = {}
|
||||
async def request_transactions(self, to_request: Tuple[Tuple[str, int], ...], cached=False):
|
||||
batches = [[]]
|
||||
remote_heights = {}
|
||||
transactions = []
|
||||
heights_in_batch = 0
|
||||
last_height = 0
|
||||
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 height != last_height:
|
||||
heights_in_batch += 1
|
||||
last_height = height
|
||||
if len(batches[-1]) == 100 or heights_in_batch == 20:
|
||||
if len(batches[-1]) == 100:
|
||||
batches.append([])
|
||||
heights_in_batch = 1
|
||||
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}
|
||||
|
||||
async def _single_batch(batch):
|
||||
if session_override:
|
||||
batch_result = await self.network.get_transaction_batch(
|
||||
batch, restricted=False, session=session_override
|
||||
)
|
||||
for batch in batches:
|
||||
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):
|
||||
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):
|
||||
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)
|
||||
return txs
|
||||
|
||||
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:
|
||||
continue
|
||||
wanted_txid = txi.txo_ref.tx_ref.id
|
||||
if wanted_txid not in remote_history:
|
||||
continue
|
||||
if wanted_txid in pending_txs:
|
||||
txi.txo_ref = pending_txs[wanted_txid].outputs[txi.txo_ref.position].ref
|
||||
else:
|
||||
batch_result = await self.network.retriable_call(self.network.get_transaction_batch, batch)
|
||||
for txid, (raw, merkle) in batch_result.items():
|
||||
remote_height = remote_heights[txid]
|
||||
merkle_height = merkle['block_height']
|
||||
cache_item = self._tx_cache.get(txid)
|
||||
if cache_item is None:
|
||||
cache_item = TransactionCacheItem()
|
||||
self._tx_cache[txid] = cache_item
|
||||
tx = cache_item.tx or Transaction(unhexlify(raw), height=remote_height)
|
||||
tx.height = remote_height
|
||||
cache_item.tx = tx
|
||||
if 'merkle' in merkle and remote_heights[txid] > 0:
|
||||
merkle_root = self.get_root_of_merkle_tree(merkle['merkle'], merkle['pos'], tx.hash)
|
||||
try:
|
||||
header = header_cache.get(remote_heights[txid]) or (await self.headers.get(merkle_height))
|
||||
except IndexError:
|
||||
log.warning("failed to verify %s at height %i", tx.id, merkle_height)
|
||||
else:
|
||||
header_cache[remote_heights[txid]] = header
|
||||
tx.position = merkle['pos']
|
||||
tx.is_verified = merkle_root == header['merkle_root']
|
||||
transactions.append(tx)
|
||||
check_db_for_txos[txi] = txi.txo_ref.id
|
||||
|
||||
for batch in batches:
|
||||
await _single_batch(batch)
|
||||
return transactions
|
||||
|
||||
async def _request_transaction_batch(self, to_request, remote_history_size, address):
|
||||
header_cache = {}
|
||||
batches = [[]]
|
||||
remote_heights = {}
|
||||
synced_txs = []
|
||||
heights_in_batch = 0
|
||||
last_height = 0
|
||||
for idx in sorted(to_request):
|
||||
txid = to_request[idx][0]
|
||||
height = to_request[idx][1]
|
||||
remote_heights[txid] = height
|
||||
if height != last_height:
|
||||
heights_in_batch += 1
|
||||
last_height = height
|
||||
if len(batches[-1]) == 100 or heights_in_batch == 20:
|
||||
batches.append([])
|
||||
heights_in_batch = 1
|
||||
batches[-1].append(txid)
|
||||
if not batches[-1]:
|
||||
batches.pop()
|
||||
|
||||
last_showed_synced_count = 0
|
||||
|
||||
async def _single_batch(batch):
|
||||
this_batch_synced = []
|
||||
batch_result = await self.network.retriable_call(self.network.get_transaction_batch, batch)
|
||||
for txid, (raw, merkle) in batch_result.items():
|
||||
remote_height = remote_heights[txid]
|
||||
merkle_height = merkle['block_height']
|
||||
cache_item = self._tx_cache.get(txid)
|
||||
if cache_item is None:
|
||||
cache_item = TransactionCacheItem()
|
||||
self._tx_cache[txid] = cache_item
|
||||
tx = cache_item.tx or Transaction(unhexlify(raw), height=remote_height)
|
||||
tx.height = remote_height
|
||||
cache_item.tx = tx
|
||||
if 'merkle' in merkle and remote_heights[txid] > 0:
|
||||
merkle_root = self.get_root_of_merkle_tree(merkle['merkle'], merkle['pos'], tx.hash)
|
||||
try:
|
||||
header = header_cache.get(remote_heights[txid]) or (await self.headers.get(merkle_height))
|
||||
except IndexError:
|
||||
log.warning("failed to verify %s at height %i", tx.id, merkle_height)
|
||||
else:
|
||||
header_cache[remote_heights[txid]] = header
|
||||
tx.position = merkle['pos']
|
||||
tx.is_verified = merkle_root == header['merkle_root']
|
||||
check_db_for_txos = []
|
||||
|
||||
for txi in tx.inputs:
|
||||
if txi.txo_ref.txo is not None:
|
||||
continue
|
||||
cache_item = self._tx_cache.get(txi.txo_ref.tx_ref.id)
|
||||
if cache_item is not None:
|
||||
if cache_item.tx is not None:
|
||||
txi.txo_ref = cache_item.tx.outputs[txi.txo_ref.position].ref
|
||||
else:
|
||||
check_db_for_txos.append(txi.txo_ref.id)
|
||||
|
||||
referenced_txos = {} if not check_db_for_txos else {
|
||||
txo.id: txo for txo in await self.db.get_txos(
|
||||
txoid__in=check_db_for_txos, order_by='txo.txoid', no_tx=True
|
||||
)
|
||||
}
|
||||
|
||||
for txi in tx.inputs:
|
||||
if txi.txo_ref.txo is not None:
|
||||
continue
|
||||
referenced_txo = referenced_txos.get(txi.txo_ref.id)
|
||||
if referenced_txo is not None:
|
||||
txi.txo_ref = referenced_txo.ref
|
||||
continue
|
||||
cache_item = self._tx_cache.get(txi.txo_ref.id)
|
||||
if cache_item is None:
|
||||
cache_item = self._tx_cache[txi.txo_ref.id] = TransactionCacheItem()
|
||||
if cache_item.tx is not None:
|
||||
txi.txo_ref = cache_item.tx.ref
|
||||
|
||||
synced_txs.append(tx)
|
||||
this_batch_synced.append(tx)
|
||||
await self.db.save_transaction_io_batch(
|
||||
this_batch_synced, address, self.address_to_hash160(address), ""
|
||||
referenced_txos = {} if not check_db_for_txos else {
|
||||
txo.id: txo for txo in await self.db.get_txos(
|
||||
txoid__in=list(check_db_for_txos.values()), order_by='txo.txoid', no_tx=True
|
||||
)
|
||||
await asyncio.wait([
|
||||
self._on_transaction_controller.add(TransactionEvent(address, tx))
|
||||
for tx in this_batch_synced
|
||||
])
|
||||
nonlocal last_showed_synced_count
|
||||
if last_showed_synced_count + 100 < len(synced_txs):
|
||||
log.info("synced %i/%i transactions for %s", len(synced_txs), remote_history_size, address)
|
||||
last_showed_synced_count = len(synced_txs)
|
||||
for batch in batches:
|
||||
await _single_batch(batch)
|
||||
return synced_txs
|
||||
}
|
||||
|
||||
for txi in check_db_for_txos:
|
||||
if txi.txo_ref.id in referenced_txos:
|
||||
txi.txo_ref = referenced_txos[txi.txo_ref.id].ref
|
||||
else:
|
||||
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]:
|
||||
details = await self.db.get_address(address=address)
|
||||
@@ -898,17 +756,13 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
include_is_my_output=False,
|
||||
include_sent_supports=False,
|
||||
include_sent_tips=False,
|
||||
include_received_tips=False,
|
||||
session_override=None) -> Tuple[List[Output], dict, int, int]:
|
||||
include_received_tips=False) -> Tuple[List[Output], dict, int, int]:
|
||||
encoded_outputs = await query
|
||||
outputs = Outputs.from_base64(encoded_outputs or b'') # TODO: why is the server returning None?
|
||||
txs = []
|
||||
txs: List[Transaction] = []
|
||||
if len(outputs.txs) > 0:
|
||||
txs: List[Transaction] = []
|
||||
if session_override:
|
||||
txs.extend((await self.request_transactions_for_inflate(tuple(outputs.txs), session_override)))
|
||||
else:
|
||||
txs.extend((await asyncio.gather(*(self.cache_transaction(*tx) for tx in outputs.txs))))
|
||||
async for tx in self.request_transactions(tuple(outputs.txs), cached=True):
|
||||
txs.extend(tx.values())
|
||||
|
||||
_txos, blocked = outputs.inflate(txs)
|
||||
|
||||
@@ -983,25 +837,17 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
async def resolve(self, accounts, urls, new_sdk_server=None, **kwargs):
|
||||
txos = []
|
||||
urls_copy = list(urls)
|
||||
|
||||
if new_sdk_server:
|
||||
resolve = partial(self.network.new_resolve, new_sdk_server)
|
||||
while urls_copy:
|
||||
batch, urls_copy = urls_copy[:500], urls_copy[500:]
|
||||
txos.extend(
|
||||
(await self._inflate_outputs(
|
||||
resolve(batch), accounts, **kwargs
|
||||
))[0]
|
||||
)
|
||||
else:
|
||||
async with self.network.single_call_context(self.network.resolve) as (resolve, session):
|
||||
while urls_copy:
|
||||
batch, urls_copy = urls_copy[:500], urls_copy[500:]
|
||||
txos.extend(
|
||||
(await self._inflate_outputs(
|
||||
resolve(batch), accounts, session_override=session, **kwargs
|
||||
))[0]
|
||||
)
|
||||
resolve = partial(self.network.retriable_call, self.network.resolve)
|
||||
while urls_copy:
|
||||
batch, urls_copy = urls_copy[:100], urls_copy[100:]
|
||||
txos.extend(
|
||||
(await self._inflate_outputs(
|
||||
resolve(batch), accounts, **kwargs
|
||||
))[0]
|
||||
)
|
||||
|
||||
assert len(urls) == len(txos), "Mismatch between urls requested for resolve and responses received."
|
||||
result = {}
|
||||
@@ -1023,17 +869,13 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
new_sdk_server=None, **kwargs) -> Tuple[List[Output], dict, int, int]:
|
||||
if new_sdk_server:
|
||||
claim_search = partial(self.network.new_claim_search, new_sdk_server)
|
||||
return await self._inflate_outputs(
|
||||
claim_search(**kwargs), accounts,
|
||||
include_purchase_receipt=include_purchase_receipt,
|
||||
include_is_my_output=include_is_my_output,
|
||||
)
|
||||
async with self.network.single_call_context(self.network.claim_search) as (claim_search, session):
|
||||
return await self._inflate_outputs(
|
||||
claim_search(**kwargs), accounts, session_override=session,
|
||||
include_purchase_receipt=include_purchase_receipt,
|
||||
include_is_my_output=include_is_my_output,
|
||||
)
|
||||
else:
|
||||
claim_search = self.network.claim_search
|
||||
return await self._inflate_outputs(
|
||||
claim_search(**kwargs), accounts,
|
||||
include_purchase_receipt=include_purchase_receipt,
|
||||
include_is_my_output=include_is_my_output,
|
||||
)
|
||||
|
||||
async def get_claim_by_claim_id(self, accounts, claim_id, **kwargs) -> Output:
|
||||
for claim in (await self.claim_search(accounts, claim_id=claim_id, **kwargs))[0]:
|
||||
@@ -1095,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]
|
||||
@@ -1110,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:
|
||||
@@ -1138,7 +1002,7 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
return self.db.get_channel_count(**constraints)
|
||||
|
||||
async def resolve_collection(self, collection, offset=0, page_size=1):
|
||||
claim_ids = collection.claim.collection.claims.ids[offset:page_size+offset]
|
||||
claim_ids = collection.claim.collection.claims.ids[offset:page_size + offset]
|
||||
try:
|
||||
resolve_results, _, _, _ = await self.claim_search([], claim_ids=claim_ids)
|
||||
except Exception as err:
|
||||
@@ -1158,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)
|
||||
@@ -1187,17 +1053,17 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
'txid': tx.id,
|
||||
'timestamp': ts,
|
||||
'date': datetime.fromtimestamp(ts).isoformat(' ')[:-3] if tx.height > 0 else None,
|
||||
'confirmations': (headers.height+1) - tx.height if tx.height > 0 else 0,
|
||||
'confirmations': (headers.height + 1) - tx.height if tx.height > 0 else 0,
|
||||
'claim_info': [],
|
||||
'update_info': [],
|
||||
'support_info': [],
|
||||
'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)
|
||||
item['value'] = dewies_to_lbc(tx.net_account_balance + tx.fee)
|
||||
item['fee'] = dewies_to_lbc(-tx.fee)
|
||||
else:
|
||||
# someone else paid the fees
|
||||
@@ -1220,13 +1086,13 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
if txi.txo_ref.txo is not None:
|
||||
other_txo = txi.txo_ref.txo
|
||||
if (other_txo.is_claim or other_txo.script.is_support_claim) \
|
||||
and other_txo.claim_id == txo.claim_id:
|
||||
and other_txo.claim_id == txo.claim_id:
|
||||
previous = other_txo
|
||||
break
|
||||
if previous is not None:
|
||||
item['update_info'].append({
|
||||
'address': txo.get_address(self),
|
||||
'balance_delta': dewies_to_lbc(previous.amount-txo.amount),
|
||||
'balance_delta': dewies_to_lbc(previous.amount - txo.amount),
|
||||
'amount': dewies_to_lbc(txo.amount),
|
||||
'claim_id': txo.claim_id,
|
||||
'claim_name': txo.claim_name,
|
||||
@@ -1304,8 +1170,8 @@ class Ledger(metaclass=LedgerRegistry):
|
||||
for account in accounts:
|
||||
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)
|
||||
balance = self._balance_cache[account.id] = \
|
||||
await account.get_detailed_balance(confirmations)
|
||||
for key, value in balance.items():
|
||||
if key == 'reserved_subtotals':
|
||||
for subkey, subvalue in value.items():
|
||||
@@ -1323,7 +1189,6 @@ class TestNetLedger(Ledger):
|
||||
extended_private_key_prefix = unhexlify('04358394')
|
||||
checkpoints = {}
|
||||
|
||||
|
||||
class RegTestLedger(Ledger):
|
||||
network_name = 'regtest'
|
||||
headers_class = UnvalidatedHeaders
|
||||
|
||||
+191
-204
@@ -1,29 +1,28 @@
|
||||
import logging
|
||||
import asyncio
|
||||
import json
|
||||
import socket
|
||||
import random
|
||||
from time import perf_counter
|
||||
from operator import itemgetter
|
||||
from contextlib import asynccontextmanager
|
||||
from functools import partial
|
||||
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
|
||||
@@ -31,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):
|
||||
@@ -59,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)
|
||||
@@ -70,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:
|
||||
@@ -90,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(
|
||||
@@ -137,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()
|
||||
@@ -148,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:
|
||||
@@ -163,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)
|
||||
@@ -186,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):
|
||||
@@ -245,38 +348,17 @@ 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
|
||||
|
||||
@asynccontextmanager
|
||||
async def single_call_context(self, function, *args, **kwargs):
|
||||
if not self.is_connected:
|
||||
log.warning("Wallet server unavailable, waiting for it to come back and retry.")
|
||||
await self.on_connected.first
|
||||
await self.session_pool.wait_for_fastest_session()
|
||||
server = self.session_pool.fastest_session.server
|
||||
session = ClientSession(network=self, server=server)
|
||||
|
||||
async def call_with_reconnect(*a, **kw):
|
||||
while self.running:
|
||||
if not session.available:
|
||||
await session.create_connection()
|
||||
try:
|
||||
return await partial(function, *args, session_override=session, **kwargs)(*a, **kw)
|
||||
except asyncio.TimeoutError:
|
||||
log.warning("'%s' failed, retrying", function.__name__)
|
||||
try:
|
||||
yield (call_with_reconnect, session)
|
||||
finally:
|
||||
await session.close()
|
||||
|
||||
def _update_remote_height(self, header_args):
|
||||
self.remote_height = header_args[0]["height"]
|
||||
|
||||
@@ -285,9 +367,9 @@ class Network:
|
||||
restricted = known_height in (None, -1, 0) or 0 > known_height > self.remote_height - 10
|
||||
return self.rpc('blockchain.transaction.get', [tx_hash], restricted)
|
||||
|
||||
def get_transaction_batch(self, txids, restricted=True, session=None):
|
||||
def get_transaction_batch(self, txids, restricted=True):
|
||||
# use any server if its old, otherwise restrict to who gave us the history
|
||||
return self.rpc('blockchain.transaction.get_batch', txids, restricted, session)
|
||||
return self.rpc('blockchain.transaction.get_batch', txids, restricted)
|
||||
|
||||
def get_transaction_and_merkle(self, tx_hash, known_height=None):
|
||||
# use any server if its old, otherwise restrict to who gave us the history
|
||||
@@ -337,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)
|
||||
|
||||
@@ -364,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:
|
||||
@@ -171,7 +171,8 @@ class BlockProcessor:
|
||||
|
||||
# Caches of unflushed items.
|
||||
self.headers = []
|
||||
self.tx_hashes = []
|
||||
self.block_hashes = []
|
||||
self.block_txs = []
|
||||
self.undo_infos = []
|
||||
|
||||
# UTXO cache
|
||||
@@ -184,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
|
||||
@@ -212,17 +214,24 @@ 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()
|
||||
self.notifications.notified_mempool_txs.clear()
|
||||
await self._maybe_flush()
|
||||
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]:
|
||||
@@ -246,7 +255,7 @@ class BlockProcessor:
|
||||
self.logger.info('chain reorg detected')
|
||||
else:
|
||||
self.logger.info(f'faking a reorg of {count:,d} blocks')
|
||||
await self.flush(True)
|
||||
|
||||
|
||||
async def get_raw_blocks(last_height, hex_hashes):
|
||||
heights = range(last_height, last_height - len(hex_hashes), -1)
|
||||
@@ -263,17 +272,27 @@ class BlockProcessor:
|
||||
self.touched.discard(None)
|
||||
self.db.flush_backup(self.flush_data(), self.touched)
|
||||
|
||||
start, last, hashes = await self.reorg_hashes(count)
|
||||
# Reverse and convert to hex strings.
|
||||
hashes = [hash_to_hex_str(hash) for hash in reversed(hashes)]
|
||||
for hex_hashes in chunks(hashes, 50):
|
||||
raw_blocks = await get_raw_blocks(last, hex_hashes)
|
||||
await self.run_in_thread_with_lock(self.backup_blocks, raw_blocks)
|
||||
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()
|
||||
try:
|
||||
await self.flush(True)
|
||||
|
||||
start, last, hashes = await self.reorg_hashes(count)
|
||||
# Reverse and convert to hex strings.
|
||||
hashes = [hash_to_hex_str(hash) for hash in reversed(hashes)]
|
||||
self.logger.info("reorg %i block hashes", len(hashes))
|
||||
for hex_hashes in chunks(hashes, 50):
|
||||
raw_blocks = await get_raw_blocks(last, hex_hashes)
|
||||
self.logger.info("got %i raw blocks", len(raw_blocks))
|
||||
await self.run_in_thread_with_lock(self.backup_blocks, raw_blocks)
|
||||
await self.run_in_thread_with_lock(flush_backup)
|
||||
last -= len(raw_blocks)
|
||||
|
||||
await self.prefetcher.reset_height(self.height)
|
||||
self.reorg_count_metric.inc()
|
||||
except:
|
||||
self.logger.exception("boom")
|
||||
raise
|
||||
finally:
|
||||
self.logger.info("done with reorg")
|
||||
|
||||
async def reorg_hashes(self, count):
|
||||
"""Return a pair (start, last, hashes) of blocks to back up during a
|
||||
@@ -336,8 +355,8 @@ class BlockProcessor:
|
||||
def flush_data(self):
|
||||
"""The data for a flush. The lock must be taken."""
|
||||
assert self.state_lock.locked()
|
||||
return FlushData(self.height, self.tx_count, self.headers,
|
||||
self.tx_hashes, self.undo_infos, self.utxo_cache,
|
||||
return FlushData(self.height, self.tx_count, self.headers, self.block_hashes,
|
||||
self.block_txs, self.undo_infos, self.utxo_cache,
|
||||
self.db_deletes, self.tip)
|
||||
|
||||
async def flush(self, flush_utxos):
|
||||
@@ -392,7 +411,8 @@ class BlockProcessor:
|
||||
for block in blocks:
|
||||
height += 1
|
||||
undo_info = self.advance_txs(
|
||||
height, block.transactions, self.coin.electrum_header(block.header, height)
|
||||
height, block.transactions, self.coin.electrum_header(block.header, height),
|
||||
self.coin.header_hash(block.header)
|
||||
)
|
||||
if height >= min_height:
|
||||
self.undo_infos.append((undo_info, height))
|
||||
@@ -403,25 +423,26 @@ class BlockProcessor:
|
||||
self.headers.extend(headers)
|
||||
self.tip = self.coin.header_hash(headers[-1])
|
||||
|
||||
def advance_txs(self, height, txs, header):
|
||||
self.tx_hashes.append(b''.join(tx_hash for tx, tx_hash in txs))
|
||||
def advance_txs(self, height, txs, header, block_hash):
|
||||
self.block_hashes.append(block_hash)
|
||||
self.block_txs.append((b''.join(tx_hash for tx, tx_hash in txs), [tx.raw for tx, _ in txs]))
|
||||
|
||||
# Use local vars for speed in the loops
|
||||
undo_info = []
|
||||
tx_num = self.tx_count
|
||||
script_hashX = self.coin.hashX_from_script
|
||||
s_pack = pack
|
||||
hashXs_by_tx = []
|
||||
|
||||
# Use local vars for speed in the loops
|
||||
put_utxo = self.utxo_cache.__setitem__
|
||||
spend_utxo = self.spend_utxo
|
||||
undo_info_append = undo_info.append
|
||||
update_touched = self.touched.update
|
||||
hashXs_by_tx = []
|
||||
append_hashXs = hashXs_by_tx.append
|
||||
append_hashX_by_tx = hashXs_by_tx.append
|
||||
hashX_from_script = self.coin.hashX_from_script
|
||||
|
||||
for tx, tx_hash in txs:
|
||||
hashXs = []
|
||||
append_hashX = hashXs.append
|
||||
tx_numb = s_pack('<I', tx_num)
|
||||
tx_numb = pack('<I', tx_num)
|
||||
|
||||
# Spend the inputs
|
||||
for txin in tx.inputs:
|
||||
@@ -434,18 +455,17 @@ class BlockProcessor:
|
||||
# Add the new UTXOs
|
||||
for idx, txout in enumerate(tx.outputs):
|
||||
# Get the hashX. Ignore unspendable outputs
|
||||
hashX = script_hashX(txout.pk_script)
|
||||
hashX = hashX_from_script(txout.pk_script)
|
||||
if hashX:
|
||||
append_hashX(hashX)
|
||||
put_utxo(tx_hash + s_pack('<H', idx),
|
||||
hashX + tx_numb + s_pack('<Q', txout.value))
|
||||
put_utxo(tx_hash + pack('<H', idx), hashX + tx_numb + pack('<Q', txout.value))
|
||||
|
||||
append_hashXs(hashXs)
|
||||
append_hashX_by_tx(hashXs)
|
||||
update_touched(hashXs)
|
||||
self.db.total_transactions.append(tx_hash)
|
||||
tx_num += 1
|
||||
|
||||
self.db.history.add_unflushed(hashXs_by_tx, self.tx_count)
|
||||
|
||||
self.tx_count = tx_num
|
||||
self.db.tx_counts.append(tx_num)
|
||||
|
||||
@@ -462,6 +482,7 @@ class BlockProcessor:
|
||||
|
||||
coin = self.coin
|
||||
for raw_block in raw_blocks:
|
||||
self.logger.info("backup block %i", self.height)
|
||||
# Check and update self.tip
|
||||
block = coin.block(raw_block, self.height)
|
||||
header_hash = coin.header_hash(block.header)
|
||||
@@ -487,20 +508,16 @@ class BlockProcessor:
|
||||
|
||||
# Use local vars for speed in the loops
|
||||
s_pack = pack
|
||||
put_utxo = self.utxo_cache.__setitem__
|
||||
spend_utxo = self.spend_utxo
|
||||
script_hashX = self.coin.hashX_from_script
|
||||
touched = self.touched
|
||||
undo_entry_len = 12 + HASHX_LEN
|
||||
|
||||
for tx, tx_hash in reversed(txs):
|
||||
for idx, txout in enumerate(tx.outputs):
|
||||
# Spend the TX outputs. Be careful with unspendable
|
||||
# outputs - we didn't save those in the first place.
|
||||
hashX = script_hashX(txout.pk_script)
|
||||
hashX = self.coin.hashX_from_script(txout.pk_script)
|
||||
if hashX:
|
||||
cache_value = spend_utxo(tx_hash, idx)
|
||||
touched.add(cache_value[:-12])
|
||||
cache_value = self.spend_utxo(tx_hash, idx)
|
||||
self.touched.add(cache_value[:-12])
|
||||
|
||||
# Restore the inputs
|
||||
for txin in reversed(tx.inputs):
|
||||
@@ -508,9 +525,10 @@ class BlockProcessor:
|
||||
continue
|
||||
n -= undo_entry_len
|
||||
undo_item = undo_info[n:n + undo_entry_len]
|
||||
put_utxo(txin.prev_hash + s_pack('<H', txin.prev_idx),
|
||||
undo_item)
|
||||
touched.add(undo_item[:-12])
|
||||
self.utxo_cache[txin.prev_hash + s_pack('<H', txin.prev_idx)] = undo_item
|
||||
self.touched.add(undo_item[:-12])
|
||||
|
||||
self.db.total_transactions.pop()
|
||||
|
||||
assert n == 0
|
||||
self.tx_count -= len(txs)
|
||||
@@ -587,15 +605,18 @@ 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:
|
||||
|
||||
tx_num, = unpack('<I', tx_num_packed)
|
||||
hash, height = self.db.fs_tx_hash(tx_num)
|
||||
try:
|
||||
hash, height = self.db.fs_tx_hash(tx_num)
|
||||
except IndexError:
|
||||
self.logger.error("data integrity error for hashx history: %s missing tx #%s (%s:%s)",
|
||||
hashX.hex(), tx_num, hash_to_hex_str(tx_hash), tx_idx)
|
||||
continue
|
||||
if hash != tx_hash:
|
||||
assert hash is not None # Should always be found
|
||||
continue
|
||||
@@ -604,12 +625,17 @@ class BlockProcessor:
|
||||
# Value: the UTXO value as a 64-bit unsigned integer
|
||||
udb_key = b'u' + hashX + hdb_key[-6:]
|
||||
utxo_value_packed = self.db.utxo_db.get(udb_key)
|
||||
if utxo_value_packed:
|
||||
# Remove both entries for this UTXO
|
||||
self.db_deletes.append(hdb_key)
|
||||
self.db_deletes.append(udb_key)
|
||||
return hashX + tx_num_packed + utxo_value_packed
|
||||
if utxo_value_packed is None:
|
||||
self.logger.warning(
|
||||
"%s:%s is not found in UTXO db for %s", hash_to_hex_str(tx_hash), tx_idx, hash_to_hex_str(hashX)
|
||||
)
|
||||
raise ChainError(f"{hash_to_hex_str(tx_hash)}:{tx_idx} is not found in UTXO db for {hash_to_hex_str(hashX)}")
|
||||
# Remove both entries for this UTXO
|
||||
self.db_deletes.append(hdb_key)
|
||||
self.db_deletes.append(udb_key)
|
||||
return hashX + tx_num_packed + utxo_value_packed
|
||||
|
||||
self.logger.error('UTXO {hash_to_hex_str(tx_hash)} / {tx_idx} not found in "h" table')
|
||||
raise ChainError('UTXO {} / {:,d} not found in "h" table'
|
||||
.format(hash_to_hex_str(tx_hash), tx_idx))
|
||||
|
||||
@@ -622,12 +648,16 @@ class BlockProcessor:
|
||||
self._caught_up_event.set()
|
||||
await self.blocks_event.wait()
|
||||
self.blocks_event.clear()
|
||||
if self.reorg_count:
|
||||
if self.reorg_count: # this could only happen by calling the reorg rpc
|
||||
await self.reorg_chain(self.reorg_count)
|
||||
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}')
|
||||
@@ -661,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()
|
||||
@@ -674,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)
|
||||
@@ -693,7 +726,6 @@ class BlockProcessor:
|
||||
|
||||
|
||||
class Timer:
|
||||
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
self.total = 0
|
||||
@@ -756,39 +788,27 @@ 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')
|
||||
self.timer.run(self.sql.execute, self.sql.LANGUAGE_INDEXES, timer_name='executing LANGUAGE_INDEXES')
|
||||
|
||||
def advance_txs(self, height, txs, header):
|
||||
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, timer_name='super().advance_txs')
|
||||
timer.run(self.sql.advance_txs, height, txs, header, self.daemon.cached_height(), forward_timer=True)
|
||||
undo = timer.run(super().advance_txs, height, txs, header, block_hash, timer_name='super().advance_txs')
|
||||
if self.sql:
|
||||
timer.run(self.sql.advance_txs, height, txs, header, self.daemon.cached_height(), forward_timer=True)
|
||||
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,11 +33,15 @@ 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')
|
||||
self.db_engine = self.default('DB_ENGINE', 'leveldb')
|
||||
self.trending_algorithms = list(set(self.default('TRENDING_ALGORITHMS', 'zscore').split(' ')))
|
||||
self.trending_algorithms = [
|
||||
trending for trending in set(self.default('TRENDING_ALGORITHMS', 'zscore').split(' ')) if trending
|
||||
]
|
||||
self.max_query_workers = self.integer('MAX_QUERY_WORKERS', None)
|
||||
self.individual_tag_indexes = self.boolean('INDIVIDUAL_TAG_INDEXES', True)
|
||||
self.track_metrics = self.boolean('TRACK_METRICS', False)
|
||||
@@ -51,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')
|
||||
@@ -92,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):
|
||||
|
||||
@@ -67,17 +67,17 @@ def hash160(x):
|
||||
return ripemd160(sha256(x))
|
||||
|
||||
|
||||
def hash_to_hex_str(x):
|
||||
def hash_to_hex_str(x: bytes) -> str:
|
||||
"""Convert a big-endian binary hash to displayed hex string.
|
||||
|
||||
Display form of a binary hash is reversed and converted to hex.
|
||||
"""
|
||||
return bytes(reversed(x)).hex()
|
||||
return x[::-1].hex()
|
||||
|
||||
|
||||
def hex_str_to_hash(x):
|
||||
def hex_str_to_hash(x: str) -> bytes:
|
||||
"""Convert a displayed hex string to a binary hash."""
|
||||
return bytes(reversed(hex_to_bytes(x)))
|
||||
return hex_to_bytes(x)[::-1]
|
||||
|
||||
|
||||
class Base58Error(Exception):
|
||||
|
||||
@@ -173,20 +173,20 @@ class History:
|
||||
|
||||
self.logger.info(f'backing up removed {nremoves:,d} history entries')
|
||||
|
||||
def get_txnums(self, hashX, limit=1000):
|
||||
"""Generator that returns an unpruned, sorted list of tx_nums in the
|
||||
history of a hashX. Includes both spending and receiving
|
||||
transactions. By default yields at most 1000 entries. Set
|
||||
limit to None to get them all. """
|
||||
limit = util.resolve_limit(limit)
|
||||
for key, hist in self.db.iterator(prefix=hashX):
|
||||
a = array.array('I')
|
||||
a.frombytes(hist)
|
||||
for tx_num in a:
|
||||
if limit == 0:
|
||||
return
|
||||
yield tx_num
|
||||
limit -= 1
|
||||
# def get_txnums(self, hashX, limit=1000):
|
||||
# """Generator that returns an unpruned, sorted list of tx_nums in the
|
||||
# history of a hashX. Includes both spending and receiving
|
||||
# transactions. By default yields at most 1000 entries. Set
|
||||
# limit to None to get them all. """
|
||||
# limit = util.resolve_limit(limit)
|
||||
# for key, hist in self.db.iterator(prefix=hashX):
|
||||
# a = array.array('I')
|
||||
# a.frombytes(hist)
|
||||
# for tx_num in a:
|
||||
# if limit == 0:
|
||||
# return
|
||||
# yield tx_num
|
||||
# limit -= 1
|
||||
|
||||
#
|
||||
# History compaction
|
||||
|
||||
+188
-89
@@ -12,17 +12,20 @@
|
||||
import asyncio
|
||||
import array
|
||||
import ast
|
||||
import base64
|
||||
import os
|
||||
import time
|
||||
import zlib
|
||||
import typing
|
||||
from typing import Optional, List, Tuple, Iterable
|
||||
from asyncio import sleep
|
||||
from bisect import bisect_right
|
||||
from collections import namedtuple
|
||||
from functools import partial
|
||||
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
|
||||
@@ -35,6 +38,10 @@ UTXO = namedtuple("UTXO", "tx_num tx_pos tx_hash height value")
|
||||
HEADER_PREFIX = b'H'
|
||||
TX_COUNT_PREFIX = b'T'
|
||||
TX_HASH_PREFIX = b'X'
|
||||
TX_PREFIX = b'B'
|
||||
TX_NUM_PREFIX = b'N'
|
||||
BLOCK_HASH_PREFIX = b'C'
|
||||
|
||||
|
||||
|
||||
@attr.s(slots=True)
|
||||
@@ -42,7 +49,8 @@ class FlushData:
|
||||
height = attr.ib()
|
||||
tx_count = attr.ib()
|
||||
headers = attr.ib()
|
||||
block_tx_hashes = attr.ib()
|
||||
block_hashes = attr.ib()
|
||||
block_txs = attr.ib()
|
||||
# The following are flushed to the UTXO DB if undo_infos is not None
|
||||
undo_infos = attr.ib()
|
||||
adds = attr.ib()
|
||||
@@ -74,6 +82,8 @@ class LevelDB:
|
||||
self.history = History()
|
||||
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')
|
||||
@@ -82,9 +92,11 @@ class LevelDB:
|
||||
self.merkle = Merkle()
|
||||
self.header_mc = MerkleCache(self.merkle, self.fs_block_hashes)
|
||||
|
||||
self.hashes_db = None
|
||||
self.headers_db = None
|
||||
self.tx_count_db = None
|
||||
self.tx_db = None
|
||||
|
||||
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):
|
||||
if self.tx_counts is not None:
|
||||
@@ -95,7 +107,7 @@ class LevelDB:
|
||||
def get_counts():
|
||||
return tuple(
|
||||
util.unpack_be_uint64(tx_count)
|
||||
for tx_count in self.tx_count_db.iterator(prefix=TX_COUNT_PREFIX, include_key=False)
|
||||
for tx_count in self.tx_db.iterator(prefix=TX_COUNT_PREFIX, include_key=False)
|
||||
)
|
||||
|
||||
tx_counts = await asyncio.get_event_loop().run_in_executor(self.executor, get_counts)
|
||||
@@ -108,9 +120,32 @@ class LevelDB:
|
||||
else:
|
||||
assert self.db_tx_count == 0
|
||||
|
||||
async def _read_txids(self):
|
||||
def get_txids():
|
||||
return list(self.tx_db.iterator(prefix=TX_HASH_PREFIX, include_key=False))
|
||||
|
||||
start = time.perf_counter()
|
||||
self.logger.info("loading txids")
|
||||
txids = await asyncio.get_event_loop().run_in_executor(self.executor, get_txids)
|
||||
assert len(txids) == len(self.tx_counts) == 0 or len(txids) == self.tx_counts[-1]
|
||||
self.total_transactions = txids
|
||||
ts = time.perf_counter() - start
|
||||
self.logger.info("loaded %i txids in %ss", len(self.total_transactions), round(ts, 4))
|
||||
|
||||
async def _read_headers(self):
|
||||
if self.headers is not None:
|
||||
return
|
||||
|
||||
def get_headers():
|
||||
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}"
|
||||
self.headers = headers
|
||||
|
||||
async def _open_dbs(self, for_sync, compacting):
|
||||
if self.executor is None:
|
||||
self.executor = ThreadPoolExecutor(max(1, os.cpu_count() - 1))
|
||||
self.executor = ThreadPoolExecutor(1)
|
||||
coin_path = os.path.join(self.env.db_dir, 'COIN')
|
||||
if not os.path.isfile(coin_path):
|
||||
with util.open_file(coin_path, create=True) as f:
|
||||
@@ -123,17 +158,11 @@ class LevelDB:
|
||||
self.logger.info('created new headers db')
|
||||
self.logger.info(f'opened headers DB (for sync: {for_sync})')
|
||||
|
||||
assert self.tx_count_db is None
|
||||
self.tx_count_db = self.db_class('tx_count', for_sync)
|
||||
if self.tx_count_db.is_new:
|
||||
self.logger.info('created new tx count db')
|
||||
self.logger.info(f'opened tx count DB (for sync: {for_sync})')
|
||||
|
||||
assert self.hashes_db is None
|
||||
self.hashes_db = self.db_class('hashes', for_sync)
|
||||
if self.hashes_db.is_new:
|
||||
self.logger.info('created new tx hashes db')
|
||||
self.logger.info(f'opened tx hashes DB (for sync: {for_sync})')
|
||||
assert self.tx_db is None
|
||||
self.tx_db = self.db_class('tx', for_sync)
|
||||
if self.tx_db.is_new:
|
||||
self.logger.info('created new tx db')
|
||||
self.logger.info(f'opened tx DB (for sync: {for_sync})')
|
||||
|
||||
assert self.utxo_db is None
|
||||
# First UTXO DB
|
||||
@@ -151,13 +180,15 @@ class LevelDB:
|
||||
|
||||
# Read TX counts (requires meta directory)
|
||||
await self._read_tx_counts()
|
||||
if self.total_transactions is None:
|
||||
await self._read_txids()
|
||||
await self._read_headers()
|
||||
|
||||
def close(self):
|
||||
self.utxo_db.close()
|
||||
self.history.close_db()
|
||||
self.headers_db.close()
|
||||
self.tx_count_db.close()
|
||||
self.hashes_db.close()
|
||||
self.tx_db.close()
|
||||
self.executor.shutdown(wait=True)
|
||||
self.executor = None
|
||||
|
||||
@@ -187,12 +218,9 @@ class LevelDB:
|
||||
if self.headers_db:
|
||||
self.headers_db.close()
|
||||
self.headers_db = None
|
||||
if self.tx_count_db:
|
||||
self.tx_count_db.close()
|
||||
self.tx_count_db = None
|
||||
if self.hashes_db:
|
||||
self.hashes_db.close()
|
||||
self.hashes_db = None
|
||||
if self.tx_db:
|
||||
self.tx_db.close()
|
||||
self.tx_db = None
|
||||
|
||||
await self._open_dbs(False, False)
|
||||
self.logger.info("opened for serving")
|
||||
@@ -217,7 +245,7 @@ class LevelDB:
|
||||
assert flush_data.height == self.fs_height == self.db_height
|
||||
assert flush_data.tip == self.db_tip
|
||||
assert not flush_data.headers
|
||||
assert not flush_data.block_tx_hashes
|
||||
assert not flush_data.block_txs
|
||||
assert not flush_data.adds
|
||||
assert not flush_data.deletes
|
||||
assert not flush_data.undo_infos
|
||||
@@ -275,33 +303,48 @@ class LevelDB:
|
||||
"""
|
||||
prior_tx_count = (self.tx_counts[self.fs_height]
|
||||
if self.fs_height >= 0 else 0)
|
||||
assert len(flush_data.block_tx_hashes) == len(flush_data.headers)
|
||||
assert len(flush_data.block_txs) == len(flush_data.headers)
|
||||
assert flush_data.height == self.fs_height + len(flush_data.headers)
|
||||
assert flush_data.tx_count == (self.tx_counts[-1] if self.tx_counts
|
||||
else 0)
|
||||
assert len(self.tx_counts) == flush_data.height + 1
|
||||
assert len(b''.join(flush_data.block_tx_hashes)) // 32 == flush_data.tx_count - prior_tx_count
|
||||
assert len(
|
||||
b''.join(hashes for hashes, _ in flush_data.block_txs)
|
||||
) // 32 == flush_data.tx_count - prior_tx_count
|
||||
|
||||
# Write the headers, tx counts, and tx hashes
|
||||
# Write the headers
|
||||
start_time = time.perf_counter()
|
||||
|
||||
with self.headers_db.write_batch() as batch:
|
||||
batch_put = batch.put
|
||||
for i, header in enumerate(flush_data.headers):
|
||||
batch_put(HEADER_PREFIX + util.pack_be_uint64(self.fs_height + i + 1), header)
|
||||
self.headers.append(header)
|
||||
flush_data.headers.clear()
|
||||
|
||||
height_start = self.fs_height + 1
|
||||
tx_num = prior_tx_count
|
||||
|
||||
for header, tx_hashes in zip(flush_data.headers, flush_data.block_tx_hashes):
|
||||
tx_count = self.tx_counts[height_start]
|
||||
self.headers_db.put(HEADER_PREFIX + util.pack_be_uint64(height_start), header)
|
||||
self.tx_count_db.put(TX_COUNT_PREFIX + util.pack_be_uint64(height_start), util.pack_be_uint64(tx_count))
|
||||
height_start += 1
|
||||
offset = 0
|
||||
while offset < len(tx_hashes):
|
||||
self.hashes_db.put(TX_HASH_PREFIX + util.pack_be_uint64(tx_num), tx_hashes[offset:offset+32])
|
||||
tx_num += 1
|
||||
offset += 32
|
||||
with self.tx_db.write_batch() as batch:
|
||||
batch_put = batch.put
|
||||
for block_hash, (tx_hashes, txs) in zip(flush_data.block_hashes, flush_data.block_txs):
|
||||
tx_count = self.tx_counts[height_start]
|
||||
batch_put(BLOCK_HASH_PREFIX + util.pack_be_uint64(height_start), block_hash[::-1])
|
||||
batch_put(TX_COUNT_PREFIX + util.pack_be_uint64(height_start), util.pack_be_uint64(tx_count))
|
||||
height_start += 1
|
||||
offset = 0
|
||||
while offset < len(tx_hashes):
|
||||
batch_put(TX_HASH_PREFIX + util.pack_be_uint64(tx_num), tx_hashes[offset:offset+32])
|
||||
batch_put(TX_NUM_PREFIX + tx_hashes[offset:offset+32], util.pack_be_uint64(tx_num))
|
||||
batch_put(TX_PREFIX + tx_hashes[offset:offset+32], txs[offset // 32])
|
||||
tx_num += 1
|
||||
offset += 32
|
||||
|
||||
flush_data.block_txs.clear()
|
||||
flush_data.block_hashes.clear()
|
||||
|
||||
flush_data.block_tx_hashes.clear()
|
||||
self.fs_height = flush_data.height
|
||||
self.fs_tx_count = flush_data.tx_count
|
||||
flush_data.headers.clear()
|
||||
elapsed = time.perf_counter() - start_time
|
||||
self.logger.info(f'flushed filesystem data in {elapsed:.2f}s')
|
||||
|
||||
@@ -362,7 +405,7 @@ class LevelDB:
|
||||
def flush_backup(self, flush_data, touched):
|
||||
"""Like flush_dbs() but when backing up. All UTXOs are flushed."""
|
||||
assert not flush_data.headers
|
||||
assert not flush_data.block_tx_hashes
|
||||
assert not flush_data.block_txs
|
||||
assert flush_data.height < self.db_height
|
||||
self.history.assert_flushed()
|
||||
|
||||
@@ -383,19 +426,31 @@ class LevelDB:
|
||||
|
||||
def backup_fs(self, height, tx_count):
|
||||
"""Back up during a reorg. This just updates our pointers."""
|
||||
self.fs_height = height
|
||||
while self.fs_height > height:
|
||||
self.fs_height -= 1
|
||||
self.headers.pop()
|
||||
self.fs_tx_count = tx_count
|
||||
# Truncate header_mc: header count is 1 more than the height.
|
||||
self.header_mc.truncate(height + 1)
|
||||
|
||||
async def raw_header(self, height):
|
||||
def raw_header(self, height):
|
||||
"""Return the binary header at the given height."""
|
||||
header, n = await self.read_headers(height, 1)
|
||||
header, n = self.read_headers(height, 1)
|
||||
if n != 1:
|
||||
raise IndexError(f'height {height:,d} out of range')
|
||||
return header
|
||||
|
||||
async def read_headers(self, start_height, count):
|
||||
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
|
||||
would be zero if start_height is beyond self.db_height, for
|
||||
@@ -404,24 +459,15 @@ class LevelDB:
|
||||
Returns a (binary, n) pair where binary is the concatenated
|
||||
binary headers, and n is the count of headers returned.
|
||||
"""
|
||||
|
||||
if start_height < 0 or count < 0:
|
||||
raise self.DBError(f'{count:,d} headers starting at '
|
||||
f'{start_height:,d} not on disk')
|
||||
|
||||
def read_headers():
|
||||
# Read some from disk
|
||||
disk_count = max(0, min(count, self.db_height + 1 - start_height))
|
||||
if disk_count:
|
||||
return b''.join(
|
||||
self.headers_db.iterator(
|
||||
start=HEADER_PREFIX + util.pack_be_uint64(start_height),
|
||||
stop=HEADER_PREFIX + util.pack_be_uint64(start_height + disk_count),
|
||||
include_key=False
|
||||
)
|
||||
), disk_count
|
||||
return b'', 0
|
||||
|
||||
return await asyncio.get_event_loop().run_in_executor(self.executor, read_headers)
|
||||
disk_count = max(0, min(count, self.db_height + 1 - start_height))
|
||||
if disk_count:
|
||||
return b''.join(self.headers[start_height:start_height + disk_count]), disk_count
|
||||
return b'', 0
|
||||
|
||||
def fs_tx_hash(self, tx_num):
|
||||
"""Return a par (tx_hash, tx_height) for the given tx number.
|
||||
@@ -429,22 +475,67 @@ class LevelDB:
|
||||
If the tx_height is not on disk, returns (None, tx_height)."""
|
||||
tx_height = bisect_right(self.tx_counts, tx_num)
|
||||
if tx_height > self.db_height:
|
||||
tx_hash = None
|
||||
else:
|
||||
tx_hash = self.hashes_db.get(TX_HASH_PREFIX + util.pack_be_uint64(tx_num))
|
||||
return tx_hash, tx_height
|
||||
return None, tx_height
|
||||
try:
|
||||
return self.total_transactions[tx_num], tx_height
|
||||
except IndexError:
|
||||
self.logger.exception(
|
||||
"Failed to access a cached transaction, known bug #3142 "
|
||||
"should be fixed in #3205"
|
||||
)
|
||||
return None, tx_height
|
||||
|
||||
def _fs_transactions(self, txids: Iterable[str]):
|
||||
unpack_be_uint64 = util.unpack_be_uint64
|
||||
tx_counts = self.tx_counts
|
||||
tx_db_get = self.tx_db.get
|
||||
tx_cache = self._tx_and_merkle_cache
|
||||
|
||||
tx_infos = {}
|
||||
|
||||
for tx_hash in txids:
|
||||
cached_tx = tx_cache.get(tx_hash)
|
||||
if cached_tx:
|
||||
tx, merkle = cached_tx
|
||||
else:
|
||||
tx_hash_bytes = bytes.fromhex(tx_hash)[::-1]
|
||||
tx_num = tx_db_get(TX_NUM_PREFIX + tx_hash_bytes)
|
||||
tx = None
|
||||
tx_height = -1
|
||||
if tx_num is not None:
|
||||
tx_num = unpack_be_uint64(tx_num)
|
||||
tx_height = bisect_right(tx_counts, tx_num)
|
||||
if tx_height < self.db_height:
|
||||
tx = tx_db_get(TX_PREFIX + tx_hash_bytes)
|
||||
if tx_height == -1:
|
||||
merkle = {
|
||||
'block_height': -1
|
||||
}
|
||||
else:
|
||||
tx_pos = tx_num - tx_counts[tx_height - 1]
|
||||
branch, root = self.merkle.branch_and_root(
|
||||
self.total_transactions[tx_counts[tx_height - 1]:tx_counts[tx_height]], tx_pos
|
||||
)
|
||||
merkle = {
|
||||
'block_height': tx_height,
|
||||
'merkle': [
|
||||
hash_to_hex_str(hash)
|
||||
for hash in branch
|
||||
],
|
||||
'pos': tx_pos
|
||||
}
|
||||
if tx_height + 10 < self.db_height:
|
||||
tx_cache[tx_hash] = tx, merkle
|
||||
tx_infos[tx_hash] = (None if not tx else tx.hex(), merkle)
|
||||
return tx_infos
|
||||
|
||||
async def fs_transactions(self, txids):
|
||||
return await asyncio.get_event_loop().run_in_executor(self.executor, self._fs_transactions, txids)
|
||||
|
||||
async def fs_block_hashes(self, height, count):
|
||||
headers_concat, headers_count = await self.read_headers(height, count)
|
||||
if headers_count != count:
|
||||
raise self.DBError(f'only got {headers_count:,d} headers starting at {height:,d}, not {count:,d}')
|
||||
offset = 0
|
||||
headers = []
|
||||
for n in range(count):
|
||||
headers.append(headers_concat[offset:offset + self.coin.BASIC_HEADER_SIZE])
|
||||
offset += self.coin.BASIC_HEADER_SIZE
|
||||
|
||||
return [self.coin.header_hash(header) for header in headers]
|
||||
if height + count > len(self.headers):
|
||||
raise self.DBError(f'only got {len(self.headers) - height:,d} headers starting at {height:,d}, not {count:,d}')
|
||||
return [self.coin.header_hash(header) for header in self.headers[height:height + count]]
|
||||
|
||||
async def limited_history(self, hashX, *, limit=1000):
|
||||
"""Return an unpruned, sorted list of (tx_hash, height) tuples of
|
||||
@@ -453,26 +544,33 @@ class LevelDB:
|
||||
transactions. By default returns at most 1000 entries. Set
|
||||
limit to None to get them all.
|
||||
"""
|
||||
|
||||
def read_history():
|
||||
hashx_history = []
|
||||
for key, hist in self.history.db.iterator(prefix=hashX):
|
||||
db_height = self.db_height
|
||||
tx_counts = self.tx_counts
|
||||
|
||||
cnt = 0
|
||||
txs = []
|
||||
|
||||
for hist in self.history.db.iterator(prefix=hashX, include_key=False):
|
||||
a = array.array('I')
|
||||
a.frombytes(hist)
|
||||
for tx_num in a:
|
||||
tx_height = bisect_right(self.tx_counts, tx_num)
|
||||
if tx_height > self.db_height:
|
||||
tx_hash = None
|
||||
else:
|
||||
tx_hash = self.hashes_db.get(TX_HASH_PREFIX + util.pack_be_uint64(tx_num))
|
||||
hashx_history.append((tx_hash, tx_height))
|
||||
if limit and len(hashx_history) >= limit:
|
||||
return hashx_history
|
||||
return hashx_history
|
||||
tx_height = bisect_right(tx_counts, tx_num)
|
||||
if tx_height > db_height:
|
||||
return
|
||||
txs.append((tx_num, tx_height))
|
||||
cnt += 1
|
||||
if limit and cnt >= limit:
|
||||
break
|
||||
if limit and cnt >= limit:
|
||||
break
|
||||
return txs
|
||||
|
||||
while True:
|
||||
history = await asyncio.get_event_loop().run_in_executor(self.executor, read_history)
|
||||
if all(hash is not None for hash, height in history):
|
||||
return history
|
||||
if history is not None:
|
||||
return [(self.total_transactions[tx_num], tx_height) for (tx_num, tx_height) in history]
|
||||
self.logger.warning(f'limited_history: tx hash '
|
||||
f'not found (reorg?), retrying...')
|
||||
await sleep(0.25)
|
||||
@@ -629,13 +727,14 @@ class LevelDB:
|
||||
utxos = []
|
||||
utxos_append = utxos.append
|
||||
s_unpack = unpack
|
||||
fs_tx_hash = self.fs_tx_hash
|
||||
# Key: b'u' + address_hashX + tx_idx + tx_num
|
||||
# Value: the UTXO value as a 64-bit unsigned integer
|
||||
prefix = b'u' + hashX
|
||||
for db_key, db_value in self.utxo_db.iterator(prefix=prefix):
|
||||
tx_pos, tx_num = s_unpack('<HI', db_key[-6:])
|
||||
value, = unpack('<Q', db_value)
|
||||
tx_hash, height = self.fs_tx_hash(tx_num)
|
||||
tx_hash, height = fs_tx_hash(tx_num)
|
||||
utxos_append(UTXO(tx_num, tx_pos, tx_hash, height, value))
|
||||
return utxos
|
||||
|
||||
|
||||
@@ -6,13 +6,11 @@
|
||||
# and warranty status of this software.
|
||||
|
||||
"""Mempool handling."""
|
||||
import os
|
||||
import asyncio
|
||||
import itertools
|
||||
import time
|
||||
from abc import ABC, abstractmethod
|
||||
from collections import defaultdict
|
||||
from concurrent.futures.thread import ThreadPoolExecutor
|
||||
from prometheus_client import Histogram
|
||||
|
||||
import attr
|
||||
@@ -74,7 +72,7 @@ class MemPoolAPI(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
async def on_mempool(self, touched, height):
|
||||
async def on_mempool(self, touched, new_touched, height):
|
||||
"""Called each time the mempool is synchronized. touched is a set of
|
||||
hashXs touched since the previous call. height is the
|
||||
daemon's height at the time the mempool was obtained."""
|
||||
@@ -117,8 +115,8 @@ class MemPool:
|
||||
# Prevents mempool refreshes during fee histogram calculation
|
||||
self.lock = asyncio.Lock()
|
||||
self.wakeup = asyncio.Event()
|
||||
self.executor = ThreadPoolExecutor(max(os.cpu_count() - 1, 1))
|
||||
self.mempool_process_time_metric = mempool_process_time_metric
|
||||
self.notified_mempool_txs = set()
|
||||
|
||||
async def _logging(self, synchronized_event):
|
||||
"""Print regular logs of mempool stats."""
|
||||
@@ -135,15 +133,11 @@ class MemPool:
|
||||
await synchronized_event.wait()
|
||||
|
||||
async def _refresh_histogram(self, synchronized_event):
|
||||
try:
|
||||
while True:
|
||||
await synchronized_event.wait()
|
||||
async with self.lock:
|
||||
# Threaded as can be expensive
|
||||
await asyncio.get_event_loop().run_in_executor(self.executor, self._update_histogram, 100_000)
|
||||
await asyncio.sleep(self.coin.MEMPOOL_HISTOGRAM_REFRESH_SECS)
|
||||
finally:
|
||||
self.executor.shutdown(wait=True)
|
||||
while True:
|
||||
await synchronized_event.wait()
|
||||
async with self.lock:
|
||||
self._update_histogram(100_000)
|
||||
await asyncio.sleep(self.coin.MEMPOOL_HISTOGRAM_REFRESH_SECS)
|
||||
|
||||
def _update_histogram(self, bin_size):
|
||||
# Build a histogram by fee rate
|
||||
@@ -216,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:
|
||||
@@ -226,10 +229,15 @@ class MemPool:
|
||||
continue
|
||||
hashes = {hex_str_to_hash(hh) for hh in hex_hashes}
|
||||
async with self.lock:
|
||||
new_hashes = hashes.difference(self.notified_mempool_txs)
|
||||
touched = await self._process_mempool(hashes)
|
||||
self.notified_mempool_txs.update(new_hashes)
|
||||
new_touched = {
|
||||
touched_hashx for touched_hashx, txs in self.hashXs.items() if txs.intersection(new_hashes)
|
||||
}
|
||||
synchronized_event.set()
|
||||
synchronized_event.clear()
|
||||
await self.api.on_mempool(touched, height)
|
||||
await self.api.on_mempool(touched, new_touched, height)
|
||||
duration = time.perf_counter() - start
|
||||
self.mempool_process_time_metric.observe(duration)
|
||||
try:
|
||||
@@ -243,7 +251,8 @@ class MemPool:
|
||||
async def _process_mempool(self, all_hashes):
|
||||
# Re-sync with the new set of hashes
|
||||
txs = self.txs
|
||||
hashXs = self.hashXs
|
||||
|
||||
hashXs = self.hashXs # hashX: [tx_hash, ...]
|
||||
touched = set()
|
||||
|
||||
# First handle txs that have disappeared
|
||||
@@ -274,8 +283,8 @@ class MemPool:
|
||||
# FIXME: this is not particularly efficient
|
||||
while tx_map and len(tx_map) != prior_count:
|
||||
prior_count = len(tx_map)
|
||||
tx_map, utxo_map = self._accept_transactions(tx_map, utxo_map,
|
||||
touched)
|
||||
tx_map, utxo_map = self._accept_transactions(tx_map, utxo_map, touched)
|
||||
|
||||
if tx_map:
|
||||
self.logger.info(f'{len(tx_map)} txs dropped')
|
||||
|
||||
@@ -286,30 +295,25 @@ class MemPool:
|
||||
hex_hashes_iter = (hash_to_hex_str(hash) for hash in hashes)
|
||||
raw_txs = await self.api.raw_transactions(hex_hashes_iter)
|
||||
|
||||
def deserialize_txs(): # This function is pure
|
||||
to_hashX = self.coin.hashX_from_script
|
||||
deserializer = self.coin.DESERIALIZER
|
||||
to_hashX = self.coin.hashX_from_script
|
||||
deserializer = self.coin.DESERIALIZER
|
||||
|
||||
txs = {}
|
||||
for hash, raw_tx in zip(hashes, raw_txs):
|
||||
# The daemon may have evicted the tx from its
|
||||
# mempool or it may have gotten in a block
|
||||
if not raw_tx:
|
||||
continue
|
||||
tx, tx_size = deserializer(raw_tx).read_tx_and_vsize()
|
||||
# Convert the inputs and outputs into (hashX, value) pairs
|
||||
# Drop generation-like inputs from MemPoolTx.prevouts
|
||||
txin_pairs = tuple((txin.prev_hash, txin.prev_idx)
|
||||
for txin in tx.inputs
|
||||
if not txin.is_generation())
|
||||
txout_pairs = tuple((to_hashX(txout.pk_script), txout.value)
|
||||
for txout in tx.outputs)
|
||||
txs[hash] = MemPoolTx(txin_pairs, None, txout_pairs,
|
||||
0, tx_size)
|
||||
return txs
|
||||
|
||||
# Thread this potentially slow operation so as not to block
|
||||
tx_map = await asyncio.get_event_loop().run_in_executor(self.executor, deserialize_txs)
|
||||
tx_map = {}
|
||||
for hash, raw_tx in zip(hashes, raw_txs):
|
||||
# The daemon may have evicted the tx from its
|
||||
# mempool or it may have gotten in a block
|
||||
if not raw_tx:
|
||||
continue
|
||||
tx, tx_size = deserializer(raw_tx).read_tx_and_vsize()
|
||||
# Convert the inputs and outputs into (hashX, value) pairs
|
||||
# Drop generation-like inputs from MemPoolTx.prevouts
|
||||
txin_pairs = tuple((txin.prev_hash, txin.prev_idx)
|
||||
for txin in tx.inputs
|
||||
if not txin.is_generation())
|
||||
txout_pairs = tuple((to_hashX(txout.pk_script), txout.value)
|
||||
for txout in tx.outputs)
|
||||
tx_map[hash] = MemPoolTx(txin_pairs, None, txout_pairs,
|
||||
0, tx_size)
|
||||
|
||||
# Determine all prevouts not in the mempool, and fetch the
|
||||
# UTXO information from the database. Failed prevout lookups
|
||||
@@ -320,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)
|
||||
|
||||
@@ -331,8 +335,8 @@ 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._refresh_histogram(synchronized_event),
|
||||
self._mempool_loop(synchronized_event),
|
||||
# self._refresh_histogram(synchronized_event),
|
||||
self._logging(synchronized_event)
|
||||
])
|
||||
|
||||
@@ -349,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
|
||||
|
||||
@@ -366,7 +370,7 @@ class MemPool:
|
||||
result.update(tx.prevouts)
|
||||
return result
|
||||
|
||||
async def transaction_summaries(self, hashX):
|
||||
def transaction_summaries(self, hashX):
|
||||
"""Return a list of MemPoolTxSummary objects for the hashX."""
|
||||
result = []
|
||||
for tx_hash in self.hashXs.get(hashX, ()):
|
||||
|
||||
@@ -63,7 +63,7 @@ class Merkle:
|
||||
raise TypeError('index must be an integer')
|
||||
# This also asserts hashes is not empty
|
||||
if not 0 <= index < len(hashes):
|
||||
raise ValueError('index out of range')
|
||||
raise ValueError(f"index '{index}/{len(hashes)}' out of range")
|
||||
natural_length = self.branch_length(len(hashes))
|
||||
if length is None:
|
||||
length = natural_length
|
||||
|
||||
@@ -319,7 +319,7 @@ class PeerManager:
|
||||
|
||||
# Check prior header too in case of hard fork.
|
||||
check_height = min(our_height, their_height)
|
||||
raw_header = await self.db.raw_header(check_height)
|
||||
raw_header = self.db.raw_header(check_height)
|
||||
if ptuple >= (1, 4):
|
||||
ours = raw_header.hex()
|
||||
message = 'blockchain.block.header'
|
||||
|
||||
@@ -25,9 +25,10 @@ class Notifications:
|
||||
def __init__(self):
|
||||
self._touched_mp = {}
|
||||
self._touched_bp = {}
|
||||
self.notified_mempool_txs = set()
|
||||
self._highest_block = -1
|
||||
|
||||
async def _maybe_notify(self):
|
||||
async def _maybe_notify(self, new_touched):
|
||||
tmp, tbp = self._touched_mp, self._touched_bp
|
||||
common = set(tmp).intersection(tbp)
|
||||
if common:
|
||||
@@ -44,24 +45,24 @@ class Notifications:
|
||||
del tmp[old]
|
||||
for old in [h for h in tbp if h <= height]:
|
||||
touched.update(tbp.pop(old))
|
||||
await self.notify(height, touched)
|
||||
await self.notify(height, touched, new_touched)
|
||||
|
||||
async def notify(self, height, touched):
|
||||
async def notify(self, height, touched, new_touched):
|
||||
pass
|
||||
|
||||
async def start(self, height, notify_func):
|
||||
self._highest_block = height
|
||||
self.notify = notify_func
|
||||
await self.notify(height, set())
|
||||
await self.notify(height, set(), set())
|
||||
|
||||
async def on_mempool(self, touched, height):
|
||||
async def on_mempool(self, touched, new_touched, height):
|
||||
self._touched_mp[height] = touched
|
||||
await self._maybe_notify()
|
||||
await self._maybe_notify(new_touched)
|
||||
|
||||
async def on_block(self, touched, height):
|
||||
self._touched_bp[height] = touched
|
||||
self._highest_block = height
|
||||
await self._maybe_notify()
|
||||
await self._maybe_notify(set())
|
||||
|
||||
|
||||
class Server:
|
||||
@@ -84,12 +85,16 @@ class Server:
|
||||
notifications.mempool_hashes = daemon.mempool_hashes
|
||||
notifications.raw_transactions = daemon.getrawtransactions
|
||||
notifications.lookup_utxos = db.lookup_utxos
|
||||
|
||||
MemPoolAPI.register(Notifications)
|
||||
self.mempool = mempool = MemPool(env.coin, notifications)
|
||||
|
||||
notifications.notified_mempool_txs = self.mempool.notified_mempool_txs
|
||||
|
||||
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
|
||||
@@ -106,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):
|
||||
|
||||
+177
-320
@@ -3,8 +3,6 @@ import ssl
|
||||
import math
|
||||
import time
|
||||
import json
|
||||
import zlib
|
||||
import pylru
|
||||
import base64
|
||||
import codecs
|
||||
import typing
|
||||
@@ -18,15 +16,16 @@ from collections import defaultdict
|
||||
from functools import partial
|
||||
|
||||
from binascii import hexlify
|
||||
from pylru import lrucache
|
||||
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
|
||||
@@ -141,7 +140,11 @@ class SessionManager:
|
||||
session_count_metric = Gauge("session_count", "Number of connected client sessions", namespace=NAMESPACE,
|
||||
labelnames=("version",))
|
||||
request_count_metric = Counter("requests_count", "Number of requests received", namespace=NAMESPACE,
|
||||
labelnames=("method", "version"))
|
||||
labelnames=("method", "version"))
|
||||
tx_request_count_metric = Counter("requested_transaction", "Number of transactions requested", namespace=NAMESPACE)
|
||||
tx_replied_count_metric = Counter("replied_transaction", "Number of transactions responded", namespace=NAMESPACE)
|
||||
urls_to_resolve_count_metric = Counter("urls_to_resolve", "Number of urls to resolve", namespace=NAMESPACE)
|
||||
resolved_url_count_metric = Counter("resolved_url", "Number of resolved urls", namespace=NAMESPACE)
|
||||
|
||||
interrupt_count_metric = Counter("interrupt", "Number of interrupted queries", namespace=NAMESPACE)
|
||||
db_operational_error_metric = Counter(
|
||||
@@ -186,7 +189,9 @@ class SessionManager:
|
||||
self.shutdown_event = shutdown_event
|
||||
self.logger = util.class_logger(__name__, self.__class__.__name__)
|
||||
self.servers: typing.Dict[str, asyncio.AbstractServer] = {}
|
||||
self.sessions: typing.Set['SessionBase'] = set()
|
||||
self.sessions: typing.Dict[int, 'SessionBase'] = {}
|
||||
self.hashx_subscriptions_by_session: typing.DefaultDict[str, typing.Set[int]] = defaultdict(set)
|
||||
self.mempool_statuses = {}
|
||||
self.cur_group = SessionGroup(0)
|
||||
self.txs_sent = 0
|
||||
self.start_time = time.time()
|
||||
@@ -242,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}')
|
||||
@@ -255,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
|
||||
@@ -272,12 +279,12 @@ class SessionManager:
|
||||
|
||||
def _group_map(self):
|
||||
group_map = defaultdict(list)
|
||||
for session in self.sessions:
|
||||
for session in self.sessions.values():
|
||||
group_map[session.group].append(session)
|
||||
return group_map
|
||||
|
||||
def _sub_count(self) -> int:
|
||||
return sum(s.sub_count() for s in self.sessions)
|
||||
return sum(s.sub_count() for s in self.sessions.values())
|
||||
|
||||
def _lookup_session(self, session_id):
|
||||
try:
|
||||
@@ -285,7 +292,7 @@ class SessionManager:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
for session in self.sessions:
|
||||
for session in self.sessions.values():
|
||||
if session.session_id == session_id:
|
||||
return session
|
||||
return None
|
||||
@@ -309,7 +316,7 @@ class SessionManager:
|
||||
while True:
|
||||
await sleep(session_timeout // 10)
|
||||
stale_cutoff = time.perf_counter() - session_timeout
|
||||
stale_sessions = [session for session in self.sessions
|
||||
stale_sessions = [session for session in self.sessions.values()
|
||||
if session.last_recv < stale_cutoff]
|
||||
if stale_sessions:
|
||||
text = ', '.join(str(session.session_id)
|
||||
@@ -341,7 +348,7 @@ class SessionManager:
|
||||
pending_requests = 0
|
||||
closing = 0
|
||||
|
||||
for s in self.sessions:
|
||||
for s in self.sessions.values():
|
||||
error_count += s.errors
|
||||
if s.log_me:
|
||||
logged += 1
|
||||
@@ -375,7 +382,7 @@ class SessionManager:
|
||||
def _session_data(self, for_log):
|
||||
"""Returned to the RPC 'sessions' call."""
|
||||
now = time.time()
|
||||
sessions = sorted(self.sessions, key=lambda s: s.start_time)
|
||||
sessions = sorted(self.sessions.values(), key=lambda s: s.start_time)
|
||||
return [(session.session_id,
|
||||
session.flags(),
|
||||
session.peer_address_str(for_log=for_log),
|
||||
@@ -567,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([
|
||||
@@ -577,9 +585,10 @@ 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
|
||||
session.close(force_after=1) for session in self.sessions.values()
|
||||
])
|
||||
await self.stop_other()
|
||||
|
||||
@@ -603,7 +612,7 @@ class SessionManager:
|
||||
async def raw_header(self, height):
|
||||
"""Return the binary header at the given height."""
|
||||
try:
|
||||
return await self.db.raw_header(height)
|
||||
return self.db.raw_header(height)
|
||||
except IndexError:
|
||||
raise RPCError(BAD_REQUEST, f'height {height:,d} '
|
||||
'out of range') from None
|
||||
@@ -629,18 +638,42 @@ class SessionManager:
|
||||
self.history_cache[hashX] = await self.db.limited_history(hashX, limit=limit)
|
||||
return self.history_cache[hashX]
|
||||
|
||||
async def _notify_sessions(self, height, touched):
|
||||
async def _notify_sessions(self, height, touched, new_touched):
|
||||
"""Notify sessions about height changes and touched addresses."""
|
||||
height_changed = height != self.notified_height
|
||||
if height_changed:
|
||||
await self._refresh_hsub_results(height)
|
||||
if self.sessions:
|
||||
await asyncio.wait([
|
||||
session.notify(touched, height_changed) for session in self.sessions
|
||||
])
|
||||
|
||||
if not self.sessions:
|
||||
return
|
||||
|
||||
if height_changed:
|
||||
header_tasks = [
|
||||
session.send_notification('blockchain.headers.subscribe', (self.hsub_results[session.subscribe_headers_raw], ))
|
||||
for session in self.sessions.values() if session.subscribe_headers
|
||||
]
|
||||
if header_tasks:
|
||||
self.logger.info(f'notify {len(header_tasks)} sessions of new header')
|
||||
asyncio.create_task(asyncio.wait(header_tasks))
|
||||
for hashX in touched.intersection(self.mempool_statuses.keys()):
|
||||
self.mempool_statuses.pop(hashX, None)
|
||||
|
||||
touched.intersection_update(self.hashx_subscriptions_by_session.keys())
|
||||
|
||||
if touched or (height_changed and self.mempool_statuses):
|
||||
notified_hashxs = 0
|
||||
notified_sessions = 0
|
||||
to_notify = touched if height_changed else new_touched
|
||||
for hashX in to_notify:
|
||||
for session_id in self.hashx_subscriptions_by_session[hashX]:
|
||||
asyncio.create_task(self.sessions[session_id].send_history_notification(hashX))
|
||||
notified_sessions += 1
|
||||
notified_hashxs += 1
|
||||
if notified_sessions:
|
||||
self.logger.info(f'notified {notified_sessions} sessions/{notified_hashxs:,d} touched addresses')
|
||||
|
||||
def add_session(self, session):
|
||||
self.sessions.add(session)
|
||||
self.sessions[id(session)] = session
|
||||
self.session_event.set()
|
||||
gid = int(session.start_time - self.start_time) // 900
|
||||
if self.cur_group.gid != gid:
|
||||
@@ -649,7 +682,13 @@ class SessionManager:
|
||||
|
||||
def remove_session(self, session):
|
||||
"""Remove a session from our sessions list if there."""
|
||||
self.sessions.remove(session)
|
||||
session_id = id(session)
|
||||
for hashX in session.hashX_subs:
|
||||
sessions = self.hashx_subscriptions_by_session[hashX]
|
||||
sessions.remove(session_id)
|
||||
if not sessions:
|
||||
self.hashx_subscriptions_by_session.pop(hashX)
|
||||
self.sessions.pop(session_id)
|
||||
self.session_event.set()
|
||||
|
||||
|
||||
@@ -684,8 +723,6 @@ class SessionBase(RPCSession):
|
||||
self._receive_message_orig = self.connection.receive_message
|
||||
self.connection.receive_message = self.receive_message
|
||||
|
||||
async def notify(self, touched, height_changed):
|
||||
pass
|
||||
|
||||
def default_framer(self):
|
||||
return NewlineFramer(self.env.max_receive)
|
||||
@@ -776,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:
|
||||
@@ -792,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()
|
||||
@@ -831,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):
|
||||
@@ -859,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,
|
||||
@@ -877,14 +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.mempool_statuses = {}
|
||||
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
|
||||
@@ -895,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,
|
||||
@@ -911,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):
|
||||
@@ -927,48 +951,22 @@ class LBRYElectrumX(SessionBase):
|
||||
def sub_count(self):
|
||||
return len(self.hashX_subs)
|
||||
|
||||
async def notify(self, touched, height_changed):
|
||||
"""Notify the client about changes to touched addresses (from mempool
|
||||
updates or new blocks) and height.
|
||||
"""
|
||||
if height_changed and self.subscribe_headers:
|
||||
args = (await self.subscribe_headers_result(), )
|
||||
if not (await self.send_notification('blockchain.headers.subscribe', args)):
|
||||
return
|
||||
|
||||
async def send_history_notification(alias, hashX):
|
||||
async def send_history_notification(self, hashX):
|
||||
start = time.perf_counter()
|
||||
alias = self.hashX_subs[hashX]
|
||||
if len(alias) == 64:
|
||||
method = 'blockchain.scripthash.subscribe'
|
||||
else:
|
||||
method = 'blockchain.address.subscribe'
|
||||
try:
|
||||
self.session_mgr.notifications_in_flight_metric.inc()
|
||||
status = await self.address_status(hashX)
|
||||
self.session_mgr.address_history_metric.observe(time.perf_counter() - start)
|
||||
start = time.perf_counter()
|
||||
if len(alias) == 64:
|
||||
method = 'blockchain.scripthash.subscribe'
|
||||
else:
|
||||
method = 'blockchain.address.subscribe'
|
||||
try:
|
||||
self.session_mgr.notifications_in_flight_metric.inc()
|
||||
status = await self.address_status(hashX)
|
||||
self.session_mgr.address_history_metric.observe(time.perf_counter() - start)
|
||||
start = time.perf_counter()
|
||||
await self.send_notification(method, (alias, status))
|
||||
self.session_mgr.notifications_sent_metric.observe(time.perf_counter() - start)
|
||||
finally:
|
||||
self.session_mgr.notifications_in_flight_metric.dec()
|
||||
|
||||
touched = touched.intersection(self.hashX_subs)
|
||||
if touched or (height_changed and self.mempool_statuses):
|
||||
notified = set()
|
||||
mempool_addrs = tuple(self.mempool_statuses.keys())
|
||||
for hashX in touched:
|
||||
alias = self.hashX_subs[hashX]
|
||||
asyncio.create_task(send_history_notification(alias, hashX))
|
||||
notified.add(hashX)
|
||||
for hashX in mempool_addrs:
|
||||
if hashX not in notified:
|
||||
alias = self.hashX_subs[hashX]
|
||||
asyncio.create_task(send_history_notification(alias, hashX))
|
||||
notified.add(hashX)
|
||||
|
||||
if touched:
|
||||
es = '' if len(touched) == 1 else 'es'
|
||||
self.logger.info(f'notified {len(notified)} mempool/{len(touched):,d} touched address{es}')
|
||||
await self.send_notification(method, (alias, status))
|
||||
self.session_mgr.notifications_sent_metric.observe(time.perf_counter() - start)
|
||||
finally:
|
||||
self.session_mgr.notifications_in_flight_metric.dec()
|
||||
|
||||
def get_metrics_or_placeholder_for_api(self, query_name):
|
||||
""" Do not hold on to a reference to the metrics
|
||||
@@ -989,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)
|
||||
@@ -1015,37 +1003,35 @@ 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:
|
||||
return await self.run_and_cache_query('resolve', reader.resolve_to_bytes, urls)
|
||||
count = len(urls)
|
||||
try:
|
||||
self.session_mgr.urls_to_resolve_count_metric.inc(count)
|
||||
return await self.run_and_cache_query('resolve', urls)
|
||||
finally:
|
||||
self.session_mgr.resolved_url_count_metric.inc(count)
|
||||
|
||||
async def get_server_height(self):
|
||||
return self.bp.height
|
||||
@@ -1060,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.'''
|
||||
@@ -1131,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]
|
||||
@@ -1180,7 +1095,7 @@ class LBRYElectrumX(SessionBase):
|
||||
# For mempool, height is -1 if it has unconfirmed inputs, otherwise 0
|
||||
|
||||
db_history = await self.session_mgr.limited_history(hashX)
|
||||
mempool = await self.mempool.transaction_summaries(hashX)
|
||||
mempool = self.mempool.transaction_summaries(hashX)
|
||||
|
||||
status = ''.join(f'{hash_to_hex_str(tx_hash)}:'
|
||||
f'{height:d}:'
|
||||
@@ -1194,9 +1109,9 @@ class LBRYElectrumX(SessionBase):
|
||||
status = None
|
||||
|
||||
if mempool:
|
||||
self.mempool_statuses[hashX] = status
|
||||
self.session_mgr.mempool_statuses[hashX] = status
|
||||
else:
|
||||
self.mempool_statuses.pop(hashX, None)
|
||||
self.session_mgr.mempool_statuses.pop(hashX, None)
|
||||
return status
|
||||
|
||||
async def hashX_listunspent(self, hashX):
|
||||
@@ -1215,13 +1130,14 @@ class LBRYElectrumX(SessionBase):
|
||||
|
||||
async def hashX_subscribe(self, hashX, alias):
|
||||
self.hashX_subs[hashX] = alias
|
||||
self.session_mgr.hashx_subscriptions_by_session[hashX].add(id(self))
|
||||
return await self.address_status(hashX)
|
||||
|
||||
async def hashX_unsubscribe(self, hashX, alias):
|
||||
try:
|
||||
del self.hashX_subs[hashX]
|
||||
except ValueError:
|
||||
pass
|
||||
sessions = self.session_mgr.hashx_subscriptions_by_session[hashX]
|
||||
sessions.remove(id(self))
|
||||
if not sessions:
|
||||
self.hashX_subs.pop(hashX, None)
|
||||
|
||||
def address_to_hashX(self, address):
|
||||
try:
|
||||
@@ -1243,7 +1159,7 @@ class LBRYElectrumX(SessionBase):
|
||||
async def address_get_mempool(self, address):
|
||||
"""Return the mempool transactions touching an address."""
|
||||
hashX = self.address_to_hashX(address)
|
||||
return await self.unconfirmed_history(hashX)
|
||||
return self.unconfirmed_history(hashX)
|
||||
|
||||
async def address_listunspent(self, address):
|
||||
"""Return the list of UTXOs of an address."""
|
||||
@@ -1256,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.
|
||||
@@ -1279,20 +1194,20 @@ class LBRYElectrumX(SessionBase):
|
||||
hashX = scripthash_to_hashX(scripthash)
|
||||
return await self.get_balance(hashX)
|
||||
|
||||
async def unconfirmed_history(self, hashX):
|
||||
def unconfirmed_history(self, hashX):
|
||||
# Note unconfirmed history is unordered in electrum-server
|
||||
# height is -1 if it has unconfirmed inputs, otherwise 0
|
||||
return [{'tx_hash': hash_to_hex_str(tx.hash),
|
||||
'height': -tx.has_unconfirmed_inputs,
|
||||
'fee': tx.fee}
|
||||
for tx in await self.mempool.transaction_summaries(hashX)]
|
||||
for tx in self.mempool.transaction_summaries(hashX)]
|
||||
|
||||
async def confirmed_and_unconfirmed_history(self, hashX):
|
||||
# Note history is ordered but unconfirmed is unordered in e-s
|
||||
history = await self.session_mgr.limited_history(hashX)
|
||||
conf = [{'tx_hash': hash_to_hex_str(tx_hash), 'height': height}
|
||||
for tx_hash, height in history]
|
||||
return conf + await self.unconfirmed_history(hashX)
|
||||
return conf + self.unconfirmed_history(hashX)
|
||||
|
||||
async def scripthash_get_history(self, scripthash):
|
||||
"""Return the confirmed and unconfirmed history of a scripthash."""
|
||||
@@ -1302,7 +1217,7 @@ class LBRYElectrumX(SessionBase):
|
||||
async def scripthash_get_mempool(self, scripthash):
|
||||
"""Return the mempool transactions touching a scripthash."""
|
||||
hashX = scripthash_to_hashX(scripthash)
|
||||
return await self.unconfirmed_history(hashX)
|
||||
return self.unconfirmed_history(hashX)
|
||||
|
||||
async def scripthash_listunspent(self, scripthash):
|
||||
"""Return the list of UTXOs of a scripthash."""
|
||||
@@ -1323,31 +1238,12 @@ class LBRYElectrumX(SessionBase):
|
||||
f'require header height {height:,d} <= '
|
||||
f'cp_height {cp_height:,d} <= '
|
||||
f'chain height {max_height:,d}')
|
||||
branch, root = await self.db.header_branch_and_root(cp_height + 1,
|
||||
height)
|
||||
branch, root = await self.db.header_branch_and_root(cp_height + 1, height)
|
||||
return {
|
||||
'branch': [hash_to_hex_str(elt) for elt in branch],
|
||||
'root': hash_to_hex_str(root),
|
||||
}
|
||||
|
||||
async def block_header(self, height, cp_height=0):
|
||||
"""Return a raw block header as a hexadecimal string, or as a
|
||||
dictionary with a merkle proof."""
|
||||
height = non_negative_integer(height)
|
||||
cp_height = non_negative_integer(cp_height)
|
||||
raw_header_hex = (await self.session_mgr.raw_header(height)).hex()
|
||||
if cp_height == 0:
|
||||
return raw_header_hex
|
||||
result = {'header': raw_header_hex}
|
||||
result.update(await self._merkle_proof(cp_height, height))
|
||||
return result
|
||||
|
||||
async def block_header_13(self, height):
|
||||
"""Return a raw block header as a hexadecimal string.
|
||||
|
||||
height: the header's height"""
|
||||
return await self.block_header(height)
|
||||
|
||||
async def block_headers(self, start_height, count, cp_height=0, b64=False):
|
||||
"""Return count concatenated block headers as hex for the main chain;
|
||||
starting at start_height.
|
||||
@@ -1361,9 +1257,12 @@ class LBRYElectrumX(SessionBase):
|
||||
|
||||
max_size = self.MAX_CHUNK_SIZE
|
||||
count = min(count, max_size)
|
||||
headers, count = await self.db.read_headers(start_height, count)
|
||||
compressobj = zlib.compressobj(wbits=-15, level=1, memLevel=9)
|
||||
headers = base64.b64encode(compressobj.compress(headers) + compressobj.flush()).decode() if b64 else headers.hex()
|
||||
headers, count = self.db.read_headers(start_height, count)
|
||||
|
||||
if b64:
|
||||
headers = self.db.encode_headers(start_height, count, headers)
|
||||
else:
|
||||
headers = headers.hex()
|
||||
result = {
|
||||
'base64' if b64 else 'hex': headers,
|
||||
'count': count,
|
||||
@@ -1381,7 +1280,7 @@ class LBRYElectrumX(SessionBase):
|
||||
index = non_negative_integer(index)
|
||||
size = self.coin.CHUNK_SIZE
|
||||
start_height = index * size
|
||||
headers, _ = await self.db.read_headers(start_height, size)
|
||||
headers, _ = self.db.read_headers(start_height, size)
|
||||
return headers.hex()
|
||||
|
||||
async def block_get_header(self, height):
|
||||
@@ -1470,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
|
||||
@@ -1480,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]
|
||||
@@ -1490,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.
|
||||
@@ -1523,27 +1419,23 @@ class LBRYElectrumX(SessionBase):
|
||||
f'network rules.\n\n{message}\n[{raw_tx}]')
|
||||
|
||||
async def transaction_info(self, tx_hash: str):
|
||||
assert_tx_hash(tx_hash)
|
||||
tx_info = await self.daemon_request('getrawtransaction', tx_hash, True)
|
||||
raw_tx = tx_info['hex']
|
||||
block_hash = tx_info.get('blockhash')
|
||||
if not block_hash:
|
||||
return raw_tx, {'block_height': -1}
|
||||
merkle_height = (await self.daemon.deserialised_block(block_hash))['height']
|
||||
merkle = await self.transaction_merkle(tx_hash, merkle_height)
|
||||
return raw_tx, merkle
|
||||
return (await self.transaction_get_batch(tx_hash))[tx_hash]
|
||||
|
||||
async def transaction_get_batch(self, *tx_hashes):
|
||||
self.session_mgr.tx_request_count_metric.inc(len(tx_hashes))
|
||||
if len(tx_hashes) > 100:
|
||||
raise RPCError(BAD_REQUEST, f'too many tx hashes in request: {len(tx_hashes)}')
|
||||
for tx_hash in tx_hashes:
|
||||
assert_tx_hash(tx_hash)
|
||||
batch_result = {}
|
||||
batch_result = await self.db.fs_transactions(tx_hashes)
|
||||
needed_merkles = {}
|
||||
|
||||
for tx_hash in tx_hashes:
|
||||
if tx_hash in batch_result and batch_result[tx_hash][0]:
|
||||
continue
|
||||
tx_info = await self.daemon_request('getrawtransaction', tx_hash, True)
|
||||
raw_tx = tx_info['hex']
|
||||
block_hash = tx_info.get('blockhash')
|
||||
merkle = {}
|
||||
if block_hash:
|
||||
block = await self.daemon.deserialised_block(block_hash)
|
||||
height = block['height']
|
||||
@@ -1552,12 +1444,20 @@ class LBRYElectrumX(SessionBase):
|
||||
except ValueError:
|
||||
raise RPCError(BAD_REQUEST, f'tx hash {tx_hash} not in '
|
||||
f'block {block_hash} at height {height:,d}')
|
||||
merkle["merkle"] = self._get_merkle_branch(block['tx'], pos)
|
||||
merkle["pos"] = pos
|
||||
needed_merkles[tx_hash] = raw_tx, block['tx'], pos, height
|
||||
else:
|
||||
height = -1
|
||||
merkle['block_height'] = height
|
||||
batch_result[tx_hash] = [raw_tx, merkle]
|
||||
batch_result[tx_hash] = [raw_tx, {'block_height': -1}]
|
||||
|
||||
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
|
||||
}
|
||||
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
|
||||
|
||||
async def transaction_get(self, tx_hash, verbose=False):
|
||||
@@ -1572,19 +1472,6 @@ class LBRYElectrumX(SessionBase):
|
||||
|
||||
return await self.daemon_request('getrawtransaction', tx_hash, verbose)
|
||||
|
||||
async def _block_hash_and_tx_hashes(self, height):
|
||||
"""Returns a pair (block_hash, tx_hashes) for the main chain block at
|
||||
the given height.
|
||||
|
||||
block_hash is a hexadecimal string, and tx_hashes is an
|
||||
ordered list of hexadecimal strings.
|
||||
"""
|
||||
height = non_negative_integer(height)
|
||||
hex_hashes = await self.daemon_request('block_hex_hashes', height, 1)
|
||||
block_hash = hex_hashes[0]
|
||||
block = await self.daemon.deserialised_block(block_hash)
|
||||
return block_hash, block['tx']
|
||||
|
||||
def _get_merkle_branch(self, tx_hashes, tx_pos):
|
||||
"""Return a merkle branch to a transaction.
|
||||
|
||||
@@ -1604,35 +1491,11 @@ class LBRYElectrumX(SessionBase):
|
||||
height: the height of the block it is in
|
||||
"""
|
||||
assert_tx_hash(tx_hash)
|
||||
block_hash, tx_hashes = await self._block_hash_and_tx_hashes(height)
|
||||
try:
|
||||
pos = tx_hashes.index(tx_hash)
|
||||
except ValueError:
|
||||
result = await self.transaction_get_batch(tx_hash)
|
||||
if tx_hash not in result or result[tx_hash][1]['block_height'] <= 0:
|
||||
raise RPCError(BAD_REQUEST, f'tx hash {tx_hash} not in '
|
||||
f'block {block_hash} at height {height:,d}')
|
||||
branch = self._get_merkle_branch(tx_hashes, pos)
|
||||
return {"block_height": height, "merkle": branch, "pos": pos}
|
||||
|
||||
async def transaction_id_from_pos(self, height, tx_pos, merkle=False):
|
||||
"""Return the txid and optionally a merkle proof, given
|
||||
a block height and position in the block.
|
||||
"""
|
||||
tx_pos = non_negative_integer(tx_pos)
|
||||
if merkle not in (True, False):
|
||||
raise RPCError(BAD_REQUEST, f'"merkle" must be a boolean')
|
||||
|
||||
block_hash, tx_hashes = await self._block_hash_and_tx_hashes(height)
|
||||
try:
|
||||
tx_hash = tx_hashes[tx_pos]
|
||||
except IndexError:
|
||||
raise RPCError(BAD_REQUEST, f'no tx at position {tx_pos:,d} in '
|
||||
f'block {block_hash} at height {height:,d}')
|
||||
|
||||
if merkle:
|
||||
branch = self._get_merkle_branch(tx_hashes, tx_pos)
|
||||
return {"tx_hash": tx_hash, "merkle": branch}
|
||||
else:
|
||||
return tx_hash
|
||||
f'block at height {height:,d}')
|
||||
return result[tx_hash][1]
|
||||
|
||||
|
||||
class LocalRPC(SessionBase):
|
||||
@@ -1647,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)
|
||||
@@ -77,18 +77,16 @@ class LevelDB(Storage):
|
||||
import plyvel
|
||||
cls.module = plyvel
|
||||
|
||||
def open(self, name, create):
|
||||
mof = 512 if self.for_sync else 128
|
||||
def open(self, name, create, lru_cache_size=None):
|
||||
mof = 10000
|
||||
path = os.path.join(self.db_dir, name)
|
||||
# Use snappy compression (the default)
|
||||
self.db = self.module.DB(path, create_if_missing=create,
|
||||
max_open_files=mof)
|
||||
self.db = self.module.DB(path, create_if_missing=create, max_open_files=mof)
|
||||
self.close = self.db.close
|
||||
self.get = self.db.get
|
||||
self.put = self.db.put
|
||||
self.iterator = self.db.iterator
|
||||
self.write_batch = partial(self.db.write_batch, transaction=True,
|
||||
sync=True)
|
||||
self.write_batch = partial(self.db.write_batch, transaction=True, sync=True)
|
||||
|
||||
|
||||
class RocksDB(Storage):
|
||||
|
||||
@@ -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):
|
||||
@@ -337,7 +342,8 @@ class Examples(CommandTestCase):
|
||||
'Use the parent_id param to make replies',
|
||||
'comment', 'create',
|
||||
'--comment="I have photographic evidence confirming Sasquatch exists"',
|
||||
f'--channel_name=@channel', f'--parent_id={comment["comment_id"]}'
|
||||
f'--channel_name=@channel', f'--parent_id={comment["comment_id"]}',
|
||||
f'--claim_id={stream_id}'
|
||||
)
|
||||
|
||||
await r(
|
||||
@@ -359,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',
|
||||
|
||||
@@ -9,17 +9,32 @@ class BlockchainReorganizationTests(CommandTestCase):
|
||||
VERBOSITY = logging.WARN
|
||||
|
||||
async def assertBlockHash(self, height):
|
||||
self.assertEqual(
|
||||
(await self.ledger.headers.hash(height)).decode(),
|
||||
await self.blockchain.get_block_hash(height)
|
||||
)
|
||||
bp = self.conductor.spv_node.server.bp
|
||||
|
||||
def get_txids():
|
||||
return [
|
||||
bp.db.fs_tx_hash(tx_num)[0][::-1].hex()
|
||||
for tx_num in range(bp.db.tx_counts[height - 1], bp.db.tx_counts[height])
|
||||
]
|
||||
|
||||
block_hash = await self.blockchain.get_block_hash(height)
|
||||
|
||||
self.assertEqual(block_hash, (await self.ledger.headers.hash(height)).decode())
|
||||
self.assertEqual(block_hash, (await bp.db.fs_block_hashes(height, 1))[0][::-1].hex())
|
||||
|
||||
txids = await asyncio.get_event_loop().run_in_executor(bp.db.executor, get_txids)
|
||||
txs = await bp.db.fs_transactions(txids)
|
||||
block_txs = (await bp.daemon.deserialised_block(block_hash))['tx']
|
||||
self.assertSetEqual(set(block_txs), set(txs.keys()), msg='leveldb/lbrycrd is missing transactions')
|
||||
self.assertListEqual(block_txs, list(txs.keys()), msg='leveldb/lbrycrd transactions are of order')
|
||||
|
||||
async def test_reorg(self):
|
||||
bp = self.conductor.spv_node.server.bp
|
||||
bp.reorg_count_metric.set(0)
|
||||
# invalidate current block, move forward 2
|
||||
self.assertEqual(self.ledger.headers.height, 206)
|
||||
await self.assertBlockHash(206)
|
||||
height = 206
|
||||
self.assertEqual(self.ledger.headers.height, height)
|
||||
await self.assertBlockHash(height)
|
||||
await self.blockchain.invalidate_block((await self.ledger.headers.hash(206)).decode())
|
||||
await self.blockchain.generate(2)
|
||||
await self.ledger.on_header.where(lambda e: e.height == 207)
|
||||
@@ -37,6 +52,11 @@ class BlockchainReorganizationTests(CommandTestCase):
|
||||
await self.assertBlockHash(207)
|
||||
await self.assertBlockHash(208)
|
||||
self.assertEqual(2, bp.reorg_count_metric._samples()[0][2])
|
||||
await self.blockchain.generate(3)
|
||||
await self.ledger.on_header.where(lambda e: e.height == 211)
|
||||
await self.assertBlockHash(209)
|
||||
await self.assertBlockHash(210)
|
||||
await self.assertBlockHash(211)
|
||||
|
||||
async def test_reorg_change_claim_height(self):
|
||||
# sanity check
|
||||
@@ -51,6 +71,8 @@ class BlockchainReorganizationTests(CommandTestCase):
|
||||
|
||||
# create a claim and verify it's returned by claim_search
|
||||
self.assertEqual(self.ledger.headers.height, 207)
|
||||
await self.assertBlockHash(207)
|
||||
|
||||
broadcast_tx = await self.daemon.jsonrpc_stream_create(
|
||||
'hovercraft', '1.0', file_path=self.create_upload_file(data=b'hi!')
|
||||
)
|
||||
@@ -58,6 +80,8 @@ class BlockchainReorganizationTests(CommandTestCase):
|
||||
await self.generate(1)
|
||||
await self.ledger.wait(broadcast_tx, self.blockchain.block_expected)
|
||||
self.assertEqual(self.ledger.headers.height, 208)
|
||||
await self.assertBlockHash(208)
|
||||
|
||||
txos, _, _, _ = await self.ledger.claim_search([], name='hovercraft')
|
||||
self.assertEqual(1, len(txos))
|
||||
txo = txos[0]
|
||||
@@ -75,29 +99,21 @@ class BlockchainReorganizationTests(CommandTestCase):
|
||||
await self.blockchain.clear_mempool()
|
||||
await self.blockchain.generate(2)
|
||||
|
||||
# wait for the client to catch up and verify the reorg
|
||||
await asyncio.wait_for(self.on_header(209), 3.0)
|
||||
await self.assertBlockHash(207)
|
||||
await self.assertBlockHash(208)
|
||||
await self.assertBlockHash(209)
|
||||
|
||||
# verify the claim was dropped from block 208 as returned by lbrycrdd
|
||||
reorg_block_hash = await self.blockchain.get_block_hash(208)
|
||||
self.assertNotEqual(invalidated_block_hash, reorg_block_hash)
|
||||
block_207 = await self.blockchain.get_block(reorg_block_hash)
|
||||
self.assertNotIn(txo.tx_ref.id, block_207['tx'])
|
||||
|
||||
# wait for the client to catch up and verify the reorg
|
||||
await asyncio.wait_for(self.on_header(209), 3.0)
|
||||
await self.assertBlockHash(207)
|
||||
await self.assertBlockHash(208)
|
||||
await self.assertBlockHash(209)
|
||||
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)
|
||||
@@ -117,11 +117,6 @@ class ResolveCommand(BaseResolveTestCase):
|
||||
await self.stream_create('foo', '0.9', allow_duplicate_name=True))
|
||||
# plain winning claim
|
||||
await self.assertResolvesToClaimId('foo', claim_id3)
|
||||
# sequence resolution
|
||||
await self.assertResolvesToClaimId('foo*1', claim_id1)
|
||||
await self.assertResolvesToClaimId('foo*2', claim_id2)
|
||||
await self.assertResolvesToClaimId('foo*3', claim_id3)
|
||||
await self.assertResolvesToClaimId('foo*4', None)
|
||||
# amount order resolution
|
||||
await self.assertResolvesToClaimId('foo$1', claim_id3)
|
||||
await self.assertResolvesToClaimId('foo$2', claim_id2)
|
||||
@@ -137,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)
|
||||
@@ -187,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'])
|
||||
|
||||
@@ -138,8 +138,8 @@ class BasicTransactionTests(IntegrationTestCase):
|
||||
# evil trick: mempool is unsorted on real life, but same order between python instances. reproduce it
|
||||
original_summary = self.conductor.spv_node.server.mempool.transaction_summaries
|
||||
|
||||
async def random_summary(*args, **kwargs):
|
||||
summary = await original_summary(*args, **kwargs)
|
||||
def random_summary(*args, **kwargs):
|
||||
summary = original_summary(*args, **kwargs)
|
||||
if summary and len(summary) > 2:
|
||||
ordered = summary.copy()
|
||||
while summary == ordered:
|
||||
|
||||
@@ -10,7 +10,7 @@ from lbry.wallet.dewies import dict_values_to_lbc
|
||||
class WalletCommands(CommandTestCase):
|
||||
|
||||
async def test_wallet_create_and_add_subscribe(self):
|
||||
session = next(iter(self.conductor.spv_node.server.session_mgr.sessions))
|
||||
session = next(iter(self.conductor.spv_node.server.session_mgr.sessions.values()))
|
||||
self.assertEqual(len(session.hashX_subs), 27)
|
||||
wallet = await self.daemon.jsonrpc_wallet_create('foo', create_account=True, single_key=True)
|
||||
self.assertEqual(len(session.hashX_subs), 28)
|
||||
@@ -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)
|
||||
@@ -36,12 +36,14 @@ class BlobExchangeTestBase(AsyncioTestCase):
|
||||
self.addCleanup(shutil.rmtree, self.server_dir)
|
||||
self.server_config = Config(data_dir=self.server_dir, download_dir=self.server_dir, wallet=self.server_dir,
|
||||
fixed_peers=[])
|
||||
self.server_config.transaction_cache_size = 10000
|
||||
self.server_storage = SQLiteStorage(self.server_config, os.path.join(self.server_dir, "lbrynet.sqlite"))
|
||||
self.server_blob_manager = BlobManager(self.loop, self.server_dir, self.server_storage, self.server_config)
|
||||
self.server = BlobServer(self.loop, self.server_blob_manager, 'bQEaw42GXsgCAGio1nxFncJSyRmnztSCjP')
|
||||
|
||||
self.client_config = Config(data_dir=self.client_dir, download_dir=self.client_dir,
|
||||
wallet=self.client_wallet_dir, fixed_peers=[])
|
||||
self.client_config.transaction_cache_size = 10000
|
||||
self.client_storage = SQLiteStorage(self.client_config, os.path.join(self.client_dir, "lbrynet.sqlite"))
|
||||
self.client_blob_manager = BlobManager(self.loop, self.client_dir, self.client_storage, self.client_config)
|
||||
self.client_peer_manager = PeerManager(self.loop)
|
||||
|
||||
@@ -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)))
|
||||
@@ -9,7 +9,7 @@ claim_id = "63f2da17b0d90042c559cc73b6b17f853945c43e"
|
||||
class TestURLParsing(unittest.TestCase):
|
||||
|
||||
segments = 'stream', 'channel'
|
||||
fields = 'name', 'claim_id', 'sequence', 'amount_order'
|
||||
fields = 'name', 'claim_id', 'amount_order'
|
||||
|
||||
def _assert_url(self, url_string, strictly=True, **kwargs):
|
||||
url = URL.parse(url_string)
|
||||
@@ -43,25 +43,22 @@ class TestURLParsing(unittest.TestCase):
|
||||
url = self._assert_url
|
||||
# stream
|
||||
url('test', stream_name='test')
|
||||
url('test*1', stream_name='test', stream_sequence='1')
|
||||
url('test*1', stream_name='test*1')
|
||||
url('test$1', stream_name='test', stream_amount_order='1')
|
||||
url(f'test#{claim_id}', stream_name='test', stream_claim_id=claim_id, strictly=False)
|
||||
url(f'test:{claim_id}', stream_name='test', stream_claim_id=claim_id)
|
||||
# channel
|
||||
url('@test', channel_name='@test')
|
||||
url('@test*1', channel_name='@test', channel_sequence='1')
|
||||
url('@test$1', channel_name='@test', channel_amount_order='1')
|
||||
url(f'@test#{claim_id}', channel_name='@test', channel_claim_id=claim_id, strictly=False)
|
||||
url(f'@test:{claim_id}', channel_name='@test', channel_claim_id=claim_id)
|
||||
# channel/stream
|
||||
url('lbry://@test/stuff', channel_name='@test', stream_name='stuff')
|
||||
url('lbry://@test*1/stuff', channel_name='@test', channel_sequence='1', stream_name='stuff')
|
||||
url('lbry://@test$1/stuff', channel_name='@test', channel_amount_order='1', stream_name='stuff')
|
||||
url(f'lbry://@test#{claim_id}/stuff', channel_name='@test', channel_claim_id=claim_id, stream_name='stuff', strictly=False)
|
||||
url(f'lbry://@test:{claim_id}/stuff', channel_name='@test', channel_claim_id=claim_id, stream_name='stuff')
|
||||
# combined legacy and new
|
||||
url('@test:1/stuff#2', channel_claim_id='1', stream_claim_id='2', channel_name='@test', stream_name='stuff', strictly=False)
|
||||
url('@test*1/stuff#2', channel_sequence='1', stream_claim_id='2', channel_name='@test', stream_name='stuff', strictly=False)
|
||||
# unicode regex edges
|
||||
_url = lambda name: url(name, stream_name=name)
|
||||
_url('\uD799')
|
||||
@@ -111,10 +108,8 @@ class TestURLParsing(unittest.TestCase):
|
||||
fail("lbry://test@")
|
||||
fail("lbry://tes@t")
|
||||
fail(f"lbry://test:1#{claim_id}")
|
||||
fail("lbry://test*0")
|
||||
fail("lbry://test$0")
|
||||
fail("lbry://test/path")
|
||||
fail("lbry://@test1*1ab/fakepath")
|
||||
fail("lbry://test:1:1:1")
|
||||
fail("whatever/lbry://test")
|
||||
fail("lbry://lbry://test")
|
||||
@@ -122,5 +117,4 @@ class TestURLParsing(unittest.TestCase):
|
||||
fail("lbry://abc:0x123")
|
||||
fail("lbry://abc:0x123/page")
|
||||
fail("lbry://@test1#ABCDEF/fakepath")
|
||||
fail("test*0001")
|
||||
fail("lbry://@test1$1/fakepath?arg1&arg2&arg3")
|
||||
@@ -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()
|
||||
|
||||
@@ -98,12 +98,14 @@ async def get_mock_wallet(sd_hash, storage, wallet_dir, balance=10.0, fee=None):
|
||||
wallet = Wallet()
|
||||
ledger = Ledger({
|
||||
'db': Database(os.path.join(wallet_dir, 'blockchain.db')),
|
||||
'headers': FakeHeaders(514082)
|
||||
'headers': FakeHeaders(514082),
|
||||
'tx_cache_size': 10000
|
||||
})
|
||||
await ledger.db.open()
|
||||
wallet.generate_account(ledger)
|
||||
manager = WalletManager()
|
||||
manager.config = Config()
|
||||
manager.config.transaction_cache_size = 10000
|
||||
manager.wallets.append(wallet)
|
||||
manager.ledgers[Ledger] = ledger
|
||||
manager.ledger.network.client = ClientSession(
|
||||
|
||||
@@ -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