Compare commits

...
129 Commits
Author SHA1 Message Date
Victor Shyba 5718be1c61 log top memory usage on status if tracemalloc enabled 2019-09-16 15:00:35 -03:00
Lex Berezhny 5c151a3a09 v0.41.0 2019-09-16 13:24:11 -04:00
Lex Berezhny 3c46c6cbb9 fix mypy type issue 2019-09-16 13:21:45 -04:00
Lex Berezhny d31f09c174 client wallet db versioning 2019-09-16 13:21:45 -04:00
Lex Berezhny 063eeb34ec fix channel import test to wait for address subscription tasks to finish before looking up channel 2019-09-16 13:21:45 -04:00
Lex Berezhny f06192601c dont fail when claim is not decodable 2019-09-16 13:21:45 -04:00
Lex Berezhny 091221ba2c added wallet/constants.py 2019-09-16 13:21:45 -04:00
Lex Berezhny 7c22111ae0 channel certificate and channel claim can be different accounts, also JSON RPC responses now include a field showing if the channel certificate is available 2019-09-16 13:21:45 -04:00
Alex Grin daac3eed09 Merge pull request #2458 from lbryio/wallet_server_default_coin
default wallet server to LBC coin
2019-09-16 12:34:54 -04:00
Alex Grintsvayg 32ee7feea8 download wallet snapshot on first run 2019-09-16 12:24:44 -04:00
Alex Grintsvayg 2026848a77 default wallet server to LBC coin 2019-09-16 12:01:38 -04:00
Jack Robison a7b205603c Merge pull request #2447 from lbryio/file_encoder
use json_file_encoder for managed streams (file list)
2019-09-13 11:21:36 -04:00
Victor Shyba 291d14f2d4 move as_dict to json_encoder 2019-09-12 14:08:37 -03:00
Victor Shyba 4a68137cfa remove dead code 2019-09-12 14:08:37 -03:00
Jack Robison b2f0374426 Merge pull request #2452 from lbryio/fix-sqlite-misuse
Fix SQLITE_MISUSE
2019-09-12 11:57:23 -04:00
Jack Robison 5fcca6ed0c feedback
-add comment for the fetchall() that if removed will cause SQLITE_MISUSE
2019-09-10 15:03:17 -04:00
Jack Robison a05c44ad1e fix SQLITE_MISUSE
fixes https://github.com/lbryio/lbry-sdk/issues/2164
2019-09-09 22:38:53 -04:00
Jack Robison f9880c8931 test sqlite binding error 2019-09-09 21:46:04 -04:00
Lex Berezhny b876896628 v0.40.1 2019-09-09 13:00:12 -04:00
Victor Shyba 375c2a3363 fix rare edge cases on network 2019-09-09 12:25:16 -04:00
Lex Berezhny 5dbc749000 v0.40.0 2019-09-03 12:36:00 -04:00
Lex Berezhny 36fbd91280 generate docs 2019-09-03 12:00:29 -04:00
Lex Berezhny d2ad3e7ff1 initial kv store 2019-09-03 12:00:29 -04:00
shyba 072f1f112e Merge pull request #2418 from lbryio/no_chdir
sync and connection issues
2019-09-03 11:53:30 -03:00
Victor Shyba 6c79f98d3c connect directly on test server 2019-09-03 11:29:02 -03:00
Victor Shyba 8edebbb684 fix tests for transaction show 2019-09-02 15:43:33 -03:00
Victor Shyba 4839ca631a make restricted default 2019-09-02 15:10:16 -03:00
Victor Shyba 5018fe90de can also be protocolerror 2019-09-01 00:02:07 -03:00
Victor Shyba 379144bcfe fix restriction rules, minor refactor, translate error from transaction not found into returning none 2019-08-31 17:39:03 -03:00
Victor Shyba d2cd0ece5f restore multi server, improve sync concurrency 2019-08-31 06:37:29 -03:00
Victor Shyba 10b7ccaa92 fix unordered history inconsistency 2019-08-31 06:37:29 -03:00
Victor Shyba 925eb618de failing test for unordered mempool 2019-08-31 06:37:29 -03:00
Victor Shyba 96800de052 switch tests and fixes + support for multiple servers 2019-08-31 06:37:29 -03:00
Victor Shyba 9df659b647 no chdir 2019-08-31 06:37:29 -03:00
Lex Berezhny aec0bd5d11 fix intermittent bug where claim metadata was cleared out 2019-08-30 09:44:30 -04:00
Lex Berezhny c1c9c2c578 regenerate api.json 2019-08-28 12:55:19 -04:00
Lex Berezhny c739fa3ca1 fixed typo in daemon API doc 2019-08-26 13:22:42 -04:00
Lex Berezhny 355dfcb6c1 v0.39.3 2019-08-26 13:06:26 -04:00
Oleg Silkin 8f7c291e33 Adds comment_hide functionality 2019-08-26 12:43:07 -04:00
Jack Robison 71fbb3df24 Merge pull request #2414 from lbryio/fix-connection-errors-reloaded
Switch to the fastest wallet server and fix connection errors
2019-08-26 11:13:20 -04:00
Victor Shyba 9cfa9b2c57 use only the main session, dont cancel on connectionerror 2019-08-26 11:17:39 -03:00
Victor Shyba b9b8178e30 use a semaphore to avoid false timeouts on large syncs 2019-08-26 11:17:39 -03:00
Victor Shyba 089cefb77b make it debug for now, there are false positives 2019-08-26 11:17:39 -03:00
Victor Shyba ee9ea1faab get history only from main server 2019-08-26 11:17:39 -03:00
Victor Shyba 22b2cf8b0c warn when out of sync 2019-08-26 11:17:39 -03:00
Victor Shyba 10bd3c9dda fix misc reconnect scenarios 2019-08-26 11:17:39 -03:00
Victor Shyba 6c3147fcf4 simple address subs instead of batch 2019-08-26 11:17:39 -03:00
Jack Robison 5e8d169c50 debug 2019-08-26 11:17:39 -03:00
Jack Robison 8657a35fd7 switch_to_fastest 2019-08-26 11:17:39 -03:00
Jack Robison 97c0b60a22 logging 2019-08-26 11:17:39 -03:00
Lex Berezhny 8a284d6c49 metrics reporting fix for wallet servers 2019-08-26 09:39:42 -04:00
Jack Robison ff4b2f2dec Merge pull request #2411 from lbryio/fix-offline-connection-errors
Fix misc errors when going offline/online
2019-08-22 13:48:02 -04:00
Jack Robison aedce256af fix wallet status silently breaking when offline
-update wallet status to use real latency values and the full list of connected servers
2019-08-22 13:11:17 -04:00
Jack Robison 48b4b97132 fix uncaught exchange rate manager errors when going offline 2019-08-22 13:11:17 -04:00
Jack Robison 6b1f88df66 fix status breaking (and loggly) when the internet connection is lost 2019-08-22 13:11:17 -04:00
shyba d246c46227 Merge pull request #2397 from lbryio/unpack_leftovers
fix unpack error known leftovers
2019-08-22 13:41:25 -03:00
Victor Shyba 7fdd9dc293 fix annoying assertEquals warning 2019-08-21 22:03:24 -03:00
Victor Shyba 202861a900 fix unpack leftovers 2019-08-21 22:03:24 -03:00
Victor Shyba 4c41e7cb29 check headers bounds on access 2019-08-21 22:03:24 -03:00
Jack Robison 92823dcea9 Merge pull request #2407 from lbryio/temporary_speedup_ci
travis: remount /tmp as tmpfs
2019-08-21 20:08:27 -04:00
Victor Shyba 795a5227bc travis: remount /tmp as tmpfs 2019-08-21 20:05:39 -03:00
Alex Grintsvayg bbd4bb99b7 committing my claim search test script 2019-08-21 13:28:30 -04:00
Alex Grin f7443061ef less verbose logging 2019-08-21 09:54:10 -04:00
Jack Robison 416c3c16ab v0.39.2 2019-08-20 20:37:20 -04:00
Jack Robison a11956ece0 Merge pull request #2398 from lbryio/retriable_batcheable_networking
Improve wallet server selection
2019-08-20 20:10:05 -04:00
Jack Robison c4e0c659a7 fix missing perf_counter 2019-08-20 19:22:22 -04:00
Jack Robison f6ba09b171 mypy 2019-08-20 15:41:27 -04:00
Jack Robison b827881024 mypy 2019-08-20 15:35:06 -04:00
Jack Robison 89e395b5f4 pylint 2019-08-20 15:26:00 -04:00
Jack Robison c590954eb9 include connection latency in server selection 2019-08-20 15:11:01 -04:00
Jack Robison a5af3866fd time.time -> time.perf_counter 2019-08-20 14:56:13 -04:00
Jack Robison 1bef56f030 disconnect from duplicate servers (same ip, different dns) 2019-08-20 14:55:24 -04:00
Jack Robison 9045737504 track response time for server.version only 2019-08-20 14:54:55 -04:00
Jack Robison 0e48772c84 track connection latency 2019-08-20 14:45:53 -04:00
Jack Robison 72690b5cff raise asyncio.TimeoutError 2019-08-20 14:19:50 -04:00
Jack Robison 07bae26fd3 close connection and reraise on CancelledError 2019-08-20 14:16:56 -04:00
Victor Shyba 7b0e4617d3 fix db test stability 2019-08-20 04:11:04 -03:00
Victor Shyba af797296ed rolling averages on response time 2019-08-19 16:50:24 -03:00
Victor Shyba c826c7da0d take load into consideration when picking fastest 2019-08-19 14:02:30 -03:00
Victor Shyba 20af1396b9 refactor stop 2019-08-19 14:02:30 -03:00
Victor Shyba f567aca532 retry and batch requests, fix some loose ends 2019-08-19 14:02:30 -03:00
Lex Berezhny c60b658443 v0.39.1 2019-08-19 13:02:16 -04:00
Jack Robison fde8c34088 Merge pull request #2401 from lbryio/check-blob-peers-pingable
UDP ping blob peers to prioritize those who can be connected to
2019-08-19 13:01:40 -04:00
Jack Robison deb6a07160 fix test 2019-08-19 12:51:17 -04:00
Jack Robison 0a66e1b24c logging 2019-08-19 12:29:13 -04:00
Jack Robison 819a551b77 Merge pull request #2402 from lbryio/aioupnp-0.0.14
bump `aioupnp` requirement to 0.0.14, fixes upnp errors blocking startup
2019-08-19 12:08:22 -04:00
Jack Robison 5119b71035 prevent attempting to download from oneself 2019-08-19 12:08:17 -04:00
Jack Robison 33945e14d3 use _value_producer in peer_list to match the downloader behavior 2019-08-19 12:08:17 -04:00
Jack Robison 1d9705fb17 reuse blob protocol object instead of transport 2019-08-19 12:08:17 -04:00
Jack Robison 1949937b5e bump aioupnp requirement to 0.0.14 2019-08-19 10:51:20 -04:00
Lex Berezhny 956e21269e monitor wallet server block transitions and report if new block is excessively delayed 2019-08-19 09:52:37 -04:00
Alex Grin ff73418fc1 Merge pull request #2371 from lbryio/basenetwork_refactor
refactor basenetwork so each session takes care of itself
2019-08-16 10:19:53 -04:00
shyba 76d40f44d8 Merge pull request #2395 from lbryio/lbrycrd17
add support for lbrycrd 17
2019-08-14 11:41:13 -03:00
Victor Shyba ab6944b7b0 wallet server: dont fail to start on segwit txs 2019-08-14 10:26:02 -03:00
Victor Shyba 4d741bd200 update lbrycrd to 17, add option to disable segwit for now 2019-08-13 18:07:15 -03:00
Victor Shyba f3a163b382 fix names and types 2019-08-12 18:16:58 -03:00
Victor Shyba 011b7f090f add urgent reconnect when api is called to bypass retry delay 2019-08-12 18:16:58 -03:00
Victor Shyba 4ead92cfbe fixes from review 2019-08-12 18:16:58 -03:00
Victor Shyba 9ee2f30df4 timeout instead of cancel + minor fixes 2019-08-12 18:16:58 -03:00
Victor Shyba 4a749f6c38 on timeout, restore latency to max 2019-08-12 18:16:58 -03:00
Victor Shyba cf924373f6 make stream test an asyncio test 2019-08-12 18:16:58 -03:00
Victor Shyba d1f5b25418 merge repeated subscription events 2019-08-12 18:16:57 -03:00
Victor Shyba 822f53c888 remove unused things 2019-08-12 18:16:57 -03:00
Victor Shyba f04c5ee902 fix test reliability 2019-08-12 18:16:57 -03:00
Victor Shyba 022d60ec2c both exceptions can be raised, depending on when the call happens 2019-08-12 18:16:57 -03:00
Victor Shyba 8fce374cae race condition where the request is sent and connection lost right after 2019-08-12 18:16:57 -03:00
Victor Shyba e78e2738ef basenet refactor 2019-08-12 18:16:57 -03:00
Victor Shyba 5728493abb refactor basenetwork so each session takes care of itself 2019-08-12 18:16:57 -03:00
Lex Berezhny af1c8ec35c adding missing comma in wallet_server_monitor 2019-08-12 14:16:47 -04:00
Lex Berezhny cb84abfb88 v0.39.0 2019-08-12 13:01:16 -04:00
Jack Robison df1e349470 Merge pull request #2385 from lbryio/blob-exchange-timeouts
Blob exchange server timeouts
2019-08-12 12:29:40 -04:00
Jack Robison 357ce881a6 more blob exchange tests 2019-08-12 10:47:28 -04:00
Jack Robison aa417f5410 test max request size 2019-08-12 10:47:28 -04:00
Jack Robison 0ca29b9518 test idle timeout 2019-08-12 10:47:28 -04:00
Jack Robison 22db04068e add server side timeouts for idle blob exchange connections and slow transfers 2019-08-12 10:47:28 -04:00
Jack Robison 65e74281e0 max request size 2019-08-12 10:47:28 -04:00
Lex Berezhny 46d89929ba fixup balance tests and other stuff 2019-08-12 10:22:14 -04:00
Lex Berezhny 1c941a355b regenerate api docs 2019-08-12 10:22:14 -04:00
Lex Berezhny 0d6248fbeb fix torba tests 2019-08-12 10:22:14 -04:00
Lex Berezhny 98d4d00f96 most commands now work across all accounts 2019-08-12 10:22:14 -04:00
Jack Robison e2d618f472 formatting in time_to_first_byte.py
-pending claim_type being usable in claim_search, don't try downloading channel claims in time_to_first_byte.py
2019-08-12 00:49:33 -04:00
Jack Robison 79d643db6c Merge pull request #2384 from lbryio/faster_file_list
Faster file list
2019-08-11 22:41:15 -04:00
Victor Shyba 13891330d9 check blob hashes from completed_blob_hashes 2019-08-11 19:11:13 -03:00
Jack Robison 6fd0c2bf77 Merge pull request #2379 from lbryio/add-wallet-server-to-ttfb-analytics
Add `connected_servers` field to wallet status and improve analytics for wallet related download errors
2019-08-09 14:18:03 -04:00
Jack Robison b8b42a1fd2 add error_message to ttfb analytics, update tests 2019-08-09 12:55:01 -04:00
Jack Robison fba1b28615 add connected_servers field to wallet status
-add `wallet_server` to time to first bytes analytics event
2019-08-09 12:54:38 -04:00
Lex Berezhny 98828387e3 slow queries saved to metabase 2019-08-06 20:41:14 -04:00
Lex Berezhny 1c12247b71 updated wallet_server_monitor to update slack 2019-08-06 17:44:31 -04:00
Lex Berezhny ee10ebd5d7 renamed lbry/scripts/wallet_server_metabase_analytics.py -> lbry/scripts/wallet_server_monitor.py 2019-08-06 16:07:45 -04:00
70 changed files with 2815 additions and 1790 deletions

No files matched your search

+1
View File
@@ -25,6 +25,7 @@ jobs:
- name: "LBRY Integration Tests"
install:
- pip install coverage tox-travis
- sudo mount -o mode=1777,nosuid,nodev -t tmpfs tmpfs /tmp
script: cd lbry && tox
after_success:
- coverage combine lbry
+289 -126
View File
@@ -41,10 +41,10 @@
"examples": [
{
"title": "Get a file",
"curl": "curl -d'{\"method\": \"get\", \"params\": {\"uri\": \"astream#5d64500fb723eded83a41b0d5055f1783f019191\"}}' http://localhost:5279/",
"lbrynet": "lbrynet get astream#5d64500fb723eded83a41b0d5055f1783f019191",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"get\", \"params\": {\"uri\": \"astream#5d64500fb723eded83a41b0d5055f1783f019191\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 3,\n \"content_fee\": null,\n \"download_directory\": \"/tmp/tmpfjnst0c0\",\n \"download_path\": \"/tmp/tmpfjnst0c0/tmpzj1qbxfj\",\n \"file_name\": \"tmpzj1qbxfj\",\n \"height\": 214,\n \"key\": \"e8b365259d5b8644a6a1eb5d2f77459f\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpzj1qbxfj\",\n \"sd_hash\": \"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"dac2f1adaf5debd8cb377673b35ee4e6eb62ba7747b4440ffdb44d6875c2197e:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"015e32d5a47f2cd3e1242457498c97578d4594d77ee519fc56b21384e97c75d5c1b6450f2138e209f7bbd2adb588609ba36d1982a2187070c391a89793a0b569f09fef656fe041eab1809e3964f6346ae0fb3d20f30a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d707a6a31716278666a180b22186170706c69636174696f6e2f6f637465742d73747265616d3230d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"sd_hash\": \"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"8b7dee36b0985027ad1476590ee5759359b57e4cb6507d5288ffe1508c32177f5a39ef20772cf90da72987f6f55ce1ba\",\n \"stream_name\": \"tmpzj1qbxfj\",\n \"streaming_url\": \"http://localhost:5280/stream/d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"suggested_file_name\": \"tmpzj1qbxfj\",\n \"timestamp\": 1561485090,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"dac2f1adaf5debd8cb377673b35ee4e6eb62ba7747b4440ffdb44d6875c2197e\",\n \"written_bytes\": 11\n }\n}"
"curl": "curl -d'{\"method\": \"get\", \"params\": {\"uri\": \"astream#bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\"}}' http://localhost:5279/",
"lbrynet": "lbrynet get astream#bfb7d50e084d6d246ca9ff909c401aab30a6f9a6",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"get\", \"params\": {\"uri\": \"astream#bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 3,\n \"content_fee\": null,\n \"download_directory\": \"/tmp/tmptn5ym8in\",\n \"download_path\": \"/tmp/tmptn5ym8in/tmpmjego0ff\",\n \"file_name\": \"tmpmjego0ff\",\n \"height\": 214,\n \"key\": \"44c98cff66e9387514d212369d4af15e\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpmjego0ff\",\n \"sd_hash\": \"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"f3338742c2b4cf0e35b7ffa73aea3e9da786926cf82f07d3100e09d04ec3f231:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01af0811078a69759a18595d052af6945827d31218a49f0b990dfb596d464fa5c166a752b4835b01f02dcabd712d4345b09c18ce4096395d25caf4fb962732f54d58df839f9dd7cc2ef1d4303c89e4dd553865ed060a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706d6a65676f306666180b22186170706c69636174696f6e2f6f637465742d73747265616d32302ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"sd_hash\": \"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"d2fdfe280a77e5dd71f82cd531782ec5f71db1b2f9b6bf4da71240b5ad6fb21367d4b53e6f84fa83cc190aff004dd7bd\",\n \"stream_name\": \"tmpmjego0ff\",\n \"streaming_url\": \"http://localhost:5280/stream/2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"suggested_file_name\": \"tmpmjego0ff\",\n \"timestamp\": 1567524492,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"f3338742c2b4cf0e35b7ffa73aea3e9da786926cf82f07d3100e09d04ec3f231\",\n \"written_bytes\": 11\n }\n}"
}
]
},
@@ -187,7 +187,13 @@
{
"name": "account_id",
"type": "str",
"description": "account to use for funding the transaction",
"description": "account to use for holding the transaction",
"is_required": false
},
{
"name": "funding_account_ids",
"type": "list",
"description": "ids of accounts to fund this transaction",
"is_required": false
},
{
@@ -213,10 +219,10 @@
"examples": [
{
"title": "Publish a file",
"curl": "curl -d'{\"method\": \"publish\", \"params\": {\"name\": \"a-new-stream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpj0rdjqc7\", \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet publish a-new-stream --bid=1.0 --file_path=/tmp/tmpj0rdjqc7",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"publish\", \"params\": {\"name\": \"a-new-stream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpj0rdjqc7\", \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000010f6edeb77e3d75b4cdfd5704e4d14ff2fa21948a5b26335aa3e69c8749d6a662010000006b483045022100d85e9ac9781bbaab17e5001055399ecd14b2a31077475734b6a6ccc7e668250e02200d6649e3deea9ca557aa897a32312aed841c56d94d095062c390b718f83e4ea0012102eea5cb67d3c756c1de57f503d4899d9560f1c689c38dfa9339d8020c04cf60e6ffffffff0200e1f50500000000bfb50c612d6e65772d73747265616d4c94000a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706a3072646a716337180b22186170706c69636174696f6e2f6f637465742d73747265616d32303f3b7f11e1ab2ce9c763196d320ec2b73bb7a9acad3f98cea94a37ccce30caa28bba70bb3931d521865c614e9012d88e6d7576a914e88e2124fffc9da0cfd28a92a92670443b4376b188ace0b46217000000001976a9143347a928ed9f8ad71955c09ecfa305efe4590cbe88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mgTdmr4kSe4jjBaQZwE3ar4Kb7XcZBqmZT\",\n \"amount\": \"4.947555\",\n \"confirmations\": 4,\n \"height\": 215,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1561485090,\n \"txid\": \"62a6d649879ce6a35a33265b8a9421faf24fd1e40457fdcdb4753d7eb7de6e0f\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"n2ibKtRbM8hdvp5EafkSAHBxbpBJ2CWWEV\",\n \"amount\": \"1.0\",\n \"claim_id\": \"74c583fc2e08061d6c32152cbdb86b09c483d3fc\",\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#74c583fc2e08061d6c32152cbdb86b09c483d3fc\",\n \"timestamp\": null,\n \"txid\": \"075ecb8118f2fe73a34683b574bb1be7a13d915ab14f3917a72c1d7e57abca1a\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpj0rdjqc7\",\n \"sd_hash\": \"3f3b7f11e1ab2ce9c763196d320ec2b73bb7a9acad3f98cea94a37ccce30caa28bba70bb3931d521865c614e9012d88e\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mkC6bv4hVXEKkjYzbHrZAJ6iZxHU7kyspa\",\n \"amount\": \"3.923448\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"075ecb8118f2fe73a34683b574bb1be7a13d915ab14f3917a72c1d7e57abca1a\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.024107\",\n \"total_input\": \"4.947555\",\n \"total_output\": \"4.923448\",\n \"txid\": \"075ecb8118f2fe73a34683b574bb1be7a13d915ab14f3917a72c1d7e57abca1a\"\n }\n}"
"curl": "curl -d'{\"method\": \"publish\", \"params\": {\"name\": \"a-new-stream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmp_djode3_\", \"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/tmp_djode3_",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"publish\", \"params\": {\"name\": \"a-new-stream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmp_djode3_\", \"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\": \"0100000001301509336d7105f77744b0d8658d111b6d5c7f4b91dd60a99a1abd58e47bd855010000006b483045022100da5af53f91b0d6f81c54fe45cd7294edad374db1538b8a842b52909fc0f81d7a022018f5c6e86caa14d8b7b9cd00fc58dc62a3dc85116f1502725417846ac425119801210303b03af351f59825ab5a3f81e2cd3ccd9bc81b08dd3894e37af617d989303048ffffffff0200e1f50500000000bfb50c612d6e65772d73747265616d4c94000a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d705f646a6f6465335f180b22186170706c69636174696f6e2f6f637465742d73747265616d3230cd64057a0fc233a5414c2f0d55ab806faafddc220c4544e9dd1b6acf750553ce29d615b463cd9fed21b4444d209db4036d7576a914104e9db82ec98a53408ba517caa2bf2828ba028788ace0b46217000000001976a914310e5cdb39f601206132e8adcaa167f5b594b23f88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mk7Hr34G619JQ1wzFNRun1zWp9c8PLq7ze\",\n \"amount\": \"4.947555\",\n \"confirmations\": 4,\n \"height\": 215,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1567524492,\n \"txid\": \"55d87be458bd1a9aa960dd914b7f5c6d1b118d65d8b04477f705716d33091530\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mh1BHTvud83u2YRfdb3PwYS29aVS36cZL7\",\n \"amount\": \"1.0\",\n \"claim_id\": \"69d710bbe991b5c96b4efd5339a16d85a2d89bc4\",\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#69d710bbe991b5c96b4efd5339a16d85a2d89bc4\",\n \"timestamp\": null,\n \"txid\": \"406b4ea7584d40ab2f48ca553bd574ad04101df9beedc126ee519b0489425953\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmp_djode3_\",\n \"sd_hash\": \"cd64057a0fc233a5414c2f0d55ab806faafddc220c4544e9dd1b6acf750553ce29d615b463cd9fed21b4444d209db403\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mjzLcPkJvG8GQgDFSW9X2iCFSkwAyF2NmP\",\n \"amount\": \"3.923448\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"406b4ea7584d40ab2f48ca553bd574ad04101df9beedc126ee519b0489425953\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.024107\",\n \"total_input\": \"4.947555\",\n \"total_output\": \"4.923448\",\n \"txid\": \"406b4ea7584d40ab2f48ca553bd574ad04101df9beedc126ee519b0489425953\"\n }\n}"
}
]
},
@@ -235,10 +241,10 @@
"examples": [
{
"title": "Resolve a claim",
"curl": "curl -d'{\"method\": \"resolve\", \"params\": {\"urls\": [\"astream#5d64500fb723eded83a41b0d5055f1783f019191\"]}}' http://localhost:5279/",
"lbrynet": "lbrynet resolve astream#5d64500fb723eded83a41b0d5055f1783f019191",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"resolve\", \"params\": {\"urls\": [\"astream#5d64500fb723eded83a41b0d5055f1783f019191\"]}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"astream#5d64500fb723eded83a41b0d5055f1783f019191\": {\n \"address\": \"mpDcDEwvfvETWqTDhddKLTzZZS2GBQWBqC\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#7/astream#5\",\n \"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\",\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\": 1561485090,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263187,\n \"is_controlling\": true,\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#5d64500fb723eded83a41b0d5055f1783f019191\",\n \"short_url\": \"lbry://astream#5\",\n \"signing_channel\": {\n \"address\": \"n3rBuPQB9qzAha4xU1uHyP5nmvR3WGq3r6\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#7\",\n \"claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"claim_op\": \"update\",\n \"confirmations\": 7,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 209,\n \"claims_in_channel\": 1,\n \"creation_height\": 209,\n \"creation_timestamp\": 1561485089,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263183,\n \"is_controlling\": true,\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#7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"short_url\": \"lbry://@channel#7\",\n \"timestamp\": 1561485089,\n \"txid\": \"0f7256329d0b2896d6f2472eea2614fbcf20ab6b22e27d168060ebb0adbaa6fa\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000465bebc31803d2a7f0f037f696665d4d610abea2e518f906410163dec7513fc2b9a82ae0c4a15602f467d4c03823d72cf95c36fc6a87e963356e44db502027ae2\",\n \"public_key_id\": \"mrqYtVaoPEPqgyRPExUPi7PrYJ9nDc59yW\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1561485090,\n \"txid\": \"dac2f1adaf5debd8cb377673b35ee4e6eb62ba7747b4440ffdb44d6875c2197e\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpzj1qbxfj\",\n \"sd_hash\": \"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n }\n}"
"curl": "curl -d'{\"method\": \"resolve\", \"params\": {\"urls\": [\"astream#bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\"]}}' http://localhost:5279/",
"lbrynet": "lbrynet resolve astream#bfb7d50e084d6d246ca9ff909c401aab30a6f9a6",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"resolve\", \"params\": {\"urls\": [\"astream#bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\"]}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"astream#bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\": {\n \"address\": \"mqwocM9E8dcY9aHCaCGG6HXB8Pd3hA9KjF\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#1/astream#b\",\n \"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\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\": 1567524492,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263187,\n \"is_controlling\": true,\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#bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\n \"short_url\": \"lbry://astream#b\",\n \"signing_channel\": {\n \"address\": \"mw6SpJDWJeYTWsr2iEFNEbRuqmNhDjpsZS\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#1\",\n \"claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"claim_op\": \"update\",\n \"confirmations\": 7,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 209,\n \"claims_in_channel\": 1,\n \"creation_height\": 209,\n \"creation_timestamp\": 1567524491,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263183,\n \"is_controlling\": true,\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#1812d3275894f62a055d59189a75698a071108af\",\n \"short_url\": \"lbry://@channel#1\",\n \"timestamp\": 1567524491,\n \"txid\": \"986dbf145a5320fe0047b3404216ddae76bb9e915895ebb04dda9c4e1b676be7\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200044974cd9d7098183f8bc9005f3957a4dbfc1ede19044311337fe9f645f256a7a4013c6a142497590bd8461fc50ce6b489453686422079c334bd5f8316b335365e\",\n \"public_key_id\": \"mrne5J4YN1SYYE3qNAAwzEVHAxnZX4AKHp\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1567524492,\n \"txid\": \"f3338742c2b4cf0e35b7ffa73aea3e9da786926cf82f07d3100e09d04ec3f231\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpmjego0ff\",\n \"sd_hash\": \"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n }\n}"
}
]
},
@@ -253,14 +259,14 @@
"name": "status",
"description": "Get daemon status",
"arguments": [],
"returns": "(dict) lbrynet-daemon status\n {\n 'installation_id': (str) installation id - base58,\n 'is_running': (bool),\n 'skipped_components': (list) [names of skipped components (str)],\n 'startup_status': { Does not include components which have been skipped\n 'blob_manager': (bool),\n 'blockchain_headers': (bool),\n 'database': (bool),\n 'dht': (bool),\n 'exchange_rate_manager': (bool),\n 'hash_announcer': (bool),\n 'peer_protocol_server': (bool),\n 'stream_manager': (bool),\n 'upnp': (bool),\n 'wallet': (bool),\n },\n 'connection_status': {\n 'code': (str) connection status code,\n 'message': (str) connection status message\n },\n 'blockchain_headers': {\n 'downloading_headers': (bool),\n 'download_progress': (float) 0-100.0\n },\n 'wallet': {\n 'blocks': (int) local blockchain height,\n 'blocks_behind': (int) remote_height - local_height,\n 'best_blockhash': (str) block hash of most recent block,\n 'is_encrypted': (bool),\n 'is_locked': (bool),\n },\n 'dht': {\n 'node_id': (str) lbry dht node id - hex encoded,\n 'peers_in_routing_table': (int) the number of peers in the routing table,\n },\n 'blob_manager': {\n 'finished_blobs': (int) number of finished blobs in the blob manager,\n 'connections': {\n 'incoming_bps': {\n <source ip and tcp port>: (int) bytes per second received,\n },\n 'outgoing_bps': {\n <destination ip and tcp port>: (int) bytes per second sent,\n },\n 'total_outgoing_mps': (float) megabytes per second sent,\n 'total_incoming_mps': (float) megabytes per second received,\n 'time': (float) timestamp\n }\n },\n 'hash_announcer': {\n 'announce_queue_size': (int) number of blobs currently queued to be announced\n },\n 'stream_manager': {\n 'managed_files': (int) count of files in the stream manager,\n },\n 'upnp': {\n 'aioupnp_version': (str),\n 'redirects': {\n <TCP | UDP>: (int) external_port,\n },\n 'gateway': (str) manufacturer and model,\n 'dht_redirect_set': (bool),\n 'peer_redirect_set': (bool),\n 'external_ip': (str) external ip address,\n }\n }",
"returns": "(dict) lbrynet-daemon status\n {\n 'installation_id': (str) installation id - base58,\n 'is_running': (bool),\n 'skipped_components': (list) [names of skipped components (str)],\n 'startup_status': { Does not include components which have been skipped\n 'blob_manager': (bool),\n 'blockchain_headers': (bool),\n 'database': (bool),\n 'dht': (bool),\n 'exchange_rate_manager': (bool),\n 'hash_announcer': (bool),\n 'peer_protocol_server': (bool),\n 'stream_manager': (bool),\n 'upnp': (bool),\n 'wallet': (bool),\n },\n 'connection_status': {\n 'code': (str) connection status code,\n 'message': (str) connection status message\n },\n 'blockchain_headers': {\n 'downloading_headers': (bool),\n 'download_progress': (float) 0-100.0\n },\n 'wallet': {\n 'blocks': (int) local blockchain height,\n 'blocks_behind': (int) remote_height - local_height,\n 'best_blockhash': (str) block hash of most recent block,\n 'is_encrypted': (bool),\n 'is_locked': (bool),\n 'connected_servers': (list) [\n {\n 'host': (str) server hostname,\n 'port': (int) server port,\n 'latency': (int) milliseconds\n }\n ],\n },\n 'dht': {\n 'node_id': (str) lbry dht node id - hex encoded,\n 'peers_in_routing_table': (int) the number of peers in the routing table,\n },\n 'blob_manager': {\n 'finished_blobs': (int) number of finished blobs in the blob manager,\n 'connections': {\n 'incoming_bps': {\n <source ip and tcp port>: (int) bytes per second received,\n },\n 'outgoing_bps': {\n <destination ip and tcp port>: (int) bytes per second sent,\n },\n 'total_outgoing_mps': (float) megabytes per second sent,\n 'total_incoming_mps': (float) megabytes per second received,\n 'time': (float) timestamp\n }\n },\n 'hash_announcer': {\n 'announce_queue_size': (int) number of blobs currently queued to be announced\n },\n 'stream_manager': {\n 'managed_files': (int) count of files in the stream manager,\n },\n 'upnp': {\n 'aioupnp_version': (str),\n 'redirects': {\n <TCP | UDP>: (int) external_port,\n },\n 'gateway': (str) manufacturer and model,\n 'dht_redirect_set': (bool),\n 'peer_redirect_set': (bool),\n 'external_ip': (str) external ip address,\n }\n }",
"examples": [
{
"title": "Get status",
"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 \"outgoing_bps\": {},\n \"time\": 174753.638136067,\n \"total_incoming_mbs\": 0.0,\n \"total_outgoing_mbs\": 0.0\n },\n \"finished_blobs\": 0\n },\n \"connection_status\": {\n \"code\": \"connected\",\n \"message\": \"No connection problems detected\"\n },\n \"installation_id\": \"8pS8Qp6ZV2azEgMT9MqurqFyEhGFgtR8L8UEbYbdGnCyvSrWEDU3ND4UZKG2iSzQ1f\",\n \"is_running\": true,\n \"skipped_components\": [\n \"dht\",\n \"upnp\",\n \"hash_announcer\",\n \"peer_protocol_server\"\n ],\n \"startup_status\": {\n \"blob_manager\": true,\n \"blockchain_headers\": true,\n \"database\": true,\n \"exchange_rate_manager\": true,\n \"stream_manager\": true,\n \"wallet\": true\n },\n \"stream_manager\": {\n \"managed_files\": 0\n },\n \"wallet\": {\n \"best_blockhash\": \"c432cf5e38130f7a6611b18078d8a4160c20481122e34b53c6e26e4831bc06c2\",\n \"blocks\": 206,\n \"blocks_behind\": 0,\n \"is_encrypted\": false,\n \"is_locked\": false\n }\n }\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blob_manager\": {\n \"connections\": {\n \"incoming_bps\": {},\n \"outgoing_bps\": {},\n \"time\": 55995.711101459,\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\": \"connected\",\n \"message\": \"No connection problems detected\"\n },\n \"installation_id\": \"7rrw8gej961zecjNyCJ6vFC1vMCZZ1tUsz5cYwrKNHn9VRVHECikd2eC47NZYEP7Bn\",\n \"is_running\": true,\n \"skipped_components\": [\n \"dht\",\n \"upnp\",\n \"hash_announcer\",\n \"peer_protocol_server\"\n ],\n \"startup_status\": {\n \"blob_manager\": true,\n \"blockchain_headers\": true,\n \"database\": true,\n \"exchange_rate_manager\": true,\n \"stream_manager\": true,\n \"wallet\": true\n },\n \"stream_manager\": {\n \"managed_files\": 0\n },\n \"wallet\": {\n \"best_blockhash\": \"4f4b0a8fd77284e1a83a05b9dfca0e5fdc337477caa94bd82239759512e5a27a\",\n \"blocks\": 206,\n \"blocks_behind\": 0,\n \"connected_servers\": [\n {\n \"host\": \"localhost\",\n \"latency\": 0.02,\n \"port\": 50002\n }\n ],\n \"is_encrypted\": false,\n \"is_locked\": false\n }\n }\n}"
}
]
},
@@ -282,7 +288,7 @@
"curl": "curl -d'{\"method\": \"version\", \"params\": {}}' http://localhost:5279/",
"lbrynet": "lbrynet version",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"version\", \"params\": {}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"build\": \"dev\",\n \"desktop\": \"GNOME\",\n \"distro\": {\n \"codename\": \"xenial\",\n \"id\": \"ubuntu\",\n \"like\": \"debian\",\n \"version\": \"16.04\",\n \"version_parts\": {\n \"build_number\": \"\",\n \"major\": \"16\",\n \"minor\": \"04\"\n }\n },\n \"lbrynet_version\": \"0.38.0rc10\",\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.3\",\n \"torba_version\": \"0.5.7\"\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.39.3\",\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.4\",\n \"torba_version\": \"0.5.7\"\n }\n}"
}
]
}
@@ -330,10 +336,10 @@
"examples": [
{
"title": "Add an account from seed",
"curl": "curl -d'{\"method\": \"account_add\", \"params\": {\"account_name\": \"new account\", \"seed\": \"admit whisper prosper true example brown sea sketch clarify pudding hen faith\", \"single_key\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet account add \"new account\" --seed=\"admit whisper prosper true example brown sea sketch clarify pudding hen faith\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_add\", \"params\": {\"account_name\": \"new account\", \"seed\": \"admit whisper prosper true example brown sea sketch clarify pudding hen faith\", \"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\": \"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1561485056.9625015,\n \"name\": \"new account\",\n \"private_key\": \"tprv8ZgxMBicQKsPfK8PpjVn9CX9dQbHu5cRhD6AB8kLNqJf7gckQYNRvtC4xawA34xQ7yQnUHkd6jwHCkZHVuY3s897sKyBHGGGWg8tokKkASU\",\n \"public_key\": \"tpubD6NzVbkrYhZ4YnABiPANYcBGCS7E4QoLGWgwTendo773xAsX2wC27Now8iQZ2kKbSq6GUaSDTV714e3Qxfdwsqh1dnYwbzUboTCqBSZ53gg\",\n \"seed\": \"admit whisper prosper true example brown sea sketch clarify pudding hen faith\"\n }\n}"
"curl": "curl -d'{\"method\": \"account_add\", \"params\": {\"account_name\": \"new account\", \"seed\": \"stadium call taxi myth power method puppy same subject second guess scrub\", \"single_key\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet account add \"new account\" --seed=\"stadium call taxi myth power method puppy same subject second guess scrub\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_add\", \"params\": {\"account_name\": \"new account\", \"seed\": \"stadium call taxi myth power method puppy same subject second guess scrub\", \"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\": \"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1567524459.2594378,\n \"name\": \"new account\",\n \"private_key\": \"tprv8ZgxMBicQKsPecCYqVR6CJDGkdewMmh6YTxdi8Q6P4QUFUYVrc3uBVMnWTe9f2ZAMxMyDQiJ5DZd9bPw1SL6DyPmLRaPJ8KC6LVgVVyWG77\",\n \"public_key\": \"tpubD6NzVbkrYhZ4Y5ELj95gbhsPKfAsX6t17mZQzeSPoLCs5xoGUzsVMyyegZTamKHdJBPEPiK63GSKho6dV4DsfaE7n9LJuifHZZ5BZDUqWiJ\",\n \"seed\": \"stadium call taxi myth power method puppy same subject second guess scrub\"\n }\n}"
}
]
},
@@ -352,23 +358,29 @@
"type": "int",
"description": "Only include transactions with this many confirmed blocks.",
"is_required": false
},
{
"name": "reserved_subtotals",
"type": "bool",
"description": "Include detailed reserved balances on claims, tips and supports.",
"is_required": false
}
],
"returns": "(decimal) amount of lbry credits in wallet",
"examples": [
{
"title": "Get default account balance",
"curl": "curl -d'{\"method\": \"account_balance\", \"params\": {}}' http://localhost:5279/",
"curl": "curl -d'{\"method\": \"account_balance\", \"params\": {\"reserved_subtotals\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet account balance",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_balance\", \"params\": {}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": \"7.999876\"\n}"
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_balance\", \"params\": {\"reserved_subtotals\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"available\": \"7.999876\",\n \"reserved\": \"0.0\",\n \"reserved_subtotals\": null,\n \"total\": \"7.999876\"\n }\n}"
},
{
"title": "Get balance for specific account by id",
"curl": "curl -d'{\"method\": \"account_balance\", \"params\": {\"account_id\": \"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\"}}' http://localhost:5279/",
"lbrynet": "lbrynet account balance \"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_balance\", \"params\": {\"account_id\": \"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": \"2.0\"\n}"
"curl": "curl -d'{\"method\": \"account_balance\", \"params\": {\"account_id\": \"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\", \"reserved_subtotals\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet account balance \"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_balance\", \"params\": {\"account_id\": \"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\", \"reserved_subtotals\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"available\": \"2.0\",\n \"reserved\": \"0.0\",\n \"reserved_subtotals\": null,\n \"total\": \"2.0\"\n }\n}"
}
]
},
@@ -396,7 +408,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\": \"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1561485056.7929218,\n \"name\": \"generated account\",\n \"private_key\": \"tprv8ZgxMBicQKsPfK8PpjVn9CX9dQbHu5cRhD6AB8kLNqJf7gckQYNRvtC4xawA34xQ7yQnUHkd6jwHCkZHVuY3s897sKyBHGGGWg8tokKkASU\",\n \"public_key\": \"tpubD6NzVbkrYhZ4YnABiPANYcBGCS7E4QoLGWgwTendo773xAsX2wC27Now8iQZ2kKbSq6GUaSDTV714e3Qxfdwsqh1dnYwbzUboTCqBSZ53gg\",\n \"seed\": \"admit whisper prosper true example brown sea sketch clarify pudding hen faith\"\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\": \"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1567524459.0664673,\n \"name\": \"generated account\",\n \"private_key\": \"tprv8ZgxMBicQKsPecCYqVR6CJDGkdewMmh6YTxdi8Q6P4QUFUYVrc3uBVMnWTe9f2ZAMxMyDQiJ5DZd9bPw1SL6DyPmLRaPJ8KC6LVgVVyWG77\",\n \"public_key\": \"tpubD6NzVbkrYhZ4Y5ELj95gbhsPKfAsX6t17mZQzeSPoLCs5xoGUzsVMyyegZTamKHdJBPEPiK63GSKho6dV4DsfaE7n9LJuifHZZ5BZDUqWiJ\",\n \"seed\": \"stadium call taxi myth power method puppy same subject second guess scrub\"\n }\n}"
}
]
},
@@ -479,24 +491,24 @@
"examples": [
{
"title": "Transfer 2 LBC from default account to specific account",
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"to_account\": \"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\", \"amount\": \"2.0\", \"everything\": false, \"broadcast\": true}}' http://localhost:5279/",
"lbrynet": "lbrynet account fund --to_account=\"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\" --amount=2.0 --broadcast",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"to_account\": \"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\", \"amount\": \"2.0\", \"everything\": false, \"broadcast\": true}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001c0fc2691a44442cb2c1b48a27518be2ec79230a771ef1a7d1c9ce9b4f293a08f010000006a47304402203f2685e9fa15bd431e61d659e3abbc2d900f2ef04c15c1864456b449c068f55902205505b654acada67b154179f6329516212f9cf3df7fb39636a286121e540f87a80121031370fc0bbc4f99acf402e5d687e846666cc0e5d7467c83104874e238c6ee6d2dffffffff0200c2eb0b000000001976a91469dd5873a711b516c47a0227efda9132a805bb0288ac90d7ae2f000000001976a914ea36761adfb298e01c377eeeb93e3a03874f6de588ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mjnGbmHPAUrnF2VmUqeDAZsSMHWbdmpfJ5\",\n \"amount\": \"10.0\",\n \"confirmations\": 6,\n \"height\": 201,\n \"is_change\": false,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1561485088,\n \"txid\": \"8fa093f2b4e99c1c7d1aef71a73092c72ebe1875a2481b2ccb4244a49126fcc0\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mqAiQYyqiqVWXaEYapnu5P49cnLvQdh11s\",\n \"amount\": \"2.0\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"0e071fe12cfda37fb80dd634afb1a44bcb861e2de16009ad5628cc7f74776634\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"n2sMeyyRYF5btHqQTa8Y5eitMZ6pGEKRoE\",\n \"amount\": \"7.999876\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"0e071fe12cfda37fb80dd634afb1a44bcb861e2de16009ad5628cc7f74776634\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000124\",\n \"total_input\": \"10.0\",\n \"total_output\": \"9.999876\",\n \"txid\": \"0e071fe12cfda37fb80dd634afb1a44bcb861e2de16009ad5628cc7f74776634\"\n }\n}"
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"to_account\": \"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\", \"amount\": \"2.0\", \"everything\": false, \"broadcast\": true}}' http://localhost:5279/",
"lbrynet": "lbrynet account fund --to_account=\"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\" --amount=2.0 --broadcast",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"to_account\": \"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\", \"amount\": \"2.0\", \"everything\": false, \"broadcast\": true}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000012d1508ed14fd8d62d75cdb57eabe66364d3a769b89517299cc2f0eb8e42ab479010000006b483045022100f3a6ef432adc9b3e04a21da7adb15dd035cb8598355801923430a4e0f163693e0220087f7a751a3d368bb9ef92069f686bac41e972ed18632e448693e8418533fef9012102ec6d1f6c1bc6b026357f87f3d6afdeb71fd1e15bc8f2f0752ed1656281aaf4d3ffffffff0200c2eb0b000000001976a9148167e7add764797c9cdc98552e401133a96a932588ac90d7ae2f000000001976a9149b95cc2634f683041cca56112526caeeed97183188ac00000000\",\n \"inputs\": [\n {\n \"address\": \"n4Xag4N3ZDjuhwCLRqifkiSEEQP6PpV36S\",\n \"amount\": \"10.0\",\n \"confirmations\": 6,\n \"height\": 201,\n \"is_change\": false,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1567524490,\n \"txid\": \"79b42ae4b80e2fcc997251899b763a4d3666beea57db5cd7628dfd14ed08152d\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"msKBwFDKRQGiCfXo8QmdDtfen9FcFYfgaQ\",\n \"amount\": \"2.0\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"3e770eda0c2cc8b74e0107e6395fc686a08e022814f55a8153f83fb0f5f923ab\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"muhcUu1j1b5TrfvnsrMJ68CAUA9hahXHZH\",\n \"amount\": \"7.999876\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"3e770eda0c2cc8b74e0107e6395fc686a08e022814f55a8153f83fb0f5f923ab\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000124\",\n \"total_input\": \"10.0\",\n \"total_output\": \"9.999876\",\n \"txid\": \"3e770eda0c2cc8b74e0107e6395fc686a08e022814f55a8153f83fb0f5f923ab\"\n }\n}"
},
{
"title": "Spread LBC between multiple addresses",
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"to_account\": \"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\", \"from_account\": \"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\", \"amount\": \"1.5\", \"everything\": false, \"outputs\": 2, \"broadcast\": true}}' http://localhost:5279/",
"lbrynet": "lbrynet account fund --to_account=\"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\" --from_account=\"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\" --amount=1.5 --outputs=2 --broadcast",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"to_account\": \"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\", \"from_account\": \"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\", \"amount\": \"1.5\", \"everything\": false, \"outputs\": 2, \"broadcast\": true}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001346677747fcc2856ad0960e12d1e86cb4ba4b1af34d60db87fa3fd2ce11f070e000000006b483045022100f03612c9d7c7e011b8f1cb72726cf1f4fb7b9841c0a353df3af355ce299b5ce2022049a9bd4e5c2708c8f13218610b30ad1948e742e6afb892c92ce6577aba44af6001210342bb0577c9c1f33257bcd8bfb791b3cf8f4dae24d37e0a2e17b8a8cc6d446a76ffffffff03c0687804000000001976a9148f7781bf51d1a0f5f75f498ebeb742c0b556cca388acc0687804000000001976a9148f7781bf51d1a0f5f75f498ebeb742c0b556cca388ac6cb9fa02000000001976a91426551ba83e54370b9bfe7e00f950d9b0e63bc40788ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mqAiQYyqiqVWXaEYapnu5P49cnLvQdh11s\",\n \"amount\": \"2.0\",\n \"confirmations\": 1,\n \"height\": 207,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 0,\n \"timestamp\": 1561485089,\n \"txid\": \"0e071fe12cfda37fb80dd634afb1a44bcb861e2de16009ad5628cc7f74776634\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mtbY5xxTz94srMVzLYHZQZvfDGCub8xfTR\",\n \"amount\": \"0.75\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"f3ecdfab319d402d18e3b83ecff474c80b787ac10b79d8542c81ed10040e6202\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mtbY5xxTz94srMVzLYHZQZvfDGCub8xfTR\",\n \"amount\": \"0.75\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"f3ecdfab319d402d18e3b83ecff474c80b787ac10b79d8542c81ed10040e6202\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mj1dvkfJo289BLRNevo2j7kiFsJcYSdQtv\",\n \"amount\": \"0.499859\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 2,\n \"timestamp\": null,\n \"txid\": \"f3ecdfab319d402d18e3b83ecff474c80b787ac10b79d8542c81ed10040e6202\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000141\",\n \"total_input\": \"2.0\",\n \"total_output\": \"1.999859\",\n \"txid\": \"f3ecdfab319d402d18e3b83ecff474c80b787ac10b79d8542c81ed10040e6202\"\n }\n}"
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"to_account\": \"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\", \"from_account\": \"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\", \"amount\": \"1.5\", \"everything\": false, \"outputs\": 2, \"broadcast\": true}}' http://localhost:5279/",
"lbrynet": "lbrynet account fund --to_account=\"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\" --from_account=\"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\" --amount=1.5 --outputs=2 --broadcast",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"to_account\": \"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\", \"from_account\": \"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\", \"amount\": \"1.5\", \"everything\": false, \"outputs\": 2, \"broadcast\": true}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001ab23f9f5b03ff853815af51428028ea086c65f39e607014eb7c82c0cda0e773e000000006a47304402200350e8549f476fe19c82ae814b96f3a3ab245f282010921bf6c8808b8cccba3302204000cf0fdc08420886919665206785fd910fdbd4d72be6325914469912bb0c4301210219ba33f16de9b9f8b551dcd3dc932a174229075302103213a0f83a3c63df7646ffffffff03c0687804000000001976a9140d9b85fa9ecda29ba36b96cddf78b033c469a0fa88acc0687804000000001976a9140d9b85fa9ecda29ba36b96cddf78b033c469a0fa88ac6cb9fa02000000001976a9147e318c3fb101eb541c5e62fe98998ad294cb27f088ac00000000\",\n \"inputs\": [\n {\n \"address\": \"msKBwFDKRQGiCfXo8QmdDtfen9FcFYfgaQ\",\n \"amount\": \"2.0\",\n \"confirmations\": 1,\n \"height\": 207,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 0,\n \"timestamp\": 1567524491,\n \"txid\": \"3e770eda0c2cc8b74e0107e6395fc686a08e022814f55a8153f83fb0f5f923ab\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mgkuPVxE2UwWfLr26kLT1QAEiYScvMohPs\",\n \"amount\": \"0.75\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"a47c8cb42a3920e7fedbf143b6cb3409d16ac85660abf7fc7892804783858f72\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mgkuPVxE2UwWfLr26kLT1QAEiYScvMohPs\",\n \"amount\": \"0.75\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"a47c8cb42a3920e7fedbf143b6cb3409d16ac85660abf7fc7892804783858f72\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"ms2CnsNwPX42NZjkYt3kTF4JfpuSxhmjHj\",\n \"amount\": \"0.499859\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 2,\n \"timestamp\": null,\n \"txid\": \"a47c8cb42a3920e7fedbf143b6cb3409d16ac85660abf7fc7892804783858f72\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000141\",\n \"total_input\": \"2.0\",\n \"total_output\": \"1.999859\",\n \"txid\": \"a47c8cb42a3920e7fedbf143b6cb3409d16ac85660abf7fc7892804783858f72\"\n }\n}"
},
{
"title": "Transfer all LBC to a specified account",
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"from_account\": \"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\", \"everything\": true, \"broadcast\": true}}' http://localhost:5279/",
"lbrynet": "lbrynet account fund --from_account=\"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\" --everything --broadcast",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"from_account\": \"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\", \"everything\": true, \"broadcast\": true}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000302620e0410ed812c54d8790bc17a780bc874f4cf3eb8e3182d409d31abdfecf3000000006a4730440220294fb6a9c2e72a48559546018a47b9809b6203d6557087fcb67836b8912c85dd0220186097a96551a014bfd997884dfaa15b6988adae64b723e5add723727ff1298801210337b6117f3a5fc40820b936e4b228d2576ce2f9a70a91228f71e6a967592572fcffffffff02620e0410ed812c54d8790bc17a780bc874f4cf3eb8e3182d409d31abdfecf3010000006a47304402203e6012c10ce76236b3685202ef4fe9ae6ce24ffd2b7f5648af5ba88d9f3ac56b022009ced72bc1ae82bf89acc2abe0b8e850467dd2814d680fd8a81dffce02a54f0901210337b6117f3a5fc40820b936e4b228d2576ce2f9a70a91228f71e6a967592572fcffffffff02620e0410ed812c54d8790bc17a780bc874f4cf3eb8e3182d409d31abdfecf3020000006b483045022100c75caa1826ede730b253d751ebd2164d40c74fb4724bc7d4d9a200325fefe7e70220262c74bcfacb214aa781d80775e39d35a396c1dda4453ddb470fc6cc0c3fb3c101210296295f9ab2bff497ac1e64d012d45d4d48a8f3bc8e926febacfe1d5e1a9cd01effffffff015027eb0b000000001976a914d15a521046fc425e25444798485573df4d2401ba88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mtbY5xxTz94srMVzLYHZQZvfDGCub8xfTR\",\n \"amount\": \"0.75\",\n \"confirmations\": 1,\n \"height\": 208,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 0,\n \"timestamp\": 1561485089,\n \"txid\": \"f3ecdfab319d402d18e3b83ecff474c80b787ac10b79d8542c81ed10040e6202\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mtbY5xxTz94srMVzLYHZQZvfDGCub8xfTR\",\n \"amount\": \"0.75\",\n \"confirmations\": 1,\n \"height\": 208,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1561485089,\n \"txid\": \"f3ecdfab319d402d18e3b83ecff474c80b787ac10b79d8542c81ed10040e6202\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mj1dvkfJo289BLRNevo2j7kiFsJcYSdQtv\",\n \"amount\": \"0.499859\",\n \"confirmations\": 1,\n \"height\": 208,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 2,\n \"timestamp\": 1561485089,\n \"txid\": \"f3ecdfab319d402d18e3b83ecff474c80b787ac10b79d8542c81ed10040e6202\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mzbuijFAnVGiEKWb9n24hcrUgdxauR3i83\",\n \"amount\": \"1.999604\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"c5e686d1617e9bc0ee1d4d14e1b7f211985db09c839e307a7876b1df1acfd15d\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000255\",\n \"total_input\": \"1.999859\",\n \"total_output\": \"1.999604\",\n \"txid\": \"c5e686d1617e9bc0ee1d4d14e1b7f211985db09c839e307a7876b1df1acfd15d\"\n }\n}"
"curl": "curl -d'{\"method\": \"account_fund\", \"params\": {\"from_account\": \"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\", \"everything\": true, \"broadcast\": true}}' http://localhost:5279/",
"lbrynet": "lbrynet account fund --from_account=\"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\" --everything --broadcast",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_fund\", \"params\": {\"from_account\": \"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\", \"everything\": true, \"broadcast\": true}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000003728f858347809278fcf7ab6056c86ad10934cbb643f1dbfee720392ab48c7ca4000000006a473044022067b37bffa018c7b54e862ce8ea6d3703718adb44a842f7acf3d8f8f38e45bdac02206c528df2c07d2301710935307530b31f6bd0864c135edeaa64246c6a8455645c012102ca78e33e37a6662255c12842d8ac4d89b2a6432f36fe37ab9de5a81f170aa339ffffffff728f858347809278fcf7ab6056c86ad10934cbb643f1dbfee720392ab48c7ca4010000006b483045022100a61a3687a73245222c16bd975518bef97bd6d975dfe5ad3eea0c935198bf1dad02207880a83ff7d52e14ad78f7ce99fa8b11d4940f33ffc6f27907940cc417b4e36b012102ca78e33e37a6662255c12842d8ac4d89b2a6432f36fe37ab9de5a81f170aa339ffffffff728f858347809278fcf7ab6056c86ad10934cbb643f1dbfee720392ab48c7ca4020000006b483045022100f46d51067598e68e9905da461175e1a5b73df742d8e073021226114fe44b772e022005c2f8e881571cbbe112f054ff6856d603b6bf621403ef0f82ea0dda836082940121028724b5be2ae3ba6b54c90e3ad283fcd211763bf81dbf15c97c166130628e3a0fffffffff015027eb0b000000001976a9146f15a545a6b6c030fb255447274e2e996be89f4688ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mgkuPVxE2UwWfLr26kLT1QAEiYScvMohPs\",\n \"amount\": \"0.75\",\n \"confirmations\": 1,\n \"height\": 208,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 0,\n \"timestamp\": 1567524491,\n \"txid\": \"a47c8cb42a3920e7fedbf143b6cb3409d16ac85660abf7fc7892804783858f72\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"mgkuPVxE2UwWfLr26kLT1QAEiYScvMohPs\",\n \"amount\": \"0.75\",\n \"confirmations\": 1,\n \"height\": 208,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1567524491,\n \"txid\": \"a47c8cb42a3920e7fedbf143b6cb3409d16ac85660abf7fc7892804783858f72\",\n \"type\": \"payment\"\n },\n {\n \"address\": \"ms2CnsNwPX42NZjkYt3kTF4JfpuSxhmjHj\",\n \"amount\": \"0.499859\",\n \"confirmations\": 1,\n \"height\": 208,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 2,\n \"timestamp\": 1567524491,\n \"txid\": \"a47c8cb42a3920e7fedbf143b6cb3409d16ac85660abf7fc7892804783858f72\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mqeKEJuCipt8ArNwvnd9Ed2mpdVSKFjFPf\",\n \"amount\": \"1.999604\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"44f8291dfc8ca34a42469e945f4aa86fbab08ec9780dce8f340e6cfb3362442c\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000255\",\n \"total_input\": \"1.999859\",\n \"total_output\": \"1.999604\",\n \"txid\": \"44f8291dfc8ca34a42469e945f4aa86fbab08ec9780dce8f340e6cfb3362442c\"\n }\n}"
}
]
},
@@ -536,7 +548,7 @@
"curl": "curl -d'{\"method\": \"account_list\", \"params\": {\"include_claims\": false, \"show_seed\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet account list",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_list\", \"params\": {\"include_claims\": false, \"show_seed\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"lbc_regtest\": [\n {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 1\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"certificates\": 0,\n \"coins\": 10.0,\n \"encrypted\": false,\n \"id\": \"mvuCTbTWTnF7u2vh3raaxSuR8Rd4hPGqs9\",\n \"is_default\": true,\n \"name\": \"Account #mvuCTbTWTnF7u2vh3raaxSuR8Rd4hPGqs9\",\n \"public_key\": \"tpubD6NzVbkrYhZ4XQhwsZYqxyH3vVf4MHQoiF2xXS2xcmGC2Ejbvq5X7S3onhZhMH7c4pgbJiFPX8C36HWwFgHUaZygQeXKJWsyaAWWzYqWSJm\",\n \"satoshis\": 1000000000\n }\n ]\n }\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"lbc_regtest\": [\n {\n \"address_generator\": {\n \"change\": {\n \"gap\": 6,\n \"maximum_uses_per_address\": 1\n },\n \"name\": \"deterministic-chain\",\n \"receiving\": {\n \"gap\": 20,\n \"maximum_uses_per_address\": 1\n }\n },\n \"certificates\": 0,\n \"coins\": 10.0,\n \"encrypted\": false,\n \"id\": \"mrsZujEBWo4WRGRu1hx6uogoqDiAdbef3b\",\n \"is_default\": true,\n \"name\": \"Account #mrsZujEBWo4WRGRu1hx6uogoqDiAdbef3b\",\n \"preferences\": {\n \"theme\": \"dark\"\n },\n \"public_key\": \"tpubD6NzVbkrYhZ4Wjno2VHeqwKLRQZRWBYQ18z41xq9oPBfRWL76diN4VUBTbUGVEgpXG1pUoD9nDgZszYJLM2uVZAK1tFtke3VXiEmk6BnsD2\",\n \"satoshis\": 1000000000\n }\n ]\n }\n}"
}
]
},
@@ -583,10 +595,10 @@
"examples": [
{
"title": "Remove an account",
"curl": "curl -d'{\"method\": \"account_remove\", \"params\": {\"account_id\": \"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\"}}' http://localhost:5279/",
"lbrynet": "lbrynet account remove mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_remove\", \"params\": {\"account_id\": \"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\"}}).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\": \"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1561485056.7929218,\n \"name\": \"generated account\",\n \"private_key\": \"tprv8ZgxMBicQKsPfK8PpjVn9CX9dQbHu5cRhD6AB8kLNqJf7gckQYNRvtC4xawA34xQ7yQnUHkd6jwHCkZHVuY3s897sKyBHGGGWg8tokKkASU\",\n \"public_key\": \"tpubD6NzVbkrYhZ4YnABiPANYcBGCS7E4QoLGWgwTendo773xAsX2wC27Now8iQZ2kKbSq6GUaSDTV714e3Qxfdwsqh1dnYwbzUboTCqBSZ53gg\",\n \"seed\": \"admit whisper prosper true example brown sea sketch clarify pudding hen faith\"\n }\n}"
"curl": "curl -d'{\"method\": \"account_remove\", \"params\": {\"account_id\": \"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\"}}' http://localhost:5279/",
"lbrynet": "lbrynet account remove mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_remove\", \"params\": {\"account_id\": \"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\"}}).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\": \"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1567524459.0664673,\n \"name\": \"generated account\",\n \"private_key\": \"tprv8ZgxMBicQKsPecCYqVR6CJDGkdewMmh6YTxdi8Q6P4QUFUYVrc3uBVMnWTe9f2ZAMxMyDQiJ5DZd9bPw1SL6DyPmLRaPJ8KC6LVgVVyWG77\",\n \"public_key\": \"tpubD6NzVbkrYhZ4Y5ELj95gbhsPKfAsX6t17mZQzeSPoLCs5xoGUzsVMyyegZTamKHdJBPEPiK63GSKho6dV4DsfaE7n9LJuifHZZ5BZDUqWiJ\",\n \"seed\": \"stadium call taxi myth power method puppy same subject second guess scrub\"\n }\n}"
}
]
},
@@ -661,10 +673,10 @@
"examples": [
{
"title": "Modify maximum number of times a change address can be reused",
"curl": "curl -d'{\"method\": \"account_set\", \"params\": {\"account_id\": \"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\", \"default\": false, \"change_max_uses\": 10}}' http://localhost:5279/",
"lbrynet": "lbrynet account set mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk --change_max_uses=10",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_set\", \"params\": {\"account_id\": \"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\", \"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\": \"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1561485057.0708687,\n \"name\": \"new account\",\n \"private_key\": \"tprv8ZgxMBicQKsPfK8PpjVn9CX9dQbHu5cRhD6AB8kLNqJf7gckQYNRvtC4xawA34xQ7yQnUHkd6jwHCkZHVuY3s897sKyBHGGGWg8tokKkASU\",\n \"public_key\": \"tpubD6NzVbkrYhZ4YnABiPANYcBGCS7E4QoLGWgwTendo773xAsX2wC27Now8iQZ2kKbSq6GUaSDTV714e3Qxfdwsqh1dnYwbzUboTCqBSZ53gg\",\n \"seed\": \"admit whisper prosper true example brown sea sketch clarify pudding hen faith\"\n }\n}"
"curl": "curl -d'{\"method\": \"account_set\", \"params\": {\"account_id\": \"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\", \"default\": false, \"change_max_uses\": 10}}' http://localhost:5279/",
"lbrynet": "lbrynet account set mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa --change_max_uses=10",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"account_set\", \"params\": {\"account_id\": \"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\", \"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\": \"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\",\n \"is_default\": false,\n \"ledger\": \"lbc_regtest\",\n \"modified_on\": 1567524459.3661392,\n \"name\": \"new account\",\n \"private_key\": \"tprv8ZgxMBicQKsPecCYqVR6CJDGkdewMmh6YTxdi8Q6P4QUFUYVrc3uBVMnWTe9f2ZAMxMyDQiJ5DZd9bPw1SL6DyPmLRaPJ8KC6LVgVVyWG77\",\n \"public_key\": \"tpubD6NzVbkrYhZ4Y5ELj95gbhsPKfAsX6t17mZQzeSPoLCs5xoGUzsVMyyegZTamKHdJBPEPiK63GSKho6dV4DsfaE7n9LJuifHZZ5BZDUqWiJ\",\n \"seed\": \"stadium call taxi myth power method puppy same subject second guess scrub\"\n }\n}"
}
]
},
@@ -714,9 +726,9 @@
"examples": [
{
"title": "Check if address is mine",
"curl": "curl -d'{\"method\": \"address_is_mine\", \"params\": {\"address\": \"mzPzDUvLyZUKv2LmQdMZAmd4ZNm1Xxgf1z\"}}' http://localhost:5279/",
"lbrynet": "lbrynet address is_mine mzPzDUvLyZUKv2LmQdMZAmd4ZNm1Xxgf1z",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_is_mine\", \"params\": {\"address\": \"mzPzDUvLyZUKv2LmQdMZAmd4ZNm1Xxgf1z\"}}).json()",
"curl": "curl -d'{\"method\": \"address_is_mine\", \"params\": {\"address\": \"mh1BHTvud83u2YRfdb3PwYS29aVS36cZL7\"}}' http://localhost:5279/",
"lbrynet": "lbrynet address is_mine mh1BHTvud83u2YRfdb3PwYS29aVS36cZL7",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_is_mine\", \"params\": {\"address\": \"mh1BHTvud83u2YRfdb3PwYS29aVS36cZL7\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": true\n}"
}
]
@@ -751,14 +763,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 \"mjnGbmHPAUrnF2VmUqeDAZsSMHWbdmpfJ5\",\n \"mfsQtTpZgv9D1KzkgS6sgevuRD3TDpx4b8\",\n \"mpDcDEwvfvETWqTDhddKLTzZZS2GBQWBqC\",\n \"msaGdm9gRuVwbRPW47pL41hjuiT7xo2vRd\",\n \"n3rBuPQB9qzAha4xU1uHyP5nmvR3WGq3r6\",\n \"n2aKiEgh36nK3xLr4C5vZzvj7hEuMhJWdb\",\n \"mfq8BbdBew1SdWUsK49XT863YobqKVheDy\",\n \"mzPzDUvLyZUKv2LmQdMZAmd4ZNm1Xxgf1z\",\n \"miLhR5kJLGVqi5Ss2VKT2Nxt4fToriqtX2\",\n \"mvrHAPqKaFJUVYXSqQS9MLWN7EHdAWArGJ\",\n \"mzZTN3wcKyqfLHL1bFAgGTqryHrJJshHPV\",\n \"mjgAKEpQjZVjvYsdHoRiucG6HfgTZxbfnD\",\n \"mkMSb7uWUMdGAQ3pnXjDgofyiVibmy2zw2\",\n \"n2ibKtRbM8hdvp5EafkSAHBxbpBJ2CWWEV\",\n \"mkaiNK23LKyWQqUxCYvk8KT1Bf7F5kccBV\",\n \"mr8ttV21zxBiiYeyHtWNfVo3dkgqJ9XtgP\",\n \"mvxcVQv1fJQGkJgCHxpRr15BzqKmTn9Jp2\",\n \"mmDrz35MC54Gqs12sxC48LcSsZiD6GRjvJ\",\n \"mq8DfGaa1vkw89tVaEaEgsQoHnkQdfwXBr\",\n \"mi9uQeFBjKe4EFze4gHvLVm9REepjj2qEm\",\n \"moXzxEEXj4nhGhnozbGGFqGXdEzysbDMHJ\",\n \"mgTdmr4kSe4jjBaQZwE3ar4Kb7XcZBqmZT\",\n \"moLhFf1vkeMKeMG3DAP1RTvbHDqSXha11K\",\n \"n2sMeyyRYF5btHqQTa8Y5eitMZ6pGEKRoE\",\n \"n2FNDLjvbu4dnW6pCtGKJN87PttvCeBWsR\",\n \"mwhWukDANoke2ikBrkj8u3kFdRh5YM2Xv7\",\n \"mzEZcphSw5ZUrEN3MpYmqRCEPBRS8iN34w\"\n ]\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n \"n4Xag4N3ZDjuhwCLRqifkiSEEQP6PpV36S\",\n \"mpXqw4ekUeJnVt4HUVaUosdMRHckFLpJCV\",\n \"mmKg1fn6nmGHvnTWGz68nxRPUZwCYRkAsD\",\n \"mh1BHTvud83u2YRfdb3PwYS29aVS36cZL7\",\n \"mgMzHjZQAVJBJhYMu4VxKM6kR5SLY4gdDD\",\n \"mqwocM9E8dcY9aHCaCGG6HXB8Pd3hA9KjF\",\n \"mg7RyLK5N2dbdPjeWD2fVr4dTcyavw2Ct2\",\n \"myCuq56SrV2pce92Dm3Nzbe6tm9r46tpEE\",\n \"mw6SpJDWJeYTWsr2iEFNEbRuqmNhDjpsZS\",\n \"n1T7bqxpN2a4Jhy2v4D8S5Z9mU3U4vxLCX\",\n \"mqK5dgq7NbPAAuxC9r86xDrtW2fqz52q4X\",\n \"mrTCKDBAm6E2j3hY1paCRtguSvR9YMjavH\",\n \"mjV34bsrCzmSJdrN93jaAWurkc9TaPBEis\",\n \"n4GBt198ctM4KF1AJGJG8ppxAeFyXFfut9\",\n \"mmpdMa9REnAKFcB53jWjbTbLbXwXcXkNd2\",\n \"myLteN944rTScB8AM9NpmA5qbDvnWNXbNY\",\n \"mg5JJDDtptTPX44PiUibpByPeyMr3tmTL8\",\n \"miCcFsZ8btLRMVDh5eS6einqWKvW5Fd6Nw\",\n \"mw9NWnxosCDEqtGZbdw7u9rnVXcXFQLpJk\",\n \"mpwknBXErVReLTFbGUaDYuJeEpdY8hmw5x\",\n \"mqeKEJuCipt8ArNwvnd9Ed2mpdVSKFjFPf\",\n \"mk7Hr34G619JQ1wzFNRun1zWp9c8PLq7ze\",\n \"mvHTTahf6ZHHUJyEMpAXCDRQrvtSq2jAxZ\",\n \"mxHmETLREWiKKZGbekHYJZLYbCVPvZ3kjX\",\n \"mzQFLzaXkTU6oki1wqikNixwngsBuMjQZG\",\n \"muhcUu1j1b5TrfvnsrMJ68CAUA9hahXHZH\",\n \"mfpDwgCS4TpWdAaMJUpgxFkv2Jw78X8MpL\"\n ]\n}"
},
{
"title": "List addresses in specified account",
"curl": "curl -d'{\"method\": \"address_list\", \"params\": {\"account_id\": \"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\"}}' http://localhost:5279/",
"lbrynet": "lbrynet address list --account_id=\"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_list\", \"params\": {\"account_id\": \"mjy1nohNLnCRF9mcGM13RHwm4fPwp6hZDk\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n \"mkZ7dj4b1JzgEk1AbdaEKXRZMc3t1Qzz5s\",\n \"miLfQZNWVqDEDYz5fz2iKU9WryD883bsu3\",\n \"mkTBCWDfCkmBWY3GCxfPzLzv1nPrj42g9i\",\n \"mhxiYAHjBy565rG4utN5N7sqyfNedA8gMj\",\n \"mqAiQYyqiqVWXaEYapnu5P49cnLvQdh11s\",\n \"mfXqWw7JwDTjYS2RFPHQRRidRKh8kBQuDA\",\n \"mveVkYXt4i79j8LyVNmSQJRPbiC3D7qfUn\",\n \"n2FP55ZGxWni8yXXRkayaGtKjjCPgjosUg\",\n \"mjUP3SWW5xSQePxyvBJEojThw53p3stPGz\",\n \"mw9wNMarhPNHJZ3WpVYmQBwwSt6RHkKBaE\",\n \"mh7e4ooAELtxhKjtDLkw2GZMdefM8DSgWT\",\n \"mvQ8JJQ892fZugZNpKcQaTRry75GceWo41\",\n \"mySo8Q8qF66jan5ma2jsvkjjf7BNWyPUo8\",\n \"mppmfdJ3EwHNXRdf4qcEN48TQ2ydE9jjSH\",\n \"mwrS4yFmX5Na1cPRoQUWVBNhEpLh63Bn5j\",\n \"mqY3oET1RoUVT7VQPYjBX2atwbUZ43XSoT\",\n \"moCXqVgoM5EGyoxC9nZL6dkabSjE1TcTNu\",\n \"mvPxFaNfj6Ynp5bmVMtZzPiN27q8AvmmVS\",\n \"mr43PzgGuS1FxCbSjfKNdXsqxZV6hjawt3\",\n \"myuyATCL66mckzXzpiFzcFGQbzdYiQjLdt\",\n \"mrzft5H9sA6crxC7kzEUNBJiWzzAS3wKKH\",\n \"mnUVBfAM4BwEQq8fwJ7xuZgARrqkJwJhLc\",\n \"myvpjybXe9sV9bdAZX5uun7mk9tt8HDFrJ\",\n \"mvWm7QzWcD33rn5VZaQNzvWh89VZGYVpbd\",\n \"mzer6QqsQnsUZKYoCrrqVbQumXajXxbpzJ\",\n \"mhCtYeSBpXoQuEUitEeZjUpjRjje6LZmSL\"\n ]\n}"
"curl": "curl -d'{\"method\": \"address_list\", \"params\": {\"account_id\": \"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\"}}' http://localhost:5279/",
"lbrynet": "lbrynet address list --account_id=\"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"address_list\", \"params\": {\"account_id\": \"mjnSjhq9hseBqH4SdLShwfWsPWmEvnFmBa\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n \"muzvTMwu85wycsEBTiR74My8AjeanjaarL\",\n \"mpipGa36pkDXB1u1XyHCTBFt3PjG8i9cc4\",\n \"ms2CnsNwPX42NZjkYt3kTF4JfpuSxhmjHj\",\n \"msKBwFDKRQGiCfXo8QmdDtfen9FcFYfgaQ\",\n \"mnCnaxRCfSnr8psqX8WeUHXTSrz9VGAcEo\",\n \"mi37PHLrkAoicex47AwsED7qcx15JwVdo7\",\n \"moBknJhYKrmBcGKeTEuL9UQunQfTkAiJ7m\",\n \"n4aN7LF4s3fbCLfncEpLD3BD1Wwqif5uiD\",\n \"mwPoyC91JPq2QmPpiXYjpUDtZDvHP4sbQn\",\n \"mrddwEaQnkvGDggNMskbYUa6menFeKUNoH\",\n \"mygJGMGKC6pydYNG7sLn5bT4PPPXMb8S54\",\n \"miyQCof94kG5bNSK3BSTr4tAkzjVRxhHTM\",\n \"msZvPxSu6kdPwzCdfcbjkDiK4TJuU8Bx4E\",\n \"mmUpT3VvpofQht94ZQJxU8RzgtWAKWVR3z\",\n \"mhqkehtFa9fCsP9u9XF19asaxuj6HCoCFE\",\n \"mi5YkQEetvta42JnM2qS8XtA5Hd5UuxptL\",\n \"mhxK9RYeGNYFFAbrdFzFSR5LLDzS2BsuTn\",\n \"mrBF61TpHevBNkXbUwWcizu37oahG65x2M\",\n \"mqJtXGmoKmrQPKht1qDTXpGRzsisiFzTBD\",\n \"mvjuDoeqvNGyVXUZ5y59tgCz8iCTjsMKkR\",\n \"mvXjURiW7rHjwiBjYBDfEjVHgsRs3U4eua\",\n \"mxq7FS1tMaf8FGV7rH1VssYTQPvjzEYdBu\",\n \"mt5mn8J9eQxnBeDkUEbMpkxLPo1FiRyphT\",\n \"mqhaqAvFqnFdi9JGmfhpyfH43kyJy1q7yp\",\n \"n29guvsCrb6qT4A94kmdogVmcRtn27L9Lh\",\n \"mxiv1v7tdpVE65QHdmVF6KHLtcm1jHx3N9\"\n ]\n}"
}
]
},
@@ -780,7 +792,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\": \"mzPzDUvLyZUKv2LmQdMZAmd4ZNm1Xxgf1z\"\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": \"mh1BHTvud83u2YRfdb3PwYS29aVS36cZL7\"\n}"
}
]
}
@@ -830,10 +842,10 @@
"examples": [
{
"title": "Delete a blob",
"curl": "curl -d'{\"method\": \"blob_delete\", \"params\": {\"blob_hash\": \"d4595a73a829c2a567a25ee1fa7ced42ae4d2d5fccc19126f01b8518537a386b6d20d611b35278afe6a5e193a762cd8c\"}}' http://localhost:5279/",
"lbrynet": "lbrynet blob delete d4595a73a829c2a567a25ee1fa7ced42ae4d2d5fccc19126f01b8518537a386b6d20d611b35278afe6a5e193a762cd8c",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"blob_delete\", \"params\": {\"blob_hash\": \"d4595a73a829c2a567a25ee1fa7ced42ae4d2d5fccc19126f01b8518537a386b6d20d611b35278afe6a5e193a762cd8c\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": \"Deleted d4595a73a829c2a567a25ee1fa7ced42ae4d2d5fccc19126f01b8518537a386b6d20d611b35278afe6a5e193a762cd8c\"\n}"
"curl": "curl -d'{\"method\": \"blob_delete\", \"params\": {\"blob_hash\": \"019de60de1c0e860ae907dfbf13cd4a618a1acb9fb107e09bcaee3a6a7b2165a2a91e740a0fc9d4a4e613a6ed496bc33\"}}' http://localhost:5279/",
"lbrynet": "lbrynet blob delete 019de60de1c0e860ae907dfbf13cd4a618a1acb9fb107e09bcaee3a6a7b2165a2a91e740a0fc9d4a4e613a6ed496bc33",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"blob_delete\", \"params\": {\"blob_hash\": \"019de60de1c0e860ae907dfbf13cd4a618a1acb9fb107e09bcaee3a6a7b2165a2a91e740a0fc9d4a4e613a6ed496bc33\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": \"Deleted 019de60de1c0e860ae907dfbf13cd4a618a1acb9fb107e09bcaee3a6a7b2165a2a91e740a0fc9d4a4e613a6ed496bc33\"\n}"
}
]
},
@@ -911,7 +923,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 \"d4595a73a829c2a567a25ee1fa7ced42ae4d2d5fccc19126f01b8518537a386b6d20d611b35278afe6a5e193a762cd8c\",\n \"609e824398f24b7420f1febfc04e1a237364e4ed00fe46a1e936c3ee4926717e4c86ba66708cb78cb1c0c9d68f488396\",\n \"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"29d60d4ba62d33a280f448584fd825539f794943625101bd633b63b8f83c2e378a62765ca2e1a05dd720e762881519c2\"\n ]\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n \"019de60de1c0e860ae907dfbf13cd4a618a1acb9fb107e09bcaee3a6a7b2165a2a91e740a0fc9d4a4e613a6ed496bc33\",\n \"a0993d23d26f15bd494699edd3a6a37155d9621fe797579a6c12d56147ec17011d869bfbfede8441ee792eadf342a16f\",\n \"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"e15a45f0d4bf7a6e6c1a39202c974d091e4f44530177b27c6cbec7e949db7afa3ec8d713c87621df4fa7dcc896e0e3ab\"\n ]\n}"
}
]
},
@@ -986,10 +998,10 @@
"examples": [
{
"title": "Abandon a channel claim",
"curl": "curl -d'{\"method\": \"channel_abandon\", \"params\": {\"claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\", \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet channel abandon 7ed794458d57978c49572424e1d32c7fa4d5325e",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_abandon\", \"params\": {\"claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\", \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001faa6baadb0eb6080167de2226bab20cffb1426ea2e47f2d696280b9d3256720f000000006a47304402205287bb4f85eeb0f38defe91a27b871ff1b7ac94cda6e9885109f9d5ed6e03939022055dcf9daad53f145f464b8e5f6def71d564f3ebc99f882e1a7b0cd5d022b3e4d0121020cd9a5a73e65c43d276d79901f21b22d09f3872e97a9311ea27908142217f6f7ffffffff0134b7f505000000001976a914d4c63445bfef987db896a7835c90728ab7eb598888ac00000000\",\n \"inputs\": [\n {\n \"address\": \"n3rBuPQB9qzAha4xU1uHyP5nmvR3WGq3r6\",\n \"amount\": \"1.0\",\n \"claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"claim_op\": \"update\",\n \"confirmations\": 8,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"timestamp\": 1561485089,\n \"txid\": \"0f7256329d0b2896d6f2472eea2614fbcf20ab6b22e27d168060ebb0adbaa6fa\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000465bebc31803d2a7f0f037f696665d4d610abea2e518f906410163dec7513fc2b9a82ae0c4a15602f467d4c03823d72cf95c36fc6a87e963356e44db502027ae2\",\n \"public_key_id\": \"mrqYtVaoPEPqgyRPExUPi7PrYJ9nDc59yW\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mzuzzC1LcwKoRaWEZcR2vcDaSxcakKTMR3\",\n \"amount\": \"0.999893\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"1384a1d6010d90d6d463cb63f1fe9b7cc8de70f62f62bf453c5a53cc05d85c22\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000107\",\n \"total_input\": \"1.0\",\n \"total_output\": \"0.999893\",\n \"txid\": \"1384a1d6010d90d6d463cb63f1fe9b7cc8de70f62f62bf453c5a53cc05d85c22\"\n }\n}"
"curl": "curl -d'{\"method\": \"channel_abandon\", \"params\": {\"claim_id\": \"1812d3275894f62a055d59189a75698a071108af\", \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet channel abandon 1812d3275894f62a055d59189a75698a071108af",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_abandon\", \"params\": {\"claim_id\": \"1812d3275894f62a055d59189a75698a071108af\", \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001e76b671b4e9cda4db0eb9558919ebb76aedd164240b34700fe20535a14bf6d98000000006a47304402206086e67b5b3ef2da252bccf728bb3902613130dfee2e69b9cd42e1d51c23462b0220156d8ece8cf7c5b4469584cf6985acbb1fb285b26d4f1f2e69302d7d9a00ca550121026b08677484e71843c5db3ce862355276261d123eaaa5437857daeafeea526930ffffffff0134b7f505000000001976a91489741016527d8e511474fe346d3a54603a173d6588ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mw6SpJDWJeYTWsr2iEFNEbRuqmNhDjpsZS\",\n \"amount\": \"1.0\",\n \"claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"claim_op\": \"update\",\n \"confirmations\": 8,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#1812d3275894f62a055d59189a75698a071108af\",\n \"timestamp\": 1567524491,\n \"txid\": \"986dbf145a5320fe0047b3404216ddae76bb9e915895ebb04dda9c4e1b676be7\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200044974cd9d7098183f8bc9005f3957a4dbfc1ede19044311337fe9f645f256a7a4013c6a142497590bd8461fc50ce6b489453686422079c334bd5f8316b335365e\",\n \"public_key_id\": \"mrne5J4YN1SYYE3qNAAwzEVHAxnZX4AKHp\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mt3juXFNHFPnCydLvtBwmTyAiXzs5joEcn\",\n \"amount\": \"0.999893\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"f0fbc91e74a19e2826aba44d919fd571ded9e8a8918a75e516795e1eb7ab0e88\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000107\",\n \"total_input\": \"1.0\",\n \"total_output\": \"0.999893\",\n \"txid\": \"f0fbc91e74a19e2826aba44d919fd571ded9e8a8918a75e516795e1eb7ab0e88\"\n }\n}"
}
]
},
@@ -1078,7 +1090,13 @@
{
"name": "account_id",
"type": "str",
"description": "id of the account to store channel",
"description": "account to use for holding the transaction",
"is_required": false
},
{
"name": "funding_account_ids",
"type": "list",
"description": "ids of accounts to fund this transaction",
"is_required": false
},
{
@@ -1104,17 +1122,17 @@
"examples": [
{
"title": "Create a channel claim without metadata",
"curl": "curl -d'{\"method\": \"channel_create\", \"params\": {\"name\": \"@channel\", \"bid\": \"1.0\", \"featured\": [], \"tags\": [], \"languages\": [], \"locations\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"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\": [], \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001346677747fcc2856ad0960e12d1e86cb4ba4b1af34d60db87fa3fd2ce11f070e010000006a4730440220183a3e4c2025f45b083bc970e3437fb3deb14891c2f877697c008d0f5ea8f482022049ac41eefb4c6700e39e78175c9c50f8133a2316663ec127cf4fb9d4aa8a30eb012102ca7e8b7efe7723f0a68d28f38c5b220af9e53f1bc2d344fb458ca527da67cf8affffffff0200e1f5050000000084b508406368616e6e656c4c5d00125a0a583056301006072a8648ce3d020106052b8104000a0342000465bebc31803d2a7f0f037f696665d4d610abea2e518f906410163dec7513fc2b9a82ae0c4a15602f467d4c03823d72cf95c36fc6a87e963356e44db502027ae26d7576a914f4f607e8d47646250a79cfc9e57059e6ca8bb56688acc462a029000000001976a91457f3a42422174d5eb185b5bf049869a01db287c988ac00000000\",\n \"inputs\": [\n {\n \"address\": \"n2sMeyyRYF5btHqQTa8Y5eitMZ6pGEKRoE\",\n \"amount\": \"7.999876\",\n \"confirmations\": 2,\n \"height\": 207,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1561485089,\n \"txid\": \"0e071fe12cfda37fb80dd634afb1a44bcb861e2de16009ad5628cc7f74776634\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"n3rBuPQB9qzAha4xU1uHyP5nmvR3WGq3r6\",\n \"amount\": \"1.0\",\n \"claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"timestamp\": null,\n \"txid\": \"50e9f458f59f7ddb51c13e956b178ac9457e00e36bddfe02f6f48079d3e3f896\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000465bebc31803d2a7f0f037f696665d4d610abea2e518f906410163dec7513fc2b9a82ae0c4a15602f467d4c03823d72cf95c36fc6a87e963356e44db502027ae2\",\n \"public_key_id\": \"mrqYtVaoPEPqgyRPExUPi7PrYJ9nDc59yW\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"moXzxEEXj4nhGhnozbGGFqGXdEzysbDMHJ\",\n \"amount\": \"6.983769\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"50e9f458f59f7ddb51c13e956b178ac9457e00e36bddfe02f6f48079d3e3f896\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.016107\",\n \"total_input\": \"7.999876\",\n \"total_output\": \"7.983769\",\n \"txid\": \"50e9f458f59f7ddb51c13e956b178ac9457e00e36bddfe02f6f48079d3e3f896\"\n }\n}"
"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\": \"0100000001ab23f9f5b03ff853815af51428028ea086c65f39e607014eb7c82c0cda0e773e010000006b483045022100fa5029892bd48ce525d38063aa87919c060111d3e8387c8b58df9d8bd15c22de02200a97855e781be63f761008887b2a4a3ff60876bf57fea6590690740fa33458ad01210245c35d292e1b029f82f9cab1749e20a4929e955995bafc33afeae20e4fe78887ffffffff0200e1f5050000000084b508406368616e6e656c4c5d00125a0a583056301006072a8648ce3d020106052b8104000a034200044974cd9d7098183f8bc9005f3957a4dbfc1ede19044311337fe9f645f256a7a4013c6a142497590bd8461fc50ce6b489453686422079c334bd5f8316b335365e6d7576a914aadf6c07f1c7cd225b42ff6abda631b0b102db2888acc462a029000000001976a9149fc8120908ab1812bd462144598da9bc3ffa9d7e88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"muhcUu1j1b5TrfvnsrMJ68CAUA9hahXHZH\",\n \"amount\": \"7.999876\",\n \"confirmations\": 2,\n \"height\": 207,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1567524491,\n \"txid\": \"3e770eda0c2cc8b74e0107e6395fc686a08e022814f55a8153f83fb0f5f923ab\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mw6SpJDWJeYTWsr2iEFNEbRuqmNhDjpsZS\",\n \"amount\": \"1.0\",\n \"claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#1812d3275894f62a055d59189a75698a071108af\",\n \"timestamp\": null,\n \"txid\": \"71075987fae1171cb3e6b0db1dc1ef7635c9ebd6e26e1d510fdce1e4ebb576fa\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200044974cd9d7098183f8bc9005f3957a4dbfc1ede19044311337fe9f645f256a7a4013c6a142497590bd8461fc50ce6b489453686422079c334bd5f8316b335365e\",\n \"public_key_id\": \"mrne5J4YN1SYYE3qNAAwzEVHAxnZX4AKHp\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mv5oQhBhKEBinD1Bs3MKmzznidZSGBN1FG\",\n \"amount\": \"6.983769\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"71075987fae1171cb3e6b0db1dc1ef7635c9ebd6e26e1d510fdce1e4ebb576fa\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.016107\",\n \"total_input\": \"7.999876\",\n \"total_output\": \"7.983769\",\n \"txid\": \"71075987fae1171cb3e6b0db1dc1ef7635c9ebd6e26e1d510fdce1e4ebb576fa\"\n }\n}"
},
{
"title": "Create a channel claim with all metadata",
"curl": "curl -d'{\"method\": \"channel_create\", \"params\": {\"name\": \"@bigchannel\", \"bid\": \"1.0\", \"title\": \"Big Channel\", \"description\": \"A channel with lots of videos.\", \"email\": \"creator@smallmedia.com\", \"website_url\": \"http://smallmedia.com\", \"featured\": [], \"tags\": [\"music\", \"art\"], \"languages\": [\"pt-BR\", \"uk\"], \"locations\": [\"BR\", \"UA::Kiyv\"], \"thumbnail_url\": \"http://smallmedia.com/logo.jpg\", \"cover_url\": \"http://smallmedia.com/logo.jpg\", \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"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\", \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001faa6baadb0eb6080167de2226bab20cffb1426ea2e47f2d696280b9d3256720f010000006a473044022061957aa9e53c7588f10eaf460686fd02ac447f91a5f5fc69b010a509ba7d99d802207be2706dd40cf990811ea5e1484502e29510c8c0d0b2368a79b2c6186f3002c90121039e6825507996b2a26d8f13aa036b7beaf1688dfa8d1323224ce52154183d3164ffffffff0200e1f50500000000fd5001b50b406269676368616e6e656c4d25010012ab010a583056301006072a8648ce3d020106052b8104000a034200042b3464f5e174daad84a899552847c9af4a4577bfc9e867402aa30da9a966ab493f7c82c30642aaa5dcfbdeebe9f3ab021f09964ad93bfecb9b9e3cac7a35c9fe121663726561746f7240736d616c6c6d656469612e636f6d1a15687474703a2f2f736d616c6c6d656469612e636f6d22202a1e687474703a2f2f736d616c6c6d656469612e636f6d2f6c6f676f2e6a7067420b426967204368616e6e656c4a1e41206368616e6e656c2077697468206c6f7473206f6620766964656f732e52202a1e687474703a2f2f736d616c6c6d656469612e636f6d2f6c6f676f2e6a70675a056d757369635a0361727462050883011820620308ab016a0208206a0908e9011a044b6979766d7576a914cf1914f5cdcaf0d0ca01b53b7688dabea5cd9eb388ace221d305000000001976a9147d8fe8303a8d1506e3823e471e55ea128bfe637d88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"n2FNDLjvbu4dnW6pCtGKJN87PttvCeBWsR\",\n \"amount\": \"1.9993355\",\n \"confirmations\": 1,\n \"height\": 210,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1561485089,\n \"txid\": \"0f7256329d0b2896d6f2472eea2614fbcf20ab6b22e27d168060ebb0adbaa6fa\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mzPzDUvLyZUKv2LmQdMZAmd4ZNm1Xxgf1z\",\n \"amount\": \"1.0\",\n \"claim_id\": \"9d667ca2325a93dfbab993f4e22f63ce529eae92\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"@bigchannel\",\n \"normalized_name\": \"@bigchannel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@bigchannel#9d667ca2325a93dfbab993f4e22f63ce529eae92\",\n \"timestamp\": null,\n \"txid\": \"aa003b09c9a280b34d3d790f7bca3a12a7b8f0473f476cc7bc81b3853acb8ab4\",\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\": \"3056301006072a8648ce3d020106052b8104000a034200042b3464f5e174daad84a899552847c9af4a4577bfc9e867402aa30da9a966ab493f7c82c30642aaa5dcfbdeebe9f3ab021f09964ad93bfecb9b9e3cac7a35c9fe\",\n \"public_key_id\": \"mxN41g7KAmKtMbA1b25XgVWASvYVvKEcVW\",\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\": \"mrxs9s9nJgdvS6qW2ca4yr5UY6RkWS5zk9\",\n \"amount\": \"0.9772285\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"aa003b09c9a280b34d3d790f7bca3a12a7b8f0473f476cc7bc81b3853acb8ab4\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.022107\",\n \"total_input\": \"1.9993355\",\n \"total_output\": \"1.9772285\",\n \"txid\": \"aa003b09c9a280b34d3d790f7bca3a12a7b8f0473f476cc7bc81b3853acb8ab4\"\n }\n}"
"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\": \"0100000001e76b671b4e9cda4db0eb9558919ebb76aedd164240b34700fe20535a14bf6d98010000006b483045022100f682c30b7e11d75a7c8003a0cf960225084bc0848dd1b87b9bcb5943df7cc89a02206eeb81a9d82041bc002938de734054e5bfbc0449ea595d047d830022815fcceb012102f468240028c0200dd91d0471061d20b84380888f5bc5e025512c710867053b4dffffffff0200e1f50500000000fd5001b50b406269676368616e6e656c4d25010012ab010a583056301006072a8648ce3d020106052b8104000a03420004af3f67b2c8c268546ddc740380fcea6dd60eadec5cb2fd081ec1d59bad5c8f94556d94f5b96f116459fe476de5597fbc9641f37751743d17fe33b213513bc658121663726561746f7240736d616c6c6d656469612e636f6d1a15687474703a2f2f736d616c6c6d656469612e636f6d22202a1e687474703a2f2f736d616c6c6d656469612e636f6d2f6c6f676f2e6a7067420b426967204368616e6e656c4a1e41206368616e6e656c2077697468206c6f7473206f6620766964656f732e52202a1e687474703a2f2f736d616c6c6d656469612e636f6d2f6c6f676f2e6a70675a056d757369635a0361727462050883011820620308ab016a0208206a0908e9011a044b6979766d7576a91462e43cc42aaf50122b0b822c72e92df47752382488ace221d305000000001976a914c2d853ebfe9374f515d77fcc99fa3a4720dcd9d288ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mvHTTahf6ZHHUJyEMpAXCDRQrvtSq2jAxZ\",\n \"amount\": \"1.9993355\",\n \"confirmations\": 1,\n \"height\": 210,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1567524491,\n \"txid\": \"986dbf145a5320fe0047b3404216ddae76bb9e915895ebb04dda9c4e1b676be7\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mpXqw4ekUeJnVt4HUVaUosdMRHckFLpJCV\",\n \"amount\": \"1.0\",\n \"claim_id\": \"70be52d169e5debb0021317540fc7bc941af02dc\",\n \"claim_op\": \"create\",\n \"confirmations\": -2,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"@bigchannel\",\n \"normalized_name\": \"@bigchannel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@bigchannel#70be52d169e5debb0021317540fc7bc941af02dc\",\n \"timestamp\": null,\n \"txid\": \"9b92799eb906956b01458dd97ace5e02f3c201a1c67089dc694b11caa77fedbd\",\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\": \"3056301006072a8648ce3d020106052b8104000a03420004af3f67b2c8c268546ddc740380fcea6dd60eadec5cb2fd081ec1d59bad5c8f94556d94f5b96f116459fe476de5597fbc9641f37751743d17fe33b213513bc658\",\n \"public_key_id\": \"n34uW64WnxJnnr9n6PWsHrzpQf2Qg8jV1h\",\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\": \"myHCXzM5bmTxED6Tyc9WcLhGsP1u8M9Wfo\",\n \"amount\": \"0.9772285\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"9b92799eb906956b01458dd97ace5e02f3c201a1c67089dc694b11caa77fedbd\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.022107\",\n \"total_input\": \"1.9993355\",\n \"total_output\": \"1.9772285\",\n \"txid\": \"9b92799eb906956b01458dd97ace5e02f3c201a1c67089dc694b11caa77fedbd\"\n }\n}"
}
]
},
@@ -1188,14 +1206,14 @@
"curl": "curl -d'{\"method\": \"channel_list\", \"params\": {}}' http://localhost:5279/",
"lbrynet": "lbrynet channel list",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_list\", \"params\": {}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"address\": \"n3rBuPQB9qzAha4xU1uHyP5nmvR3WGq3r6\",\n \"amount\": \"1.0\",\n \"claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"height\": 209,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"timestamp\": 1561485089,\n \"txid\": \"50e9f458f59f7ddb51c13e956b178ac9457e00e36bddfe02f6f48079d3e3f896\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000465bebc31803d2a7f0f037f696665d4d610abea2e518f906410163dec7513fc2b9a82ae0c4a15602f467d4c03823d72cf95c36fc6a87e963356e44db502027ae2\",\n \"public_key_id\": \"mrqYtVaoPEPqgyRPExUPi7PrYJ9nDc59yW\"\n },\n \"value_type\": \"channel\"\n }\n ]\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"address\": \"mw6SpJDWJeYTWsr2iEFNEbRuqmNhDjpsZS\",\n \"amount\": \"1.0\",\n \"claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"height\": 209,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#1812d3275894f62a055d59189a75698a071108af\",\n \"timestamp\": 1567524491,\n \"txid\": \"71075987fae1171cb3e6b0db1dc1ef7635c9ebd6e26e1d510fdce1e4ebb576fa\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200044974cd9d7098183f8bc9005f3957a4dbfc1ede19044311337fe9f645f256a7a4013c6a142497590bd8461fc50ce6b489453686422079c334bd5f8316b335365e\",\n \"public_key_id\": \"mrne5J4YN1SYYE3qNAAwzEVHAxnZX4AKHp\"\n },\n \"value_type\": \"channel\"\n }\n ]\n}"
},
{
"title": "Paginate your channel claims",
"curl": "curl -d'{\"method\": \"channel_list\", \"params\": {\"page\": 1, \"page_size\": 20}}' http://localhost:5279/",
"lbrynet": "lbrynet channel list --page=1 --page_size=20",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_list\", \"params\": {\"page\": 1, \"page_size\": 20}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"n3rBuPQB9qzAha4xU1uHyP5nmvR3WGq3r6\",\n \"amount\": \"1.0\",\n \"claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"height\": 209,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"timestamp\": 1561485089,\n \"txid\": \"50e9f458f59f7ddb51c13e956b178ac9457e00e36bddfe02f6f48079d3e3f896\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000465bebc31803d2a7f0f037f696665d4d610abea2e518f906410163dec7513fc2b9a82ae0c4a15602f467d4c03823d72cf95c36fc6a87e963356e44db502027ae2\",\n \"public_key_id\": \"mrqYtVaoPEPqgyRPExUPi7PrYJ9nDc59yW\"\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\": \"mw6SpJDWJeYTWsr2iEFNEbRuqmNhDjpsZS\",\n \"amount\": \"1.0\",\n \"claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"height\": 209,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#1812d3275894f62a055d59189a75698a071108af\",\n \"timestamp\": 1567524491,\n \"txid\": \"71075987fae1171cb3e6b0db1dc1ef7635c9ebd6e26e1d510fdce1e4ebb576fa\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200044974cd9d7098183f8bc9005f3957a4dbfc1ede19044311337fe9f645f256a7a4013c6a142497590bd8461fc50ce6b489453686422079c334bd5f8316b335365e\",\n \"public_key_id\": \"mrne5J4YN1SYYE3qNAAwzEVHAxnZX4AKHp\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
}
]
},
@@ -1302,7 +1320,13 @@
{
"name": "account_id",
"type": "str",
"description": "id of the account to store channel",
"description": "account to use for holding the transaction",
"is_required": false
},
{
"name": "funding_account_ids",
"type": "list",
"description": "ids of accounts to fund this transaction",
"is_required": false
},
{
@@ -1340,10 +1364,10 @@
"examples": [
{
"title": "Update a channel claim",
"curl": "curl -d'{\"method\": \"channel_update\", \"params\": {\"claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\", \"title\": \"New Channel\", \"featured\": [], \"clear_featured\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"new_signing_key\": false, \"preview\": false, \"blocking\": false, \"replace\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet channel update 7ed794458d57978c49572424e1d32c7fa4d5325e --title=\"New Channel\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_update\", \"params\": {\"claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\", \"title\": \"New Channel\", \"featured\": [], \"clear_featured\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"new_signing_key\": false, \"preview\": false, \"blocking\": false, \"replace\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000296f8e3d37980f4f602fedd6be3007e45c98a176b953ec151db7d9ff558f4e950000000006a473044022061d6150bc3b011aaea76878575017c4e5eb21fac6b8a4cbbee9c085bd33587d50220488279fbf29cc4cbbedf4203082a16ae48b966181fea88d5d30e3627f28811730121020cd9a5a73e65c43d276d79901f21b22d09f3872e97a9311ea27908142217f6f7ffffffff5dd1cf1adfb176787a309e839cb05d9811f2b7e1144d1deec09b7e61d186e6c5000000006a47304402205b253336e35c39d7bee5e39508281043e4b463cf1ad1f76dc244ee869ef185b502205891abd1fa4c637b43ae19dde8857e9fb09627a173e84ba6bd96dfc1d154a087012103398d533373ab8881bb7a9e1060284ce9afd4e25fcca09d30fcf41da9b809ff11ffffffff0200e1f50500000000a6b708406368616e6e656c145e32d5a47f2cd3e1242457498c97578d4594d77e4c6a00125a0a583056301006072a8648ce3d020106052b8104000a0342000465bebc31803d2a7f0f037f696665d4d610abea2e518f906410163dec7513fc2b9a82ae0c4a15602f467d4c03823d72cf95c36fc6a87e963356e44db502027ae2420b4e6577204368616e6e656c6d6d76a914f4f607e8d47646250a79cfc9e57059e6ca8bb56688ac6ebeea0b000000001976a914e367f3d29e8b54f79c92ec2cf83a79ca5e04c60688ac00000000\",\n \"inputs\": [\n {\n \"address\": \"n3rBuPQB9qzAha4xU1uHyP5nmvR3WGq3r6\",\n \"amount\": \"1.0\",\n \"claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"height\": 209,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"timestamp\": 1561485089,\n \"txid\": \"50e9f458f59f7ddb51c13e956b178ac9457e00e36bddfe02f6f48079d3e3f896\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000465bebc31803d2a7f0f037f696665d4d610abea2e518f906410163dec7513fc2b9a82ae0c4a15602f467d4c03823d72cf95c36fc6a87e963356e44db502027ae2\",\n \"public_key_id\": \"mrqYtVaoPEPqgyRPExUPi7PrYJ9nDc59yW\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mzbuijFAnVGiEKWb9n24hcrUgdxauR3i83\",\n \"amount\": \"1.999604\",\n \"confirmations\": 1,\n \"height\": 209,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 0,\n \"timestamp\": 1561485089,\n \"txid\": \"c5e686d1617e9bc0ee1d4d14e1b7f211985db09c839e307a7876b1df1acfd15d\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"n3rBuPQB9qzAha4xU1uHyP5nmvR3WGq3r6\",\n \"amount\": \"1.0\",\n \"claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"claim_op\": \"update\",\n \"confirmations\": -2,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"timestamp\": null,\n \"txid\": \"0f7256329d0b2896d6f2472eea2614fbcf20ab6b22e27d168060ebb0adbaa6fa\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000465bebc31803d2a7f0f037f696665d4d610abea2e518f906410163dec7513fc2b9a82ae0c4a15602f467d4c03823d72cf95c36fc6a87e963356e44db502027ae2\",\n \"public_key_id\": \"mrqYtVaoPEPqgyRPExUPi7PrYJ9nDc59yW\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"n2FNDLjvbu4dnW6pCtGKJN87PttvCeBWsR\",\n \"amount\": \"1.9993355\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"0f7256329d0b2896d6f2472eea2614fbcf20ab6b22e27d168060ebb0adbaa6fa\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.0002685\",\n \"total_input\": \"2.999604\",\n \"total_output\": \"2.9993355\",\n \"txid\": \"0f7256329d0b2896d6f2472eea2614fbcf20ab6b22e27d168060ebb0adbaa6fa\"\n }\n}"
"curl": "curl -d'{\"method\": \"channel_update\", \"params\": {\"claim_id\": \"1812d3275894f62a055d59189a75698a071108af\", \"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 1812d3275894f62a055d59189a75698a071108af --title=\"New Channel\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"channel_update\", \"params\": {\"claim_id\": \"1812d3275894f62a055d59189a75698a071108af\", \"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\": \"0100000002fa76b5ebe4e1dc0f511d6ee2d6ebc93576efc11ddbb0e6b31c17e1fa87590771000000006b483045022100c66ff055a275b9217ef363ae87ffda7ef44986bef685cec8d2ccafbbc367160e02206c191c13d228d516854537915a2101dee9065ed364c17437fc6a9aa8fb1421e70121026b08677484e71843c5db3ce862355276261d123eaaa5437857daeafeea526930ffffffff2c446233fb6c0e348fce0d78c98eb0ba6fa84a5f949e46424aa38cfc1d29f844000000006a47304402206956d6778c51de7306fb9e924ff8f58e2401517290ed64cb2e6c46b8a7bb69f902205c1375c4c0a8411db6a415a4950ec433410c01985c1ca7cbfb0de7145368aa50012102dface3eea48cf6ad620818099a453434adbf56c152268e680f23666d55ce2ac3ffffffff0200e1f50500000000a6b708406368616e6e656c14af0811078a69759a18595d052af6945827d312184c6a00125a0a583056301006072a8648ce3d020106052b8104000a034200044974cd9d7098183f8bc9005f3957a4dbfc1ede19044311337fe9f645f256a7a4013c6a142497590bd8461fc50ce6b489453686422079c334bd5f8316b335365e420b4e6577204368616e6e656c6d6d76a914aadf6c07f1c7cd225b42ff6abda631b0b102db2888ac6ebeea0b000000001976a914a1fc688cf5f6899e6342e463d72eca70f73b973388ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mw6SpJDWJeYTWsr2iEFNEbRuqmNhDjpsZS\",\n \"amount\": \"1.0\",\n \"claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"height\": 209,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#1812d3275894f62a055d59189a75698a071108af\",\n \"timestamp\": 1567524491,\n \"txid\": \"71075987fae1171cb3e6b0db1dc1ef7635c9ebd6e26e1d510fdce1e4ebb576fa\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200044974cd9d7098183f8bc9005f3957a4dbfc1ede19044311337fe9f645f256a7a4013c6a142497590bd8461fc50ce6b489453686422079c334bd5f8316b335365e\",\n \"public_key_id\": \"mrne5J4YN1SYYE3qNAAwzEVHAxnZX4AKHp\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mqeKEJuCipt8ArNwvnd9Ed2mpdVSKFjFPf\",\n \"amount\": \"1.999604\",\n \"confirmations\": 1,\n \"height\": 209,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 0,\n \"timestamp\": 1567524491,\n \"txid\": \"44f8291dfc8ca34a42469e945f4aa86fbab08ec9780dce8f340e6cfb3362442c\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mw6SpJDWJeYTWsr2iEFNEbRuqmNhDjpsZS\",\n \"amount\": \"1.0\",\n \"claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"claim_op\": \"update\",\n \"confirmations\": -2,\n \"height\": -2,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#1812d3275894f62a055d59189a75698a071108af\",\n \"timestamp\": null,\n \"txid\": \"986dbf145a5320fe0047b3404216ddae76bb9e915895ebb04dda9c4e1b676be7\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200044974cd9d7098183f8bc9005f3957a4dbfc1ede19044311337fe9f645f256a7a4013c6a142497590bd8461fc50ce6b489453686422079c334bd5f8316b335365e\",\n \"public_key_id\": \"mrne5J4YN1SYYE3qNAAwzEVHAxnZX4AKHp\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n {\n \"address\": \"mvHTTahf6ZHHUJyEMpAXCDRQrvtSq2jAxZ\",\n \"amount\": \"1.9993355\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"986dbf145a5320fe0047b3404216ddae76bb9e915895ebb04dda9c4e1b676be7\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.0002685\",\n \"total_input\": \"2.999604\",\n \"total_output\": \"2.9993355\",\n \"txid\": \"986dbf145a5320fe0047b3404216ddae76bb9e915895ebb04dda9c4e1b676be7\"\n }\n}"
}
]
}
@@ -1382,14 +1406,14 @@
"curl": "curl -d'{\"method\": \"claim_list\", \"params\": {}}' http://localhost:5279/",
"lbrynet": "lbrynet claim list",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_list\", \"params\": {}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"address\": \"mpDcDEwvfvETWqTDhddKLTzZZS2GBQWBqC\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_change\": false,\n \"is_channel_signature_valid\": true,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#5d64500fb723eded83a41b0d5055f1783f019191\",\n \"signing_channel\": {\n \"address\": \"n3rBuPQB9qzAha4xU1uHyP5nmvR3WGq3r6\",\n \"amount\": \"1.0\",\n \"claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"timestamp\": 1561485089,\n \"txid\": \"0f7256329d0b2896d6f2472eea2614fbcf20ab6b22e27d168060ebb0adbaa6fa\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000465bebc31803d2a7f0f037f696665d4d610abea2e518f906410163dec7513fc2b9a82ae0c4a15602f467d4c03823d72cf95c36fc6a87e963356e44db502027ae2\",\n \"public_key_id\": \"mrqYtVaoPEPqgyRPExUPi7PrYJ9nDc59yW\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1561485090,\n \"txid\": \"dac2f1adaf5debd8cb377673b35ee4e6eb62ba7747b4440ffdb44d6875c2197e\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpzj1qbxfj\",\n \"sd_hash\": \"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"n3rBuPQB9qzAha4xU1uHyP5nmvR3WGq3r6\",\n \"amount\": \"1.0\",\n \"claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"timestamp\": 1561485089,\n \"txid\": \"0f7256329d0b2896d6f2472eea2614fbcf20ab6b22e27d168060ebb0adbaa6fa\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000465bebc31803d2a7f0f037f696665d4d610abea2e518f906410163dec7513fc2b9a82ae0c4a15602f467d4c03823d72cf95c36fc6a87e963356e44db502027ae2\",\n \"public_key_id\": \"mrqYtVaoPEPqgyRPExUPi7PrYJ9nDc59yW\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n }\n ]\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"address\": \"mqwocM9E8dcY9aHCaCGG6HXB8Pd3hA9KjF\",\n \"amount\": \"1.0\",\n \"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_change\": false,\n \"is_channel_signature_valid\": true,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\n \"signing_channel\": {\n \"address\": \"mw6SpJDWJeYTWsr2iEFNEbRuqmNhDjpsZS\",\n \"amount\": \"1.0\",\n \"claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#1812d3275894f62a055d59189a75698a071108af\",\n \"timestamp\": 1567524491,\n \"txid\": \"986dbf145a5320fe0047b3404216ddae76bb9e915895ebb04dda9c4e1b676be7\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200044974cd9d7098183f8bc9005f3957a4dbfc1ede19044311337fe9f645f256a7a4013c6a142497590bd8461fc50ce6b489453686422079c334bd5f8316b335365e\",\n \"public_key_id\": \"mrne5J4YN1SYYE3qNAAwzEVHAxnZX4AKHp\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1567524492,\n \"txid\": \"f3338742c2b4cf0e35b7ffa73aea3e9da786926cf82f07d3100e09d04ec3f231\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpmjego0ff\",\n \"sd_hash\": \"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mw6SpJDWJeYTWsr2iEFNEbRuqmNhDjpsZS\",\n \"amount\": \"1.0\",\n \"claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#1812d3275894f62a055d59189a75698a071108af\",\n \"timestamp\": 1567524491,\n \"txid\": \"986dbf145a5320fe0047b3404216ddae76bb9e915895ebb04dda9c4e1b676be7\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200044974cd9d7098183f8bc9005f3957a4dbfc1ede19044311337fe9f645f256a7a4013c6a142497590bd8461fc50ce6b489453686422079c334bd5f8316b335365e\",\n \"public_key_id\": \"mrne5J4YN1SYYE3qNAAwzEVHAxnZX4AKHp\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n }\n ]\n}"
},
{
"title": "Paginate your claims",
"curl": "curl -d'{\"method\": \"claim_list\", \"params\": {\"page\": 1, \"page_size\": 20}}' http://localhost:5279/",
"lbrynet": "lbrynet claim list --page=1 --page_size=20",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_list\", \"params\": {\"page\": 1, \"page_size\": 20}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mpDcDEwvfvETWqTDhddKLTzZZS2GBQWBqC\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_change\": false,\n \"is_channel_signature_valid\": true,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#5d64500fb723eded83a41b0d5055f1783f019191\",\n \"signing_channel\": {\n \"address\": \"n3rBuPQB9qzAha4xU1uHyP5nmvR3WGq3r6\",\n \"amount\": \"1.0\",\n \"claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"timestamp\": 1561485089,\n \"txid\": \"0f7256329d0b2896d6f2472eea2614fbcf20ab6b22e27d168060ebb0adbaa6fa\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000465bebc31803d2a7f0f037f696665d4d610abea2e518f906410163dec7513fc2b9a82ae0c4a15602f467d4c03823d72cf95c36fc6a87e963356e44db502027ae2\",\n \"public_key_id\": \"mrqYtVaoPEPqgyRPExUPi7PrYJ9nDc59yW\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1561485090,\n \"txid\": \"dac2f1adaf5debd8cb377673b35ee4e6eb62ba7747b4440ffdb44d6875c2197e\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpzj1qbxfj\",\n \"sd_hash\": \"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"n3rBuPQB9qzAha4xU1uHyP5nmvR3WGq3r6\",\n \"amount\": \"1.0\",\n \"claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"timestamp\": 1561485089,\n \"txid\": \"0f7256329d0b2896d6f2472eea2614fbcf20ab6b22e27d168060ebb0adbaa6fa\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000465bebc31803d2a7f0f037f696665d4d610abea2e518f906410163dec7513fc2b9a82ae0c4a15602f467d4c03823d72cf95c36fc6a87e963356e44db502027ae2\",\n \"public_key_id\": \"mrqYtVaoPEPqgyRPExUPi7PrYJ9nDc59yW\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n }\n ],\n \"page\": 1,\n \"page_size\": 20,\n \"total_items\": 2,\n \"total_pages\": 1\n }\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mqwocM9E8dcY9aHCaCGG6HXB8Pd3hA9KjF\",\n \"amount\": \"1.0\",\n \"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_change\": false,\n \"is_channel_signature_valid\": true,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\n \"signing_channel\": {\n \"address\": \"mw6SpJDWJeYTWsr2iEFNEbRuqmNhDjpsZS\",\n \"amount\": \"1.0\",\n \"claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#1812d3275894f62a055d59189a75698a071108af\",\n \"timestamp\": 1567524491,\n \"txid\": \"986dbf145a5320fe0047b3404216ddae76bb9e915895ebb04dda9c4e1b676be7\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200044974cd9d7098183f8bc9005f3957a4dbfc1ede19044311337fe9f645f256a7a4013c6a142497590bd8461fc50ce6b489453686422079c334bd5f8316b335365e\",\n \"public_key_id\": \"mrne5J4YN1SYYE3qNAAwzEVHAxnZX4AKHp\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1567524492,\n \"txid\": \"f3338742c2b4cf0e35b7ffa73aea3e9da786926cf82f07d3100e09d04ec3f231\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpmjego0ff\",\n \"sd_hash\": \"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mw6SpJDWJeYTWsr2iEFNEbRuqmNhDjpsZS\",\n \"amount\": \"1.0\",\n \"claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#1812d3275894f62a055d59189a75698a071108af\",\n \"timestamp\": 1567524491,\n \"txid\": \"986dbf145a5320fe0047b3404216ddae76bb9e915895ebb04dda9c4e1b676be7\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200044974cd9d7098183f8bc9005f3957a4dbfc1ede19044311337fe9f645f256a7a4013c6a142497590bd8461fc50ce6b489453686422079c334bd5f8316b335365e\",\n \"public_key_id\": \"mrne5J4YN1SYYE3qNAAwzEVHAxnZX4AKHp\",\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}"
}
]
},
@@ -1429,13 +1453,13 @@
},
{
"name": "channel_ids",
"type": "str",
"type": "list",
"description": "claims signed by any of these channels (arguments must be claim ids of the channels), includes claims with invalid signatures, implies --has_channel_signature, use in conjunction with --valid_channel_signature",
"is_required": false
},
{
"name": "not_channel_ids",
"type": "str",
"type": "list",
"description": "exclude claims signed by any of these channels (arguments must be claim ids of the channels)",
"is_required": false
},
@@ -1651,9 +1675,15 @@
},
{
"name": "order_by",
"type": "str",
"type": "list",
"description": "field to order by, default is descending order, to do an ascending order prepend ^ to the field name, eg. '^amount' available fields: 'name', 'height', 'release_time', 'publish_time', 'amount', 'effective_amount', 'support_amount', 'trending_group', 'trending_mixed', 'trending_local', 'trending_global', 'activation_height'",
"is_required": false
},
{
"name": "no_totals",
"type": "bool",
"description": "do not calculate the total number of pages and items in result set (significant performance boost)",
"is_required": false
}
],
"returns": " {\n \"page\": \"Page number of the current items.\",\n \"page_size\": \"Number of items to show on a page.\",\n \"total_pages\": \"Total number of pages.\",\n \"total_items\": \"Total number of items.\",\n \"items\": [\n {\n \"txid\": \"hash of transaction in hex\",\n \"nout\": \"position in the transaction\",\n \"height\": \"block where transaction was recorded\",\n \"amount\": \"value of the txo as a decimal\",\n \"address\": \"address of who can spend the txo\",\n \"confirmations\": \"number of confirmed blocks\",\n \"is_change\": \"payment to change address, only available when it can be determined\",\n \"is_mine\": \"payment to one of your accounts, only available when it can be determined\",\n \"type\": \"one of 'claim', 'support' or 'payment'\",\n \"name\": \"when type is 'claim' or 'support', this is the claim name\",\n \"claim_id\": \"when type is 'claim' or 'support', this is the claim id\",\n \"claim_op\": \"when type is 'claim', this determines if it is 'create' or 'update'\",\n \"value\": \"when type is 'claim' or 'support' with payload, this is the decoded protobuf payload\",\n \"value_type\": \"determines the type of the 'value' field: 'channel', 'stream', etc\",\n \"protobuf\": \"hex encoded raw protobuf version of 'value' field\",\n \"permanent_url\": \"when type is 'claim' or 'support', this is the long permanent claim URL\",\n \"signing_channel\": \"for signed claims only, metadata of signing channel\",\n \"is_channel_signature_valid\": \"for signed claims only, whether signature is valid\"\n }\n ]\n }",
@@ -1663,22 +1693,36 @@
"curl": "curl -d'{\"method\": \"claim_search\", \"params\": {\"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\": []}}' http://localhost:5279/",
"lbrynet": "lbrynet claim search --channel=@channel",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_search\", \"params\": {\"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\": []}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mpDcDEwvfvETWqTDhddKLTzZZS2GBQWBqC\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#7/astream#5\",\n \"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\",\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\": 1561485090,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263187,\n \"is_controlling\": true,\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#5d64500fb723eded83a41b0d5055f1783f019191\",\n \"short_url\": \"lbry://astream#5\",\n \"signing_channel\": {\n \"address\": \"n3rBuPQB9qzAha4xU1uHyP5nmvR3WGq3r6\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#7\",\n \"claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 209,\n \"claims_in_channel\": 1,\n \"creation_height\": 209,\n \"creation_timestamp\": 1561485089,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263183,\n \"is_controlling\": true,\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#7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"short_url\": \"lbry://@channel#7\",\n \"timestamp\": 1561485089,\n \"txid\": \"0f7256329d0b2896d6f2472eea2614fbcf20ab6b22e27d168060ebb0adbaa6fa\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000465bebc31803d2a7f0f037f696665d4d610abea2e518f906410163dec7513fc2b9a82ae0c4a15602f467d4c03823d72cf95c36fc6a87e963356e44db502027ae2\",\n \"public_key_id\": \"mrqYtVaoPEPqgyRPExUPi7PrYJ9nDc59yW\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1561485090,\n \"txid\": \"dac2f1adaf5debd8cb377673b35ee4e6eb62ba7747b4440ffdb44d6875c2197e\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpzj1qbxfj\",\n \"sd_hash\": \"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"page\": 1,\n \"page_size\": 10,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mqwocM9E8dcY9aHCaCGG6HXB8Pd3hA9KjF\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#1/astream#b\",\n \"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\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\": 1567524492,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263187,\n \"is_controlling\": true,\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#bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\n \"short_url\": \"lbry://astream#b\",\n \"signing_channel\": {\n \"address\": \"mw6SpJDWJeYTWsr2iEFNEbRuqmNhDjpsZS\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#1\",\n \"claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 209,\n \"claims_in_channel\": 1,\n \"creation_height\": 209,\n \"creation_timestamp\": 1567524491,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263183,\n \"is_controlling\": true,\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#1812d3275894f62a055d59189a75698a071108af\",\n \"short_url\": \"lbry://@channel#1\",\n \"timestamp\": 1567524491,\n \"txid\": \"986dbf145a5320fe0047b3404216ddae76bb9e915895ebb04dda9c4e1b676be7\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200044974cd9d7098183f8bc9005f3957a4dbfc1ede19044311337fe9f645f256a7a4013c6a142497590bd8461fc50ce6b489453686422079c334bd5f8316b335365e\",\n \"public_key_id\": \"mrne5J4YN1SYYE3qNAAwzEVHAxnZX4AKHp\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1567524492,\n \"txid\": \"f3338742c2b4cf0e35b7ffa73aea3e9da786926cf82f07d3100e09d04ec3f231\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpmjego0ff\",\n \"sd_hash\": \"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"page\": 1,\n \"page_size\": 10,\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\", \"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\": []}}' http://localhost:5279/",
"lbrynet": "lbrynet claim search --name=\"astream\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"claim_search\", \"params\": {\"name\": \"astream\", \"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\": []}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mpDcDEwvfvETWqTDhddKLTzZZS2GBQWBqC\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#7/astream#5\",\n \"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\",\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\": 1561485090,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263187,\n \"is_controlling\": true,\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#5d64500fb723eded83a41b0d5055f1783f019191\",\n \"short_url\": \"lbry://astream#5\",\n \"signing_channel\": {\n \"address\": \"n3rBuPQB9qzAha4xU1uHyP5nmvR3WGq3r6\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#7\",\n \"claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 209,\n \"claims_in_channel\": 1,\n \"creation_height\": 209,\n \"creation_timestamp\": 1561485089,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263183,\n \"is_controlling\": true,\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#7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"short_url\": \"lbry://@channel#7\",\n \"timestamp\": 1561485089,\n \"txid\": \"0f7256329d0b2896d6f2472eea2614fbcf20ab6b22e27d168060ebb0adbaa6fa\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000465bebc31803d2a7f0f037f696665d4d610abea2e518f906410163dec7513fc2b9a82ae0c4a15602f467d4c03823d72cf95c36fc6a87e963356e44db502027ae2\",\n \"public_key_id\": \"mrqYtVaoPEPqgyRPExUPi7PrYJ9nDc59yW\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1561485090,\n \"txid\": \"dac2f1adaf5debd8cb377673b35ee4e6eb62ba7747b4440ffdb44d6875c2197e\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpzj1qbxfj\",\n \"sd_hash\": \"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"page\": 1,\n \"page_size\": 10,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mqwocM9E8dcY9aHCaCGG6HXB8Pd3hA9KjF\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#1/astream#b\",\n \"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\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\": 1567524492,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263187,\n \"is_controlling\": true,\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#bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\n \"short_url\": \"lbry://astream#b\",\n \"signing_channel\": {\n \"address\": \"mw6SpJDWJeYTWsr2iEFNEbRuqmNhDjpsZS\",\n \"amount\": \"1.0\",\n \"canonical_url\": \"lbry://@channel#1\",\n \"claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"meta\": {\n \"activation_height\": 209,\n \"claims_in_channel\": 1,\n \"creation_height\": 209,\n \"creation_timestamp\": 1567524491,\n \"effective_amount\": \"1.0\",\n \"expiration_height\": 263183,\n \"is_controlling\": true,\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#1812d3275894f62a055d59189a75698a071108af\",\n \"short_url\": \"lbry://@channel#1\",\n \"timestamp\": 1567524491,\n \"txid\": \"986dbf145a5320fe0047b3404216ddae76bb9e915895ebb04dda9c4e1b676be7\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200044974cd9d7098183f8bc9005f3957a4dbfc1ede19044311337fe9f645f256a7a4013c6a142497590bd8461fc50ce6b489453686422079c334bd5f8316b335365e\",\n \"public_key_id\": \"mrne5J4YN1SYYE3qNAAwzEVHAxnZX4AKHp\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1567524492,\n \"txid\": \"f3338742c2b4cf0e35b7ffa73aea3e9da786926cf82f07d3100e09d04ec3f231\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpmjego0ff\",\n \"sd_hash\": \"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"page\": 1,\n \"page_size\": 10,\n \"total_items\": 1,\n \"total_pages\": 1\n }\n}"
}
]
}
]
},
"comment": {
"doc": "Create and list comments.",
"doc": "View, create and abandon comments.",
"commands": [
{
"name": "comment_abandon",
"description": "Abandon a comment published under your channel identity.",
"arguments": [
{
"name": "comment_id",
"type": "str",
"description": "The ID of the comment to be abandoned.",
"is_required": true
}
],
"returns": "(dict) Object with the `comment_id` passed in as the key, and a flag indicating if it was abandoned\n {\n <comment_id> (str): {\n \"abandoned\": (bool)\n }\n }",
"examples": []
},
{
"name": "comment_create",
"description": "Create and associate a comment with a claim using your channel identity.",
@@ -1723,6 +1767,20 @@
"returns": "(dict) Comment object if successfully made, (None) otherwise\n {\n \"comment\": (str) The actual string as inputted by the user,\n \"comment_id\": (str) The Comment's unique identifier,\n \"channel_name\": (str) Name of the channel this was posted under, prepended with a '@',\n \"channel_id\": (str) The Channel Claim ID that this comment was posted under,\n \"signature\": (str) The signature of the comment,\n \"channel_url\": (str) Channel's URI in the ClaimTrie,\n \"parent_id\": (str) Comment this is replying to, (None) if this is the root,\n \"timestamp\": (int) The time at which comment was entered into the server at, in nanoseconds.\n }",
"examples": []
},
{
"name": "comment_hide",
"description": "Hide a comment published to a claim you control.",
"arguments": [
{
"name": "comment_ids",
"type": "str, list",
"description": "one or more comment_id to hide.",
"is_required": false
}
],
"returns": "(dict) keyed by comment_id, containing success info\n '<comment_id>': {\n \"hidden\": (bool) flag indicating if comment_id was hidden\n }",
"examples": []
},
{
"name": "comment_list",
"description": "List comments associated with a claim.",
@@ -1762,6 +1820,18 @@
"type": "bool",
"description": "Only include comments with valid signatures. [Warning: Paginated total size will not change, even if list reduces]",
"is_required": false
},
{
"name": "visible",
"type": "bool",
"description": "Select only Visisble Comments",
"is_required": false
},
{
"name": "hidden",
"type": "bool",
"description": "Select only Hidden Comments",
"is_required": false
}
],
"returns": "(dict) Containing the list, and information about the paginated content:\n {\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\": \"A List of dict objects representing comments.\"\n [\n {\n \"comment\": (str) The actual string as inputted by the user,\n \"comment_id\": (str) The Comment's unique identifier,\n \"channel_name\": (str) Name of the channel this was posted under, prepended with a '@',\n \"channel_id\": (str) The Channel Claim ID that this comment was posted under,\n \"signature\": (str) The signature of the comment,\n \"channel_url\": (str) Channel's URI in the ClaimTrie,\n \"parent_id\": (str) Comment this is replying to, (None) if this is the root,\n \"timestamp\": (int) The time at which comment was entered into the server at, in nanoseconds.\n },\n ...\n ]\n }",
@@ -1853,9 +1923,9 @@
"examples": [
{
"title": "Delete a file",
"curl": "curl -d'{\"method\": \"file_delete\", \"params\": {\"delete_from_download_dir\": false, \"delete_all\": false, \"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\"}}' http://localhost:5279/",
"lbrynet": "lbrynet file delete --claim_id=\"5d64500fb723eded83a41b0d5055f1783f019191\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_delete\", \"params\": {\"delete_from_download_dir\": false, \"delete_all\": false, \"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\"}}).json()",
"curl": "curl -d'{\"method\": \"file_delete\", \"params\": {\"delete_from_download_dir\": false, \"delete_all\": false, \"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\"}}' http://localhost:5279/",
"lbrynet": "lbrynet file delete --claim_id=\"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_delete\", \"params\": {\"delete_from_download_dir\": false, \"delete_all\": false, \"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": true\n}"
}
]
@@ -1962,14 +2032,14 @@
"curl": "curl -d'{\"method\": \"file_list\", \"params\": {\"reverse\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet file list",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_list\", \"params\": {\"reverse\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": -1,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": -1,\n \"key\": \"e8b365259d5b8644a6a1eb5d2f77459f\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpzj1qbxfj\",\n \"sd_hash\": \"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"dac2f1adaf5debd8cb377673b35ee4e6eb62ba7747b4440ffdb44d6875c2197e:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"015e32d5a47f2cd3e1242457498c97578d4594d77ee519fc56b21384e97c75d5c1b6450f2138e209f7bbd2adb588609ba36d1982a2187070c391a89793a0b569f09fef656fe041eab1809e3964f6346ae0fb3d20f30a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d707a6a31716278666a180b22186170706c69636174696f6e2f6f637465742d73747265616d3230d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"sd_hash\": \"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"8b7dee36b0985027ad1476590ee5759359b57e4cb6507d5288ffe1508c32177f5a39ef20772cf90da72987f6f55ce1ba\",\n \"stream_name\": \"tmpzj1qbxfj\",\n \"streaming_url\": \"http://localhost:5280/stream/d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"suggested_file_name\": \"tmpzj1qbxfj\",\n \"timestamp\": null,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"dac2f1adaf5debd8cb377673b35ee4e6eb62ba7747b4440ffdb44d6875c2197e\",\n \"written_bytes\": null\n },\n {\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"8cef1fdff80ef393ddb24a73ba60196610bedbc9\",\n \"claim_name\": \"blank-image\",\n \"completed\": true,\n \"confirmations\": -1,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": -1,\n \"key\": \"e7256de8c71f32d15b11d820dded4ae8\",\n \"metadata\": {\n \"author\": \"Picaso\",\n \"description\": \"A blank PNG that is 5x7.\",\n \"fee\": {\n \"address\": \"miLhR5kJLGVqi5Ss2VKT2Nxt4fToriqtX2\",\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\": \"1561485066\",\n \"source\": {\n \"hash\": \"6c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545\",\n \"media_type\": \"image/png\",\n \"name\": \"tmp_zkvgv47.png\",\n \"sd_hash\": \"d4595a73a829c2a567a25ee1fa7ced42ae4d2d5fccc19126f01b8518537a386b6d20d611b35278afe6a5e193a762cd8c\",\n \"size\": \"99\"\n },\n \"stream_type\": \"image\",\n \"tags\": [\n \"blank\",\n \"art\"\n ],\n \"thumbnail\": {\n \"url\": \"http://smallmedia.com/thumbnail.jpg\"\n },\n \"title\": \"Blank Image\"\n },\n \"mime_type\": \"image/png\",\n \"nout\": 0,\n \"outpoint\": \"62a6d649879ce6a35a33265b8a9421faf24fd1e40457fdcdb4753d7eb7de6e0f:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"015e32d5a47f2cd3e1242457498c97578d4594d77ef0d8c8998fb8a90c600f66f6bce1b38b4f8ccca60f1896a1d0b85e3735c50d5b4841a37bb45dfdbef1ca2712189280efd4382ac843e11e6272e0389c1b99b6630ae6010a82010a306c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50eLine truncated
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": -1,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": -1,\n \"key\": \"44c98cff66e9387514d212369d4af15e\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpmjego0ff\",\n \"sd_hash\": \"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"f3338742c2b4cf0e35b7ffa73aea3e9da786926cf82f07d3100e09d04ec3f231:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01af0811078a69759a18595d052af6945827d31218a49f0b990dfb596d464fa5c166a752b4835b01f02dcabd712d4345b09c18ce4096395d25caf4fb962732f54d58df839f9dd7cc2ef1d4303c89e4dd553865ed060a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706d6a65676f306666180b22186170706c69636174696f6e2f6f637465742d73747265616d32302ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"sd_hash\": \"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"d2fdfe280a77e5dd71f82cd531782ec5f71db1b2f9b6bf4da71240b5ad6fb21367d4b53e6f84fa83cc190aff004dd7bd\",\n \"stream_name\": \"tmpmjego0ff\",\n \"streaming_url\": \"http://localhost:5280/stream/2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"suggested_file_name\": \"tmpmjego0ff\",\n \"timestamp\": null,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"f3338742c2b4cf0e35b7ffa73aea3e9da786926cf82f07d3100e09d04ec3f231\",\n \"written_bytes\": 0\n },\n {\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"0e08f286e3e5cf0b17d3fa64da93fbf96b0e9c90\",\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 \"key\": \"9625cf71e26cdbc140dcec6d6cbfc46e\",\n \"metadata\": {\n \"author\": \"Picaso\",\n \"description\": \"A blank PNG that is 5x7.\",\n \"fee\": {\n \"address\": \"n4GBt198ctM4KF1AJGJG8ppxAeFyXFfut9\",\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\": \"1567524468\",\n \"source\": {\n \"hash\": \"6c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545\",\n \"media_type\": \"image/png\",\n \"name\": \"tmpg_6t0r6a.png\",\n \"sd_hash\": \"019de60de1c0e860ae907dfbf13cd4a618a1acb9fb107e09bcaee3a6a7b2165a2a91e740a0fc9d4a4e613a6ed496bc33\",\n \"size\": \"99\"\n },\n \"stream_type\": \"image\",\n \"tags\": [\n \"blank\",\n \"art\"\n ],\n \"thumbnail\": {\n \"url\": \"http://smallmedia.com/thumbnail.jpg\"\n },\n \"title\": \"Blank Image\"\n },\n \"mime_type\": \"image/png\",\n \"nout\": 0,\n \"outpoint\": \"55d87be458bd1a9aa960dd914b7f5c6d1b118d65d8b04477f705716d33091530:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01af0811078a69759a18595d052af6945827d312183830ab666b25817d8432e95af7bb26baed712eeca26420f81c8f8255ca008c86dbb6c771a21cbc97d0f460f7b4d4243e40a26d66f77c615f0f9cb4f99a228a830ae6010a82010a306c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85Line truncated
},
{
"title": "List files matching a parameter",
"curl": "curl -d'{\"method\": \"file_list\", \"params\": {\"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\", \"reverse\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet file list --claim_id=\"5d64500fb723eded83a41b0d5055f1783f019191\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_list\", \"params\": {\"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\", \"reverse\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 3,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": 214,\n \"key\": \"e8b365259d5b8644a6a1eb5d2f77459f\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpzj1qbxfj\",\n \"sd_hash\": \"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"dac2f1adaf5debd8cb377673b35ee4e6eb62ba7747b4440ffdb44d6875c2197e:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"015e32d5a47f2cd3e1242457498c97578d4594d77ee519fc56b21384e97c75d5c1b6450f2138e209f7bbd2adb588609ba36d1982a2187070c391a89793a0b569f09fef656fe041eab1809e3964f6346ae0fb3d20f30a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d707a6a31716278666a180b22186170706c69636174696f6e2f6f637465742d73747265616d3230d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"sd_hash\": \"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"8b7dee36b0985027ad1476590ee5759359b57e4cb6507d5288ffe1508c32177f5a39ef20772cf90da72987f6f55ce1ba\",\n \"stream_name\": \"tmpzj1qbxfj\",\n \"streaming_url\": \"http://localhost:5280/stream/d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"suggested_file_name\": \"tmpzj1qbxfj\",\n \"timestamp\": 1561485090,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"dac2f1adaf5debd8cb377673b35ee4e6eb62ba7747b4440ffdb44d6875c2197e\",\n \"written_bytes\": null\n }\n ]\n}"
"curl": "curl -d'{\"method\": \"file_list\", \"params\": {\"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\", \"reverse\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet file list --claim_id=\"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_list\", \"params\": {\"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\", \"reverse\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 3,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": 214,\n \"key\": \"44c98cff66e9387514d212369d4af15e\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpmjego0ff\",\n \"sd_hash\": \"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"f3338742c2b4cf0e35b7ffa73aea3e9da786926cf82f07d3100e09d04ec3f231:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01af0811078a69759a18595d052af6945827d31218a49f0b990dfb596d464fa5c166a752b4835b01f02dcabd712d4345b09c18ce4096395d25caf4fb962732f54d58df839f9dd7cc2ef1d4303c89e4dd553865ed060a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706d6a65676f306666180b22186170706c69636174696f6e2f6f637465742d73747265616d32302ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"sd_hash\": \"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"status\": \"finished\",\n \"stopped\": true,\n \"stream_hash\": \"d2fdfe280a77e5dd71f82cd531782ec5f71db1b2f9b6bf4da71240b5ad6fb21367d4b53e6f84fa83cc190aff004dd7bd\",\n \"stream_name\": \"tmpmjego0ff\",\n \"streaming_url\": \"http://localhost:5280/stream/2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"suggested_file_name\": \"tmpmjego0ff\",\n \"timestamp\": 1567524492,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"f3338742c2b4cf0e35b7ffa73aea3e9da786926cf82f07d3100e09d04ec3f231\",\n \"written_bytes\": 0\n }\n ]\n}"
}
]
},
@@ -2086,10 +2156,10 @@
"examples": [
{
"title": "Save a file to the downloads directory",
"curl": "curl -d'{\"method\": \"file_save\", \"params\": {\"sd_hash\": \"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\"}}' http://localhost:5279/",
"lbrynet": "lbrynet file save --sd_hash=\"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_save\", \"params\": {\"sd_hash\": \"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 3,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": 214,\n \"key\": \"e8b365259d5b8644a6a1eb5d2f77459f\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpzj1qbxfj\",\n \"sd_hash\": \"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"dac2f1adaf5debd8cb377673b35ee4e6eb62ba7747b4440ffdb44d6875c2197e:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"015e32d5a47f2cd3e1242457498c97578d4594d77ee519fc56b21384e97c75d5c1b6450f2138e209f7bbd2adb588609ba36d1982a2187070c391a89793a0b569f09fef656fe041eab1809e3964f6346ae0fb3d20f30a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d707a6a31716278666a180b22186170706c69636174696f6e2f6f637465742d73747265616d3230d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"sd_hash\": \"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"status\": \"running\",\n \"stopped\": false,\n \"stream_hash\": \"8b7dee36b0985027ad1476590ee5759359b57e4cb6507d5288ffe1508c32177f5a39ef20772cf90da72987f6f55ce1ba\",\n \"stream_name\": \"tmpzj1qbxfj\",\n \"streaming_url\": \"http://localhost:5280/stream/d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"suggested_file_name\": \"tmpzj1qbxfj\",\n \"timestamp\": 1561485090,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"dac2f1adaf5debd8cb377673b35ee4e6eb62ba7747b4440ffdb44d6875c2197e\",\n \"written_bytes\": null\n }\n}"
"curl": "curl -d'{\"method\": \"file_save\", \"params\": {\"sd_hash\": \"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\"}}' http://localhost:5279/",
"lbrynet": "lbrynet file save --sd_hash=\"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"file_save\", \"params\": {\"sd_hash\": \"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"blobs_completed\": 1,\n \"blobs_in_stream\": 1,\n \"blobs_remaining\": 0,\n \"channel_claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"channel_name\": \"@channel\",\n \"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\n \"claim_name\": \"astream\",\n \"completed\": true,\n \"confirmations\": 3,\n \"content_fee\": null,\n \"download_directory\": null,\n \"download_path\": null,\n \"file_name\": null,\n \"height\": 214,\n \"key\": \"44c98cff66e9387514d212369d4af15e\",\n \"metadata\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpmjego0ff\",\n \"sd_hash\": \"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"mime_type\": \"application/octet-stream\",\n \"nout\": 0,\n \"outpoint\": \"f3338742c2b4cf0e35b7ffa73aea3e9da786926cf82f07d3100e09d04ec3f231:0\",\n \"points_paid\": 0.0,\n \"protobuf\": \"01af0811078a69759a18595d052af6945827d31218a49f0b990dfb596d464fa5c166a752b4835b01f02dcabd712d4345b09c18ce4096395d25caf4fb962732f54d58df839f9dd7cc2ef1d4303c89e4dd553865ed060a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706d6a65676f306666180b22186170706c69636174696f6e2f6f637465742d73747265616d32302ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"sd_hash\": \"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"status\": \"running\",\n \"stopped\": false,\n \"stream_hash\": \"d2fdfe280a77e5dd71f82cd531782ec5f71db1b2f9b6bf4da71240b5ad6fb21367d4b53e6f84fa83cc190aff004dd7bd\",\n \"stream_name\": \"tmpmjego0ff\",\n \"streaming_url\": \"http://localhost:5280/stream/2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"suggested_file_name\": \"tmpmjego0ff\",\n \"timestamp\": 1567524492,\n \"total_bytes\": 16,\n \"total_bytes_lower_bound\": 0,\n \"txid\": \"f3338742c2b4cf0e35b7ffa73aea3e9da786926cf82f07d3100e09d04ec3f231\",\n \"written_bytes\": 0\n }\n}"
}
]
},
@@ -2165,6 +2235,73 @@
}
]
},
"preference": {
"doc": "Preferences management.",
"commands": [
{
"name": "preference_get",
"description": "Get preference value for key or all values if not key is passed in.",
"arguments": [
{
"name": "key",
"type": "str",
"description": "key associated with value",
"is_required": false
},
{
"name": "account_id",
"type": "str",
"description": "id of the account containing value",
"is_required": false
}
],
"returns": "(dict) Dictionary of preference(s)",
"examples": [
{
"title": "Get preferences",
"curl": "curl -d'{\"method\": \"preference_get\", \"params\": {}}' http://localhost:5279/",
"lbrynet": "lbrynet preference get",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"preference_get\", \"params\": {}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"theme\": \"dark\"\n }\n}"
}
]
},
{
"name": "preference_set",
"description": "Set preferences",
"arguments": [
{
"name": "key",
"type": "str",
"description": "key associated with value",
"is_required": true
},
{
"name": "value",
"type": "str",
"description": "key associated with value",
"is_required": true
},
{
"name": "account_id",
"type": "str",
"description": "id of the account containing value",
"is_required": false
}
],
"returns": "(dict) Dictionary with key/value of new preference",
"examples": [
{
"title": "Set preference",
"curl": "curl -d'{\"method\": \"preference_set\", \"params\": {\"key\": \"theme\", \"value\": \"dark\"}}' http://localhost:5279/",
"lbrynet": "lbrynet preference set \"theme\" \"dark\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"preference_set\", \"params\": {\"key\": \"theme\", \"value\": \"dark\"}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"theme\": \"dark\"\n }\n}"
}
]
}
]
},
"settings": {
"doc": "Settings management.",
"commands": [
@@ -2179,7 +2316,7 @@
"curl": "curl -d'{\"method\": \"settings_get\", \"params\": {}}' http://localhost:5279/",
"lbrynet": "lbrynet settings get",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"settings_get\", \"params\": {}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"announce_head_and_sd_only\": true,\n \"api\": \"localhost:5279\",\n \"blob_download_timeout\": 30.0,\n \"blob_lru_cache_size\": 0,\n \"blockchain_name\": \"lbrycrd_regtest\",\n \"cache_time\": 150,\n \"coin_selection_strategy\": \"standard\",\n \"comment_server\": \"https://comments.lbry.com/api\",\n \"components_to_skip\": [\n \"dht\",\n \"upnp\",\n \"hash_announcer\",\n \"peer_protocol_server\"\n ],\n \"concurrent_blob_announcers\": 10,\n \"concurrent_reflector_uploads\": 10,\n \"config\": \"/home/lex/.local/share/lbry/lbrynet/daemon_settings.yml\",\n \"data_dir\": \"/tmp/tmpfjnst0c0\",\n \"download_dir\": \"/tmp/tmpfjnst0c0\",\n \"download_timeout\": 30.0,\n \"fixed_peer_delay\": 2.0,\n \"known_dht_nodes\": [],\n \"lbryum_servers\": [\n [\n \"127.0.0.1\",\n 50001\n ]\n ],\n \"max_connections_per_download\": 4,\n \"max_key_fee\": {\n \"amount\": 50.0,\n \"currency\": \"USD\"\n },\n \"network_interface\": \"0.0.0.0\",\n \"node_rpc_timeout\": 5.0,\n \"peer_connect_timeout\": 3.0,\n \"reflect_streams\": true,\n \"reflector_servers\": [\n [\n \"127.0.0.1\",\n 5566\n ]\n ],\n \"s3_headers_depth\": 960,\n \"save_blobs\": true,\n \"save_files\": true,\n \"share_usage_data\": false,\n \"split_buckets_under_index\": 1,\n \"streaming_get\": true,\n \"streaming_server\": \"localhost:5280\",\n \"tcp_port\": 3333,\n \"udp_port\": 4444,\n \"use_upnp\": false,\n \"wallet_dir\": \"/tmp/tmpfjnst0c0\"\n }\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"announce_head_and_sd_only\": true,\n \"api\": \"localhost:5279\",\n \"blob_download_timeout\": 30.0,\n \"blob_lru_cache_size\": 0,\n \"blockchain_name\": \"lbrycrd_regtest\",\n \"cache_time\": 150,\n \"coin_selection_strategy\": \"standard\",\n \"comment_server\": \"https://comments.lbry.com/api\",\n \"components_to_skip\": [\n \"dht\",\n \"upnp\",\n \"hash_announcer\",\n \"peer_protocol_server\"\n ],\n \"concurrent_blob_announcers\": 10,\n \"concurrent_reflector_uploads\": 10,\n \"config\": \"/home/lex/.local/share/lbry/lbrynet/daemon_settings.yml\",\n \"data_dir\": \"/tmp/tmptn5ym8in\",\n \"download_dir\": \"/tmp/tmptn5ym8in\",\n \"download_timeout\": 30.0,\n \"fixed_peer_delay\": 2.0,\n \"known_dht_nodes\": [],\n \"lbryum_servers\": [\n [\n \"127.0.0.1\",\n 50001\n ]\n ],\n \"max_connections_per_download\": 4,\n \"max_key_fee\": {\n \"amount\": 50.0,\n \"currency\": \"USD\"\n },\n \"network_interface\": \"0.0.0.0\",\n \"node_rpc_timeout\": 5.0,\n \"peer_connect_timeout\": 3.0,\n \"reflect_streams\": true,\n \"reflector_servers\": [\n [\n \"127.0.0.1\",\n 5566\n ]\n ],\n \"s3_headers_depth\": 960,\n \"save_blobs\": true,\n \"save_files\": true,\n \"share_usage_data\": false,\n \"split_buckets_under_index\": 1,\n \"streaming_get\": true,\n \"streaming_server\": \"localhost:5280\",\n \"tcp_port\": 3333,\n \"track_bandwidth\": true,\n \"udp_port\": 4444,\n \"use_upnp\": false,\n \"wallet_dir\": \"/tmp/tmptn5ym8in\"\n }\n}"
}
]
},
@@ -2188,7 +2325,15 @@
"description": "Set daemon settings",
"arguments": [],
"returns": "(dict) Updated dictionary of daemon settings",
"examples": []
"examples": [
{
"title": "Set settings",
"curl": "curl -d'{\"method\": \"settings_set\", \"params\": {\"key\": \"tcp_port\", \"value\": 99}}' http://localhost:5279/",
"lbrynet": "lbrynet settings set \"tcp_port\" 99",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"settings_set\", \"params\": {\"key\": \"tcp_port\", \"value\": 99}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"tcp_port\": 99\n }\n}"
}
]
}
]
},
@@ -2240,10 +2385,10 @@
"examples": [
{
"title": "Abandon a stream claim",
"curl": "curl -d'{\"method\": \"stream_abandon\", \"params\": {\"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\", \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream abandon 5d64500fb723eded83a41b0d5055f1783f019191",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_abandon\", \"params\": {\"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\", \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000017e19c275684db4fd0f44b44777ba62ebe6e45eb3737637cbd8eb5dafadf1c2da000000006b483045022100c624c1ad3ba9ef23da28e8a21bda59d223bca0cc7011e952d14ab9fc065058aa022046708292d323bf9053ded6de63ae948058fa5650c8a2a3286ca700bb797be32e0121039efda2d8dd29b422fb044b6ccf6791ec3b0489713619b3f9dd9e8c89a4e54779ffffffff0134b7f505000000001976a9145b91c67ced35c7e2197da2da28fde8c113ef8a4588ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mpDcDEwvfvETWqTDhddKLTzZZS2GBQWBqC\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\",\n \"claim_op\": \"update\",\n \"confirmations\": 3,\n \"height\": 214,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#5d64500fb723eded83a41b0d5055f1783f019191\",\n \"timestamp\": 1561485090,\n \"txid\": \"dac2f1adaf5debd8cb377673b35ee4e6eb62ba7747b4440ffdb44d6875c2197e\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpzj1qbxfj\",\n \"sd_hash\": \"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mos8RABG1AF9QQ4HPVABG9p9ERCQ4DGG2Z\",\n \"amount\": \"0.999893\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"43b91f8ca1e4b543ddaa540e1b9026084f137cea5e9a9d7381321508086f3ce5\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000107\",\n \"total_input\": \"1.0\",\n \"total_output\": \"0.999893\",\n \"txid\": \"43b91f8ca1e4b543ddaa540e1b9026084f137cea5e9a9d7381321508086f3ce5\"\n }\n}"
"curl": "curl -d'{\"method\": \"stream_abandon\", \"params\": {\"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\", \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream abandon bfb7d50e084d6d246ca9ff909c401aab30a6f9a6",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_abandon\", \"params\": {\"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\", \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000131f2c34ed0090e10d3072ff86c9286a79d3eea3aa7ffb7350ecfb4c2428733f3000000006b4830450221008cf6f4d298c8275a90eab2e01822fedb9d12346873dfe0b44816a15121f150560220638d9b125eedbf87ed043a05df039e06b834159d1ecfb46c9da763b0390034180121023b0815369b8ef78200d00b1fef7fdd6bf0dac1a84cb34756aa390e54e07e85ecffffffff0134b7f505000000001976a9144f20673b0be85c20dfaf5e27efc880c0b31c8b0988ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mqwocM9E8dcY9aHCaCGG6HXB8Pd3hA9KjF\",\n \"amount\": \"1.0\",\n \"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\n \"claim_op\": \"update\",\n \"confirmations\": 3,\n \"height\": 214,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\n \"timestamp\": 1567524492,\n \"txid\": \"f3338742c2b4cf0e35b7ffa73aea3e9da786926cf82f07d3100e09d04ec3f231\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpmjego0ff\",\n \"sd_hash\": \"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mnjLVdEZcL1cPXoWntjbvkaPDPpYLTVdSJ\",\n \"amount\": \"0.999893\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 0,\n \"timestamp\": null,\n \"txid\": \"b2cba880bb6bb4fbf9c3acca5f9df6c3eee2ebf83df37688bf9a69e1876ffef0\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.000107\",\n \"total_input\": \"1.0\",\n \"total_output\": \"0.999893\",\n \"txid\": \"b2cba880bb6bb4fbf9c3acca5f9df6c3eee2ebf83df37688bf9a69e1876ffef0\"\n }\n}"
}
]
},
@@ -2406,7 +2551,13 @@
{
"name": "account_id",
"type": "str",
"description": "account to use for funding the transaction",
"description": "account to use for holding the transaction",
"is_required": false
},
{
"name": "funding_account_ids",
"type": "list",
"description": "ids of accounts to fund this transaction",
"is_required": false
},
{
@@ -2432,17 +2583,17 @@
"examples": [
{
"title": "Create a stream claim without metadata",
"curl": "curl -d'{\"method\": \"stream_create\", \"params\": {\"name\": \"astream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpzj1qbxfj\", \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream create astream 1.0 /tmp/tmpzj1qbxfj",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_create\", \"params\": {\"name\": \"astream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpzj1qbxfj\", \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"010000000196f8e3d37980f4f602fedd6be3007e45c98a176b953ec151db7d9ff558f4e950010000006b483045022100c86c0b5aa41515436e96d86767e75566cb5addd6c41fc03b182fd41cb50e6750022044937d16a79ed035ee77af8c4e05282b66417349a5d9bc4f340d7d5a3569f048012103fe478df2bbf4c46284220d4d439f5ced6d923cc18915e25b0fa1f14a039a758effffffff0200e1f50500000000bab5076173747265616d4c94000a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d707a6a31716278666a180b22186170706c69636174696f6e2f6f637465742d73747265616d3230d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d36d7576a9145f714bd8d8f78a7a6836eba4625ab0d05cbf9bf188ac38fb9423000000001976a914b18165ea11e7fc078a724665b8d5f4ed879418af88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"moXzxEEXj4nhGhnozbGGFqGXdEzysbDMHJ\",\n \"amount\": \"6.983769\",\n \"confirmations\": 4,\n \"height\": 209,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1561485089,\n \"txid\": \"50e9f458f59f7ddb51c13e956b178ac9457e00e36bddfe02f6f48079d3e3f896\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mpDcDEwvfvETWqTDhddKLTzZZS2GBQWBqC\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\",\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#5d64500fb723eded83a41b0d5055f1783f019191\",\n \"timestamp\": null,\n \"txid\": \"c983a65d949c9badee6fdd78ec68dc214c44816576e90998a86c062790e8fffe\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpzj1qbxfj\",\n \"sd_hash\": \"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mwhWukDANoke2ikBrkj8u3kFdRh5YM2Xv7\",\n \"amount\": \"5.969662\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"c983a65d949c9badee6fdd78ec68dc214c44816576e90998a86c062790e8fffe\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.014107\",\n \"total_input\": \"6.983769\",\n \"total_output\": \"6.969662\",\n \"txid\": \"c983a65d949c9badee6fdd78ec68dc214c44816576e90998a86c062790e8fffe\"\n }\n}"
"curl": "curl -d'{\"method\": \"stream_create\", \"params\": {\"name\": \"astream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpmjego0ff\", \"tags\": [], \"languages\": [], \"locations\": [], \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream create astream 1.0 /tmp/tmpmjego0ff",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_create\", \"params\": {\"name\": \"astream\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpmjego0ff\", \"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\": \"0100000001fa76b5ebe4e1dc0f511d6ee2d6ebc93576efc11ddbb0e6b31c17e1fa87590771010000006a47304402201470c22dd0eda9464317b03e19df649fdf3e714bd7ab7216786065cbcf7f506602204c1e906566d6470a6ec400b364970a07bc56f3c338929089966a6573a3b032a2012102cd305212f95664613654fae6a0b947c64fb741ab641b8ca731446f5301f8d2daffffffff0200e1f50500000000bab5076173747265616d4c94000a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706d6a65676f306666180b22186170706c69636174696f6e2f6f637465742d73747265616d32302ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb376d7576a914726468487bd5cd1825dbe133ff4c1fee98694a1988ac38fb9423000000001976a9145f53c37fbba1d75a500cc3a95bd28d4ccf34894e88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mv5oQhBhKEBinD1Bs3MKmzznidZSGBN1FG\",\n \"amount\": \"6.983769\",\n \"confirmations\": 4,\n \"height\": 209,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1567524491,\n \"txid\": \"71075987fae1171cb3e6b0db1dc1ef7635c9ebd6e26e1d510fdce1e4ebb576fa\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mqwocM9E8dcY9aHCaCGG6HXB8Pd3hA9KjF\",\n \"amount\": \"1.0\",\n \"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\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#bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\n \"timestamp\": null,\n \"txid\": \"16d37a20dd97fec3f8f86456ed6eee78547e7145c802afdf5c91418a6d99204a\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpmjego0ff\",\n \"sd_hash\": \"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mpCzqHAmHsyhp3J1NFWGPof1PoYhVugGdg\",\n \"amount\": \"5.969662\",\n \"confirmations\": -2,\n \"height\": -2,\n \"nout\": 1,\n \"timestamp\": null,\n \"txid\": \"16d37a20dd97fec3f8f86456ed6eee78547e7145c802afdf5c91418a6d99204a\",\n \"type\": \"payment\"\n }\n ],\n \"total_fee\": \"0.014107\",\n \"total_input\": \"6.983769\",\n \"total_output\": \"6.969662\",\n \"txid\": \"16d37a20dd97fec3f8f86456ed6eee78547e7145c802afdf5c91418a6d99204a\"\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/tmp_zkvgv47.png\", \"fee_currency\": \"LBC\", \"fee_amount\": \"0.3\", \"title\": \"Blank Image\", \"description\": \"A blank PNG that is 5x7.\", \"author\": \"Picaso\", \"tags\": [\"blank\", \"art\"], \"languages\": [\"en\"], \"locations\": [\"US:NH:Manchester\"], \"license\": \"Public Domain\", \"license_url\": \"http://public-domain.org\", \"thumbnail_url\": \"http://smallmedia.com/thumbnail.jpg\", \"release_time\": 1561485066, \"channel_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\", \"channel_account_id\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream create blank-image 1.0 /tmp/tmp_zkvgv47.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=1561485066 --channel_id=\"7ed794458d57978c49572424e1d32c7fa4d5325e\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_create\", \"params\": {\"name\": \"blank-image\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmp_zkvgv47.png\", \"fee_currency\": \"LBC\", \"fee_amount\": \"0.3\", \"title\": \"Blank Image\", \"description\": \"A blank PNG that is 5x7.\", \"author\": \"Picaso\", \"tags\": [\"blank\", \"art\"], \"languages\": [\"en\"], \"locations\": [\"US:NH:Manchester\"], \"license\": \"Public Domain\", \"license_url\": \"http://public-domain.org\", \"thumbnail_url\": \"http://smallmedia.com/thumbnail.jpg\", \"release_time\": 1561485066, \"channel_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\", \"channel_account_id\": [], \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000001feffe89027066ca89809e9766581444c21dc68ec78dd6feead9b9c945da683c9010000006b483045022100b3f2904121f6c6b5a41f31aae658e82db8b9b03385c5a68b4837603476905e3102206361878bb10bdf9ec3aa09e57777d67e97d93ecd6759784b937dc27441d4cb130121033c5a8006c1b3c7e3fce456220accfdf3a7b1f7f9c7a312789637d857dc8d68cbffffffff0200e1f50500000000fddc01b50b626c616e6b2d696d6167654db101015e32d5a47f2cd3e1242457498c97578d4594d77ef0d8c8998fb8a90c600f66f6bce1b38b4f8ccca60f1896a1d0b85e3735c50d5b4841a37bb45dfdbef1ca2712189280efd4382ac843e11e6272e0389c1b99b6630ae6010a82010a306c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545120f746d705f7a6b76677634372e706e6718632209696d6167652f706e673230d4595a73a829c2a567a25ee1fa7ced42ae4d2d5fccc19126f01b8518537a386b6d20d611b35278afe6a5e193a762cd8c120650696361736f1a0d5075626c696320446f6d61696e2218687474703a2f2f7075626c69632d646f6d61696e2e6f7267288abec9e8053222080112196f1ef7cc2a7373816b32207342ec23f8c38dccf01292bec029188087a70e520408051007420b426c616e6b20496d6167654a184120626c616e6b20504e472074686174206973203578372e52252a23687474703a2f2f736d616c6c6d656469612e636f6d2f7468756d626e61696c2e6a70675a05626c616e6b5a03617274620208016a1308ec0112024e481a0a4d616e636865737465726d7576a9141ef7cc2a7373816b32207342ec23f8c38dccf01288acac5e7d1d000000001976a9140a576ae154110bade7e05856edb02f02c4192c2c88ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mwhWukDANoke2ikBrkj8u3kFdRh5YM2Xv7\",\n \"amount\": \"5.969662\",\n \"confirmations\": 2,\n \"height\": 213,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1561485090,\n \"txid\": \"c983a65d949c9badee6fdd78ec68dc214c44816576e90998a86c062790e8fffe\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"miLhR5kJLGVqi5Ss2VKT2Nxt4fToriqtX2\",\n \"amount\": \"1.0\",\n \"claim_id\": \"8cef1fdff80ef393ddb24a73ba60196610bedbc9\",\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#8cef1fdff80ef393ddb24a73ba60196610bedbc9\",\n \"signing_channel\": {\n \"address\": \"n3rBuPQB9qzAha4xU1uHyP5nmvR3WGq3r6\",\n \"amount\": \"1.0\",\n \"claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"timestamp\": 1561485089,\n \"txid\": \"0f7256329d0b2896d6f2472eea2614fbcf20ab6b22e27d168060ebb0adbaa6fa\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000465bebc31803d2a7f0f037f696665d4d610abea2e518f906410163dec7513fc2b9a82ae0c4a15602f467d4c03823d72cf95c36fc6a87e963356e44db502027ae2\",\n \"public_key_id\": \"mrqYtVaoPEPqgyRPExUPi7PrYJ9nDc59yW\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": null,\n \"txid\": \"62a6d649879ce6a35a33265b8a9421faf24fd1e40457fdcdb4753d7eb7de6e0f\",\n \"type\": \"claim\",\n \"value\": {\n \"author\": \"Picaso\",\n \"description\": \"A blank PNG that is 5x7.\",\n \"fee\": {\n \"address\": \"miLhR5kJLGVqi5Ss2VKT2Nxt4fToriqtX2\",\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\": \"1561485066\",\n \"source\": {\n \"hash\": \"6c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545\",\n \"media_type\": \"image/png\",\n \"name\": \"tmp_zkvgv47.png\",\n \"sd_hash\": \"d4595a73a829c2a567a25ee1fa7ced42ae4d2d5fccc19126f01b8518537a386b6d20d611b35278afe6a5e193a762cd8c\",\n \"size\": \"99\"\n },\n \"stream_type\": \"image\",\n \"taLine truncated
"curl": "curl -d'{\"method\": \"stream_create\", \"params\": {\"name\": \"blank-image\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpg_6t0r6a.png\", \"fee_currency\": \"LBC\", \"fee_amount\": \"0.3\", \"title\": \"Blank Image\", \"description\": \"A blank PNG that is 5x7.\", \"author\": \"Picaso\", \"tags\": [\"blank\", \"art\"], \"languages\": [\"en\"], \"locations\": [\"US:NH:Manchester\"], \"license\": \"Public Domain\", \"license_url\": \"http://public-domain.org\", \"thumbnail_url\": \"http://smallmedia.com/thumbnail.jpg\", \"release_time\": 1567524468, \"channel_id\": \"1812d3275894f62a055d59189a75698a071108af\", \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream create blank-image 1.0 /tmp/tmpg_6t0r6a.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=1567524468 --channel_id=\"1812d3275894f62a055d59189a75698a071108af\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_create\", \"params\": {\"name\": \"blank-image\", \"bid\": \"1.0\", \"file_path\": \"/tmp/tmpg_6t0r6a.png\", \"fee_currency\": \"LBC\", \"fee_amount\": \"0.3\", \"title\": \"Blank Image\", \"description\": \"A blank PNG that is 5x7.\", \"author\": \"Picaso\", \"tags\": [\"blank\", \"art\"], \"languages\": [\"en\"], \"locations\": [\"US:NH:Manchester\"], \"license\": \"Public Domain\", \"license_url\": \"http://public-domain.org\", \"thumbnail_url\": \"http://smallmedia.com/thumbnail.jpg\", \"release_time\": 1567524468, \"channel_id\": \"1812d3275894f62a055d59189a75698a071108af\", \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"01000000014a20996d8a41915cdfaf02c845717e5478ee6eed5664f8f8c3fe97dd207ad316010000006b483045022100f808f427a2644e1b0bfdaaabb9dab4774b741a1033030b53ca8d19e2376e0af402205ff5c862bbbeda9cede5e42e1e13f48059325cea04f700817d725c11df91db8f012102ddf444347dfb68dc2f69ca9462ecfe0d30f1db4c10080bdcf696cb22de42ed25ffffffff0200e1f50500000000fddc01b50b626c616e6b2d696d6167654db10101af0811078a69759a18595d052af6945827d312183830ab666b25817d8432e95af7bb26baed712eeca26420f81c8f8255ca008c86dbb6c771a21cbc97d0f460f7b4d4243e40a26d66f77c615f0f9cb4f99a228a830ae6010a82010a306c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545120f746d70675f3674307236612e706e6718632209696d6167652f706e673230019de60de1c0e860ae907dfbf13cd4a618a1acb9fb107e09bcaee3a6a7b2165a2a91e740a0fc9d4a4e613a6ed496bc33120650696361736f1a0d5075626c696320446f6d61696e2218687474703a2f2f7075626c69632d646f6d61696e2e6f726728f48cbaeb053222080112196ff97ffe7af1a8d072313edc64a91a58bebcc96496d7b1fc76188087a70e520408051007420b426c616e6b20496d6167654a184120626c616e6b20504e472074686174206973203578372e52252a23687474703a2f2f736d616c6c6d656469612e636f6d2f7468756d626e61696c2e6a70675a05626c616e6b5a03617274620208016a1308ec0112024e481a0a4d616e636865737465726d7576a914f97ffe7af1a8d072313edc64a91a58bebcc9649688acac5e7d1d000000001976a914325ef76f0613598d31a4952b241c4ad04e5452d688ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mpCzqHAmHsyhp3J1NFWGPof1PoYhVugGdg\",\n \"amount\": \"5.969662\",\n \"confirmations\": 2,\n \"height\": 213,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1567524492,\n \"txid\": \"16d37a20dd97fec3f8f86456ed6eee78547e7145c802afdf5c91418a6d99204a\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"n4GBt198ctM4KF1AJGJG8ppxAeFyXFfut9\",\n \"amount\": \"1.0\",\n \"claim_id\": \"0e08f286e3e5cf0b17d3fa64da93fbf96b0e9c90\",\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#0e08f286e3e5cf0b17d3fa64da93fbf96b0e9c90\",\n \"signing_channel\": {\n \"address\": \"mw6SpJDWJeYTWsr2iEFNEbRuqmNhDjpsZS\",\n \"amount\": \"1.0\",\n \"claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#1812d3275894f62a055d59189a75698a071108af\",\n \"timestamp\": 1567524491,\n \"txid\": \"986dbf145a5320fe0047b3404216ddae76bb9e915895ebb04dda9c4e1b676be7\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200044974cd9d7098183f8bc9005f3957a4dbfc1ede19044311337fe9f645f256a7a4013c6a142497590bd8461fc50ce6b489453686422079c334bd5f8316b335365e\",\n \"public_key_id\": \"mrne5J4YN1SYYE3qNAAwzEVHAxnZX4AKHp\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": null,\n \"txid\": \"55d87be458bd1a9aa960dd914b7f5c6d1b118d65d8b04477f705716d33091530\",\n \"type\": \"claim\",\n \"value\": {\n \"author\": \"Picaso\",\n \"description\": \"A blank PNG that is 5x7.\",\n \"fee\": {\n \"address\": \"n4GBt198ctM4KF1AJGJG8ppxAeFyXFfut9\",\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\": \"1567524468\",\n \"source\": {\n \"hash\": \"6c7df435d412c603390f593ef658c199817c7830ba3f16b7eadd8f99fa50e85dbd0d2b3dc61eadc33fe096e3872d1545\",\n \"media_type\": \"image/png\",\n \"name\": \"tmpg_6t0r6a.png\",\n \"sd_hash\": \"019de60de1c0e860ae907dfbf13cd4a618a1acb9fb107e09bcaee3a6a7b2165a2a91e740a0fc9d4a4e613a6ed496bc33\",\n \"size\": \"99\"\n },\n \"stream_type\": \"image\",\n \"taLine truncated
}
]
},
@@ -2476,14 +2627,14 @@
"curl": "curl -d'{\"method\": \"stream_list\", \"params\": {}}' http://localhost:5279/",
"lbrynet": "lbrynet stream list",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_list\", \"params\": {}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"address\": \"mpDcDEwvfvETWqTDhddKLTzZZS2GBQWBqC\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_change\": false,\n \"is_channel_signature_valid\": true,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#5d64500fb723eded83a41b0d5055f1783f019191\",\n \"signing_channel\": {\n \"address\": \"n3rBuPQB9qzAha4xU1uHyP5nmvR3WGq3r6\",\n \"amount\": \"1.0\",\n \"claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"timestamp\": 1561485089,\n \"txid\": \"0f7256329d0b2896d6f2472eea2614fbcf20ab6b22e27d168060ebb0adbaa6fa\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000465bebc31803d2a7f0f037f696665d4d610abea2e518f906410163dec7513fc2b9a82ae0c4a15602f467d4c03823d72cf95c36fc6a87e963356e44db502027ae2\",\n \"public_key_id\": \"mrqYtVaoPEPqgyRPExUPi7PrYJ9nDc59yW\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1561485090,\n \"txid\": \"dac2f1adaf5debd8cb377673b35ee4e6eb62ba7747b4440ffdb44d6875c2197e\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpzj1qbxfj\",\n \"sd_hash\": \"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ]\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"address\": \"mqwocM9E8dcY9aHCaCGG6HXB8Pd3hA9KjF\",\n \"amount\": \"1.0\",\n \"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_change\": false,\n \"is_channel_signature_valid\": true,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\n \"signing_channel\": {\n \"address\": \"mw6SpJDWJeYTWsr2iEFNEbRuqmNhDjpsZS\",\n \"amount\": \"1.0\",\n \"claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#1812d3275894f62a055d59189a75698a071108af\",\n \"timestamp\": 1567524491,\n \"txid\": \"986dbf145a5320fe0047b3404216ddae76bb9e915895ebb04dda9c4e1b676be7\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200044974cd9d7098183f8bc9005f3957a4dbfc1ede19044311337fe9f645f256a7a4013c6a142497590bd8461fc50ce6b489453686422079c334bd5f8316b335365e\",\n \"public_key_id\": \"mrne5J4YN1SYYE3qNAAwzEVHAxnZX4AKHp\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1567524492,\n \"txid\": \"f3338742c2b4cf0e35b7ffa73aea3e9da786926cf82f07d3100e09d04ec3f231\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpmjego0ff\",\n \"sd_hash\": \"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n }\n ]\n}"
},
{
"title": "Paginate your stream claims",
"curl": "curl -d'{\"method\": \"stream_list\", \"params\": {\"page\": 1, \"page_size\": 20}}' http://localhost:5279/",
"lbrynet": "lbrynet stream list --page=1 --page_size=20",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_list\", \"params\": {\"page\": 1, \"page_size\": 20}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mpDcDEwvfvETWqTDhddKLTzZZS2GBQWBqC\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_change\": false,\n \"is_channel_signature_valid\": true,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#5d64500fb723eded83a41b0d5055f1783f019191\",\n \"signing_channel\": {\n \"address\": \"n3rBuPQB9qzAha4xU1uHyP5nmvR3WGq3r6\",\n \"amount\": \"1.0\",\n \"claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"timestamp\": 1561485089,\n \"txid\": \"0f7256329d0b2896d6f2472eea2614fbcf20ab6b22e27d168060ebb0adbaa6fa\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000465bebc31803d2a7f0f037f696665d4d610abea2e518f906410163dec7513fc2b9a82ae0c4a15602f467d4c03823d72cf95c36fc6a87e963356e44db502027ae2\",\n \"public_key_id\": \"mrqYtVaoPEPqgyRPExUPi7PrYJ9nDc59yW\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1561485090,\n \"txid\": \"dac2f1adaf5debd8cb377673b35ee4e6eb62ba7747b4440ffdb44d6875c2197e\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpzj1qbxfj\",\n \"sd_hash\": \"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\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}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"items\": [\n {\n \"address\": \"mqwocM9E8dcY9aHCaCGG6HXB8Pd3hA9KjF\",\n \"amount\": \"1.0\",\n \"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\n \"claim_op\": \"update\",\n \"confirmations\": 1,\n \"height\": 214,\n \"is_change\": false,\n \"is_channel_signature_valid\": true,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\n \"signing_channel\": {\n \"address\": \"mw6SpJDWJeYTWsr2iEFNEbRuqmNhDjpsZS\",\n \"amount\": \"1.0\",\n \"claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"claim_op\": \"update\",\n \"confirmations\": 5,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#1812d3275894f62a055d59189a75698a071108af\",\n \"timestamp\": 1567524491,\n \"txid\": \"986dbf145a5320fe0047b3404216ddae76bb9e915895ebb04dda9c4e1b676be7\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200044974cd9d7098183f8bc9005f3957a4dbfc1ede19044311337fe9f645f256a7a4013c6a142497590bd8461fc50ce6b489453686422079c334bd5f8316b335365e\",\n \"public_key_id\": \"mrne5J4YN1SYYE3qNAAwzEVHAxnZX4AKHp\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": 1567524492,\n \"txid\": \"f3338742c2b4cf0e35b7ffa73aea3e9da786926cf82f07d3100e09d04ec3f231\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpmjego0ff\",\n \"sd_hash\": \"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\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}"
}
]
},
@@ -2674,7 +2825,13 @@
{
"name": "account_id",
"type": "str",
"description": "account to use for funding the transaction",
"description": "account to use for holding the transaction",
"is_required": false
},
{
"name": "funding_account_ids",
"type": "list",
"description": "ids of accounts to fund this transaction",
"is_required": false
},
{
@@ -2706,10 +2863,10 @@
"examples": [
{
"title": "Update a stream claim to add channel",
"curl": "curl -d'{\"method\": \"stream_update\", \"params\": {\"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\", \"clear_fee\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"channel_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\", \"clear_channel\": false, \"channel_account_id\": [], \"preview\": false, \"blocking\": false, \"replace\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream update 5d64500fb723eded83a41b0d5055f1783f019191 --channel_id=\"7ed794458d57978c49572424e1d32c7fa4d5325e\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_update\", \"params\": {\"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\", \"clear_fee\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"channel_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\", \"clear_channel\": false, \"channel_account_id\": [], \"preview\": false, \"blocking\": false, \"replace\": false}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": {\n \"height\": -2,\n \"hex\": \"0100000002feffe89027066ca89809e9766581444c21dc68ec78dd6feead9b9c945da683c9000000006b483045022100d50e402d04306f995730a8cce777723723fff2846104882c27008649b9aae9bf022050a7b0432dd4a4bfd050e53cb072769cbd812f80e497c5c4c4c3e41bdae2e2800121039efda2d8dd29b422fb044b6ccf6791ec3b0489713619b3f9dd9e8c89a4e54779ffffffffb48acb3a85b381bcc76c473f47f0b8a7123aca7b0f793d4db380a2c9093b00aa010000006b483045022100a6948b248bedc73306df727c5068a0c34be18d9dde725e20c841719c0efcaea902203a842193eb567f4abee70e7560732cad4e216863d4c4d1c892359cff4678c18e012103931d91a3c5ade5cdc8a50814a522fcd34a309a6704ff608db69a878d214f6db0ffffffff0200e1f50500000000fd2301b7076173747265616d149191013f78f155500d1ba483eded23b70f50645d4ce8015e32d5a47f2cd3e1242457498c97578d4594d77ee519fc56b21384e97c75d5c1b6450f2138e209f7bbd2adb588609ba36d1982a2187070c391a89793a0b569f09fef656fe041eab1809e3964f6346ae0fb3d20f30a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d707a6a31716278666a180b22186170706c69636174696f6e2f6f637465742d73747265616d3230d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d36d6d76a9145f714bd8d8f78a7a6836eba4625ab0d05cbf9bf188ac32a0d205000000001976a9143b92d98084d9425628023c45e47f808c4abeacc588ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mpDcDEwvfvETWqTDhddKLTzZZS2GBQWBqC\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"height\": 213,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#5d64500fb723eded83a41b0d5055f1783f019191\",\n \"timestamp\": 1561485090,\n \"txid\": \"c983a65d949c9badee6fdd78ec68dc214c44816576e90998a86c062790e8fffe\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpzj1qbxfj\",\n \"sd_hash\": \"d85e47456630442a413f6cbedbdc4b0a5177770155d8a4523bbf2f301ebae95e0785cb475ca8d1a9d3cab54a05de64d3\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"mrxs9s9nJgdvS6qW2ca4yr5UY6RkWS5zk9\",\n \"amount\": \"0.9772285\",\n \"confirmations\": 3,\n \"height\": 211,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1561485089,\n \"txid\": \"aa003b09c9a280b34d3d790f7bca3a12a7b8f0473f476cc7bc81b3853acb8ab4\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mpDcDEwvfvETWqTDhddKLTzZZS2GBQWBqC\",\n \"amount\": \"1.0\",\n \"claim_id\": \"5d64500fb723eded83a41b0d5055f1783f019191\",\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#5d64500fb723eded83a41b0d5055f1783f019191\",\n \"signing_channel\": {\n \"address\": \"n3rBuPQB9qzAha4xU1uHyP5nmvR3WGq3r6\",\n \"amount\": \"1.0\",\n \"claim_id\": \"7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"claim_op\": \"update\",\n \"confirmations\": 4,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#7ed794458d57978c49572424e1d32c7fa4d5325e\",\n \"timestamp\": 1561485089,\n \"txid\": \"0f7256329d0b2896d6f2472eea2614fbcf20ab6b22e27d168060ebb0adbaa6fa\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a0342000465bebc31803d2a7f0f037f696665d4d610abea2e518f906410163dec7513fc2b9a82ae0c4a15602f467d4c03823d72cf95c36fc6a87e963356e44db502027ae2\",\n \"public_key_id\": \"mrqYtVaoPEPqgyRPExUPi7PrYJ9nDc59yW\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": null,\n \"txid\": \"dac2f1adaf5debd8cb377673b35ee4e6eb62ba7747b4440ffdb44d6875c2197e\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4Line truncated
"curl": "curl -d'{\"method\": \"stream_update\", \"params\": {\"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\", \"clear_fee\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"channel_id\": \"1812d3275894f62a055d59189a75698a071108af\", \"clear_channel\": false, \"channel_account_id\": [], \"funding_account_ids\": [], \"preview\": false, \"blocking\": false, \"replace\": false}}' http://localhost:5279/",
"lbrynet": "lbrynet stream update bfb7d50e084d6d246ca9ff909c401aab30a6f9a6 --channel_id=\"1812d3275894f62a055d59189a75698a071108af\"",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"stream_update\", \"params\": {\"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\", \"clear_fee\": false, \"tags\": [], \"clear_tags\": false, \"languages\": [], \"clear_languages\": false, \"locations\": [], \"clear_locations\": false, \"channel_id\": \"1812d3275894f62a055d59189a75698a071108af\", \"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\": \"01000000024a20996d8a41915cdfaf02c845717e5478ee6eed5664f8f8c3fe97dd207ad316000000006b4830450221009c4970496e636abc34224449e1f1d622371f01b147049da7f6f6f3bcb67baa2802200b3287b5a1c69d5ef2c2e3e7b7e9b380e9b8f4ab98432bb2af3f9ac4669d96690121023b0815369b8ef78200d00b1fef7fdd6bf0dac1a84cb34756aa390e54e07e85ecffffffffbded7fa7ca114b69dc8970c6a101c2f3025ece7ad98d45016b9506b99e79929b010000006a473044022013977e030d5d69106109c028565c3797bd4e38c6d3da87350ef2764a6dfa73be022050375628a5458937d7ad2d76acd4e405a75bf3fa5d99a8858417512e5c450697012102886cb9914841d8ba268858f82323ecab77a977d3cf5cf605a3bf0df8b70503e9ffffffff0200e1f50500000000fd2301b7076173747265616d14a6f9a630ab1a409c90ffa96c246d4d080ed5b7bf4ce801af0811078a69759a18595d052af6945827d31218a49f0b990dfb596d464fa5c166a752b4835b01f02dcabd712d4345b09c18ce4096395d25caf4fb962732f54d58df839f9dd7cc2ef1d4303c89e4dd553865ed060a90010a8d010a30fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd120b746d706d6a65676f306666180b22186170706c69636174696f6e2f6f637465742d73747265616d32302ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb376d6d76a914726468487bd5cd1825dbe133ff4c1fee98694a1988ac32a0d205000000001976a914b7fb7f269d470a1f77e83285c02e2d07f5a83c0588ac00000000\",\n \"inputs\": [\n {\n \"address\": \"mqwocM9E8dcY9aHCaCGG6HXB8Pd3hA9KjF\",\n \"amount\": \"1.0\",\n \"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\n \"claim_op\": \"create\",\n \"confirmations\": 1,\n \"height\": 213,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"astream\",\n \"normalized_name\": \"astream\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://astream#bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\n \"timestamp\": 1567524492,\n \"txid\": \"16d37a20dd97fec3f8f86456ed6eee78547e7145c802afdf5c91418a6d99204a\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd\",\n \"media_type\": \"application/octet-stream\",\n \"name\": \"tmpmjego0ff\",\n \"sd_hash\": \"2ab7bbd96cb5db43df9ff909c0555dd8a132866355768c41d24f2b4be7c0478ae5f82d2c853e95c9b1179c6743e4bb37\",\n \"size\": \"11\"\n },\n \"stream_type\": \"binary\"\n },\n \"value_type\": \"stream\"\n },\n {\n \"address\": \"myHCXzM5bmTxED6Tyc9WcLhGsP1u8M9Wfo\",\n \"amount\": \"0.9772285\",\n \"confirmations\": 3,\n \"height\": 211,\n \"is_change\": true,\n \"is_mine\": true,\n \"nout\": 1,\n \"timestamp\": 1567524491,\n \"txid\": \"9b92799eb906956b01458dd97ace5e02f3c201a1c67089dc694b11caa77fedbd\",\n \"type\": \"payment\"\n }\n ],\n \"outputs\": [\n {\n \"address\": \"mqwocM9E8dcY9aHCaCGG6HXB8Pd3hA9KjF\",\n \"amount\": \"1.0\",\n \"claim_id\": \"bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\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#bfb7d50e084d6d246ca9ff909c401aab30a6f9a6\",\n \"signing_channel\": {\n \"address\": \"mw6SpJDWJeYTWsr2iEFNEbRuqmNhDjpsZS\",\n \"amount\": \"1.0\",\n \"claim_id\": \"1812d3275894f62a055d59189a75698a071108af\",\n \"claim_op\": \"update\",\n \"confirmations\": 4,\n \"height\": 210,\n \"is_change\": false,\n \"is_mine\": true,\n \"meta\": {},\n \"name\": \"@channel\",\n \"normalized_name\": \"@channel\",\n \"nout\": 0,\n \"permanent_url\": \"lbry://@channel#1812d3275894f62a055d59189a75698a071108af\",\n \"timestamp\": 1567524491,\n \"txid\": \"986dbf145a5320fe0047b3404216ddae76bb9e915895ebb04dda9c4e1b676be7\",\n \"type\": \"claim\",\n \"value\": {\n \"public_key\": \"3056301006072a8648ce3d020106052b8104000a034200044974cd9d7098183f8bc9005f3957a4dbfc1ede19044311337fe9f645f256a7a4013c6a142497590bd8461fc50ce6b489453686422079c334bd5f8316b335365e\",\n \"public_key_id\": \"mrne5J4YN1SYYE3qNAAwzEVHAxnZX4AKHp\",\n \"title\": \"New Channel\"\n },\n \"value_type\": \"channel\"\n },\n \"timestamp\": null,\n \"txid\": \"f3338742c2b4cf0e35b7ffa73aea3e9da786926cf82f07d3100e09d04ec3f231\",\n \"type\": \"claim\",\n \"value\": {\n \"source\": {\n \"hash\": \"fdbd8e75a67f29f701a4e0Line truncated
}
]
}
@@ -2725,7 +2882,7 @@
{
"name": "claim_id",
"type": "str",
"description": "claim_id of the claim to abandon",
"description": "claim_id of the support to abandon",
"is_required": false
},
{
@@ -2793,7 +2950,13 @@
{
"name": "account_id",
"type": "str",
"description": "id of the account to use",
"description": "account to use for holding the transaction",
"is_required": false
},
{
"name": "funding_account_ids",
"type": "list",
"description": "ids of accounts to fund this transaction",
"is_required": false
},
{
@@ -2911,7 +3074,7 @@
"curl": "curl -d'{\"method\": \"transaction_list\", \"params\": {}}' http://localhost:5279/",
"lbrynet": "lbrynet transaction list",
"python": "requests.post(\"http://localhost:5279\", json={\"method\": \"transaction_list\", \"params\": {}}).json()",
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"abandon_info\": [],\n \"claim_info\": [],\n \"confirmations\": 1,\n \"date\": \"2019-06-25 13:51\",\n \"fee\": \"-0.000124\",\n \"support_info\": [],\n \"timestamp\": 1561485089,\n \"txid\": \"0e071fe12cfda37fb80dd634afb1a44bcb861e2de16009ad5628cc7f74776634\",\n \"update_info\": [],\n \"value\": \"-2.0\"\n },\n {\n \"abandon_info\": [],\n \"claim_info\": [],\n \"confirmations\": 7,\n \"date\": \"2019-06-25 13:51\",\n \"fee\": \"0.0\",\n \"support_info\": [],\n \"timestamp\": 1561485088,\n \"txid\": \"8fa093f2b4e99c1c7d1aef71a73092c72ebe1875a2481b2ccb4244a49126fcc0\",\n \"update_info\": [],\n \"value\": \"10.0\"\n }\n ]\n}"
"output": "{\n \"jsonrpc\": \"2.0\",\n \"result\": [\n {\n \"abandon_info\": [],\n \"claim_info\": [],\n \"confirmations\": 1,\n \"date\": \"2019-09-03 11:28\",\n \"fee\": \"-0.000124\",\n \"support_info\": [],\n \"timestamp\": 1567524491,\n \"txid\": \"3e770eda0c2cc8b74e0107e6395fc686a08e022814f55a8153f83fb0f5f923ab\",\n \"update_info\": [],\n \"value\": \"0.0\"\n },\n {\n \"abandon_info\": [],\n \"claim_info\": [],\n \"confirmations\": 7,\n \"date\": \"2019-09-03 11:28\",\n \"fee\": \"0.0\",\n \"support_info\": [],\n \"timestamp\": 1567524490,\n \"txid\": \"79b42ae4b80e2fcc997251899b763a4d3666beea57db5cd7628dfd14ed08152d\",\n \"update_info\": [],\n \"value\": \"10.0\"\n }\n ]\n}"
}
]
},
+1 -1
View File
@@ -1,4 +1,4 @@
__name__ = "lbry"
__version__ = "0.38.7"
__version__ = "0.41.0"
version = tuple(__version__.split('.'))
+29 -24
View File
@@ -1,7 +1,9 @@
import asyncio
import time
import logging
import typing
import binascii
from typing import Optional
from lbry.error import InvalidBlobHashError, InvalidDataError
from lbry.blob_exchange.serialization import BlobResponse, BlobRequest
from lbry.utils import cache_concurrent
@@ -65,7 +67,8 @@ class BlobExchangeClientProtocol(asyncio.Protocol):
self.blob.set_length(blob_response.length)
elif blob_response and not blob_response.error and self.blob.blob_hash != blob_response.blob_hash:
# the server started sending a blob we didn't request
log.warning("mismatch with self.blob %s", self.blob.blob_hash)
log.warning("%s started sending blob we didnt request %s instead of %s", self.peer_address,
blob_response.blob_hash, self.blob.blob_hash)
return
if response.responses:
log.debug("got response from %s:%i <- %s", self.peer_address, self.peer_port, response.to_dict())
@@ -94,10 +97,11 @@ class BlobExchangeClientProtocol(asyncio.Protocol):
if self._response_fut and not self._response_fut.done():
self._response_fut.set_exception(err)
async def _download_blob(self) -> typing.Tuple[int, typing.Optional[asyncio.Transport]]:
async def _download_blob(self) -> typing.Tuple[int, Optional['BlobExchangeClientProtocol']]:
"""
:return: download success (bool), keep connection (bool)
:return: download success (bool), connected protocol (BlobExchangeClientProtocol)
"""
start_time = time.perf_counter()
request = BlobRequest.make_request_for_blob_hash(self.blob.blob_hash)
blob_hash = self.blob.blob_hash
if not self.peer_address:
@@ -150,9 +154,11 @@ class BlobExchangeClientProtocol(asyncio.Protocol):
log.debug(msg)
msg = f"downloaded {self.blob.blob_hash[:8]} from {self.peer_address}:{self.peer_port}"
await asyncio.wait_for(self.writer.finished, self.peer_timeout, loop=self.loop)
log.info(msg)
log.info("%s at %fMB/s", msg,
round((float(self._blob_bytes_received) /
float(time.perf_counter() - start_time)) / 1000000.0, 2))
# await self.blob.finished_writing.wait() not necessary, but a dangerous change. TODO: is it needed?
return self._blob_bytes_received, self.transport
return self._blob_bytes_received, self
except asyncio.TimeoutError:
return self._blob_bytes_received, self.close()
except (InvalidBlobHashError, InvalidDataError):
@@ -173,11 +179,11 @@ class BlobExchangeClientProtocol(asyncio.Protocol):
self.transport = None
self.buf = b''
async def download_blob(self, blob: 'AbstractBlob') -> typing.Tuple[int, typing.Optional[asyncio.Transport]]:
async def download_blob(self, blob: 'AbstractBlob') -> typing.Tuple[int, Optional['BlobExchangeClientProtocol']]:
self.closed.clear()
blob_hash = blob.blob_hash
if blob.get_is_verified() or not blob.is_writeable():
return 0, self.transport
return 0, self
try:
self._blob_bytes_received = 0
self.blob, self.writer = blob, blob.get_blob_writer(self.peer_address, self.peer_port)
@@ -218,33 +224,32 @@ class BlobExchangeClientProtocol(asyncio.Protocol):
@cache_concurrent
async def request_blob(loop: asyncio.AbstractEventLoop, blob: typing.Optional['AbstractBlob'], address: str,
async def request_blob(loop: asyncio.AbstractEventLoop, blob: Optional['AbstractBlob'], address: str,
tcp_port: int, peer_connect_timeout: float, blob_download_timeout: float,
connected_transport: asyncio.Transport = None, connection_id: int = 0,
connection_manager: typing.Optional['ConnectionManager'] = None)\
-> typing.Tuple[int, typing.Optional[asyncio.Transport]]:
connected_protocol: Optional['BlobExchangeClientProtocol'] = None,
connection_id: int = 0, connection_manager: Optional['ConnectionManager'] = None)\
-> typing.Tuple[int, Optional['BlobExchangeClientProtocol']]:
"""
Returns [<downloaded blob>, <keep connection>]
Returns [<amount of bytes received>, <client protocol if connected>]
"""
protocol = BlobExchangeClientProtocol(
loop, blob_download_timeout, connection_manager
)
if connected_transport and not connected_transport.is_closing():
connected_transport.set_protocol(protocol)
protocol.transport = connected_transport
log.debug("reusing connection for %s:%d", address, tcp_port)
protocol = connected_protocol
if not connected_protocol or not connected_protocol.transport or connected_protocol.transport.is_closing():
connected_protocol = None
protocol = BlobExchangeClientProtocol(
loop, blob_download_timeout, connection_manager
)
else:
connected_transport = None
log.debug("reusing connection for %s:%d", address, tcp_port)
try:
if not connected_transport:
if not connected_protocol:
await asyncio.wait_for(loop.create_connection(lambda: protocol, address, tcp_port),
peer_connect_timeout, loop=loop)
connected_transport = protocol.transport
connected_protocol = protocol
if blob is None or blob.get_is_verified() or not blob.is_writeable():
# blob is None happens when we are just opening a connection
# file exists but not verified means someone is writing right now, give it time, come back later
return 0, connected_transport
return await protocol.download_blob(blob)
return 0, connected_protocol
return await connected_protocol.download_blob(blob)
except (asyncio.TimeoutError, ConnectionRefusedError, ConnectionAbortedError, OSError):
return 0, None
+11 -12
View File
@@ -9,6 +9,7 @@ if typing.TYPE_CHECKING:
from lbry.dht.peer import KademliaPeer
from lbry.blob.blob_manager import BlobManager
from lbry.blob.blob_file import AbstractBlob
from lbry.blob_exchange.client import BlobExchangeClientProtocol
log = logging.getLogger(__name__)
@@ -27,7 +28,7 @@ class BlobDownloader:
self.scores: typing.Dict['KademliaPeer', int] = {}
self.failures: typing.Dict['KademliaPeer', int] = {}
self.connection_failures: typing.List['KademliaPeer'] = []
self.connections: typing.Dict['KademliaPeer', asyncio.Transport] = {}
self.connections: typing.Dict['KademliaPeer', 'BlobExchangeClientProtocol'] = {}
self.is_running = asyncio.Event(loop=self.loop)
def should_race_continue(self, blob: 'AbstractBlob'):
@@ -40,26 +41,24 @@ class BlobDownloader:
just_probe: bool = False):
if blob.get_is_verified():
return
transport = self.connections.get(peer)
start = self.loop.time()
bytes_received, transport = await request_blob(
bytes_received, protocol = await request_blob(
self.loop, blob if not just_probe else None, peer.address, peer.tcp_port, self.config.peer_connect_timeout,
self.config.blob_download_timeout, connected_transport=transport, connection_id=connection_id,
connection_manager=self.blob_manager.connection_manager
self.config.blob_download_timeout, connected_protocol=self.connections.get(peer),
connection_id=connection_id, connection_manager=self.blob_manager.connection_manager
)
if not bytes_received and not transport and peer not in self.connection_failures:
if not bytes_received and not protocol and peer not in self.connection_failures:
self.connection_failures.append(peer)
if not transport and peer not in self.ignored:
if not protocol and peer not in self.ignored:
self.ignored[peer] = self.loop.time()
log.debug("drop peer %s:%i", peer.address, peer.tcp_port)
self.failures[peer] = self.failures.get(peer, 0) + 1
if peer in self.connections:
del self.connections[peer]
elif transport:
elif protocol:
log.debug("keep peer %s:%i", peer.address, peer.tcp_port)
self.failures[peer] = 0
self.connections[peer] = transport
self.connections[peer] = protocol
elapsed = self.loop.time() - start
self.scores[peer] = bytes_received / elapsed if bytes_received and elapsed else 1
@@ -120,8 +119,8 @@ class BlobDownloader:
self.scores.clear()
self.ignored.clear()
self.is_running.clear()
for transport in self.connections.values():
transport.close()
for protocol in self.connections.values():
protocol.close()
async def download_blob(loop, config: 'Config', blob_manager: 'BlobManager', node: 'Node',
+66 -22
View File
@@ -12,25 +12,56 @@ if typing.TYPE_CHECKING:
log = logging.getLogger(__name__)
# a standard request will be 295 bytes
MAX_REQUEST_SIZE = 1200
class BlobServerProtocol(asyncio.Protocol):
def __init__(self, loop: asyncio.AbstractEventLoop, blob_manager: 'BlobManager', lbrycrd_address: str):
def __init__(self, loop: asyncio.AbstractEventLoop, blob_manager: 'BlobManager', lbrycrd_address: str,
idle_timeout: float = 30.0, transfer_timeout: float = 60.0):
self.loop = loop
self.blob_manager = blob_manager
self.server_task: asyncio.Task = None
self.idle_timeout = idle_timeout
self.transfer_timeout = transfer_timeout
self.server_task: typing.Optional[asyncio.Task] = None
self.started_listening = asyncio.Event(loop=self.loop)
self.buf = b''
self.transport = None
self.transport: typing.Optional[asyncio.Transport] = None
self.lbrycrd_address = lbrycrd_address
self.peer_address_and_port: typing.Optional[str] = None
self.started_transfer = asyncio.Event(loop=self.loop)
self.transfer_finished = asyncio.Event(loop=self.loop)
self.close_on_idle_task: typing.Optional[asyncio.Task] = None
async def close_on_idle(self):
while self.transport:
try:
await asyncio.wait_for(self.started_transfer.wait(), self.idle_timeout, loop=self.loop)
except asyncio.TimeoutError:
log.debug("closing idle connection from %s", self.peer_address_and_port)
return self.close()
self.started_transfer.clear()
await self.transfer_finished.wait()
self.transfer_finished.clear()
def close(self):
if self.transport:
self.transport.close()
def connection_made(self, transport):
self.transport = transport
self.close_on_idle_task = self.loop.create_task(self.close_on_idle())
self.peer_address_and_port = "%s:%i" % self.transport.get_extra_info('peername')
self.blob_manager.connection_manager.connection_received(self.peer_address_and_port)
log.debug("received connection from %s", self.peer_address_and_port)
def connection_lost(self, exc: typing.Optional[Exception]) -> None:
log.debug("lost connection from %s", self.peer_address_and_port)
self.blob_manager.connection_manager.incoming_connection_lost(self.peer_address_and_port)
self.transport = None
if self.close_on_idle_task and not self.close_on_idle_task.done():
self.close_on_idle_task.cancel()
self.close_on_idle_task = None
def send_response(self, responses: typing.List[blob_response_types]):
to_send = []
@@ -65,20 +96,30 @@ class BlobServerProtocol(asyncio.Protocol):
incoming_blob = {'blob_hash': blob.blob_hash, 'length': blob.length}
responses.append(BlobDownloadResponse(incoming_blob=incoming_blob))
self.send_response(responses)
log.debug("send %s to %s:%i", blob.blob_hash[:8], peer_address, peer_port)
bh = blob.blob_hash[:8]
log.debug("send %s to %s:%i", bh, peer_address, peer_port)
self.started_transfer.set()
try:
sent = await blob.sendfile(self)
except (ConnectionResetError, BrokenPipeError, RuntimeError, OSError):
if self.transport:
self.transport.close()
return
log.info("sent %s (%i bytes) to %s:%i", blob.blob_hash[:8], sent, peer_address, peer_port)
sent = await asyncio.wait_for(blob.sendfile(self), self.transfer_timeout, loop=self.loop)
self.blob_manager.connection_manager.sent_data(self.peer_address_and_port, sent)
log.info("sent %s (%i bytes) to %s:%i", bh, sent, peer_address, peer_port)
except (ConnectionResetError, BrokenPipeError, RuntimeError, OSError, asyncio.TimeoutError) as err:
if isinstance(err, asyncio.TimeoutError):
log.debug("timed out sending blob %s to %s", bh, peer_address)
else:
log.debug("stopped sending %s to %s:%i", bh, peer_address, peer_port)
self.close()
finally:
self.transfer_finished.set()
if responses:
self.send_response(responses)
# self.transport.close()
def data_received(self, data):
request = None
if len(self.buf) + len(data or b'') >= MAX_REQUEST_SIZE:
log.warning("request from %s is too large", self.peer_address_and_port)
self.close()
return
if data:
self.blob_manager.connection_manager.received_data(self.peer_address_and_port, len(data))
message, separator, remainder = data.rpartition(b'}')
@@ -89,26 +130,28 @@ class BlobServerProtocol(asyncio.Protocol):
request = BlobRequest.deserialize(self.buf + data)
self.buf = remainder
except JSONDecodeError:
addr = self.transport.get_extra_info('peername')
peer_address, peer_port = addr
log.error("failed to decode blob request from %s:%i (%i bytes): %s", peer_address, peer_port,
len(data), '' if not data else binascii.hexlify(data).decode())
if not request:
addr = self.transport.get_extra_info('peername')
peer_address, peer_port = addr
log.warning("failed to decode blob request from %s:%i", peer_address, peer_port)
self.transport.close()
log.error("request from %s is not valid json (%i bytes): %s", self.peer_address_and_port,
len(self.buf + data), '' if not data else binascii.hexlify(self.buf + data).decode())
self.close()
return
if not request.requests:
log.error("failed to decode request from %s (%i bytes): %s", self.peer_address_and_port,
len(self.buf + data), '' if not data else binascii.hexlify(self.buf + data).decode())
self.close()
return
self.loop.create_task(self.handle_request(request))
class BlobServer:
def __init__(self, loop: asyncio.AbstractEventLoop, blob_manager: 'BlobManager', lbrycrd_address: str):
def __init__(self, loop: asyncio.AbstractEventLoop, blob_manager: 'BlobManager', lbrycrd_address: str,
idle_timeout: float = 30.0, transfer_timeout: float = 60.0):
self.loop = loop
self.blob_manager = blob_manager
self.server_task: typing.Optional[asyncio.Task] = None
self.started_listening = asyncio.Event(loop=self.loop)
self.lbrycrd_address = lbrycrd_address
self.idle_timeout = idle_timeout
self.transfer_timeout = transfer_timeout
self.server_protocol_class = BlobServerProtocol
def start_server(self, port: int, interface: typing.Optional[str] = '0.0.0.0'):
@@ -117,7 +160,8 @@ class BlobServer:
async def _start_server():
server = await self.loop.create_server(
lambda: self.server_protocol_class(self.loop, self.blob_manager, self.lbrycrd_address),
lambda: self.server_protocol_class(self.loop, self.blob_manager, self.lbrycrd_address,
self.idle_timeout, self.transfer_timeout),
interface, port
)
self.started_listening.set()
+2 -3
View File
@@ -377,12 +377,11 @@ class BaseConfig:
@contextmanager
def update_config(self):
if not isinstance(self.persisted, ConfigFileAccess):
raise TypeError("Config file cannot be updated.")
self._updating_config = True
yield self
self._updating_config = False
self.persisted.save()
if isinstance(self.persisted, ConfigFileAccess):
self.persisted.save()
@property
def modify_order(self):
+1 -2
View File
@@ -22,13 +22,12 @@ class BlobAnnouncer:
if peers > 4:
return blob_hash
else:
log.warning("failed to announce %s, could only find %d peers, retrying soon.", blob_hash[:8], peers)
log.debug("failed to announce %s, could only find %d peers, retrying soon.", blob_hash[:8], peers)
except Exception as err:
if isinstance(err, asyncio.CancelledError):
raise err
log.warning("error announcing %s: %s", blob_hash[:8], str(err))
async def _announce(self, batch_size: typing.Optional[int] = 10):
while batch_size:
if not self.node.joined.is_set():
+31 -3
View File
@@ -88,10 +88,10 @@ class Node:
)
stored_to = [node_id for node_id, contacted in stored_to_tup if contacted]
if stored_to:
log.info("Stored %s to %i of %i attempted peers", binascii.hexlify(hash_value).decode()[:8],
log.debug("Stored %s to %i of %i attempted peers", binascii.hexlify(hash_value).decode()[:8],
len(stored_to), len(peers))
else:
log.warning("Failed announcing %s, stored to 0 peers", blob_hash[:8])
log.debug("Failed announcing %s, stored to 0 peers", blob_hash[:8])
return stored_to
def stop(self) -> None:
@@ -208,8 +208,36 @@ class Node:
task.cancel()
async def _value_producer(self, blob_hash: str, result_queue: asyncio.Queue):
async def ping(_peer):
try:
await self.protocol.get_rpc_peer(_peer).ping()
result_queue.put_nowait([_peer])
except asyncio.TimeoutError:
pass
async for results in self.get_iterative_value_finder(binascii.unhexlify(blob_hash.encode())):
result_queue.put_nowait(results)
to_put = []
for peer in results:
if peer.address == self.protocol.external_ip and self.protocol.peer_port == peer.tcp_port:
continue
is_good = self.protocol.peer_manager.peer_is_good(peer)
if is_good:
to_put.append(peer)
elif is_good is None:
udp_port_to_try = 4444
if 3400 > peer.tcp_port > 3332:
if not peer.udp_port:
udp_port_to_try = (peer.tcp_port - 3333) + 4444
elif 4500 > peer.tcp_port > 4443:
if not peer.udp_port:
udp_port_to_try = peer.tcp_port
if not peer.udp_port:
peer.update_udp_port(udp_port_to_try)
self.loop.create_task(ping(peer))
else:
log.debug("skip bad peer %s:%i for %s", peer.address, peer.tcp_port, blob_hash)
if to_put:
result_queue.put_nowait(to_put)
def accumulate_peers(self, search_queue: asyncio.Queue,
peer_queue: typing.Optional[asyncio.Queue] = None) -> typing.Tuple[
+9
View File
@@ -218,6 +218,7 @@ class HeadersComponent(Component):
await self.headers.close()
else:
log.info("Header checkpoint verified.")
async def stop(self):
pass
@@ -240,6 +241,14 @@ class WalletComponent(Component):
remote_height = self.wallet_manager.ledger.network.remote_height
best_hash = self.wallet_manager.get_best_blockhash()
return {
'connected_servers': [
{
'host': session.server[0],
'port': session.server[1],
'latency': round(session.connection_latency, 2),
} for session in self.wallet_manager.ledger.network.session_pool.sessions
if session and session.available
],
'blocks': max(local_height, 0),
'blocks_behind': max(remote_height - local_height, 0),
'best_blockhash': best_hash,
+306 -123
View File
@@ -9,6 +9,7 @@ import base58
import random
import ecdsa
import hashlib
import tracemalloc
from urllib.parse import urlencode, quote
from typing import Callable, Optional, List
from binascii import hexlify, unhexlify
@@ -145,6 +146,14 @@ DHT_HAS_CONTACTS = "dht_has_contacts"
WALLET_IS_UNLOCKED = "wallet_is_unlocked"
def debug_log_tracemalloc():
snapshot = tracemalloc.take_snapshot()
top_stats = snapshot.statistics('lineno')
log.debug("[ Top 10 memory usage ]")
for stat in top_stats[:10]:
log.debug(stat)
class DHTHasContacts(RequiredCondition):
name = DHT_HAS_CONTACTS
component = DHT_COMPONENT
@@ -392,6 +401,10 @@ class Daemon(metaclass=JSONRPCServerType):
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 get_connection_status(self) -> str:
@@ -747,6 +760,13 @@ class Daemon(metaclass=JSONRPCServerType):
'best_blockhash': (str) block hash of most recent block,
'is_encrypted': (bool),
'is_locked': (bool),
'connected_servers': (list) [
{
'host': (str) server hostname,
'port': (int) server port,
'latency': (int) milliseconds
}
],
},
'dht': {
'node_id': (str) lbry dht node id - hex encoded,
@@ -784,6 +804,8 @@ class Daemon(metaclass=JSONRPCServerType):
}
}
"""
if tracemalloc.is_tracing():
debug_log_tracemalloc()
connection_code = await self.get_connection_status()
@@ -993,6 +1015,54 @@ class Daemon(metaclass=JSONRPCServerType):
setattr(c, key, cleaned)
return {key: cleaned}
PREFERENCE_DOC = """
Preferences management.
"""
def jsonrpc_preference_get(self, key=None, account_id=None):
"""
Get preference value for key or all values if not key is passed in.
Usage:
preference_get [<key>]
Options:
--key=<key> : (str) key associated with value
--account_id=<account_id> : (str) id of the account containing value
Returns:
(dict) Dictionary of preference(s)
"""
account = self.get_account_or_default(account_id)
if key:
if key in account.preferences:
return {key: account.preferences[key]}
return
return account.preferences
def jsonrpc_preference_set(self, key, value, account_id=None):
"""
Set preferences
Usage:
preference_set (<key>) (<value>)
Options:
--key=<key> : (str) key associated with value
--value=<key> : (str) key associated with value
--account_id=<account_id> : (str) id of the account containing value
Returns:
(dict) Dictionary with key/value of new preference
"""
account = self.get_account_or_default(account_id)
if value and isinstance(value, str) and value[0] in ('[', '{'):
value = json.loads(value)
account.preferences[key] = value
account.modified_on = time.time()
self.default_wallet.save()
return {key: value}
ACCOUNT_DOC = """
Create, modify and inspect wallet accounts.
"""
@@ -1455,7 +1525,7 @@ class Daemon(metaclass=JSONRPCServerType):
(bool) true, if address is associated with current wallet
"""
account = self.get_account_or_default(account_id)
match = await self.ledger.db.get_address(address=address, account=account)
match = await self.ledger.db.get_address(address=address, accounts=[account])
if match is not None:
return True
return False
@@ -1696,12 +1766,14 @@ class Daemon(metaclass=JSONRPCServerType):
Returns: {Paginated[Output]}
"""
account = self.get_account_or_default(account_id)
return maybe_paginate(
account.get_claims,
account.get_claim_count,
page, page_size
)
if account_id:
account = self.get_account_or_error(account_id)
claims = account.get_claims
claim_count = account.get_claim_count
else:
claims = self.ledger.get_claims
claim_count = self.ledger.get_claim_count
return maybe_paginate(claims, claim_count, page, page_size)
@requires(WALLET_COMPONENT)
async def jsonrpc_claim_search(self, **kwargs):
@@ -1852,7 +1924,7 @@ class Daemon(metaclass=JSONRPCServerType):
@requires(WALLET_COMPONENT, conditions=[WALLET_IS_UNLOCKED])
async def jsonrpc_channel_create(
self, name, bid, allow_duplicate_name=False, account_id=None, claim_address=None,
preview=False, blocking=False, **kwargs):
funding_account_ids=None, preview=False, blocking=False, **kwargs):
"""
Create a new channel by generating a channel private key and establishing an '@' prefixed claim.
@@ -1864,6 +1936,7 @@ class Daemon(metaclass=JSONRPCServerType):
[--tags=<tags>...] [--languages=<languages>...] [--locations=<locations>...]
[--thumbnail_url=<thumbnail_url>] [--cover_url=<cover_url>]
[--account_id=<account_id>] [--claim_address=<claim_address>]
[--funding_account_ids=<funding_account_ids>...]
[--preview] [--blocking]
Options:
@@ -1917,7 +1990,8 @@ class Daemon(metaclass=JSONRPCServerType):
--thumbnail_url=<thumbnail_url>: (str) thumbnail url
--cover_url=<cover_url> : (str) url of cover image
--account_id=<account_id> : (str) id of the account to store channel
--account_id=<account_id> : (str) account to use for holding the transaction
--funding_account_ids=<funding_account_ids>: (list) ids of accounts to fund this transaction
--claim_address=<claim_address>: (str) address where the channel is sent to, if not specified
it will be determined automatically from the account
--preview : (bool) do not broadcast the transaction
@@ -1926,6 +2000,7 @@ class Daemon(metaclass=JSONRPCServerType):
Returns: {Transaction}
"""
account = self.get_account_or_default(account_id)
funding_accounts = self.get_accounts_or_all(funding_account_ids)
self.valid_channel_name_or_error(name)
amount = self.get_dewies_or_error('bid', bid, positive_value=True)
claim_address = await self.get_receiving_address(claim_address, account)
@@ -1941,16 +2016,16 @@ class Daemon(metaclass=JSONRPCServerType):
claim = Claim()
claim.channel.update(**kwargs)
tx = await Transaction.claim_create(
name, claim, amount, claim_address, [account], account
name, claim, amount, claim_address, funding_accounts, funding_accounts[0]
)
txo = tx.outputs[0]
txo.generate_channel_private_key()
if not preview:
await tx.sign([account])
await tx.sign(funding_accounts)
account.add_channel_private_key(txo.private_key)
self.default_wallet.save()
await self.broadcast_or_release(account, tx, blocking)
await self.broadcast_or_release(tx, blocking)
await self.storage.save_claims([self._old_get_temp_claim_info(
tx, txo, claim_address, claim, name, dewies_to_lbc(amount)
)])
@@ -1963,7 +2038,8 @@ class Daemon(metaclass=JSONRPCServerType):
@requires(WALLET_COMPONENT, conditions=[WALLET_IS_UNLOCKED])
async def jsonrpc_channel_update(
self, claim_id, bid=None, account_id=None, claim_address=None,
new_signing_key=False, preview=False, blocking=False, replace=False, **kwargs):
funding_account_ids=None, new_signing_key=False, preview=False,
blocking=False, replace=False, **kwargs):
"""
Update an existing channel claim.
@@ -1977,6 +2053,7 @@ class Daemon(metaclass=JSONRPCServerType):
[--locations=<locations>...] [--clear_locations]
[--thumbnail_url=<thumbnail_url>] [--cover_url=<cover_url>]
[--account_id=<account_id>] [--claim_address=<claim_address>] [--new_signing_key]
[--funding_account_ids=<funding_account_ids>...]
[--preview] [--blocking] [--replace]
Options:
@@ -2032,7 +2109,8 @@ class Daemon(metaclass=JSONRPCServerType):
--clear_locations : (bool) clear existing locations (prior to adding new ones)
--thumbnail_url=<thumbnail_url>: (str) thumbnail url
--cover_url=<cover_url> : (str) url of cover image
--account_id=<account_id> : (str) id of the account to store channel
--account_id=<account_id> : (str) account to use for holding the transaction
--funding_account_ids=<funding_account_ids>: (list) ids of accounts to fund this transaction
--claim_address=<claim_address>: (str) address where the channel is sent
--new_signing_key : (bool) generate a new signing key, will invalidate all previous publishes
--preview : (bool) do not broadcast the transaction
@@ -2045,6 +2123,7 @@ class Daemon(metaclass=JSONRPCServerType):
Returns: {Transaction}
"""
account = self.get_account_or_default(account_id)
funding_accounts = self.get_accounts_or_all(funding_account_ids)
existing_channels = await account.get_claims(claim_id=claim_id)
if len(existing_channels) != 1:
@@ -2074,7 +2153,7 @@ class Daemon(metaclass=JSONRPCServerType):
claim = Claim.from_bytes(old_txo.claim.to_bytes())
claim.channel.update(**kwargs)
tx = await Transaction.claim_update(
old_txo, claim, amount, claim_address, [account], account
old_txo, claim, amount, claim_address, funding_accounts, funding_accounts[0]
)
new_txo = tx.outputs[0]
@@ -2086,10 +2165,10 @@ class Daemon(metaclass=JSONRPCServerType):
new_txo.script.generate()
if not preview:
await tx.sign([account])
await tx.sign(funding_accounts)
account.add_channel_private_key(new_txo.private_key)
self.default_wallet.save()
await self.broadcast_or_release(account, tx, blocking)
await self.broadcast_or_release(tx, blocking)
await self.storage.save_claims([self._old_get_temp_claim_info(
tx, new_txo, claim_address, new_txo.claim, new_txo.claim_name, dewies_to_lbc(amount)
)])
@@ -2139,7 +2218,7 @@ class Daemon(metaclass=JSONRPCServerType):
)
if not preview:
await self.broadcast_or_release(account, tx, blocking)
await self.broadcast_or_release(tx, blocking)
await self.analytics_manager.send_claim_action('abandon')
else:
await account.ledger.release_tx(tx)
@@ -2162,12 +2241,14 @@ class Daemon(metaclass=JSONRPCServerType):
Returns: {Paginated[Output]}
"""
account = self.get_account_or_default(account_id)
return maybe_paginate(
account.get_channels,
account.get_channel_count,
page, page_size
)
if account_id:
account = self.get_account_or_error(account_id)
channels = account.get_channels
channel_count = account.get_channel_count
else:
channels = self.ledger.get_channels
channel_count = self.ledger.get_channel_count
return maybe_paginate(channels, channel_count, page, page_size)
@requires(WALLET_COMPONENT)
async def jsonrpc_channel_export(self, channel_id=None, channel_name=None, account_id=None):
@@ -2221,15 +2302,39 @@ class Daemon(metaclass=JSONRPCServerType):
channel_private_key = ecdsa.SigningKey.from_pem(
data['signing_private_key'], hashfunc=hashlib.sha256
)
account: LBCAccount = await self.ledger.get_account_for_address(data['holding_address'])
if not account:
account = LBCAccount.from_dict(self.ledger, self.default_wallet, {
'name': f"Holding Account For Channel {data['name']}",
'public_key': data['holding_public_key'],
'address_generator': {'name': 'single-address'}
})
if self.ledger.network.is_connected:
await self.ledger.subscribe_account(account)
public_key_der = channel_private_key.get_verifying_key().to_der()
# check that the holding_address hasn't changed since the export was made
holding_address = data['holding_address']
channels, _, _ = await self.ledger.claim_search(
public_key_id=self.ledger.public_key_to_address(public_key_der)
)
if channels and channels[0].get_address(self.ledger) != holding_address:
holding_address = channels[0].get_address(self.ledger)
account: LBCAccount = await self.ledger.get_account_for_address(holding_address)
if account:
# Case 1: channel holding address is in one of the accounts we already have
# simply add the certificate to existing account
pass
else:
# Case 2: channel holding address hasn't changed and thus is in the bundled read-only account
# create a single-address holding account to manage the channel
if holding_address == data['holding_address']:
account = LBCAccount.from_dict(self.ledger, self.default_wallet, {
'name': f"Holding Account For Channel {data['name']}",
'public_key': data['holding_public_key'],
'address_generator': {'name': 'single-address'}
})
if self.ledger.network.is_connected:
await self.ledger.subscribe_account(account)
await self.ledger._update_tasks.done.wait()
# Case 3: the holding address has changed and we can't create or find an account for it
else:
raise Exception(
"Channel owning account has changed since the channel was exported and "
"it is not an account to which you have access."
)
account.add_channel_private_key(channel_private_key)
self.default_wallet.save()
return f"Added channel signing key for {data['name']}."
@@ -2254,6 +2359,7 @@ class Daemon(metaclass=JSONRPCServerType):
[--channel_id=<channel_id> | --channel_name=<channel_name>]
[--channel_account_id=<channel_account_id>...]
[--account_id=<account_id>] [--claim_address=<claim_address>]
[--funding_account_ids=<funding_account_ids>...]
[--preview] [--blocking]
Options:
@@ -2321,7 +2427,8 @@ class Daemon(metaclass=JSONRPCServerType):
--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
for channel certificates, defaults to all accounts.
--account_id=<account_id> : (str) account to use for funding the transaction
--account_id=<account_id> : (str) account to use for holding the 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
@@ -2352,8 +2459,8 @@ class Daemon(metaclass=JSONRPCServerType):
async def jsonrpc_stream_create(
self, name, bid, file_path, allow_duplicate_name=False,
channel_id=None, channel_name=None, channel_account_id=None,
account_id=None, claim_address=None, preview=False, blocking=False,
**kwargs):
account_id=None, claim_address=None, funding_account_ids=None,
preview=False, blocking=False, **kwargs):
"""
Make a new stream claim and announce the associated file to lbrynet.
@@ -2368,6 +2475,7 @@ class Daemon(metaclass=JSONRPCServerType):
[--channel_id=<channel_id> | --channel_name=<channel_name>]
[--channel_account_id=<channel_account_id>...]
[--account_id=<account_id>] [--claim_address=<claim_address>]
[--funding_account_ids=<funding_account_ids>...]
[--preview] [--blocking]
Options:
@@ -2437,7 +2545,8 @@ class Daemon(metaclass=JSONRPCServerType):
--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 funding the transaction
--account_id=<account_id> : (str) account to use for holding the 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
@@ -2447,6 +2556,7 @@ class Daemon(metaclass=JSONRPCServerType):
"""
self.valid_stream_name_or_error(name)
account = self.get_account_or_default(account_id)
funding_accounts = self.get_accounts_or_all(funding_account_ids)
channel = await self.get_channel_or_none(channel_account_id, channel_id, channel_name, for_signing=True)
amount = self.get_dewies_or_error('bid', bid, positive_value=True)
claim_address = await self.get_receiving_address(claim_address, account)
@@ -2463,7 +2573,7 @@ class Daemon(metaclass=JSONRPCServerType):
claim = Claim()
claim.stream.update(file_path=file_path, sd_hash='0'*96, **kwargs)
tx = await Transaction.claim_create(
name, claim, amount, claim_address, [account], account, channel
name, claim, amount, claim_address, funding_accounts, funding_accounts[0], channel
)
new_txo = tx.outputs[0]
@@ -2475,10 +2585,10 @@ class Daemon(metaclass=JSONRPCServerType):
if channel:
new_txo.sign(channel)
await tx.sign([account])
await tx.sign(funding_accounts)
if not preview:
await self.broadcast_or_release(account, tx, blocking)
await self.broadcast_or_release(tx, blocking)
await self.storage.save_claims([self._old_get_temp_claim_info(
tx, new_txo, claim_address, claim, name, dewies_to_lbc(amount)
)])
@@ -2494,7 +2604,7 @@ class Daemon(metaclass=JSONRPCServerType):
async def jsonrpc_stream_update(
self, claim_id, bid=None, file_path=None,
channel_id=None, channel_name=None, channel_account_id=None, clear_channel=False,
account_id=None, claim_address=None,
account_id=None, claim_address=None, funding_account_ids=None,
preview=False, blocking=False, replace=False, **kwargs):
"""
Update an existing stream claim and if a new file is provided announce it to lbrynet.
@@ -2513,6 +2623,7 @@ class Daemon(metaclass=JSONRPCServerType):
[--channel_id=<channel_id> | --channel_name=<channel_name> | --clear_channel]
[--channel_account_id=<channel_account_id>...]
[--account_id=<account_id>] [--claim_address=<claim_address>]
[--funding_account_ids=<funding_account_ids>...]
[--preview] [--blocking] [--replace]
Options:
@@ -2588,7 +2699,8 @@ class Daemon(metaclass=JSONRPCServerType):
--clear_channel : (bool) remove channel signature
--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 funding the transaction
--account_id=<account_id> : (str) account to use for holding the 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
@@ -2601,6 +2713,7 @@ class Daemon(metaclass=JSONRPCServerType):
Returns: {Transaction}
"""
account = self.get_account_or_default(account_id)
funding_accounts = self.get_accounts_or_all(funding_account_ids)
existing_claims = await account.get_claims(claim_id=claim_id)
if len(existing_claims) != 1:
@@ -2648,7 +2761,7 @@ class Daemon(metaclass=JSONRPCServerType):
claim = Claim.from_bytes(old_txo.claim.to_bytes())
claim.stream.update(file_path=file_path, **kwargs)
tx = await Transaction.claim_update(
old_txo, claim, amount, claim_address, [account], account, channel
old_txo, claim, amount, claim_address, funding_accounts, funding_accounts[0], channel
)
new_txo = tx.outputs[0]
@@ -2668,10 +2781,10 @@ class Daemon(metaclass=JSONRPCServerType):
if channel:
new_txo.sign(channel)
await tx.sign([account])
await tx.sign(funding_accounts)
if not preview:
await self.broadcast_or_release(account, tx, blocking)
await self.broadcast_or_release(tx, blocking)
await self.storage.save_claims([self._old_get_temp_claim_info(
tx, new_txo, claim_address, new_txo.claim, new_txo.claim_name, dewies_to_lbc(amount)
)])
@@ -2723,7 +2836,7 @@ class Daemon(metaclass=JSONRPCServerType):
)
if not preview:
await self.broadcast_or_release(account, tx, blocking)
await self.broadcast_or_release(tx, blocking)
await self.analytics_manager.send_claim_action('abandon')
else:
await account.ledger.release_tx(tx)
@@ -2746,12 +2859,14 @@ class Daemon(metaclass=JSONRPCServerType):
Returns: {Paginated[Output]}
"""
account = self.get_account_or_default(account_id)
return maybe_paginate(
account.get_streams,
account.get_stream_count,
page, page_size
)
if account_id:
account = self.get_account_or_error(account_id)
streams = account.get_streams
stream_count = account.get_stream_count
else:
streams = self.ledger.get_streams
stream_count = self.ledger.get_stream_count
return maybe_paginate(streams, stream_count, page, page_size)
@requires(WALLET_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, BLOB_COMPONENT,
DHT_COMPONENT, DATABASE_COMPONENT,
@@ -2778,7 +2893,7 @@ class Daemon(metaclass=JSONRPCServerType):
@requires(WALLET_COMPONENT, conditions=[WALLET_IS_UNLOCKED])
async def jsonrpc_support_create(
self, claim_id, amount, tip=False, account_id=None,
self, claim_id, amount, tip=False, account_id=None, funding_account_ids=None,
preview=False, blocking=False):
"""
Create a support or a tip for name claim.
@@ -2786,31 +2901,34 @@ class Daemon(metaclass=JSONRPCServerType):
Usage:
support_create (<claim_id> | --claim_id=<claim_id>) (<amount> | --amount=<amount>)
[--tip] [--account_id=<account_id>] [--preview] [--blocking]
[--funding_account_ids=<funding_account_ids>...]
Options:
--claim_id=<claim_id> : (str) claim_id of the claim to support
--amount=<amount> : (decimal) amount of support
--tip : (bool) send support to claim owner, default: false.
--account_id=<account_id> : (str) id of the account to use
--account_id=<account_id> : (str) account to use for holding the transaction
--funding_account_ids=<funding_account_ids>: (list) ids of accounts to fund this transaction
--preview : (bool) do not broadcast the transaction
--blocking : (bool) wait until transaction is in mempool
Returns: {Transaction}
"""
account = self.get_account_or_default(account_id)
funding_accounts = self.get_accounts_or_all(funding_account_ids)
amount = self.get_dewies_or_error("amount", amount)
claim = await self.ledger.get_claim_by_claim_id(claim_id)
claim_address = claim.get_address(self.ledger)
if not tip:
account = self.get_account_or_default(account_id)
claim_address = await account.receiving.get_or_create_usable_address()
tx = await Transaction.support(
claim.claim_name, claim_id, amount, claim_address, [account], account
claim.claim_name, claim_id, amount, claim_address, funding_accounts, funding_accounts[0]
)
if not preview:
await tx.sign([account])
await self.broadcast_or_release(account, tx, blocking)
await tx.sign(funding_accounts)
await self.broadcast_or_release(tx, blocking)
await self.storage.save_supports({claim_id: [{
'txid': tx.id,
'nout': tx.position,
@@ -2820,7 +2938,7 @@ class Daemon(metaclass=JSONRPCServerType):
}]})
await self.analytics_manager.send_claim_action('new_support')
else:
await account.ledger.release_tx(tx)
await self.ledger.release_tx(tx)
return tx
@@ -2840,12 +2958,14 @@ class Daemon(metaclass=JSONRPCServerType):
Returns: {Paginated[Output]}
"""
account = self.get_account_or_default(account_id)
return maybe_paginate(
account.get_supports,
account.get_support_count,
page, page_size
)
if account_id:
account = self.get_account_or_error(account_id)
supports = account.get_supports
support_count = account.get_support_count
else:
supports = self.ledger.get_supports
support_count = self.ledger.get_support_count
return maybe_paginate(supports, support_count, page, page_size)
@requires(WALLET_COMPONENT, conditions=[WALLET_IS_UNLOCKED])
async def jsonrpc_support_abandon(
@@ -2860,7 +2980,7 @@ class Daemon(metaclass=JSONRPCServerType):
[--account_id=<account_id>] [--preview] [--blocking]
Options:
--claim_id=<claim_id> : (str) claim_id of the claim to abandon
--claim_id=<claim_id> : (str) claim_id of the support to abandon
--txid=<txid> : (str) txid of the claim to abandon
--nout=<nout> : (int) nout of the claim to abandon
--keep=<keep> : (decimal) amount of lbc to keep as support
@@ -2870,12 +2990,18 @@ class Daemon(metaclass=JSONRPCServerType):
Returns: {Transaction}
"""
account = self.get_account_or_default(account_id)
if account_id:
account = self.get_account_or_error(account_id)
funding_accounts = [account]
get_supports = account.get_supports
else:
funding_accounts = self.ledger.accounts
get_supports = self.ledger.get_supports
if txid is not None and nout is not None:
supports = await account.get_supports(**{'txo.txid': txid, 'txo.position': nout})
supports = await get_supports(**{'txo.txid': txid, 'txo.position': nout})
elif claim_id is not None:
supports = await account.get_supports(claim_id=claim_id)
supports = await get_supports(claim_id=claim_id)
else:
raise Exception('Must specify claim_id, or txid and nout')
@@ -2896,14 +3022,14 @@ class Daemon(metaclass=JSONRPCServerType):
]
tx = await Transaction.create(
[Input.spend(txo) for txo in supports], outputs, [account], account
[Input.spend(txo) for txo in supports], outputs, funding_accounts, funding_accounts[0]
)
if not preview:
await self.broadcast_or_release(account, tx, blocking)
await self.broadcast_or_release(tx, blocking)
await self.analytics_manager.send_claim_action('abandon')
else:
await account.ledger.release_tx(tx)
await self.ledger.release_tx(tx)
return tx
@@ -2971,12 +3097,14 @@ class Daemon(metaclass=JSONRPCServerType):
}
"""
account = self.get_account_or_default(account_id)
return maybe_paginate(
self.wallet_manager.get_history,
self.ledger.db.get_transaction_count,
page, page_size, account=account
)
if account_id:
account = self.get_account_or_error(account_id)
transactions = account.get_transaction_history
transaction_count = account.get_transaction_history_count
else:
transactions = self.ledger.get_transaction_history
transaction_count = self.ledger.get_transaction_history_count
return maybe_paginate(transactions, transaction_count, page, page_size)
@requires(WALLET_COMPONENT)
def jsonrpc_transaction_show(self, txid):
@@ -3013,12 +3141,14 @@ class Daemon(metaclass=JSONRPCServerType):
Returns: {Paginated[Output]}
"""
account = self.get_account_or_default(account_id)
return maybe_paginate(
account.get_utxos,
account.get_utxo_count,
page, page_size
)
if account_id:
account = self.get_account_or_error(account_id)
utxos = account.get_utxos
utxo_count = account.get_utxo_count
else:
utxos = self.ledger.get_utxos
utxo_count = self.ledger.get_utxo_count
return maybe_paginate(utxos, utxo_count, page, page_size)
@requires(WALLET_COMPONENT)
def jsonrpc_utxo_release(self, account_id=None):
@@ -3126,9 +3256,10 @@ class Daemon(metaclass=JSONRPCServerType):
else:
search_bottom_out_limit = 4
peers = []
async for new_peers in self.dht_node.get_iterative_value_finder(unhexlify(blob_hash.encode()), max_results=1,
bottom_out_limit=search_bottom_out_limit):
peers.extend(new_peers)
peer_q = asyncio.Queue(loop=self.component_manager.loop)
await self.dht_node._value_producer(blob_hash, peer_q)
while not peer_q.empty():
peers.extend(peer_q.get_nowait())
results = [
{
"node_id": hexlify(peer.node_id).decode(),
@@ -3376,7 +3507,8 @@ class Daemon(metaclass=JSONRPCServerType):
@requires(WALLET_COMPONENT)
async def jsonrpc_comment_list(self, claim_id, parent_id=None, page=1, page_size=50,
include_replies=True, is_channel_signature_valid=False):
include_replies=True, is_channel_signature_valid=False,
hidden=False, visible=False):
"""
List comments associated with a claim.
@@ -3385,6 +3517,7 @@ class Daemon(metaclass=JSONRPCServerType):
[(--page=<page> --page_size=<page_size>)]
[--parent_id=<parent_id>] [--include_replies]
[--is_channel_signature_valid]
[--visible | --hidden]
Options:
--claim_id=<claim_id> : (str) The claim on which the comment will be made on
@@ -3395,6 +3528,8 @@ class Daemon(metaclass=JSONRPCServerType):
--is_channel_signature_valid : (bool) Only include comments with valid signatures.
[Warning: Paginated total size will not change, even
if list reduces]
--visible : (bool) Select only Visisble Comments
--hidden : (bool) Select only Hidden Comments
Returns:
(dict) Containing the list, and information about the paginated content:
@@ -3419,15 +3554,25 @@ class Daemon(metaclass=JSONRPCServerType):
]
}
"""
result = await comment_client.jsonrpc_post(
self.conf.comment_server,
"get_claim_comments",
claim_id=claim_id,
parent_id=parent_id,
page=page,
page_size=page_size,
top_level=not include_replies
)
if hidden ^ visible:
result = await comment_client.jsonrpc_post(
self.conf.comment_server,
'get_claim_hidden_comments',
claim_id=claim_id,
hidden=hidden,
page=page,
page_size=page_size
)
else:
result = await comment_client.jsonrpc_post(
self.conf.comment_server,
'get_claim_comments',
claim_id=claim_id,
parent_id=parent_id,
page=page,
page_size=page_size,
top_level=not include_replies
)
for comment in result.get('items', []):
channel_url = comment.get('channel_url')
if not channel_url:
@@ -3506,13 +3651,13 @@ class Daemon(metaclass=JSONRPCServerType):
comment_abandon (<comment_id> | --comment_id=<comment_id>)
Options:
--comment_id=<comment_id> : (str) The ID of the comment to be deleted.
--comment_id=<comment_id> : (str) The ID of the comment to be abandoned.
Returns:
(dict) Object with the `comment_id` passed in as the key, and a flag indicating if it was deleted
(dict) Object with the `comment_id` passed in as the key, and a flag indicating if it was abandoned
{
<comment_id> (str): {
"deleted": (bool)
"abandoned": (bool)
}
}
"""
@@ -3521,22 +3666,62 @@ class Daemon(metaclass=JSONRPCServerType):
self.conf.comment_server, 'get_channel_from_comment_id', comment_id=comment_id
)
if 'error' in channel:
return {comment_id: {'deleted': False}}
return {comment_id: {'abandoned': False}}
channel = await self.get_channel_or_none(None, **channel)
abandon_comment_body.update({
'channel_id': channel.claim_id,
'channel_name': channel.claim_name,
})
comment_client.sign_comment(abandon_comment_body, channel, abandon=True)
return await comment_client.jsonrpc_post(self.conf.comment_server, 'delete_comment', abandon_comment_body)
return await comment_client.jsonrpc_post(self.conf.comment_server, 'abandon_comment', abandon_comment_body)
async def broadcast_or_release(self, account, tx, blocking=False):
@requires(WALLET_COMPONENT)
async def jsonrpc_comment_hide(self, comment_ids: typing.Union[str, list]):
"""
Hide a comment published to a claim you control.
Usage:
comment_hide <comment_ids>...
Options:
--comment_ids=<comment_ids> : (str, list) one or more comment_id to hide.
Returns:
(dict) keyed by comment_id, containing success info
'<comment_id>': {
"hidden": (bool) flag indicating if comment_id was hidden
}
"""
if isinstance(comment_ids, str):
comment_ids = [comment_ids]
comments = await comment_client.jsonrpc_post(
self.conf.comment_server, 'get_comments_by_id', comment_ids=comment_ids
)
claim_ids = {comment['claim_id'] for comment in comments}
claims = {cid: await self.ledger.get_claim_by_claim_id(claim_id=cid) for cid in claim_ids}
pieces = []
for comment in comments:
claim = claims.get(comment['claim_id'])
if claim:
channel = await self.get_channel_or_none(
account_ids=[],
channel_id=claim.channel.claim_id,
channel_name=claim.channel.claim_name,
for_signing=True
)
piece = {'comment_id': comment['comment_id']}
comment_client.sign_comment(piece, channel, abandon=True)
pieces.append(piece)
return await comment_client.jsonrpc_post(self.conf.comment_server, 'hide_comments', pieces=pieces)
async def broadcast_or_release(self, tx, blocking=False):
try:
await account.ledger.broadcast(tx)
await self.ledger.broadcast(tx)
if blocking:
await account.ledger.wait(tx)
await self.ledger.wait(tx)
except:
await account.ledger.release_tx(tx)
await self.ledger.release_tx(tx)
raise
def valid_address_or_error(self, address):
@@ -3549,18 +3734,14 @@ class Daemon(metaclass=JSONRPCServerType):
def valid_stream_name_or_error(name: str):
try:
if not name:
raise Exception(
"Stream name cannot be blank."
)
raise Exception('Stream name cannot be blank.')
parsed = URL.parse(name)
if parsed.has_channel:
raise Exception(
"Stream names cannot start with '@' symbol. This is reserved for channels claims."
)
if not parsed.has_stream or parsed.stream.name != name:
raise Exception(
"Stream name has invalid characters."
)
raise Exception('Stream name has invalid characters.')
except (TypeError, ValueError):
raise Exception("Invalid stream name.")
@@ -3605,17 +3786,19 @@ class Daemon(metaclass=JSONRPCServerType):
key, value = 'name', channel_name
else:
raise ValueError("Couldn't find channel because a channel_id or channel_name was not provided.")
for account in self.get_accounts_or_all(account_ids):
channels = await account.get_channels(**{f'claim_{key}': value}, limit=1)
if len(channels) == 1:
if for_signing and channels[0].private_key is None:
raise Exception(f"Couldn't find private key for {key} '{value}'. ")
return channels[0]
elif len(channels) > 1:
raise ValueError(
f"Multiple channels found with channel_{key} '{value}', "
f"pass a channel_id to narrow it down."
)
channels = await self.ledger.get_channels(
accounts=self.get_accounts_or_all(account_ids),
**{f'claim_{key}': value}
)
if len(channels) == 1:
if for_signing and not channels[0].has_private_key:
raise Exception(f"Couldn't find private key for {key} '{value}'. ")
return channels[0]
elif len(channels) > 1:
raise ValueError(
f"Multiple channels found with channel_{key} '{value}', "
f"pass a channel_id to narrow it down."
)
raise ValueError(f"Couldn't find channel with channel_{key} '{value}'.")
def get_account_or_default(self, account_id: str, argument_name: str = "account", lbc_only=True) -> LBCAccount:
+10 -4
View File
@@ -51,13 +51,15 @@ def _download_properties(conf: Config, external_ip: str, resolve_duration: float
head_blob_hash: typing.Optional[str] = None,
head_blob_length: typing.Optional[int] = None,
head_blob_download_duration: typing.Optional[float] = None,
error: typing.Optional[str] = None) -> typing.Dict:
error: typing.Optional[str] = None, error_msg: typing.Optional[str] = None,
wallet_server: typing.Optional[str] = None) -> typing.Dict:
return {
"external_ip": external_ip,
"download_id": download_id,
"total_duration": round(total_duration, 4),
"resolve_duration": None if not resolve_duration else round(resolve_duration, 4),
"error": error,
"error_message": error_msg,
'name': name,
"outpoint": outpoint,
@@ -77,7 +79,8 @@ def _download_properties(conf: Config, external_ip: str, resolve_duration: float
"head_blob_length": head_blob_length,
"head_blob_duration": None if not head_blob_download_duration else round(head_blob_download_duration, 4),
"connection_failures_count": connection_failures_count
"connection_failures_count": connection_failures_count,
"wallet_server": wallet_server
}
@@ -184,11 +187,14 @@ class AnalyticsManager:
head_blob_hash: typing.Optional[str] = None,
head_blob_length: typing.Optional[int] = None,
head_blob_duration: typing.Optional[int] = None,
error: typing.Optional[str] = None):
error: typing.Optional[str] = None,
error_msg: typing.Optional[str] = None,
wallet_server: typing.Optional[str] = None):
await self.track(self._event(TIME_TO_FIRST_BYTES, _download_properties(
self.conf, self.external_ip, resolve_duration, total_duration, download_id, name, outpoint,
found_peers_count, tried_peers_count, connection_failures_count, added_fixed_peers, fixed_peers_delay,
sd_hash, sd_download_duration, head_blob_hash, head_blob_length, head_blob_duration, error
sd_hash, sd_download_duration, head_blob_hash, head_blob_length, head_blob_duration, error, error_msg,
wallet_server
)))
async def send_download_finished(self, download_id, name, sd_hash):
+1 -2
View File
@@ -57,8 +57,7 @@ async def jsonrpc_post(url: str, method: str, params: dict = None, **kwargs) ->
params = params or {}
params.update(kwargs)
json_body = {'jsonrpc': '2.0', 'id': None, 'method': method, 'params': params}
headers = {'Content-Type': 'application/json'}
async with utils.aiohttp_request('POST', url, json=json_body, headers=headers) as response:
async with utils.aiohttp_request('POST', url, json=json_body) as response:
try:
result = await response.json()
return result['result'] if 'result' in result else result
@@ -3,7 +3,8 @@ import time
import logging
import json
from decimal import Decimal
from typing import Optional
from aiohttp.client_exceptions import ClientError
from lbry.error import InvalidExchangeRateResponse, CurrencyConversionError
from lbry.utils import aiohttp_request
@@ -44,7 +45,7 @@ class MarketFeed:
self.params = params
self.fee = fee
self.rate = None
self._task: asyncio.Task = None
self._task: Optional[asyncio.Task] = None
self._online = True
def rate_is_initialized(self):
@@ -80,7 +81,7 @@ class MarketFeed:
try:
response = await asyncio.wait_for(self._make_request(), self.REQUESTS_TIMEOUT)
self._save_price(self._subtract_fee(self._handle_response(response)))
except (asyncio.TimeoutError, InvalidExchangeRateResponse) as err:
except (asyncio.TimeoutError, InvalidExchangeRateResponse, ClientError) as err:
self._on_error(err)
await asyncio.sleep(self.EXCHANGE_RATE_UPDATE_RATE_SEC)
@@ -148,7 +148,7 @@ class JSONResponseEncoder(JSONEncoder):
'amount': dewies_to_lbc(txo.amount),
'address': txo.get_address(self.ledger),
'confirmations': (best_height+1) - tx_height if tx_height > 0 else tx_height,
'timestamp': self.ledger.headers[tx_height]['timestamp'] if tx_height > 0 else None
'timestamp': self.ledger.headers[tx_height]['timestamp'] if 0 < tx_height <= best_height else None
}
if txo.is_change is not None:
output['is_change'] = txo.is_change
@@ -172,7 +172,7 @@ class JSONResponseEncoder(JSONEncoder):
'normalized_name': txo.normalized_name,
'claim_id': txo.claim_id,
'permanent_url': txo.permanent_url,
'meta': self.encode_claim_meta(txo.meta)
'meta': self.encode_claim_meta(txo.meta.copy())
})
if 'short_url' in output['meta']:
output['short_url'] = output['meta'].pop('short_url')
@@ -184,6 +184,8 @@ class JSONResponseEncoder(JSONEncoder):
output['value_type'] = txo.claim.claim_type
if self.include_protobuf:
output['protobuf'] = hexlify(txo.claim.to_bytes())
if txo.claim.is_channel:
output['has_signing_key'] = txo.has_private_key
if check_signature and txo.claim.is_signed:
if txo.channel is not None:
output['signing_channel'] = self.encode_output(txo.channel)
@@ -200,7 +202,7 @@ class JSONResponseEncoder(JSONEncoder):
if key.endswith('_amount'):
if isinstance(value, int):
meta[key] = dewies_to_lbc(value)
if meta.get('creation_height', 0) > 0:
if 0 < meta.get('creation_height', 0) <= self.ledger.headers.height:
meta['creation_timestamp'] = self.ledger.headers[meta['creation_height']]['timestamp']
return meta
@@ -218,15 +220,44 @@ class JSONResponseEncoder(JSONEncoder):
return result
def encode_file(self, managed_stream):
file = managed_stream.as_dict()
output_exists = managed_stream.output_file_exists
tx_height = managed_stream.stream_claim_info.height
best_height = self.ledger.headers.height
file.update({
return {
'streaming_url': managed_stream.stream_url,
'completed': managed_stream.completed,
'file_name': managed_stream.file_name if output_exists else None,
'download_directory': managed_stream.download_directory if output_exists else None,
'download_path': managed_stream.full_path if output_exists else None,
'points_paid': 0.0,
'stopped': not managed_stream.running,
'stream_hash': managed_stream.stream_hash,
'stream_name': managed_stream.descriptor.stream_name,
'suggested_file_name': managed_stream.descriptor.suggested_file_name,
'sd_hash': managed_stream.descriptor.sd_hash,
'mime_type': managed_stream.mime_type,
'key': managed_stream.descriptor.key,
'total_bytes_lower_bound': managed_stream.descriptor.lower_bound_decrypted_length(),
'total_bytes': managed_stream.descriptor.upper_bound_decrypted_length(),
'written_bytes': managed_stream.written_bytes,
'blobs_completed': managed_stream.blobs_completed,
'blobs_in_stream': managed_stream.blobs_in_stream,
'blobs_remaining': managed_stream.blobs_remaining,
'status': managed_stream.status,
'claim_id': managed_stream.claim_id,
'txid': managed_stream.txid,
'nout': managed_stream.nout,
'outpoint': managed_stream.outpoint,
'metadata': managed_stream.metadata,
'protobuf': managed_stream.metadata_protobuf,
'channel_claim_id': managed_stream.channel_claim_id,
'channel_name': managed_stream.channel_name,
'claim_name': managed_stream.claim_name,
'content_fee': managed_stream.content_fee,
'height': tx_height,
'confirmations': (best_height+1) - tx_height if tx_height > 0 else tx_height,
'timestamp': self.ledger.headers[tx_height]['timestamp'] if tx_height > 0 else None
})
return file
'confirmations': (best_height + 1) - tx_height if tx_height > 0 else tx_height,
'timestamp': self.ledger.headers[tx_height]['timestamp'] if 0 < tx_height <= best_height else None
}
def encode_claim(self, claim):
encoded = getattr(claim, claim.claim_type).to_dict()
+7 -3
View File
@@ -1,4 +1,5 @@
import asyncio
from aiohttp.client_exceptions import ClientError
import json
import logging.handlers
import traceback
@@ -49,9 +50,12 @@ class HTTPSLogglyHandler(logging.Handler):
return record.getMessage()
async def _emit(self, record):
payload = self.format(record)
async with utils.aiohttp_request('post', self.url, data=payload.encode(), cookies=self.cookies) as response:
self.cookies.update(response.cookies)
try:
async with utils.aiohttp_request('post', self.url, data=self.format(record).encode(),
cookies=self.cookies) as response:
self.cookies.update(response.cookies)
except ClientError:
pass
def emit(self, record):
asyncio.ensure_future(self._emit(record))
-119
View File
@@ -90,20 +90,6 @@ def get_claims_from_stream_hashes(transaction: sqlite3.Connection,
}
def get_content_claim_from_outpoint(transaction: sqlite3.Connection,
outpoint: str) -> typing.Optional[StoredStreamClaim]:
query = (
"select content_claim.stream_hash, c.*, case when c.channel_claim_id is not null then "
" (select claim_name from claim where claim_id==c.channel_claim_id) "
" else null end as channel_name "
" from content_claim "
" inner join claim c on c.claim_outpoint=content_claim.claim_outpoint and content_claim.claim_outpoint=?"
)
claim_fields = transaction.execute(query, (outpoint, )).fetchone()
if claim_fields:
return StoredStreamClaim(*claim_fields)
def _batched_select(transaction, query, parameters, batch_size=900):
for start_index in range(0, len(parameters), batch_size):
current_batch = parameters[start_index:start_index+batch_size]
@@ -325,31 +311,6 @@ class SQLiteStorage(SQLiteMixin):
"select status from blob where blob_hash=?", blob_hash
)
def should_announce(self, blob_hash: str):
return self.run_and_return_one_or_none(
"select should_announce from blob where blob_hash=?", blob_hash
)
def count_should_announce_blobs(self):
return self.run_and_return_one_or_none(
"select count(*) from blob where should_announce=1 and status='finished'"
)
def get_all_should_announce_blobs(self):
return self.run_and_return_list(
"select blob_hash from blob where should_announce=1 and status='finished'"
)
def get_all_finished_blobs(self):
return self.run_and_return_list(
"select blob_hash from blob where status='finished'"
)
def count_finished_blobs(self):
return self.run_and_return_one_or_none(
"select count(*) from blob where status='finished'"
)
def update_last_announced_blobs(self, blob_hashes: typing.List[str]):
def _update_last_announced_blobs(transaction: sqlite3.Connection):
last_announced = self.time_getter()
@@ -427,26 +388,6 @@ class SQLiteStorage(SQLiteMixin):
}
return self.db.run(_sync_blobs)
def sync_files_to_blobs(self):
def _sync_blobs(transaction: sqlite3.Connection):
transaction.executemany(
"update file set status='stopped' where stream_hash=?",
transaction.execute(
"select distinct sb.stream_hash from stream_blob sb "
"inner join blob b on b.blob_hash=sb.blob_hash and b.status=='pending'"
).fetchall()
)
return self.db.run(_sync_blobs)
def set_files_as_streaming(self, stream_hashes: typing.List[str]):
def _set_streaming(transaction: sqlite3.Connection):
transaction.executemany(
"update file set file_name=null, download_directory=null where stream_hash=?",
[(stream_hash, ) for stream_hash in stream_hashes]
)
return self.db.run(_set_streaming)
# # # # # # # # # stream functions # # # # # # # # #
async def stream_exists(self, sd_hash: str) -> bool:
@@ -459,11 +400,6 @@ class SQLiteStorage(SQLiteMixin):
"s.stream_hash=f.stream_hash and s.sd_hash=?", sd_hash)
return streams is not None
def rowid_for_stream(self, stream_hash: str) -> typing.Awaitable[typing.Optional[int]]:
return self.run_and_return_one_or_none(
"select rowid from file where stream_hash=?", stream_hash
)
def store_stream(self, sd_blob: 'BlobFile', descriptor: 'StreamDescriptor'):
return self.db.run(store_stream, sd_blob, descriptor)
@@ -509,12 +445,6 @@ class SQLiteStorage(SQLiteMixin):
"select stream_hash from stream where sd_hash = ?", sd_blob_hash
)
def get_stream_info_for_sd_hash(self, sd_blob_hash):
return self.run_and_return_one_or_none(
"select stream_hash, stream_name, suggested_filename, stream_key from stream where sd_hash = ?",
sd_blob_hash
)
def delete_stream(self, descriptor: 'StreamDescriptor'):
return self.db.run_with_foreign_keys_disabled(delete_stream, descriptor)
@@ -788,55 +718,6 @@ class SQLiteStorage(SQLiteMixin):
claim['effective_amount'] = calculate_effective_amount(claim['amount'], supports)
return claim
async def get_claims_from_stream_hashes(self, stream_hashes: typing.List[str],
include_supports: typing.Optional[bool] = True):
claims = await self.db.run(get_claims_from_stream_hashes, stream_hashes)
return {stream_hash: claim_info.as_dict() for stream_hash, claim_info in claims.items()}
async def get_claim(self, claim_outpoint, include_supports=True):
claim_info = await self.db.run(get_content_claim_from_outpoint, claim_outpoint)
if not claim_info:
return
result = claim_info.as_dict()
if include_supports:
supports = await self.get_supports(result['claim_id'])
result['supports'] = supports
result['effective_amount'] = calculate_effective_amount(result['amount'], supports)
return result
def get_unknown_certificate_ids(self):
def _get_unknown_certificate_claim_ids(transaction):
return [
claim_id for (claim_id,) in transaction.execute(
"select distinct c1.channel_claim_id from claim as c1 "
"where c1.channel_claim_id!='' "
"and c1.channel_claim_id not in "
"(select c2.claim_id from claim as c2)"
).fetchall()
]
return self.db.run(_get_unknown_certificate_claim_ids)
async def get_pending_claim_outpoints(self):
claim_outpoints = await self.run_and_return_list("select claim_outpoint from claim where height=-1")
results = {} # {txid: [nout, ...]}
for outpoint_str in claim_outpoints:
txid, nout = outpoint_str.split(":")
outputs = results.get(txid, [])
outputs.append(int(nout))
results[txid] = outputs
if results:
log.debug("missing transaction heights for %i claims", len(results))
return results
def save_claim_tx_heights(self, claim_tx_heights):
def _save_claim_heights(transaction):
for outpoint, height in claim_tx_heights.items():
transaction.execute(
"update claim set height=? where claim_outpoint=? and height=-1",
(height, outpoint)
)
return self.db.run(_save_claim_heights)
# # # # # # # # # reflector functions # # # # # # # # #
def update_reflected_stream(self, sd_hash, reflector_address, success=True):
+9 -42
View File
@@ -123,6 +123,14 @@ class ManagedStream:
def written_bytes(self) -> int:
return 0 if not self.output_file_exists else os.stat(self.full_path).st_size
@property
def completed(self):
return self.written_bytes >= self.descriptor.lower_bound_decrypted_length()
@property
def stream_url(self):
return f"http://{self.config.streaming_host}:{self.config.streaming_port}/stream/{self.sd_hash}"
async def update_status(self, status: str):
assert status in [self.STATUS_RUNNING, self.STATUS_STOPPED, self.STATUS_FINISHED]
self._status = status
@@ -179,7 +187,7 @@ class ManagedStream:
@property
def blobs_completed(self) -> int:
return sum([1 if self.blob_manager.is_blob_verified(b.blob_hash) else 0
return sum([1 if b.blob_hash in self.blob_manager.completed_blob_hashes else 0
for b in self.descriptor.blobs[:-1]])
@property
@@ -203,47 +211,6 @@ class ManagedStream:
def mime_type(self):
return guess_media_type(os.path.basename(self.descriptor.suggested_file_name))[0]
def as_dict(self) -> typing.Dict:
full_path = self.full_path
file_name = self.file_name
download_directory = self.download_directory
if not self.output_file_exists:
full_path = None
file_name = None
download_directory = None
return {
'streaming_url': f"http://{self.config.streaming_host}:{self.config.streaming_port}/stream/{self.sd_hash}",
'completed': self.written_bytes >= self.descriptor.lower_bound_decrypted_length(),
'file_name': file_name,
'download_directory': download_directory,
'points_paid': 0.0,
'stopped': not self.running,
'stream_hash': self.stream_hash,
'stream_name': self.descriptor.stream_name,
'suggested_file_name': self.descriptor.suggested_file_name,
'sd_hash': self.descriptor.sd_hash,
'download_path': full_path,
'mime_type': self.mime_type,
'key': self.descriptor.key,
'total_bytes_lower_bound': self.descriptor.lower_bound_decrypted_length(),
'total_bytes': self.descriptor.upper_bound_decrypted_length(),
'written_bytes': self.written_bytes,
'blobs_completed': self.blobs_completed,
'blobs_in_stream': self.blobs_in_stream,
'blobs_remaining': self.blobs_remaining,
'status': self.status,
'claim_id': self.claim_id,
'txid': self.txid,
'nout': self.nout,
'outpoint': self.outpoint,
'metadata': self.metadata,
'protobuf': self.metadata_protobuf,
'channel_claim_id': self.channel_claim_id,
'channel_name': self.channel_name,
'claim_name': self.claim_name,
'content_fee': self.content_fee
}
@classmethod
async def create(cls, loop: asyncio.AbstractEventLoop, config: 'Config', blob_manager: 'BlobManager',
file_path: str, key: typing.Optional[bytes] = None,
+4 -1
View File
@@ -448,6 +448,7 @@ class StreamManager:
finally:
if self.analytics_manager and (error or (stream and (stream.downloader.time_to_descriptor or
stream.downloader.time_to_first_bytes))):
server = self.wallet.ledger.network.client.server
self.loop.create_task(
self.analytics_manager.send_time_to_first_bytes(
resolved_time, self.loop.time() - start_time, None if not stream else stream.download_id,
@@ -462,7 +463,9 @@ class StreamManager:
None if not (stream and stream.descriptor) else stream.descriptor.blobs[0].blob_hash,
None if not (stream and stream.descriptor) else stream.descriptor.blobs[0].length,
None if not stream else stream.downloader.time_to_first_bytes,
None if not error else error.__class__.__name__
None if not error else error.__class__.__name__,
None if not error else str(error),
None if not server else f"{server[0]}:{server[1]}"
)
)
+5 -11
View File
@@ -81,28 +81,22 @@ def check_connection(server="lbry.com", port=80, timeout=5) -> bool:
try:
server = socket.gethostbyname(server)
socket.create_connection((server, port), timeout).close()
log.debug('Connection successful')
return True
except (socket.gaierror, socket.herror) as ex:
log.warning("Failed to connect to %s:%s. Unable to resolve domain. Trying to bypass DNS",
server, port)
log.debug("Failed to connect to %s:%s. Unable to resolve domain. Trying to bypass DNS",
server, port)
try:
server = "8.8.8.8"
port = 53
socket.create_connection((server, port), timeout).close()
log.debug('Connection successful')
return True
except Exception:
log.error("Failed to connect to %s:%s. Maybe the internet connection is not working",
server, port)
except OSError:
return False
except Exception:
log.error("Failed to connect to %s:%s. Maybe the internet connection is not working",
server, port)
except OSError:
return False
async def async_check_connection(server="lbry.com", port=80, timeout=5) -> bool:
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)
+1 -1
View File
@@ -2,7 +2,7 @@ __node_daemon__ = 'lbrycrdd'
__node_cli__ = 'lbrycrd-cli'
__node_bin__ = ''
__node_url__ = (
'https://github.com/lbryio/lbrycrd/releases/download/v0.12.4.1/lbrycrd-linux.zip'
'https://github.com/lbryio/lbrycrd/releases/download/v0.17.2.1/lbrycrd-linux.zip'
)
__spvserver__ = 'lbry.wallet.server.coin.LBCRegTest'
+24 -23
View File
@@ -6,6 +6,7 @@ from string import hexdigits
import ecdsa
from lbry.wallet.dewies import dewies_to_lbc
from lbry.wallet.constants import TXO_TYPES
from torba.client.baseaccount import BaseAccount, HierarchicalDeterministic
@@ -27,6 +28,7 @@ class Account(BaseAccount):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.channel_keys = {}
self.preferences = {}
@property
def hash(self) -> bytes:
@@ -38,6 +40,7 @@ class Account(BaseAccount):
def apply(self, d: dict):
super().apply(d)
self.channel_keys.update(d.get('certificates', {}))
self.preferences.update(d.get('preferences', {}))
def add_channel_private_key(self, private_key):
public_key_bytes = private_key.get_verifying_key().to_der()
@@ -74,7 +77,7 @@ class Account(BaseAccount):
def get_balance(self, confirmations=0, include_claims=False, **constraints):
if not include_claims:
constraints.update({'is_claim': 0, 'is_update': 0, 'is_support': 0})
constraints.update({'txo_type': 0})
return super().get_balance(confirmations, **constraints)
async def get_granular_balances(self, confirmations=0, reserved_subtotals=False):
@@ -82,7 +85,7 @@ class Account(BaseAccount):
get_total_balance = partial(self.get_balance, confirmations=confirmations, include_claims=True)
total = await get_total_balance()
if reserved_subtotals:
claims_balance = await get_total_balance(claim_type__or={'is_claim':True, 'is_update': True})
claims_balance = await get_total_balance(txo_type__in=[TXO_TYPES['stream'], TXO_TYPES['channel']])
for amount, spent, from_me, to_me, height in await self.get_support_summary():
if confirmations > 0 and not 0 < height <= self.ledger.headers.height - (confirmations - 1):
continue
@@ -94,8 +97,7 @@ class Account(BaseAccount):
reserved = claims_balance + supports_balance + tips_balance
else:
reserved = await self.get_balance(
confirmations=confirmations, include_claims=True,
claim_type__or={'is_claim': True, 'is_support': True, 'is_update': True}
confirmations=confirmations, include_claims=True, txo_type__gt=0
)
return {
'total': dewies_to_lbc(total),
@@ -118,54 +120,53 @@ class Account(BaseAccount):
def from_dict(cls, ledger, wallet, d: dict) -> 'Account':
account = super().from_dict(ledger, wallet, d)
account.channel_keys = d.get('certificates', {})
account.preferences = d.get('preferences', {})
return account
def to_dict(self, include_channel_keys=True):
def to_dict(self, include_channel_keys=True, include_preferences=True):
d = super().to_dict()
if include_channel_keys:
d['certificates'] = self.channel_keys
if include_preferences and self.preferences:
d['preferences'] = self.preferences
return d
async def get_details(self, **kwargs):
details = await super().get_details(**kwargs)
details['certificates'] = len(self.channel_keys)
if self.preferences:
details['preferences'] = self.preferences
return details
@staticmethod
def constraint_spending_utxos(constraints):
constraints.update({'is_claim': 0, 'is_update': 0, 'is_support': 0})
def get_transaction_history(self, **constraints):
return self.ledger.get_transaction_history(account=self, **constraints)
def get_utxos(self, **constraints):
self.constraint_spending_utxos(constraints)
return super().get_utxos(**constraints)
def get_utxo_count(self, **constraints):
self.constraint_spending_utxos(constraints)
return super().get_utxo_count(**constraints)
def get_transaction_history_count(self, **constraints):
return self.ledger.get_transaction_history_count(account=self, **constraints)
def get_claims(self, **constraints):
return self.ledger.db.get_claims(account=self, **constraints)
return self.ledger.get_claims(account=self, **constraints)
def get_claim_count(self, **constraints):
return self.ledger.db.get_claim_count(account=self, **constraints)
return self.ledger.get_claim_count(account=self, **constraints)
def get_streams(self, **constraints):
return self.ledger.db.get_streams(account=self, **constraints)
return self.ledger.get_streams(account=self, **constraints)
def get_stream_count(self, **constraints):
return self.ledger.db.get_stream_count(account=self, **constraints)
return self.ledger.get_stream_count(account=self, **constraints)
def get_channels(self, **constraints):
return self.ledger.db.get_channels(account=self, **constraints)
return self.ledger.get_channels(account=self, **constraints)
def get_channel_count(self, **constraints):
return self.ledger.db.get_channel_count(account=self, **constraints)
return self.ledger.get_channel_count(account=self, **constraints)
def get_supports(self, **constraints):
return self.ledger.db.get_supports(account=self, **constraints)
return self.ledger.get_supports(account=self, **constraints)
def get_support_count(self, **constraints):
return self.ledger.db.get_support_count(account=self, **constraints)
return self.ledger.get_support_count(account=self, **constraints)
def get_support_summary(self):
return self.ledger.db.get_supports_summary(account_id=self.id)
+5
View File
@@ -0,0 +1,5 @@
TXO_TYPES = {
"stream": 1,
"channel": 2,
"support": 3
}
+29 -27
View File
@@ -3,6 +3,7 @@ from typing import List
from torba.client.basedatabase import BaseDatabase
from lbry.wallet.transaction import Output
from lbry.wallet.constants import TXO_TYPES
class WalletDatabase(BaseDatabase):
@@ -17,15 +18,12 @@ class WalletDatabase(BaseDatabase):
script blob not null,
is_reserved boolean not null default 0,
txo_type integer not null default 0,
claim_id text,
claim_name text,
is_claim boolean not null default 0,
is_update boolean not null default 0,
is_support boolean not null default 0,
is_buy boolean not null default 0,
is_sell boolean not null default 0
claim_name text
);
create index if not exists txo_claim_id_idx on txo (claim_id);
create index if not exists txo_txo_type_idx on txo (txo_type);
"""
CREATE_TABLES_QUERY = (
@@ -40,20 +38,20 @@ class WalletDatabase(BaseDatabase):
def txo_to_row(self, tx, address, txo):
row = super().txo_to_row(tx, address, txo)
row.update({
'is_claim': txo.script.is_claim_name,
'is_update': txo.script.is_update_claim,
'is_support': txo.script.is_support_claim,
'is_buy': txo.script.is_buy_claim,
'is_sell': txo.script.is_sell_claim,
})
if txo.is_claim:
if txo.can_decode_claim:
row['txo_type'] = TXO_TYPES.get(txo.claim.claim_type, TXO_TYPES['stream'])
else:
row['txo_type'] = TXO_TYPES['stream']
elif txo.is_support:
row['txo_type'] = TXO_TYPES['support']
if txo.script.is_claim_involved:
row['claim_id'] = txo.claim_id
row['claim_name'] = txo.claim_name
return row
async def get_txos(self, **constraints) -> List[Output]:
my_account = constraints.get('my_account', constraints.get('account', None))
my_accounts = constraints.get('my_accounts', constraints.get('accounts', []))
txos = await super().get_txos(**constraints)
@@ -62,16 +60,20 @@ class WalletDatabase(BaseDatabase):
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 my_account is not None:
txo.private_key = my_account.get_channel_private_key(
txo.claim.channel.public_key_bytes
)
if txo.claim.is_channel and my_accounts:
for account in my_accounts:
private_key = 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_claims(
my_account=my_account,
my_accounts=my_accounts,
claim_id__in=channel_ids
))
}
@@ -83,7 +85,9 @@ class WalletDatabase(BaseDatabase):
@staticmethod
def constrain_claims(constraints):
constraints['claim_type__any'] = {'is_claim': 1, 'is_update': 1}
constraints['txo_type__in'] = [
TXO_TYPES['stream'], TXO_TYPES['channel']
]
async def get_claims(self, **constraints) -> List[Output]:
self.constrain_claims(constraints)
@@ -95,8 +99,7 @@ class WalletDatabase(BaseDatabase):
@staticmethod
def constrain_streams(constraints):
if 'claim_name' not in constraints or 'claim_id' not in constraints:
constraints['claim_name__not_like'] = '@%'
constraints['txo_type'] = TXO_TYPES['stream']
def get_streams(self, **constraints):
self.constrain_streams(constraints)
@@ -108,8 +111,7 @@ class WalletDatabase(BaseDatabase):
@staticmethod
def constrain_channels(constraints):
if 'claim_name' not in constraints or 'claim_id' not in constraints:
constraints['claim_name__like'] = '@%'
constraints['txo_type'] = TXO_TYPES['channel']
def get_channels(self, **constraints):
self.constrain_channels(constraints)
@@ -121,7 +123,7 @@ class WalletDatabase(BaseDatabase):
@staticmethod
def constrain_supports(constraints):
constraints['is_support'] = 1
constraints['txo_type'] = TXO_TYPES['support']
def get_supports(self, **constraints):
self.constrain_supports(constraints)
@@ -140,12 +142,12 @@ class WalletDatabase(BaseDatabase):
)
def get_supports_summary(self, account_id):
return self.db.execute_fetchall("""
return self.db.execute_fetchall(f"""
select txo.amount, exists(select * from txi where txi.txoid=txo.txoid) as spent,
(txo.txid in
(select txi.txid from txi join pubkey_address a on txi.address = a.address
where a.account = ?)) as from_me,
(txo.address in (select address from pubkey_address where account=?)) as to_me,
tx.height
from txo join tx using (txid) where is_support=1
from txo join tx using (txid) where txo_type={TXO_TYPES['support']}
""", (account_id, account_id))
+148 -5
View File
@@ -1,14 +1,14 @@
import asyncio
import logging
from binascii import unhexlify
from typing import Tuple, List, Dict
from typing import Tuple, List
from datetime import datetime
from torba.client.baseledger import BaseLedger
from torba.client.baseaccount import SingleKey
from lbry.schema.result import Outputs
from lbry.schema.url import URL
from lbry.wallet.dewies import dewies_to_lbc
from lbry.wallet.resolve import Resolver
from lbry.wallet.account import Account
from lbry.wallet.network import Network
from lbry.wallet.database import WalletDatabase
@@ -51,7 +51,6 @@ class MainNetLedger(BaseLedger):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fee_per_name_char = self.config.get('fee_per_name_char', self.default_fee_per_name_char)
self.resolver = Resolver(self)
async def _inflate_outputs(self, query):
outputs = Outputs.from_base64(await query)
@@ -74,10 +73,10 @@ class MainNetLedger(BaseLedger):
result[url] = {'error': f'{url} did not resolve to a claim'}
return result
async def claim_search(self, **kwargs) -> Tuple[List, int, int]:
async def claim_search(self, **kwargs) -> Tuple[List[Output], int, int]:
return await self._inflate_outputs(self.network.claim_search(**kwargs))
async def get_claim_by_claim_id(self, claim_id) -> Dict[str, Output]:
async def get_claim_by_claim_id(self, claim_id) -> Output:
for claim in (await self.claim_search(claim_id=claim_id))[0]:
return claim
@@ -109,6 +108,150 @@ class MainNetLedger(BaseLedger):
'Failed to display wallet state, please file issue '
'for this bug along with the traceback you see below:')
@staticmethod
def constraint_spending_utxos(constraints):
constraints['txo_type'] = 0
def get_utxos(self, **constraints):
self.constraint_spending_utxos(constraints)
return super().get_utxos(**constraints)
def get_utxo_count(self, **constraints):
self.constraint_spending_utxos(constraints)
return super().get_utxo_count(**constraints)
def get_claims(self, **constraints):
self.constraint_account_or_all(constraints)
return self.db.get_claims(**constraints)
def get_claim_count(self, **constraints):
self.constraint_account_or_all(constraints)
return self.db.get_claim_count(**constraints)
def get_streams(self, **constraints):
self.constraint_account_or_all(constraints)
return self.db.get_streams(**constraints)
def get_stream_count(self, **constraints):
self.constraint_account_or_all(constraints)
return self.db.get_stream_count(**constraints)
def get_channels(self, **constraints):
self.constraint_account_or_all(constraints)
return self.db.get_channels(**constraints)
def get_channel_count(self, **constraints):
self.constraint_account_or_all(constraints)
return self.db.get_channel_count(**constraints)
def get_supports(self, **constraints):
self.constraint_account_or_all(constraints)
return self.db.get_supports(**constraints)
def get_support_count(self, **constraints):
self.constraint_account_or_all(constraints)
return self.db.get_support_count(**constraints)
async def get_transaction_history(self, **constraints):
self.constraint_account_or_all(constraints)
txs = await self.db.get_transactions(**constraints)
headers = self.headers
history = []
for tx in txs:
ts = headers[tx.height]['timestamp'] if tx.height > 0 else None
item = {
'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,
'claim_info': [],
'update_info': [],
'support_info': [],
'abandon_info': []
}
is_my_inputs = all([txi.is_my_account 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['fee'] = dewies_to_lbc(-tx.fee)
else:
# someone else paid the fees
item['value'] = dewies_to_lbc(tx.net_account_balance)
item['fee'] = '0.0'
for txo in tx.my_claim_outputs:
item['claim_info'].append({
'address': txo.get_address(self),
'balance_delta': dewies_to_lbc(-txo.amount),
'amount': dewies_to_lbc(txo.amount),
'claim_id': txo.claim_id,
'claim_name': txo.claim_name,
'nout': txo.position
})
for txo in tx.my_update_outputs:
if is_my_inputs: # updating my own claim
previous = None
for txi in tx.inputs:
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:
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),
'amount': dewies_to_lbc(txo.amount),
'claim_id': txo.claim_id,
'claim_name': txo.claim_name,
'nout': txo.position
})
else: # someone sent us their claim
item['update_info'].append({
'address': txo.get_address(self),
'balance_delta': dewies_to_lbc(0),
'amount': dewies_to_lbc(txo.amount),
'claim_id': txo.claim_id,
'claim_name': txo.claim_name,
'nout': txo.position
})
for txo in tx.my_support_outputs:
item['support_info'].append({
'address': txo.get_address(self),
'balance_delta': dewies_to_lbc(txo.amount if not is_my_inputs else -txo.amount),
'amount': dewies_to_lbc(txo.amount),
'claim_id': txo.claim_id,
'claim_name': txo.claim_name,
'is_tip': not is_my_inputs,
'nout': txo.position
})
if is_my_inputs:
for txo in tx.other_support_outputs:
item['support_info'].append({
'address': txo.get_address(self),
'balance_delta': dewies_to_lbc(-txo.amount),
'amount': dewies_to_lbc(txo.amount),
'claim_id': txo.claim_id,
'claim_name': txo.claim_name,
'is_tip': is_my_inputs,
'nout': txo.position
})
for txo in tx.my_abandon_outputs:
item['abandon_info'].append({
'address': txo.get_address(self),
'balance_delta': dewies_to_lbc(txo.amount),
'amount': dewies_to_lbc(txo.amount),
'claim_id': txo.claim_id,
'claim_name': txo.claim_name,
'nout': txo.position
})
history.append(item)
return history
def get_transaction_history_count(self, **constraints):
self.constraint_account_or_all(constraints)
return self.db.get_transaction_count(**constraints)
class TestNetLedger(MainNetLedger):
network_name = 'testnet'
+2 -99
View File
@@ -3,16 +3,13 @@ import json
import logging
from binascii import unhexlify
from datetime import datetime
from torba.client.basemanager import BaseWalletManager
from torba.rpc.jsonrpc import CodeMessageError
from lbry.wallet.ledger import MainNetLedger
from lbry.wallet.account import BaseAccount
from lbry.wallet.transaction import Transaction
from lbry.wallet.database import WalletDatabase
from lbry.wallet.dewies import dewies_to_lbc
from lbry.conf import Config
@@ -202,6 +199,8 @@ class LbryWalletManager(BaseWalletManager):
if not tx:
try:
raw = await self.ledger.network.get_transaction(txid)
if not raw:
return {'success': False, 'code': 404, 'message': 'transaction not found'}
height = await self.ledger.network.get_transaction_height(txid)
except CodeMessageError as e:
return {'success': False, 'code': e.code, 'message': e.message}
@@ -209,102 +208,6 @@ class LbryWalletManager(BaseWalletManager):
await self.ledger.maybe_verify_transaction(tx, height)
return tx
@staticmethod
async def get_history(account: BaseAccount, **constraints):
headers = account.ledger.headers
txs = await account.get_transactions(**constraints)
history = []
for tx in txs:
ts = headers[tx.height]['timestamp'] if tx.height > 0 else None
item = {
'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,
'claim_info': [],
'update_info': [],
'support_info': [],
'abandon_info': []
}
is_my_inputs = all([txi.is_my_account 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['fee'] = dewies_to_lbc(-tx.fee)
else:
# someone else paid the fees
item['value'] = dewies_to_lbc(tx.net_account_balance)
item['fee'] = '0.0'
for txo in tx.my_claim_outputs:
item['claim_info'].append({
'address': txo.get_address(account.ledger),
'balance_delta': dewies_to_lbc(-txo.amount),
'amount': dewies_to_lbc(txo.amount),
'claim_id': txo.claim_id,
'claim_name': txo.claim_name,
'nout': txo.position
})
for txo in tx.my_update_outputs:
if is_my_inputs: # updating my own claim
previous = None
for txi in tx.inputs:
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:
previous = other_txo
break
if previous is not None:
item['update_info'].append({
'address': txo.get_address(account.ledger),
'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,
'nout': txo.position
})
else: # someone sent us their claim
item['update_info'].append({
'address': txo.get_address(account.ledger),
'balance_delta': dewies_to_lbc(0),
'amount': dewies_to_lbc(txo.amount),
'claim_id': txo.claim_id,
'claim_name': txo.claim_name,
'nout': txo.position
})
for txo in tx.my_support_outputs:
item['support_info'].append({
'address': txo.get_address(account.ledger),
'balance_delta': dewies_to_lbc(txo.amount if not is_my_inputs else -txo.amount),
'amount': dewies_to_lbc(txo.amount),
'claim_id': txo.claim_id,
'claim_name': txo.claim_name,
'is_tip': not is_my_inputs,
'nout': txo.position
})
if is_my_inputs:
for txo in tx.other_support_outputs:
item['support_info'].append({
'address': txo.get_address(account.ledger),
'balance_delta': dewies_to_lbc(-txo.amount),
'amount': dewies_to_lbc(txo.amount),
'claim_id': txo.claim_id,
'claim_name': txo.claim_name,
'is_tip': is_my_inputs,
'nout': txo.position
})
for txo in tx.my_abandon_outputs:
item['abandon_info'].append({
'address': txo.get_address(account.ledger),
'balance_delta': dewies_to_lbc(txo.amount),
'amount': dewies_to_lbc(txo.amount),
'claim_id': txo.claim_id,
'claim_name': txo.claim_name,
'nout': txo.position
})
history.append(item)
return history
def save(self):
for wallet in self.wallets:
wallet.save()
-404
View File
@@ -1,404 +0,0 @@
import logging
import asyncio
from binascii import unhexlify, hexlify
from lbry.utils import lru_cache_concurrent
from lbry.wallet.account import validate_claim_id
from lbry.wallet.dewies import dewies_to_lbc
from lbry.error import UnknownNameError, UnknownClaimID, UnknownURI, UnknownOutpoint
from lbry.schema.claim import Claim
from google.protobuf.message import DecodeError
from lbry.schema.url import URL
from lbry.wallet.claim_proofs import verify_proof, InvalidProofError
log = logging.getLogger(__name__)
class Resolver:
def __init__(self, ledger):
self.transaction_class = ledger.transaction_class
self.network = ledger.network
self.ledger = ledger
async def resolve(self, page, page_size, *uris):
uris = set(uris)
try:
for uri in uris:
for part in URL.parse(uri).parts:
if part.claim_id:
validate_claim_id(part.claim_id)
claim_trie_root = self.ledger.headers.claim_trie_root
resolutions = await self.network.get_values_for_uris(self.ledger.headers.hash().decode(), *uris)
if len(uris) > 1:
return await self._batch_handle(resolutions, uris, page, page_size, claim_trie_root)
return await self._handle_resolutions(resolutions, uris, page, page_size, claim_trie_root)
except ValueError as err:
return {'error': err.args[0]}
except Exception as e:
log.exception(e)
return {'error': str(e)}
async def _batch_handle(self, resolutions, uris, page, page_size, claim_trie_root):
futs = []
for uri in uris:
futs.append(
asyncio.ensure_future(self._handle_resolutions(resolutions, [uri], page, page_size, claim_trie_root))
)
results = await asyncio.gather(*futs)
return dict(list(map(lambda result: list(result.items())[0], results)))
@lru_cache_concurrent(256)
async def _fetch_tx(self, txid):
return self.transaction_class(unhexlify(await self.network.get_transaction(txid)))
async def _handle_resolutions(self, resolutions, requested_uris, page, page_size, claim_trie_root):
results = {}
for uri in requested_uris:
resolution = (resolutions or {}).get(uri, {})
if resolution:
try:
results[uri] = _handle_claim_result(
await self._handle_resolve_uri_response(uri, resolution, claim_trie_root, page, page_size),
uri
)
except (UnknownNameError, UnknownClaimID, UnknownURI) as err:
log.exception(err)
results[uri] = {'error': str(err)}
else:
results[uri] = {'error': "URI lbry://{} cannot be resolved".format(uri.replace("lbry://", ""))}
return results
async def _handle_resolve_uri_response(self, uri, resolution, claim_trie_root, page=0, page_size=10):
result = {}
parsed_uri = URL.parse(uri)
certificate_response = None
# parse an included certificate
if 'certificate' in resolution:
certificate_response = resolution['certificate']['result']
certificate_resolution_type = resolution['certificate']['resolution_type']
if certificate_resolution_type == "winning" and certificate_response:
if 'height' in certificate_response:
certificate_response = _verify_proof(parsed_uri.stream.name,
claim_trie_root,
certificate_response,
ledger=self.ledger)
elif certificate_resolution_type not in ['winning', 'claim_id', 'sequence']:
raise Exception(f"unknown response type: {certificate_resolution_type}")
result['certificate'] = await self.parse_and_validate_claim_result(certificate_response)
result['claims_in_channel'] = len(resolution.get('unverified_claims_in_channel', []))
# if this was a resolution for a name, parse the result
if 'claim' in resolution:
claim_response = resolution['claim']['result']
claim_resolution_type = resolution['claim']['resolution_type']
if claim_resolution_type == "winning" and claim_response:
if 'height' in claim_response:
claim_response = _verify_proof(parsed_uri.stream.name,
claim_trie_root,
claim_response,
ledger=self.ledger)
elif claim_resolution_type not in ["sequence", "winning", "claim_id"]:
raise Exception(f"unknown response type: {claim_resolution_type}")
result['claim'] = await self.parse_and_validate_claim_result(claim_response,
certificate_response)
# if this was a resolution for a name in a channel make sure there is only one valid
# match
elif 'unverified_claims_for_name' in resolution and 'certificate' in result:
unverified_claims_for_name = resolution['unverified_claims_for_name']
channel_info = await self.get_channel_claims_page(unverified_claims_for_name,
result['certificate'], page=1)
claims_in_channel, upper_bound = channel_info
if not claims_in_channel:
log.error("No valid claims for this name for this channel")
elif len(claims_in_channel) > 1:
log.warning("Multiple signed claims for the same name.")
winner = pick_winner_from_channel_path_collision(claims_in_channel)
if winner:
result['claim'] = winner
else:
log.error("No valid claims for this name for this channel")
else:
result['claim'] = claims_in_channel[0]
# parse and validate claims in a channel iteratively into pages of results
elif 'unverified_claims_in_channel' in resolution and 'certificate' in result:
ids_to_check = resolution['unverified_claims_in_channel']
channel_info = await self.get_channel_claims_page(ids_to_check, result['certificate'],
page=page, page_size=page_size)
claims_in_channel, upper_bound = channel_info
if claims_in_channel:
result['total_claims'] = upper_bound
result['claims_in_channel'] = claims_in_channel
elif 'error' not in result:
return {'error': 'claim not found', 'success': False, 'uri': str(parsed_uri)}
# invalid signatures can only return outside a channel
if result.get('claim', {}).get('has_signature', False):
if parsed_uri.has_stream and not result['claim']['signature_is_valid']:
return {'error': 'claim not found', 'success': False, 'uri': str(parsed_uri)}
return result
async def parse_and_validate_claim_result(self, claim_result, certificate=None):
if not claim_result or 'value' not in claim_result:
return claim_result
claim_result = _decode_claim_result(claim_result)
if claim_result.get('height'):
claim_result['timestamp'] = self.ledger.headers[claim_result['height']]['timestamp']
if claim_result.get('depth'):
claim_result['confirmations'] = claim_result.pop('depth')
if claim_result['value']:
claim_result['has_signature'] = False
if claim_result['value'].is_signed:
claim_result['has_signature'] = True
claim_tx = await self._fetch_tx(claim_result['txid'])
if certificate is None:
log.info("fetching certificate to check claim signature")
channel_id = claim_result['value'].signing_channel_id
certificate = (await self.network.get_claims_by_ids([channel_id])).get(channel_id)
if not certificate:
log.warning('Certificate %s not found', channel_id)
claim_result['channel_name'] = certificate['name'] if certificate else None
cert_tx = await self._fetch_tx(certificate['txid']) if certificate else None
claim_result['signature_is_valid'] = validate_claim_signature_and_get_channel_name(
claim_result, certificate, self.ledger, claim_tx=claim_tx, cert_tx=cert_tx
)
# fixme: workaround while json encoder isnt used here
if cert_tx:
channel_txo = cert_tx.outputs[certificate['nout']]
claim_result['signing_channel'] = {
'name': channel_txo.claim_name,
'claim_id': channel_txo.claim_id,
'value': channel_txo.claim
}
claim_result['is_channel_signature_valid'] = claim_result['signature_is_valid']
if 'amount' in claim_result:
claim_result['amount'] = dewies_to_lbc(claim_result['amount'])
claim_result['effective_amount'] = dewies_to_lbc(claim_result['effective_amount'])
claim_result['supports'] = [
{'txid': txid, 'nout': nout, 'amount': dewies_to_lbc(amount)}
for (txid, nout, amount) in claim_result['supports']
]
claim_result['height'] = claim_result.get('height', -1) or -1
claim_result['permanent_url'] = f"lbry://{claim_result['name']}#{claim_result['claim_id']}"
return claim_result
@staticmethod
def prepare_claim_queries(start_position, query_size, channel_claim_infos):
queries = [tuple()]
names = {}
# a table of index counts for the sorted claim ids, including ignored claims
absolute_position_index = {}
block_sorted_infos = sorted(channel_claim_infos.items(), key=lambda x: int(x[1][1]))
per_block_infos = {}
for claim_id, (name, height) in block_sorted_infos:
claims = per_block_infos.get(height, [])
claims.append((claim_id, name))
per_block_infos[height] = sorted(claims, key=lambda x: int(x[0], 16))
abs_position = 0
for height in sorted(per_block_infos.keys(), reverse=True):
for claim_id, name in per_block_infos[height]:
names[claim_id] = name
absolute_position_index[claim_id] = abs_position
if abs_position >= start_position:
if len(queries[-1]) >= query_size:
queries.append(tuple())
queries[-1] += (claim_id,)
abs_position += 1
return queries, names, absolute_position_index
async def iter_channel_claims_pages(self, queries, claim_positions, claim_names, certificate,
page_size=10):
# lbryum server returns a dict of {claim_id: (name, claim_height)}
# first, sort the claims by block height (and by claim id int value within a block).
# map the sorted claims into getclaimsbyids queries of query_size claim ids each
# send the batched queries to lbryum server and iteratively validate and parse
# the results, yield a page of results at a time.
# these results can include those where `signature_is_valid` is False. if they are skipped,
# page indexing becomes tricky, as the number of results isn't known until after having
# processed them.
# TODO: fix ^ in lbry.schema
async def iter_validate_channel_claims():
formatted_claims = []
for claim_ids in queries:
batch_result = await self.network.get_claims_by_ids(claim_ids)
for claim_id in claim_ids:
claim = batch_result[claim_id]
if claim['name'] == claim_names[claim_id]:
formatted_claim = await self.parse_and_validate_claim_result(claim, certificate)
formatted_claim['absolute_channel_position'] = claim_positions[
claim['claim_id']]
formatted_claims.append(formatted_claim)
else:
log.warning("ignoring claim with name mismatch %s %s", claim['name'],
claim['claim_id'])
return formatted_claims
results = []
for claim in await iter_validate_channel_claims():
results.append(claim)
# if there is a full page of results, yield it
if len(results) and len(results) % page_size == 0:
return results[-page_size:]
return results
async def get_channel_claims_page(self, channel_claim_infos, certificate, page, page_size=10):
page = page or 0
page_size = max(page_size, 1)
if page_size > 500:
raise Exception("page size above maximum allowed")
start_position = (page - 1) * page_size
queries, names, claim_positions = self.prepare_claim_queries(start_position, page_size,
channel_claim_infos)
upper_bound = len(claim_positions)
if not page:
return None, upper_bound
if start_position > upper_bound:
raise IndexError("claim %i greater than max %i" % (start_position, upper_bound))
page_generator = await self.iter_channel_claims_pages(queries, claim_positions, names,
certificate, page_size=page_size)
return page_generator, upper_bound
def _verify_proof(name, claim_trie_root, result, ledger):
"""
Verify proof for name claim
"""
support_amount = sum([amt for (stxid, snout, amt) in result['supports']])
def _build_response(name, tx, nOut):
output = tx.outputs[nOut]
r = {
'name': name,
'value': hexlify(output.script.values['claim']),
'claim_id': output.claim_id,
'txid': tx.id,
'nout': nOut,
'amount': output.amount,
'effective_amount': output.amount + support_amount,
'height': result['height'],
'confirmations': result['depth'],
'claim_sequence': result['claim_sequence'],
'address': output.get_address(ledger),
'valid_at_height': result['valid_at_height'],
'timestamp': ledger.headers[result['height']]['timestamp'],
'supports': result['supports']
}
return r
def _parse_proof_result(name, result):
if 'txhash' in result['proof'] and 'nOut' in result['proof']:
if 'transaction' in result:
tx = ledger.transaction_class(raw=unhexlify(result['transaction']))
nOut = result['proof']['nOut']
if result['proof']['txhash'] == tx.id:
if 0 <= nOut < len(tx.outputs):
if tx.outputs[nOut].claim_name == name:
return _build_response(name, tx, nOut)
return {'error': 'name in proof did not match requested name'}
outputs = len(tx['outputs'])
return {'error': 'invalid nOut: %d (let(outputs): %d' % (nOut, outputs)}
return {'error': "computed txid did not match given transaction: %s vs %s" %
(tx.id, result['proof']['txhash'])
}
return {'error': "didn't receive a transaction with the proof"}
return {'error': 'name is not claimed'}
if 'proof' in result:
name = result.get('name', name)
proof_name = result.get('normalized_name', name)
try:
verify_proof(result['proof'], claim_trie_root, proof_name)
except InvalidProofError:
return {'error': "Proof was invalid"}
return _parse_proof_result(name, result)
else:
return {'error': "proof not in result"}
def validate_claim_signature_and_get_channel_name(claim_result, certificate_claim, ledger,
claim_tx=None, cert_tx=None):
valid_signature = False
if cert_tx and certificate_claim and claim_tx and claim_result:
valid_signature = claim_tx.outputs[claim_result['nout']].is_signed_by(
cert_tx.outputs[certificate_claim['nout']], ledger
)
if not valid_signature:
log.warning("lbry://%s#%s has an invalid signature",
claim_result['name'], claim_result['claim_id'])
return valid_signature
# TODO: The following came from code handling lbryum results. Now that it's all in one place a refactor should unify it.
def _decode_claim_result(claim):
if 'decoded_claim' in claim:
return claim
if 'value' not in claim:
log.warning('Got an invalid claim while parsing, please report: %s', claim)
claim['protobuf'] = None
claim['value'] = None
backend_message = ' SDK message: ' + claim.get('error', '')
claim['error'] = "Failed to parse: missing value." + backend_message
return claim
try:
if not isinstance(claim['value'], Claim):
claim['value'] = Claim.from_bytes(unhexlify(claim['value']))
claim['protobuf'] = hexlify(claim['value'].to_bytes())
claim['decoded_claim'] = True
except DecodeError:
claim['decoded_claim'] = False
claim['protobuf'] = claim['value']
claim['value'] = None
return claim
def _handle_claim_result(results, uri):
if not results:
raise UnknownURI(uri)
if 'error' in results:
if results['error'] in ['name is not claimed', 'claim not found']:
if 'claim_id' in results:
raise UnknownClaimID(results['claim_id'])
if 'name' in results:
raise UnknownNameError(results['name'])
if 'uri' in results:
raise UnknownURI(results['uri'])
if 'outpoint' in results:
raise UnknownOutpoint(results['outpoint'])
raise Exception(results['error'])
if not {'value', 'claim', 'certificate'}.intersection(results.keys()):
raise Exception(f'result in unexpected format:{results}')
return results
def pick_winner_from_channel_path_collision(claims_in_channel):
# we should be doing this by effective amount so we pick the controlling claim, however changing the resolved
# claim triggers another issue where 2 claims cant be saved for the same file. This code picks the oldest, so it
# stays the same. Using effective amount would change the resolved claims for a channel path on takeovers,
# potentially triggering that.
winner = {}
for claim in claims_in_channel:
if not winner or claim['height'] < winner['height'] or \
(claim['height'] == winner['height'] and claim['nout'] < winner['nout']):
winner = claim if claim['signature_is_valid'] else winner
return winner or None
+1 -1
View File
@@ -102,7 +102,7 @@ class LBC(Coin):
'''
Overrides electrumx hashX from script by extracting addresses from claim scripts.
'''
if script and script[0] == OpCodes.OP_RETURN:
if script and script[0] == OpCodes.OP_RETURN or not script:
return None
if script[0] in [
OutputScript.OP_CLAIM_NAME,
+3 -1
View File
@@ -1,3 +1,4 @@
import os
import sqlite3
from typing import Union, Tuple, Set, List
from itertools import chain
@@ -705,7 +706,8 @@ class LBRYDB(DB):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.sql = SQLDB(self, 'claims.db')
path = os.path.join(self.env.db_dir, 'claims.db')
self.sql = SQLDB(self, path)
def close(self):
super().close()
+2 -2
View File
@@ -52,7 +52,7 @@ class APICallMetrics:
self.errored_queries = set()
self.interrupted_queries = set()
def to_json_and_reset(self):
def to_json(self):
return {
# total requests received
"receive_count": self.receive_count,
@@ -128,7 +128,7 @@ class ServerLoadData:
def to_json_and_reset(self, status):
try:
return {
'api': {name: api.to_json_and_reset() for name, api in self._apis.items()},
'api': {name: api.to_json() for name, api in self._apis.items()},
'status': status
}
finally:
+24 -8
View File
@@ -54,16 +54,20 @@ class LBRYSessionManager(SessionManager):
async def process_metrics(self):
while self.running:
data = self.metrics.to_json_and_reset({'sessions': self.session_count()})
data = self.metrics.to_json_and_reset({
'sessions': self.session_count(),
'height': self.db.db_height,
})
if self.websocket is not None:
self.websocket.send_message(data)
await asyncio.sleep(1)
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, 'claims.db', self.env.coin.NET, self.env.database_query_timeout,
initargs=(self.logger, path, self.env.coin.NET, self.env.database_query_timeout,
self.env.track_metrics)
)
if self.env.max_query_workers is not None and self.env.max_query_workers == 0:
@@ -109,33 +113,44 @@ class LBRYElectrumX(ElectrumX):
}
self.request_handlers.update(handlers)
async def run_in_executor(self, metrics: APICallMetrics, func, kwargs):
def get_metrics_or_placeholder_for_api(self, query_name):
""" Do not hold on to a reference to the metrics
returned by this method past an `await` or
you may be working with a stale metrics object.
"""
if self.env.track_metrics:
return self.session_mgr.metrics.for_api(query_name)
else:
return APICallMetrics(query_name)
async def run_in_executor(self, query_name, func, kwargs):
start = time.perf_counter()
try:
result = await asyncio.get_running_loop().run_in_executor(
self.session_mgr.query_executor, func, kwargs
)
except reader.SQLiteInterruptedError as error:
metrics = self.get_metrics_or_placeholder_for_api(query_name)
metrics.query_interrupt(start, error.metrics)
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)
raise RPCError(JSONRPC.INTERNAL_ERROR, 'query failed to execute')
except:
metrics = self.get_metrics_or_placeholder_for_api(query_name)
metrics.query_error(start, {})
raise RPCError(JSONRPC.INTERNAL_ERROR, 'unknown server error')
if self.env.track_metrics:
metrics = self.get_metrics_or_placeholder_for_api(query_name)
(result, metrics_data) = result
metrics.query_response(start, metrics_data)
return base64.b64encode(result).decode()
async def run_and_cache_query(self, query_name, function, kwargs):
if self.env.track_metrics:
metrics = self.session_mgr.metrics.for_api(query_name)
else:
metrics = APICallMetrics(query_name)
metrics = self.get_metrics_or_placeholder_for_api(query_name)
metrics.start()
cache = self.session_mgr.search_cache[query_name]
cache_key = str(kwargs)
@@ -148,9 +163,10 @@ class LBRYElectrumX(ElectrumX):
async with cache_item.lock:
if cache_item.result is None:
cache_item.result = await self.run_in_executor(
metrics, function, kwargs
query_name, function, kwargs
)
else:
metrics = self.get_metrics_or_placeholder_for_api(query_name)
metrics.cache_response()
return cache_item.result
+3 -2
View File
@@ -8,7 +8,7 @@ RUN mkdir -p /home/$user/
RUN chown -R $user:$user /home/$user/
# install python, pip, git and clean up
RUN apt-get update && apt-get -y --no-install-recommends install build-essential git python3.7 python3.7-dev python3-pip && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get -y --no-install-recommends install build-essential git tar wget python3.7 python3.7-dev python3-pip && rm -rf /var/lib/apt/lists/*
# create and chown database dir
ARG db_dir=/database
@@ -53,4 +53,5 @@ ENV BANDWIDTH_LIMIT=1000000000000000000000000000000000000000000
ENV MAX_SESSIONS=1000000000
ENV MAX_SEND=1000000000000000000
ENV EVENT_LOOP_POLICY=uvloop
ENTRYPOINT ["/home/lbry/.local/bin/torba-server"]
COPY ./lbry/scripts/wallet_server_entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
+20
View File
@@ -78,11 +78,31 @@ class Examples(CommandTestCase):
'Get version',
'version'
)
# settings
await r(
'Get settings',
'settings', 'get'
)
await r(
'Set settings',
'settings', 'set', '"tcp_port"', '99'
)
# preferences
await r(
'Set preference',
'preference', 'set', '"theme"', '"dark"'
)
await r(
'Get preferences',
'preference', 'get'
)
# accounts
await r(
+47
View File
@@ -0,0 +1,47 @@
import asyncio
from torba.client.basenetwork import ClientSession
from torba.rpc.jsonrpc import RPCError
import logging
import json
import sys
logging.getLogger('torba').setLevel(logging.CRITICAL)
async def main():
try:
hostname = sys.argv[1]
except IndexError:
hostname = 'spv1.lbry.com'
loop = asyncio.get_event_loop()
client = ClientSession(network=None, server=(hostname, 50001))
error = None
args = {
'any_tags': ['art'],
'not_tags': ['xxx', 'porn', 'mature', 'nsfw', 'titan'],
'order_by': ["name"],
'offset': 3000,
'limit': 200,
'no_totals': False,
}
start = loop.time()
try:
await client.create_connection()
try:
await client.send_request('blockchain.claimtrie.search', args)
except RPCError as err:
error = err
finally:
await client.close()
finally:
print(json.dumps({
"time": loop.time() - start,
"error": error.__str__() if error else None,
"args": args,
}, indent=4))
if __name__ == "__main__":
asyncio.run(main())
+3 -3
View File
@@ -75,7 +75,7 @@ async def main(cmd_args=None):
return 1
else:
url_to_claim.update({
claim['permanent_url']: claim for claim in response['items']
claim['permanent_url']: claim for claim in response['items'] if claim['value_type'] == 'stream'
})
print(f'Claim search page {page} took: {time.perf_counter() - start}')
except (ClientConnectorError, ConnectionError):
@@ -127,7 +127,7 @@ async def main(cmd_args=None):
if first_byte_times:
result += f"Worst first byte time: {round(max(first_byte_times), 2)}\n" \
f"Best first byte time: {round(min(first_byte_times), 2)}\n" \
f"95% confidence time-to-first-byte: {confidence(first_byte_times, 1.984)}s\n" \
f"*95% confidence time-to-first-byte: {confidence(first_byte_times, 1.984)}s*\n" \
f"99% confidence time-to-first-byte: {confidence(first_byte_times, 2.626)}s\n" \
f"Variance: {variance(first_byte_times)}\n"
if download_successes:
@@ -140,7 +140,7 @@ async def main(cmd_args=None):
for reason in ('start', 'finish'):
failures = [url for url, why in failed_to.items() if reason == why]
if failures:
result += f"\nFailed to {reason}:\n" + "\n".join(failures)
result += f"\nFailed to {reason}:\n" + "\n•".join(failures)
print(result)
webhook = os.environ.get('TTFB_SLACK_TOKEN', None)
+15
View File
@@ -0,0 +1,15 @@
#!/bin/bash
# entrypoint for wallet server Docker image
SNAPSHOT_URL="${SNAPSHOT_URL:-}" #off by default. latest snapshot at https://lbry.com/snapshot/wallet
if [[ -n "$SNAPSHOT_URL" ]] && [[ ! -f /database/claims.db ]]; then
echo "Downloading wallet snapshot from $SNAPSHOT_URL"
wget -O wallet_snapshot.tar.bz2 "$SNAPSHOT_URL"
echo "Extracting snapshot..."
tar xvjf wallet_snapshot.tar.bz2 --directory /database
rm wallet_snapshot.tar.bz2
fi
/home/lbry/.local/bin/torba-server "$@"
@@ -1,216 +0,0 @@
import sys
import json
import asyncio
import argparse
from datetime import datetime
try:
import aiohttp
import psycopg2
except ImportError:
print(f"To run {sys.argv[0]} you need to install aiohttp and psycopg2:")
print(f"")
print(f" $ pip install aiohttp psycopg2")
print("")
sys.exit(1)
if not sys.version_info >= (3, 7):
print("Please use Python 3.7 or higher, this script expects that dictionary keys preserve order.")
sys.exit(1)
async def monitor(db, server):
c = db.cursor()
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(10)) as session:
try:
ws = await session.ws_connect(server)
except (aiohttp.ClientConnectorError, asyncio.TimeoutError):
print(f"failed connecting to {server}")
return
print(f"connected to {server}")
async for msg in ws:
r = json.loads(msg.data)
c.execute("""
INSERT INTO wallet_server_stats (server, sessions, event_time) VALUES (%s,%s,%s);
""", (server, r['status']['sessions'], datetime.now()))
for command, stats in r["api"].items():
data = {
'server': server,
'command': command,
'event_time': datetime.now()
}
for key, value in stats.items():
if key.endswith("_queries"):
continue
if isinstance(value, list):
data.update({
key+'_avg': value[0],
key+'_min': value[1],
key+'_five': value[2],
key+'_twenty_five': value[3],
key+'_fifty': value[4],
key+'_seventy_five': value[5],
key+'_ninety_five': value[6],
key+'_max': value[7],
})
else:
data[key] = value
c.execute(f"""
INSERT INTO wallet_server_command_stats ({','.join(data)})
VALUES ({','.join('%s' for _ in data)});
""", list(data.values()))
db.commit()
async def main(dsn, servers):
db = ensure_database(dsn)
await asyncio.gather(*(
asyncio.create_task(monitor(db, server))
for server in servers
))
def ensure_database(dsn):
db = psycopg2.connect(**dsn)
c = db.cursor()
c.execute("SELECT to_regclass('wallet_server_stats');")
if c.fetchone()[0] is None:
print("creating table 'wallet_server_stats'...")
c.execute("""
CREATE TABLE wallet_server_stats (
server text,
sessions integer,
event_time timestamp
);
""")
print("creating table 'wallet_server_command_stats'...")
c.execute("""
CREATE TABLE wallet_server_command_stats (
server text,
command text,
event_time timestamp,
-- total requests received during event window
receive_count integer,
-- sum of these is total responses made
cache_response_count integer,
query_response_count integer,
intrp_response_count integer,
error_response_count integer,
-- millisecond timings for non-cache responses (response_*, interrupt_*, error_*)
response_avg float,
response_min float,
response_five float,
response_twenty_five float,
response_fifty float,
response_seventy_five float,
response_ninety_five float,
response_max float,
interrupt_avg float,
interrupt_min float,
interrupt_five float,
interrupt_twenty_five float,
interrupt_fifty float,
interrupt_seventy_five float,
interrupt_ninety_five float,
interrupt_max float,
error_avg float,
error_min float,
error_five float,
error_twenty_five float,
error_fifty float,
error_seventy_five float,
error_ninety_five float,
error_max float,
-- response, interrupt and error each also report the python, wait and sql stats
python_avg float,
python_min float,
python_five float,
python_twenty_five float,
python_fifty float,
python_seventy_five float,
python_ninety_five float,
python_max float,
wait_avg float,
wait_min float,
wait_five float,
wait_twenty_five float,
wait_fifty float,
wait_seventy_five float,
wait_ninety_five float,
wait_max float,
sql_avg float,
sql_min float,
sql_five float,
sql_twenty_five float,
sql_fifty float,
sql_seventy_five float,
sql_ninety_five float,
sql_max float,
-- extended timings for individual sql executions
individual_sql_avg float,
individual_sql_min float,
individual_sql_five float,
individual_sql_twenty_five float,
individual_sql_fifty float,
individual_sql_seventy_five float,
individual_sql_ninety_five float,
individual_sql_max float,
individual_sql_count integer
);
""")
db.commit()
return db
def get_dsn(args):
dsn = {}
for attr in ('dbname', 'user', 'password', 'host', 'port'):
value = getattr(args, f'pg_{attr}')
if value:
dsn[attr] = value
return dsn
def get_servers(args):
if '..' in args.server_range:
start, end = args.server_range.split('..')
else:
start = end = args.server_range
return [
args.server_url.format(i)
for i in range(int(start), int(end)+1)
]
def get_args():
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("--pg-dbname", default="analytics", help="PostgreSQL database name")
parser.add_argument("--pg-user", help="PostgreSQL username")
parser.add_argument("--pg-password", help="PostgreSQL password")
parser.add_argument("--pg-host", default="localhost", help="PostgreSQL host")
parser.add_argument("--pg-port", default="5432", help="PostgreSQL port")
parser.add_argument("--server-url", default="http://spv{}.lbry.com:50005", help="URL with '{}' placeholder")
parser.add_argument("--server-range", default="1..5", help="Range of numbers or single number to use in URL placeholder")
return parser.parse_args()
if __name__ == "__main__":
args = get_args()
asyncio.run(main(get_dsn(args), get_servers(args)))
+331
View File
@@ -0,0 +1,331 @@
import sys
import json
import random
import asyncio
import argparse
import traceback
from time import time
from datetime import datetime
try:
import aiohttp
import psycopg2
import slack
except ImportError:
print(f"To run {sys.argv[0]} you need to install aiohttp, psycopg2 and slackclient:")
print(f"")
print(f" $ pip install aiohttp psycopg2 slackclient")
print("")
sys.exit(1)
if not sys.version_info >= (3, 7):
print("Please use Python 3.7 or higher, this script expects that dictionary keys preserve order.")
sys.exit(1)
async def handle_slow_query(cursor, server, command, queries):
for query in queries:
cursor.execute("""
INSERT INTO wallet_server_slow_queries (server, command, query, event_time) VALUES (%s,%s,%s,%s);
""", (server, command, query, datetime.now()))
async def handle_analytics_event(cursor, event, server):
cursor.execute("""
INSERT INTO wallet_server_stats (server, sessions, event_time) VALUES (%s,%s,%s);
""", (server, event['status']['sessions'], datetime.now()))
for command, stats in event["api"].items():
data = {
'server': server,
'command': command,
'event_time': datetime.now()
}
for key, value in stats.items():
if key.endswith("_queries"):
if key == "interrupted_queries":
await handle_slow_query(cursor, server, command, value)
continue
if isinstance(value, list):
data.update({
key + '_avg': value[0],
key + '_min': value[1],
key + '_five': value[2],
key + '_twenty_five': value[3],
key + '_fifty': value[4],
key + '_seventy_five': value[5],
key + '_ninety_five': value[6],
key + '_max': value[7],
})
else:
data[key] = value
cursor.execute(f"""
INSERT INTO wallet_server_command_stats ({','.join(data)})
VALUES ({','.join('%s' for _ in data)});
""", list(data.values()))
SLACKCLIENT = None
async def boris_says(what_boris_says):
if SLACKCLIENT:
await SLACKCLIENT.chat_postMessage(
username="boris the wallet monitor",
icon_emoji=":boris:",
channel='#tech-sdk',
text=what_boris_says
)
else:
print(what_boris_says)
async def monitor(db, server):
c = db.cursor()
delay = 30
height_changed = None, time()
height_change_reported = False
first_attempt = True
while True:
try:
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(10)) as session:
try:
ws = await session.ws_connect(server)
except (aiohttp.ClientConnectorError, asyncio.TimeoutError):
if first_attempt:
print(f"failed connecting to {server}")
await boris_says(random.choice([
f"{server} is not responding, probably dead, will not connect again.",
]))
return
raise
if first_attempt:
await boris_says(f"{server} is online")
else:
await boris_says(f"{server} is back online")
delay = 30
first_attempt = False
print(f"connected to {server}")
async for msg in ws:
event = json.loads(msg.data)
height = event['status']['height']
height_change_time = int(time()-height_changed[1])
if height_changed[0] != height:
height_changed = (height, time())
if height_change_reported:
await boris_says(
f"Server {server} received new block after {height_change_time / 60:.1f} minutes.",
)
height_change_reported = False
elif height_change_time > 10*60:
if not height_change_reported or height_change_time % (2*60) == 0:
await boris_says(
f"It's been {height_change_time/60:.1f} minutes since {server} received a new block.",
)
height_change_reported = True
await handle_analytics_event(c, event, server)
db.commit()
except (aiohttp.ClientConnectorError, asyncio.TimeoutError):
await boris_says(random.choice([
f"<!channel> Guys, we have a problem! Nobody home at {server}. Will check on it again in {delay} seconds.",
f"<!channel> Something wrong with {server}. I think dead. Will poke it again in {delay} seconds.",
f"<!channel> Don't hear anything from {server}, maybe dead. Will try it again in {delay} seconds.",
]))
await asyncio.sleep(delay)
delay += 30
async def main(dsn, servers):
db = ensure_database(dsn)
await boris_says(random.choice([
"No fear, Boris is here! I will monitor the servers now and will try not to fall asleep again.",
"Comrad the Cat and Boris are here now, monitoring wallet servers.",
]))
await asyncio.gather(*(
asyncio.create_task(monitor(db, server))
for server in servers
))
def ensure_database(dsn):
db = psycopg2.connect(**dsn)
c = db.cursor()
c.execute("SELECT to_regclass('wallet_server_stats');")
if c.fetchone()[0] is None:
print("creating table 'wallet_server_stats'...")
c.execute("""
CREATE TABLE wallet_server_stats (
server text,
sessions integer,
event_time timestamp
);
""")
c.execute("SELECT to_regclass('wallet_server_slow_queries');")
if c.fetchone()[0] is None:
print("creating table 'wallet_server_slow_queries'...")
c.execute("""
CREATE TABLE wallet_server_slow_queries (
server text,
command text,
query text,
event_time timestamp
);
""")
c.execute("SELECT to_regclass('wallet_server_command_stats');")
if c.fetchone()[0] is None:
print("creating table 'wallet_server_command_stats'...")
c.execute("""
CREATE TABLE wallet_server_command_stats (
server text,
command text,
event_time timestamp,
-- total requests received during event window
receive_count integer,
-- sum of these is total responses made
cache_response_count integer,
query_response_count integer,
intrp_response_count integer,
error_response_count integer,
-- millisecond timings for non-cache responses (response_*, interrupt_*, error_*)
response_avg float,
response_min float,
response_five float,
response_twenty_five float,
response_fifty float,
response_seventy_five float,
response_ninety_five float,
response_max float,
interrupt_avg float,
interrupt_min float,
interrupt_five float,
interrupt_twenty_five float,
interrupt_fifty float,
interrupt_seventy_five float,
interrupt_ninety_five float,
interrupt_max float,
error_avg float,
error_min float,
error_five float,
error_twenty_five float,
error_fifty float,
error_seventy_five float,
error_ninety_five float,
error_max float,
-- response, interrupt and error each also report the python, wait and sql stats
python_avg float,
python_min float,
python_five float,
python_twenty_five float,
python_fifty float,
python_seventy_five float,
python_ninety_five float,
python_max float,
wait_avg float,
wait_min float,
wait_five float,
wait_twenty_five float,
wait_fifty float,
wait_seventy_five float,
wait_ninety_five float,
wait_max float,
sql_avg float,
sql_min float,
sql_five float,
sql_twenty_five float,
sql_fifty float,
sql_seventy_five float,
sql_ninety_five float,
sql_max float,
-- extended timings for individual sql executions
individual_sql_avg float,
individual_sql_min float,
individual_sql_five float,
individual_sql_twenty_five float,
individual_sql_fifty float,
individual_sql_seventy_five float,
individual_sql_ninety_five float,
individual_sql_max float,
individual_sql_count integer
);
""")
db.commit()
return db
def get_dsn(args):
dsn = {}
for attr in ('dbname', 'user', 'password', 'host', 'port'):
value = getattr(args, f'pg_{attr}')
if value:
dsn[attr] = value
return dsn
def get_servers(args):
if '..' in args.server_range:
start, end = args.server_range.split('..')
else:
start = end = args.server_range
return [
args.server_url.format(i)
for i in range(int(start), int(end)+1)
]
def get_slack_client(args):
if args.slack_token:
return slack.WebClient(token=args.slack_token, run_async=True)
def get_args():
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("--pg-dbname", default="analytics", help="PostgreSQL database name")
parser.add_argument("--pg-user", help="PostgreSQL username")
parser.add_argument("--pg-password", help="PostgreSQL password")
parser.add_argument("--pg-host", default="localhost", help="PostgreSQL host")
parser.add_argument("--pg-port", default="5432", help="PostgreSQL port")
parser.add_argument("--server-url", default="http://spv{}.lbry.com:50005", help="URL with '{}' placeholder")
parser.add_argument("--server-range", default="1..5", help="Range of numbers or single number to use in URL placeholder")
parser.add_argument("--slack-token")
return parser.parse_args()
if __name__ == "__main__":
loop = asyncio.get_event_loop()
args = get_args()
SLACKCLIENT = get_slack_client(args)
try:
loop.run_until_complete(main(get_dsn(args), get_servers(args)))
except KeyboardInterrupt as e:
pass
except Exception as e:
loop.run_until_complete(boris_says("<!channel> I crashed with the following exception:"))
loop.run_until_complete(boris_says(traceback.format_exc()))
finally:
loop.run_until_complete(
boris_says(random.choice([
"Wallet servers will have to watch themselves, I'm leaving now.",
"I'm going to go take a nap, hopefully nothing blows up while I'm gone.",
"Babushka is calling, I'll be back later, someone else watch the servers while I'm gone.",
]))
)
+1 -1
View File
@@ -25,7 +25,7 @@ setup(
install_requires=[
'torba',
'aiohttp==3.5.4',
'aioupnp==0.0.13',
'aioupnp==0.0.14',
'appdirs==1.4.3',
'certifi>=2018.11.29',
'colorama==0.3.7',
@@ -1,7 +1,23 @@
import asyncio
import sqlite3
from lbry.testcase import CommandTestCase
from torba.client.basedatabase import SQLiteMixin
from lbry.wallet.dewies import dewies_to_lbc
from lbry.wallet.account import Account
def extract(d, keys):
return dict((k, d[k]) for k in keys)
class AccountManagement(CommandTestCase):
async def test_sqlite_binding_error(self):
tasks = [
self.loop.create_task(self.daemon.jsonrpc_account_create('second account' + str(x))) for x in range(100)
]
await asyncio.wait(tasks)
for result in tasks:
self.assertFalse(isinstance(result.result(), Exception))
async def test_account_list_set_create_remove_add(self):
# check initial account
@@ -65,3 +81,101 @@ class AccountManagement(CommandTestCase):
self.account.channel_keys[keys[1]] = "some invalid junk"
await self.account.maybe_migrate_certificates()
self.assertEqual(list(self.account.channel_keys.keys()), [keys[2]])
async def assertFindsClaims(self, claim_names, awaitable):
self.assertEqual(claim_names, [txo.claim_name for txo in await awaitable])
async def assertOutputAmount(self, amounts, awaitable):
self.assertEqual(amounts, [dewies_to_lbc(txo.amount) for txo in await awaitable])
async def test_commands_across_accounts(self):
channel_list = self.daemon.jsonrpc_channel_list
stream_list = self.daemon.jsonrpc_stream_list
support_list = self.daemon.jsonrpc_support_list
utxo_list = self.daemon.jsonrpc_utxo_list
default_account = self.daemon.default_account
second_account = await self.daemon.jsonrpc_account_create('second account')
tx = await self.daemon.jsonrpc_account_send(
'0.05', await self.daemon.jsonrpc_address_unused(account_id=second_account.id)
)
await self.confirm_tx(tx.id)
await self.assertOutputAmount(['0.05', '9.949876'], utxo_list())
await self.assertOutputAmount(['0.05'], utxo_list(account_id=second_account.id))
await self.assertOutputAmount(['9.949876'], utxo_list(account_id=default_account.id))
channel1 = await self.channel_create('@channel-in-account1', '0.01')
channel2 = await self.channel_create(
'@channel-in-account2', '0.01', account_id=second_account.id, funding_account_ids=[default_account.id]
)
await self.assertFindsClaims(['@channel-in-account2', '@channel-in-account1'], channel_list())
await self.assertFindsClaims(['@channel-in-account1'], channel_list(account_id=default_account.id))
await self.assertFindsClaims(['@channel-in-account2'], channel_list(account_id=second_account.id))
stream1 = await self.stream_create('stream-in-account1', '0.01', channel_id=self.get_claim_id(channel1))
stream2 = await self.stream_create(
'stream-in-account2', '0.01', channel_id=self.get_claim_id(channel2),
account_id=second_account.id, funding_account_ids=[default_account.id]
)
await self.assertFindsClaims(['stream-in-account2', 'stream-in-account1'], stream_list())
await self.assertFindsClaims(['stream-in-account1'], stream_list(account_id=default_account.id))
await self.assertFindsClaims(['stream-in-account2'], stream_list(account_id=second_account.id))
await self.assertFindsClaims(
['stream-in-account2', 'stream-in-account1', '@channel-in-account2', '@channel-in-account1'],
self.daemon.jsonrpc_claim_list()
)
await self.assertFindsClaims(
['stream-in-account1', '@channel-in-account1'],
self.daemon.jsonrpc_claim_list(account_id=default_account.id)
)
await self.assertFindsClaims(
['stream-in-account2', '@channel-in-account2'],
self.daemon.jsonrpc_claim_list(account_id=second_account.id)
)
support1 = await self.support_create(self.get_claim_id(stream1), '0.01')
support2 = await self.support_create(
self.get_claim_id(stream2), '0.01', account_id=second_account.id, funding_account_ids=[default_account.id]
)
self.assertEqual([support2['txid'], support1['txid']], [txo.tx_ref.id for txo in await support_list()])
self.assertEqual([support1['txid']], [txo.tx_ref.id for txo in await support_list(account_id=default_account.id)])
self.assertEqual([support2['txid']], [txo.tx_ref.id for txo in await support_list(account_id=second_account.id)])
history = await self.daemon.jsonrpc_transaction_list()
self.assertEqual(len(history), 8)
self.assertEqual(extract(history[0]['support_info'][0], ['claim_name', 'is_tip', 'amount', 'balance_delta']), {
'claim_name': 'stream-in-account2',
'is_tip': False,
'amount': '0.01',
'balance_delta': '-0.01'
})
self.assertEqual(extract(history[1]['support_info'][0], ['claim_name', 'is_tip', 'amount', 'balance_delta']), {
'claim_name': 'stream-in-account1',
'is_tip': False,
'amount': '0.01',
'balance_delta': '-0.01'
})
self.assertEqual(extract(history[2]['claim_info'][0], ['claim_name', 'amount', 'balance_delta']), {
'claim_name': 'stream-in-account2',
'amount': '0.01',
'balance_delta': '-0.01'
})
self.assertEqual(extract(history[3]['claim_info'][0], ['claim_name', 'amount', 'balance_delta']), {
'claim_name': 'stream-in-account1',
'amount': '0.01',
'balance_delta': '-0.01'
})
self.assertEqual(extract(history[4]['claim_info'][0], ['claim_name', 'amount', 'balance_delta']), {
'claim_name': '@channel-in-account2',
'amount': '0.01',
'balance_delta': '-0.01'
})
self.assertEqual(extract(history[5]['claim_info'][0], ['claim_name', 'amount', 'balance_delta']), {
'claim_name': '@channel-in-account1',
'amount': '0.01',
'balance_delta': '-0.01'
})
self.assertEqual(history[6]['value'], '0.0')
self.assertEqual(history[7]['value'], '10.0')
+29 -50
View File
@@ -478,7 +478,8 @@ class ChannelCommands(CommandTestCase):
tx = await self.out(self.channel_update(claim_id, claim_address=other_address))
# after sending
self.assertEqual(len(await self.daemon.jsonrpc_channel_list()), 2)
self.assertEqual(len(await self.daemon.jsonrpc_channel_list()), 3)
self.assertEqual(len(await self.daemon.jsonrpc_channel_list(account_id=self.account.id)), 2)
self.assertEqual(len(await self.daemon.jsonrpc_channel_list(account_id=account2_id)), 1)
# shoud not have private key
@@ -498,44 +499,9 @@ class ChannelCommands(CommandTestCase):
claim_id = self.get_claim_id(tx)
channel_private_key = (await self.account.get_channels())[0].private_key
exported_data = await self.out(self.daemon.jsonrpc_channel_export(claim_id))
daemon2 = await self.add_daemon()
# before importing channel
self.assertEqual(1, len(daemon2.default_wallet.accounts))
# importing channel which will create a new single key account
await daemon2.jsonrpc_channel_import(exported_data)
# after import
self.assertEqual(2, len(daemon2.default_wallet.accounts))
new_account = daemon2.default_wallet.accounts[1]
await daemon2.ledger._update_tasks.done.wait()
channels = await new_account.get_channels()
self.assertEqual(1, len(channels))
self.assertEqual(channel_private_key.to_string(), channels[0].private_key.to_string())
async def test_channel_export_import_into_existing_account(self):
tx = await self.channel_create('@foo', '1.0')
claim_id = self.get_claim_id(tx)
channel_private_key = (await self.account.get_channels())[0].private_key
exported_data = await self.out(self.daemon.jsonrpc_channel_export(claim_id))
daemon2 = await self.add_daemon(seed=self.account.seed)
await daemon2.ledger._update_tasks.done.wait() # will sync channel previously created
# before importing channel key, has channel without key
self.assertEqual(1, len(daemon2.default_wallet.accounts))
channels = await daemon2.default_account.get_channels()
self.assertEqual(1, len(channels))
self.assertIsNone(channels[0].private_key)
# importing channel will add it to existing account
await daemon2.jsonrpc_channel_import(exported_data)
# after import, still just one account but with private key now
self.assertEqual(1, len(daemon2.default_wallet.accounts))
channels = await daemon2.default_account.get_channels()
channels = await daemon2.jsonrpc_channel_list()
self.assertEqual(1, len(channels))
self.assertEqual(channel_private_key.to_string(), channels[0].private_key.to_string())
@@ -618,12 +584,17 @@ class StreamCommands(ClaimTestCase):
channels = await self.out(self.daemon.jsonrpc_channel_list(account1_id))
self.assertEqual(len(channels), 1)
self.assertEqual(channels[0]['name'], '@spam')
self.assertEqual(channels, await self.out(self.daemon.jsonrpc_channel_list()))
self.assertEqual(channels, await self.out(self.daemon.jsonrpc_channel_list(account1_id)))
channels = await self.out(self.daemon.jsonrpc_channel_list(account2_id))
self.assertEqual(len(channels), 1)
self.assertEqual(channels[0]['name'], '@baz')
channels = await self.out(self.daemon.jsonrpc_channel_list())
self.assertEqual(len(channels), 2)
self.assertEqual(channels[0]['name'], '@baz')
self.assertEqual(channels[1]['name'], '@spam')
# defaults to using all accounts to lookup channel
await self.stream_create('hovercraft1', '0.1', channel_id=baz_id)
self.assertEqual((await self.claim_search(name='hovercraft1'))[0]['signing_channel']['name'], '@baz')
@@ -647,6 +618,15 @@ class StreamCommands(ClaimTestCase):
'hovercraft5', '0.1', channel_name='@baz', channel_account_id=[account1_id]
)
# signing with channel works even if channel and certificate are in different accounts
await self.channel_update(
baz_id, account_id=account2_id,
claim_address=await self.daemon.jsonrpc_address_unused(account1_id)
)
await self.stream_create(
'hovercraft5', '0.1', channel_id=baz_id
)
async def test_preview_works_with_signed_streams(self):
await self.out(self.channel_create('@spam', '1.0'))
signed = await self.out(self.stream_create('bar', '1.0', channel_name='@spam', preview=True, confirm=False))
@@ -806,13 +786,15 @@ class StreamCommands(ClaimTestCase):
# before sending
self.assertEqual(len(await self.daemon.jsonrpc_claim_list()), 4)
self.assertEqual(len(await self.daemon.jsonrpc_claim_list(account_id=self.account.id)), 4)
self.assertEqual(len(await self.daemon.jsonrpc_claim_list(account_id=account2_id)), 0)
other_address = await account2.receiving.get_or_create_usable_address()
tx = await self.out(self.stream_update(claim_id, claim_address=other_address))
# after sending
self.assertEqual(len(await self.daemon.jsonrpc_claim_list()), 3)
self.assertEqual(len(await self.daemon.jsonrpc_claim_list()), 4)
self.assertEqual(len(await self.daemon.jsonrpc_claim_list(account_id=self.account.id)), 3)
self.assertEqual(len(await self.daemon.jsonrpc_claim_list(account_id=account2_id)), 1)
async def test_setting_fee_fields(self):
@@ -1112,8 +1094,7 @@ class SupportCommands(CommandTestCase):
await self.assertBalance(account2, '5.0')
# create the claim we'll be tipping and supporting
tx = await self.stream_create()
claim_id = self.get_claim_id(tx)
claim_id = self.get_claim_id(await self.stream_create())
# account1 and account2 balances:
await self.assertBalance(self.account, '3.979769')
@@ -1121,18 +1102,17 @@ class SupportCommands(CommandTestCase):
# send a tip to the claim using account2
tip = await self.out(
self.daemon.jsonrpc_support_create(claim_id, '1.0', True, account2_id)
self.daemon.jsonrpc_support_create(
claim_id, '1.0', True, account2_id, funding_account_ids=[account2_id])
)
await self.on_transaction_dict(tip)
await self.generate(1)
await self.on_transaction_dict(tip)
await self.confirm_tx(tip['txid'])
# tips don't affect balance so account1 balance is same but account2 balance went down
await self.assertBalance(self.account, '3.979769')
await self.assertBalance(account2, '3.9998585')
# verify that the incoming tip is marked correctly as is_tip=True in account1
txs = await self.out(self.daemon.jsonrpc_transaction_list())
txs = await self.out(self.daemon.jsonrpc_transaction_list(self.account.id))
self.assertEqual(len(txs[0]['support_info']), 1)
self.assertEqual(txs[0]['support_info'][0]['balance_delta'], '1.0')
self.assertEqual(txs[0]['support_info'][0]['claim_id'], claim_id)
@@ -1153,11 +1133,10 @@ class SupportCommands(CommandTestCase):
# send a support to the claim using account2
support = await self.out(
self.daemon.jsonrpc_support_create(claim_id, '2.0', False, account2_id)
self.daemon.jsonrpc_support_create(
claim_id, '2.0', False, account2_id, funding_account_ids=[account2_id])
)
await self.on_transaction_dict(support)
await self.generate(1)
await self.on_transaction_dict(support)
await self.confirm_tx(support['txid'])
# account2 balance went down ~2
await self.assertBalance(self.account, '3.979769')
+182 -31
View File
@@ -26,6 +26,7 @@ class MockedCommentServer:
'signing_ts': None,
'timestamp': None,
'channel_url': None,
'is_hidden': False,
}
def __init__(self, port=2903):
@@ -45,10 +46,9 @@ class MockedCommentServer:
@staticmethod
def clean(d: dict):
return {k: v for k, v in d.items() if v}
return {k: v for k, v in d.items() if v or isinstance(v, bool)}
def create_comment(self, channel_name=None, channel_id=None, **kwargs):
self.comment_id += 1
comment_id = self.comment_id
channel_url = 'lbry://' + channel_name + '#' + channel_id if channel_id else None
comment = self._create_comment(
@@ -60,57 +60,97 @@ class MockedCommentServer:
**kwargs
)
self.comments.append(comment)
self.comment_id += 1
return self.clean(comment)
def delete_comment(self, comment_id: int, channel_id: str, **kwargs):
def abandon_comment(self, comment_id: int, channel_id: str, **kwargs):
deleted = False
try:
if 0 <= comment_id <= len(self.comments) and self.comments[comment_id - 1]['channel_id'] == channel_id:
self.comments.pop(comment_id - 1)
if 0 <= comment_id < len(self.comments) and self.comments[comment_id]['channel_id'] == channel_id:
self.comments.pop(comment_id)
deleted = True
finally:
return {
str(comment_id): {
'deleted': deleted
'abandoned': deleted
}
}
def get_claim_comments(self, page=1, page_size=50, **kwargs):
def hide_comment(self, comment_id, signing_ts, signature):
comment_id = int(comment_id) if not isinstance(comment_id, int) else comment_id
if 0 <= comment_id < len(self.comments) and len(signature) == 128 and signing_ts.isalnum():
self.comments[comment_id]['is_hidden'] = True
return True
return False
def hide_comments(self, pieces: list):
comments_hidden = []
for p in pieces:
if self.hide_comment(**p):
comments_hidden.append(p['comment_id'])
return {'hidden': comments_hidden}
def get_claim_comments(self, claim_id, page=1, page_size=50,**kwargs):
comments = list(filter(lambda c: c['claim_id'] == claim_id, self.comments))
return {
'page': page,
'page_size': page_size,
'total_pages': ceil(len(self.comments)/page_size),
'total_items': len(self.comments),
'items': [self.clean(c) for c in (self.comments[::-1])[(page - 1) * page_size: page * page_size]]
'total_pages': ceil(len(comments)/page_size),
'total_items': len(comments),
'items': [self.clean(c) for c in (comments[::-1])[(page - 1) * page_size: page * page_size]],
'has_hidden_comments': bool(list(filter(lambda x: x['is_hidden'], comments)))
}
def get_claim_hidden_comments(self, claim_id, hidden=True, page=1, page_size=50):
comments = list(filter(lambda c: c['claim_id'] == claim_id, self.comments))
select_comments = list(filter(lambda c: c['is_hidden'] == hidden, comments))
return {
'page': page,
'page_size': page_size,
'total_pages': ceil(len(select_comments) / page_size),
'total_items': len(select_comments),
'items': [self.clean(c) for c in (select_comments[::-1])[(page - 1) * page_size: page * page_size]],
'has_hidden_comments': bool(list(filter(lambda c: c['is_hidden'], comments)))
}
def get_comment_channel_by_id(self, comment_id: int, **kwargs):
comment = self.comments[comment_id - 1]
comment = self.comments[comment_id]
return {
'channel_id': comment.get('channel_id'),
'channel_name': comment.get('channel_name')
}
def get_comments_by_id(self, comment_ids: list):
comment_ids = [int(c) if not isinstance(c, int) else c for c in comment_ids]
comments = [self.comments[cmnt_id] for cmnt_id in comment_ids if 0 <= cmnt_id < len(self.comments)]
return comments
methods = {
'get_claim_comments': get_claim_comments,
'get_comments_by_id': get_comments_by_id,
'create_comment': create_comment,
'delete_comment': delete_comment,
'abandon_comment': abandon_comment,
'get_channel_from_comment_id': get_comment_channel_by_id,
'get_claim_hidden_comments': get_claim_hidden_comments,
'hide_comments': hide_comments,
}
def process_json(self, body) -> dict:
response = {'jsonrpc': '2.0', 'id': body['id']}
try:
if body['method'] in self.methods:
params = body.get('params', {})
if 'comment_id' in params and type(params['comment_id']) is str:
params['comment_id'] = int(params['comment_id'])
params: dict = body.get('params', {})
comment_id = params.get('comment_id')
if comment_id and not isinstance(comment_id, int):
params['comment_id'] = int(comment_id)
result = self.methods[body['method']](self, **params)
response['result'] = result
else:
response['error'] = self.ERRORS['INVALID_METHOD']
except Exception:
except Exception as err:
response['error'] = self.ERRORS['UNKNOWN']
response['error'].update({'exception': f'{type(err).__name__}: {err}'})
return response
async def start(self):
@@ -181,20 +221,19 @@ class CommentCommands(CommandTestCase):
async def test02_unsigned_comment_list(self):
stream = (await self.stream_create())['outputs'][0]
comments = []
for i in range(28):
num_items = 28
for i in range(num_items):
comment = await self.daemon.jsonrpc_comment_create(
comment=f'{i}',
claim_id=stream['claim_id'],
)
self.assertIn('comment_id', comment)
comments.append(comment)
comment_list = await self.daemon.jsonrpc_comment_list(
claim_id=stream['claim_id']
)
self.assertIs(comment_list['page_size'], 50)
self.assertIs(comment_list['page'], 1)
self.assertIs(comment_list['total_items'], 28)
list_fields = ['items', 'page', 'page_size', 'has_hidden_comments', 'total_items', 'total_pages']
comment_list = await self.daemon.jsonrpc_comment_list(stream['claim_id'])
for field in list_fields:
self.assertIn(field, comment_list)
self.assertEqual(comment_list['total_items'], num_items)
for comment in comment_list['items']:
self.assertEqual(comment['comment'], comments.pop()['comment'])
@@ -216,10 +255,12 @@ class CommentCommands(CommandTestCase):
)
self.assertIn('comment_id', comment)
comments.append(comment)
list_fields = ['items', 'page', 'page_size', 'has_hidden_comments', 'total_items', 'total_pages']
comment_list = await self.daemon.jsonrpc_comment_list(
claim_id=stream['claim_id']
)
for field in list_fields:
self.assertIn(field, comment_list)
self.assertIs(comment_list['page_size'], 50)
self.assertIs(comment_list['page'], 1)
self.assertIs(comment_list['total_items'], 28)
@@ -241,10 +282,120 @@ class CommentCommands(CommandTestCase):
channel_id=rswanson['claim_id']
)
self.assertIn('signature', comment)
deleted = await self.daemon.jsonrpc_comment_abandon(comment['comment_id'])
self.assertIn(comment['comment_id'], deleted)
self.assertTrue(deleted[comment['comment_id']]['deleted'])
abandoned = await self.daemon.jsonrpc_comment_abandon(comment['comment_id'])
self.assertIn(comment['comment_id'], abandoned)
self.assertTrue(abandoned[comment['comment_id']]['abandoned'])
deleted = await self.daemon.jsonrpc_comment_abandon(comment['comment_id'])
self.assertIn(comment['comment_id'], deleted)
self.assertFalse(deleted[comment['comment_id']]['deleted'])
abandoned = await self.daemon.jsonrpc_comment_abandon(comment['comment_id'])
self.assertFalse(abandoned[comment['comment_id']]['abandoned'])
async def test05_comment_hide(self):
moth = (await self.channel_create('@InconspicuousMoth'))['outputs'][0]
bee = (await self.channel_create('@LazyBumblebee'))['outputs'][0]
moth_id = moth['claim_id']
stream = await self.stream_create('Cool Lamps to Sit On', channel_id=moth_id)
claim_id = stream['outputs'][0]['claim_id']
comment1 = await self.daemon.jsonrpc_comment_create(
comment='Who on earth would want to sit around on a lamp all day',
claim_id=claim_id,
channel_id=bee['claim_id']
)
self.assertFalse(comment1['is_hidden'])
comment2 = await self.daemon.jsonrpc_comment_create(
comment='silence mortal',
claim_id=claim_id,
channel_id=moth_id,
)
self.assertFalse(comment2['is_hidden'])
comments = await self.daemon.jsonrpc_comment_list(claim_id)
self.assertIn('has_hidden_comments', comments)
self.assertFalse(comments['has_hidden_comments'])
hidden = await self.daemon.jsonrpc_comment_hide([comment1['comment_id']])
self.assertIn('hidden', hidden)
hidden = hidden['hidden']
self.assertIn(comment1['comment_id'], hidden)
comments = await self.daemon.jsonrpc_comment_list(claim_id)
self.assertIn('has_hidden_comments', comments)
self.assertTrue(comments['has_hidden_comments'])
hidden_cmts1 = list(filter(lambda c: c['is_hidden'], comments['items']))
self.assertTrue(len(hidden_cmts1) == 1)
hidden_comment = hidden_cmts1[0]
self.assertEqual(hidden_comment['comment_id'], hidden[0])
hidden_comments = await self.daemon.jsonrpc_comment_list(claim_id, hidden=True)
self.assertIn('has_hidden_comments', hidden_comments)
self.assertTrue(hidden_comments['has_hidden_comments'])
self.assertLess(hidden_comments['total_items'], comments['total_items'])
self.assertListEqual(hidden_comments['items'], hidden_cmts1)
visible_comments = await self.daemon.jsonrpc_comment_list(claim_id, visible=True)
self.assertIn('has_hidden_comments', visible_comments)
self.assertTrue(visible_comments['has_hidden_comments'])
self.assertLess(visible_comments['total_items'], comments['total_items'])
total_hidden = hidden_comments['total_items']
total_visible = visible_comments['total_items']
self.assertEqual(total_hidden + total_visible, comments['total_items'])
items_hidden = hidden_comments['items']
items_visible = visible_comments['items']
for item in items_visible + items_hidden:
self.assertIn(item, comments['items'])
async def test06_comment_list_test(self):
moth = (await self.channel_create('@InconspicuousMoth'))['outputs'][0]
bee = (await self.channel_create('@LazyBumblebee'))['outputs'][0]
moth_id = moth['claim_id']
stream = await self.stream_create('Cool Lamps to Sit On', channel_id=moth_id)
claim_id = stream['outputs'][0]['claim_id']
hidden_comment = await self.daemon.jsonrpc_comment_create(
comment='Who on earth would want to sit around on a lamp all day',
claim_id=claim_id,
channel_id=bee['claim_id']
)
await self.daemon.jsonrpc_comment_hide([hidden_comment['comment_id']])
owner_comment = await self.daemon.jsonrpc_comment_create(
comment='Go away you yellow freak',
claim_id=claim_id,
channel_id=moth_id,
)
other_comment = await self.daemon.jsonrpc_comment_create(
comment='I got my swim trunks and my flippy-floppies',
claim_id=claim_id,
channel_id=bee['claim_id']
)
anon_comment = await self.daemon.jsonrpc_comment_create(
claim_id=claim_id,
comment='Anonymous comment'
)
all_comments = [anon_comment, other_comment, owner_comment, hidden_comment]
list_fields = ['items', 'page', 'page_size', 'has_hidden_comments', 'total_items', 'total_pages']
normal_list = await self.daemon.jsonrpc_comment_list(claim_id)
for field in list_fields:
self.assertIn(field, normal_list)
self.assertEqual(normal_list['total_items'], 4)
self.assertTrue(normal_list['has_hidden_comments'])
for i, cmnt in enumerate(all_comments):
self.assertEqual(cmnt['comment_id'], normal_list['items'][i]['comment_id'])
hidden = await self.daemon.jsonrpc_comment_list(claim_id, hidden=True)
self.assertTrue(hidden['has_hidden_comments'])
for field in list_fields:
self.assertIn(field, hidden)
self.assertEqual(hidden['total_items'], 1)
visible = await self.daemon.jsonrpc_comment_list(claim_id, visible=True)
for field in list_fields:
self.assertIn(field, visible)
self.assertTrue(visible['has_hidden_comments'])
self.assertEqual(visible['total_items'], normal_list['total_items'] - hidden['total_items'])
valid_list = await self.daemon.jsonrpc_comment_list(claim_id, is_channel_signature_valid=True)
for field in list_fields:
self.assertIn(field, valid_list)
self.assertTrue(visible['has_hidden_comments'])
self.assertEqual(len(valid_list['items']), len(normal_list['items']) - 1)
+1 -1
View File
@@ -34,7 +34,7 @@ class DHTIntegrationTest(AsyncioTestCase):
async def test_replace_bad_nodes(self):
await self.setup_network(20)
self.assertEquals(len(self.nodes), 20)
self.assertEqual(len(self.nodes), 20)
node = self.nodes[0]
bad_peers = []
for candidate in self.nodes[1:10]:
+28
View File
@@ -84,3 +84,31 @@ class AccountSynchronization(AsyncioTestCase):
self.daemon.jsonrpc_sync_apply('password', data=add_cert)
self.assertEqual(self.daemon.jsonrpc_sync_hash(), hash_w_cert)
self.assertEqual(self.account.channel_keys, {'abcdefg1234:0': '---PRIVATE KEY---'})
@mock.patch('time.time', mock.Mock(return_value=12345))
def test_account_preferences_syncing(self):
starting_hash = '69afcd60a300f47933917d77ef011beeeb4decfafebbda91c144c84282c6814f'
self.account.modified_on = 123.456
self.assertEqual(self.daemon.jsonrpc_sync_hash(), starting_hash)
self.assertEqual(self.daemon.jsonrpc_sync_apply('password')['hash'], starting_hash)
self.assertFalse(self.daemon.jsonrpc_preference_get())
hash_w_pref = '2fe43f0b2f8bbf1fbb55537f862d8bcb0823791019a7151c848bd5f5bd32d336'
add_pref = (
'czo4MTkyOjE2OjE6Jgn3nAGrfYP2usMA4KQ/73+YHAwMyiGdSWuxCmgZKlpwSpnfQv8R7R0tum/n2oTSBQxjdL'
'OlTW+tv/G5L2GfQ5op3xaT89gN+F/JJnvf3cdWvYH7Nc+uTUMb7cKhJP7hQvFW5bb1Y3jX3EBBY00Jkqyj9RCR'
'XPtbLVu71KbVRvCAR/oAnMEsgD+ITsC3WkXMwE3BS2LjJDQmeqbH4YXNdcjJN/JzQ6fxOmr3Uk1GqnpuhFsta8'
'H14ViRilq1pLKOSZIN80rrm5cKq45nFO5kFeoqBCEaal4u2/OkX9nOnpQlO3E95wD8hkCmZ3i20aSte6nqwqXx'
'ZKVRZqR2a0TjwVWB8kPXPA2ewKvPILaj190bXPl8EVu+TAnTCQwMgytinYjtcKNZmMz3ENJyI2mCANwpWlX7xl'
'y/J+qLi5b9N+agghTxggs5rVJ/hkaue7GS542dXDrwMrw9nwGqNw3dS/lcU+1wRUQ0fnHwb/85XbbwyO2aDj2i'
'DFNkdyLyUIiIUvB1JfWAnWqX3vQcL1REK1ePgUei7dCHJ3WyWdsRx3cVXzlK8yOPkf0N6d3AKrZQWVebwDC7Nd'
'eL4sDW8AkaXuBIrbuZw6XUHd6WI0NvU/q10j2qMm0YoXSu+dExou1/1THwx5g86MxcX5nwodKUEVCOTzKMyrLz'
'CRsitH/+dAXhZNRp/FbnDCGBMyD3MOYCjZvAFbCZUasoRwqponxILw=='
)
self.daemon.jsonrpc_sync_apply('password', data=add_pref)
self.assertEqual(self.daemon.jsonrpc_sync_hash(), hash_w_pref)
self.assertEqual(self.daemon.jsonrpc_preference_get(), {"fruit": ["apple", "orange"]})
self.daemon.jsonrpc_preference_set("fruit", ["peach", "apricot"])
self.assertEqual(self.daemon.jsonrpc_preference_get(), {"fruit": ["peach", "apricot"]})
self.assertNotEqual(self.daemon.jsonrpc_sync_hash(), hash_w_pref)
@@ -38,42 +38,77 @@ class TransactionCommandsTestCase(CommandTestCase):
await self.assertBalance(self.account, '11.0')
async def test_granular_balances(self):
initial_balance = await self.daemon.jsonrpc_account_balance(reserved_subtotals=True)
self.assertEqual({
account_balance = self.daemon.jsonrpc_account_balance
self.assertEqual(await account_balance(reserved_subtotals=False), {
'total': '10.0',
'available': '10.0',
'reserved': '0.0',
'reserved_subtotals': None
})
self.assertEqual(await account_balance(reserved_subtotals=True), {
'total': '10.0',
'available': '10.0',
'reserved': '0.0',
'reserved_subtotals': {'claims': '0.0', 'supports': '0.0', 'tips': '0.0'}
}, initial_balance)
first_claim_id = self.get_claim_id(await self.stream_create('granularity', bid='3.0'))
await self.stream_update(first_claim_id, data=b'news', bid='1.0')
await self.support_create(first_claim_id, bid='2.0')
second_account_id = (await self.out(self.daemon.jsonrpc_account_create("Tip-er")))['id']
second_accound_address = await self.daemon.jsonrpc_address_unused(second_account_id)
await self.confirm_tx((await self.daemon.jsonrpc_account_send('1.0', second_accound_address)).id)
self.assertEqual({
})
# claim with update + supporting our own claim
stream1 = await self.stream_create('granularity', '3.0')
await self.stream_update(self.get_claim_id(stream1), data=b'news', bid='1.0')
await self.support_create(self.get_claim_id(stream1), '2.0')
self.assertEqual(await account_balance(reserved_subtotals=True), {
'total': '9.977534',
'available': '6.977534',
'reserved': '3.0',
'reserved_subtotals': {'claims': '1.0', 'supports': '2.0', 'tips': '0.0'}
})
account2 = await self.daemon.jsonrpc_account_create("Tip-er")
address2 = await self.daemon.jsonrpc_address_unused(account2.id)
# send lbc to someone else
tx = await self.daemon.jsonrpc_account_send('1.0', address2)
await self.confirm_tx(tx.id)
self.assertEqual(await account_balance(reserved_subtotals=True), {
'total': '8.97741',
'available': '5.97741',
'reserved': '3.0',
'reserved_subtotals': {'claims': '1.0', 'supports': '2.0', 'tips': '0.0'}
}, await self.daemon.jsonrpc_account_balance(reserved_subtotals=True))
second_claim_id = self.get_claim_id(await self.stream_create(
name='granularity-is-cool', account_id=second_account_id, bid='0.1'))
await self.daemon.jsonrpc_support_create(second_claim_id, '0.5', tip=True)
first_account_tip_txid = await self.confirm_tx((await self.daemon.jsonrpc_support_create(
first_claim_id, '0.3', tip=True, account_id=second_account_id)).id)
for with_subtotals in (True, False):
self.assertEqual({
'total': '8.777264',
'available': '5.477264',
'reserved': '3.3',
'reserved_subtotals': {'claims': '1.0', 'supports': '2.0', 'tips': '0.3'} if with_subtotals else None
}, await self.daemon.jsonrpc_account_balance(reserved_subtotals=with_subtotals))
await self.confirm_tx((await self.daemon.jsonrpc_support_abandon(txid=first_account_tip_txid, nout=0)).id)
for with_subtotals in (True, False):
self.assertEqual({
'total': '8.777157',
'available': '5.777157',
'reserved': '3.0',
'reserved_subtotals': {'claims': '1.0', 'supports': '2.0', 'tips': '0.0'} if with_subtotals else None
}, await self.daemon.jsonrpc_account_balance(reserved_subtotals=with_subtotals))
})
# tip received
support1 = await self.support_create(
self.get_claim_id(stream1), '0.3', tip=True, funding_account_ids=[account2.id]
)
self.assertEqual(await account_balance(reserved_subtotals=True), {
'total': '9.27741',
'available': '5.97741',
'reserved': '3.3',
'reserved_subtotals': {'claims': '1.0', 'supports': '2.0', 'tips': '0.3'}
})
# tip claimed
tx = await self.daemon.jsonrpc_support_abandon(txid=support1['txid'], nout=0)
await self.confirm_tx(tx.id)
self.assertEqual(await account_balance(reserved_subtotals=True), {
'total': '9.277303',
'available': '6.277303',
'reserved': '3.0',
'reserved_subtotals': {'claims': '1.0', 'supports': '2.0', 'tips': '0.0'}
})
stream2 = await self.stream_create(
'granularity-is-cool', '0.1', account_id=account2.id, funding_account_ids=[account2.id]
)
# tip another claim
await self.support_create(
self.get_claim_id(stream2), '0.2', tip=True, funding_account_ids=[self.account.id])
self.assertEqual(await account_balance(reserved_subtotals=True), {
'total': '9.077157',
'available': '6.077157',
'reserved': '3.0',
'reserved_subtotals': {'claims': '1.0', 'supports': '2.0', 'tips': '0.0'}
})
@@ -20,9 +20,10 @@ class TestSessionBloat(IntegrationTestCase):
await self.ledger.stop()
self.conductor.spv_node.session_timeout = 1
await self.conductor.start_spv()
session = ClientSession(network=None, server=self.ledger.network.client.server, timeout=0.2)
session = ClientSession(
network=None, server=(self.conductor.spv_node.hostname, self.conductor.spv_node.port), timeout=0.2
)
await session.create_connection()
session.ping_task.cancel()
await session.send_request('server.banner', ())
self.assertEqual(len(self.conductor.spv_node.server.session_mgr.sessions), 1)
self.assertFalse(session.is_closing())
@@ -33,6 +34,14 @@ class TestSessionBloat(IntegrationTestCase):
self.assertEqual(len(self.conductor.spv_node.server.session_mgr.sessions), 0)
class TestSegwitServer(IntegrationTestCase):
LEDGER = lbry.wallet
ENABLE_SEGWIT = True
async def test_at_least_it_starts(self):
await asyncio.wait_for(self.ledger.network.get_headers(0, 1), 1.0)
class TestHeadersComponent(CommandTestCase):
LEDGER = lbry.wallet
@@ -225,3 +225,84 @@ class TestBlobExchange(BlobExchangeTestBase):
server_protocol.data_received(bytes([byte]))
await asyncio.sleep(0.1) # yield execution
self.assertTrue(len(received_data.getvalue()) > 0)
async def test_idle_timeout(self):
self.server.idle_timeout = 1
blob_hash = "7f5ab2def99f0ddd008da71db3a3772135f4002b19b7605840ed1034c8955431bd7079549e65e6b2a3b9c17c773073ed"
mock_blob_bytes = b'1' * ((2 * 2 ** 20) - 1)
await self._add_blob_to_server(blob_hash, mock_blob_bytes)
client_blob = self.client_blob_manager.get_blob(blob_hash)
# download the blob
downloaded, protocol = await request_blob(self.loop, client_blob, self.server_from_client.address,
self.server_from_client.tcp_port, 2, 3)
self.assertIsNotNone(protocol)
self.assertFalse(protocol.transport.is_closing())
await client_blob.verified.wait()
self.assertTrue(client_blob.get_is_verified())
self.assertTrue(downloaded)
client_blob.delete()
# wait for less than the idle timeout
await asyncio.sleep(0.5, loop=self.loop)
# download the blob again
downloaded, protocol2 = await request_blob(self.loop, client_blob, self.server_from_client.address,
self.server_from_client.tcp_port, 2, 3,
connected_protocol=protocol)
self.assertTrue(protocol is protocol2)
self.assertFalse(protocol.transport.is_closing())
await client_blob.verified.wait()
self.assertTrue(client_blob.get_is_verified())
self.assertTrue(downloaded)
client_blob.delete()
# check that the connection times out from the server side
await asyncio.sleep(0.9, loop=self.loop)
self.assertFalse(protocol.transport.is_closing())
self.assertIsNotNone(protocol.transport._sock)
await asyncio.sleep(0.1, loop=self.loop)
self.assertIsNone(protocol.transport)
def test_max_request_size(self):
protocol = BlobServerProtocol(self.loop, self.server_blob_manager, 'bQEaw42GXsgCAGio1nxFncJSyRmnztSCjP')
called = asyncio.Event()
protocol.close = called.set
protocol.data_received(b'0' * 1199)
self.assertFalse(called.is_set())
protocol.data_received(b'0')
self.assertTrue(called.is_set())
def test_bad_json(self):
protocol = BlobServerProtocol(self.loop, self.server_blob_manager, 'bQEaw42GXsgCAGio1nxFncJSyRmnztSCjP')
called = asyncio.Event()
protocol.close = called.set
protocol.data_received(b'{{0}')
self.assertTrue(called.is_set())
def test_no_request(self):
protocol = BlobServerProtocol(self.loop, self.server_blob_manager, 'bQEaw42GXsgCAGio1nxFncJSyRmnztSCjP')
called = asyncio.Event()
protocol.close = called.set
protocol.data_received(b'{}')
self.assertTrue(called.is_set())
async def test_transfer_timeout(self):
self.server.transfer_timeout = 1
blob_hash = "7f5ab2def99f0ddd008da71db3a3772135f4002b19b7605840ed1034c8955431bd7079549e65e6b2a3b9c17c773073ed"
mock_blob_bytes = b'1' * ((2 * 2 ** 20) - 1)
await self._add_blob_to_server(blob_hash, mock_blob_bytes)
client_blob = self.client_blob_manager.get_blob(blob_hash)
server_blob = self.server_blob_manager.get_blob(blob_hash)
async def sendfile(writer):
await asyncio.sleep(2, loop=self.loop)
return 0
server_blob.sendfile = sendfile
with self.assertRaises(asyncio.CancelledError):
await request_blob(self.loop, client_blob, self.server_from_client.address,
self.server_from_client.tcp_port, 2, 3)
@@ -43,11 +43,11 @@ class TestManagedStream(BlobExchangeTestBase):
async def test_status_file_completed(self):
await self._test_transfer_stream(10)
self.assertTrue(self.stream.output_file_exists)
self.assertTrue(self.stream.as_dict()['completed'])
self.assertTrue(self.stream.completed)
with open(self.stream.full_path, 'w+b') as outfile:
outfile.truncate(1)
self.assertTrue(self.stream.output_file_exists)
self.assertFalse(self.stream.as_dict()['completed'])
self.assertFalse(self.stream.completed)
async def _test_transfer_stream(self, blob_count: int, mock_accumulate_peers=None, stop_when_done=True):
await self.setup_stream(blob_count)
+35 -6
View File
@@ -1,4 +1,5 @@
import os
import shutil
import binascii
from unittest import mock
import asyncio
@@ -77,6 +78,7 @@ def get_mock_wallet(sd_hash, storage, balance=10.0, fee=None):
mock_wallet = mock.Mock(spec=LbryWalletManager)
mock_wallet.ledger.resolve = mock_resolve
mock_wallet.ledger.network.client.server = ('fakespv.lbry.com', 50001)
async def get_balance(*_):
return balance
@@ -130,6 +132,7 @@ class TestStreamManager(BlobExchangeTestBase):
head_blob_duration = event['properties']['head_blob_duration']
sd_blob_duration = event['properties']['sd_blob_duration']
self.assertFalse(event['properties']['added_fixed_peers'])
self.assertEqual(event['properties']['wallet_server'], "fakespv.lbry.com:50001")
self.assertTrue(total_duration >= resolve_duration + head_blob_duration + sd_blob_duration)
await self._test_time_to_first_bytes(check_post)
@@ -172,6 +175,9 @@ class TestStreamManager(BlobExchangeTestBase):
self.assertIsNone(event['properties']['sd_blob_duration'])
self.assertFalse(event['properties']['added_fixed_peers'])
self.assertEqual(event['properties']['connection_failures_count'], 1)
self.assertEqual(
event['properties']['error_message'], f'Failed to download sd blob {self.sd_hash} within timeout'
)
await self._test_time_to_first_bytes(check_post, DownloadSDTimeout, after_setup=after_setup)
@@ -213,6 +219,9 @@ class TestStreamManager(BlobExchangeTestBase):
self.assertEqual(event['properties']['use_fixed_peers'], False)
self.assertEqual(event['properties']['added_fixed_peers'], False)
self.assertEqual(event['properties']['fixed_peer_delay'], None)
self.assertEqual(
event['properties']['error_message'], f'Failed to download sd blob {self.sd_hash} within timeout'
)
start = self.loop.time()
await self._test_time_to_first_bytes(check_post, DownloadSDTimeout)
@@ -272,14 +281,21 @@ class TestStreamManager(BlobExchangeTestBase):
self.assertListEqual(expected_events, received)
async def _test_download_error_on_start(self, expected_error, timeout=None):
with self.assertRaises(expected_error):
error = None
try:
await self.stream_manager.download_stream_from_uri(self.uri, self.exchange_rate_manager, timeout)
except Exception as err:
if isinstance(err, asyncio.CancelledError):
raise
error = err
self.assertEqual(expected_error, type(error))
async def _test_download_error_analytics_on_start(self, expected_error, timeout=None):
async def _test_download_error_analytics_on_start(self, expected_error, error_message, timeout=None):
received = []
async def check_post(event):
self.assertEqual("Time To First Bytes", event['event'])
self.assertEqual(event['properties']['error_message'], error_message)
received.append(event['properties']['error'])
self.stream_manager.analytics_manager._post = check_post
@@ -295,7 +311,7 @@ class TestStreamManager(BlobExchangeTestBase):
'version': '_0_0_1'
}
await self.setup_stream_manager(10.0, fee)
await self._test_download_error_on_start(InsufficientFundsError)
await self._test_download_error_on_start(InsufficientFundsError, "")
async def test_fee_above_max_allowed(self):
fee = {
@@ -305,7 +321,7 @@ class TestStreamManager(BlobExchangeTestBase):
'version': '_0_0_1'
}
await self.setup_stream_manager(1000000.0, fee)
await self._test_download_error_on_start(KeyFeeAboveMaxAllowed)
await self._test_download_error_on_start(KeyFeeAboveMaxAllowed, "")
async def test_resolve_error(self):
await self.setup_stream_manager()
@@ -315,14 +331,27 @@ class TestStreamManager(BlobExchangeTestBase):
async def test_download_sd_timeout(self):
self.server.stop_server()
await self.setup_stream_manager()
await self._test_download_error_analytics_on_start(DownloadSDTimeout, timeout=1)
await self._test_download_error_analytics_on_start(
DownloadSDTimeout, f'Failed to download sd blob {self.sd_hash} within timeout', timeout=1
)
async def test_download_data_timeout(self):
await self.setup_stream_manager()
with open(os.path.join(self.server_dir, self.sd_hash), 'r') as sdf:
head_blob_hash = json.loads(sdf.read())['blobs'][0]['blob_hash']
self.server_blob_manager.delete_blob(head_blob_hash)
await self._test_download_error_analytics_on_start(DownloadDataTimeout, timeout=1)
await self._test_download_error_analytics_on_start(
DownloadDataTimeout, f'Failed to download data blobs for sd hash {self.sd_hash} within timeout', timeout=1
)
async def test_unexpected_error(self):
await self.setup_stream_manager()
err_msg = f"invalid blob directory '{self.client_dir}'"
shutil.rmtree(self.client_dir)
await self._test_download_error_analytics_on_start(
OSError, err_msg, timeout=1
)
os.mkdir(self.client_dir) # so the test cleanup doesn't error
async def test_non_head_data_timeout(self):
await self.setup_stream_manager()
@@ -3,6 +3,7 @@ import asyncio
from unittest.mock import Mock
from torba.client.basenetwork import BaseNetwork
from torba.orchstr8.node import SPVNode
from torba.rpc import RPCSession
from torba.testcase import IntegrationTestCase, AsyncioTestCase
@@ -20,33 +21,63 @@ class ReconnectTests(IntegrationTestCase):
VERBOSITY = logging.WARN
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.assertTrue(self.ledger.network.is_connected)
switch_event = self.ledger.network.on_connected.first
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)
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.assertFalse(self.ledger.network.is_connected)
sendtxid = await self.blockchain.send_to_address(address1, 1.1337)
await self.on_transaction_id(sendtxid) # mempool
await asyncio.wait_for(self.on_transaction_id(sendtxid), 1.0) # mempool
await self.blockchain.generate(1)
await self.on_transaction_id(sendtxid) # confirmed
self.assertLess(self.ledger.network.client.response_time, 1) # response time properly set lower, we are fine
await self.assertBalance(self.account, '1.1337')
# is it real? are we rich!? let me see this tx...
d = self.ledger.network.get_transaction(sendtxid)
# what's that smoke on my ethernet cable? oh no!
master_client = self.ledger.network.client
self.ledger.network.client.connection_lost(Exception())
with self.assertRaises(asyncio.CancelledError):
await d
with self.assertRaises(asyncio.TimeoutError):
await d
self.assertIsNone(master_client.response_time) # response time unknown as it failed
# rich but offline? no way, no water, let's retry
with self.assertRaisesRegex(ConnectionError, 'connection is not available'):
await self.ledger.network.get_transaction(sendtxid)
# * goes to pick some water outside... * time passes by and another donation comes in
sendtxid = await self.blockchain.send_to_address(address1, 42)
await self.blockchain.generate(1)
# (this is just so the test doesnt hang forever if it doesnt reconnect)
if not self.ledger.network.is_connected:
await asyncio.wait_for(self.ledger.network.on_connected.first, timeout=1.0)
# omg, the burned cable still works! torba is fire proof!
await self.ledger.network.get_transaction(sendtxid)
async def test_timeout_then_reconnect(self):
# tests that it connects back after some failed attempts
await self.conductor.spv_node.stop()
self.assertFalse(self.ledger.network.is_connected)
await asyncio.sleep(0.2) # let it retry and fail once
await self.conductor.spv_node.start(self.conductor.blockchain_node)
await self.ledger.network.on_connected.first
self.assertTrue(self.ledger.network.is_connected)
@@ -79,9 +110,9 @@ class ServerPickingTestCase(AsyncioTestCase):
await self._make_bad_server(),
('localhost', 1),
('example.that.doesnt.resolve', 9000),
await self._make_fake_server(latency=1.2, port=1340),
await self._make_fake_server(latency=0.5, port=1337),
await self._make_fake_server(latency=0.7, port=1339),
await self._make_fake_server(latency=1.0, port=1340),
await self._make_fake_server(latency=0.1, port=1337),
await self._make_fake_server(latency=0.4, port=1339),
],
'connect_timeout': 3
})
@@ -89,9 +120,10 @@ class ServerPickingTestCase(AsyncioTestCase):
network = BaseNetwork(ledger)
self.addCleanup(network.stop)
asyncio.ensure_future(network.start())
await asyncio.wait_for(network.on_connected.first, timeout=3)
await asyncio.wait_for(network.on_connected.first, timeout=1)
self.assertTrue(network.is_connected)
self.assertEqual(network.client.server, ('127.0.0.1', 1337))
# ensure we are connected to all of them
self.assertTrue(all([not session.is_closing() for session in network.session_pool.sessions]))
self.assertEqual(len(network.session_pool.sessions), 3)
self.assertTrue(all([not session.is_closing() for session in network.session_pool.available_sessions]))
# ensure we are connected to all of them after a while
await asyncio.sleep(1)
self.assertEqual(len(list(network.session_pool.available_sessions)), 3)
@@ -1,6 +1,9 @@
import logging
import asyncio
import random
from itertools import chain
from random import shuffle
from torba.testcase import IntegrationTestCase
from torba.client.util import satoshis_to_coins, coins_to_satoshis
@@ -129,3 +132,48 @@ class BasicTransactionTests(IntegrationTestCase):
self.assertEqual(tx.outputs[0].get_address(self.ledger), address2)
self.assertEqual(tx.outputs[0].is_change, False)
self.assertEqual(tx.outputs[1].is_change, True)
async def test_history_edge_cases(self):
await self.assertBalance(self.account, '0.0')
address = await self.account.receiving.get_or_create_usable_address()
# 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)
if summary and len(summary) > 2:
ordered = summary.copy()
while summary == ordered:
random.shuffle(summary)
return summary
self.conductor.spv_node.server.mempool.transaction_summaries = random_summary
# 10 unconfirmed txs, all from blockchain wallet
sends = list(self.blockchain.send_to_address(address, 10) for _ in range(10))
# use batching to reduce issues with send_to_address on cli
for batch in range(0, len(sends), 10):
txids = await asyncio.gather(*sends[batch:batch + 10])
await asyncio.wait([self.on_transaction_id(txid) for txid in txids])
remote_status = await self.ledger.network.subscribe_address(address)
self.assertTrue(await self.ledger.update_history(address, remote_status))
# 20 unconfirmed txs, 10 from blockchain, 10 from local to local
utxos = await self.account.get_utxos()
txs = []
for utxo in utxos:
tx = await self.ledger.transaction_class.create(
[self.ledger.transaction_class.input_class.spend(utxo)],
[],
[self.account], self.account
)
await self.broadcast(tx)
txs.append(tx)
await asyncio.wait([self.on_transaction_address(tx, address) for tx in txs], timeout=1)
remote_status = await self.ledger.network.subscribe_address(address)
self.assertTrue(await self.ledger.update_history(address, remote_status))
# server history grows unordered
txid = await self.blockchain.send_to_address(address, 1)
await self.on_transaction_id(txid)
self.assertTrue(await self.ledger.update_history(address, remote_status))
self.assertEqual(21, len((await self.ledger.get_local_status_and_history(address))[1]))
self.assertEqual(0, len(self.ledger._known_addresses_out_of_sync))
# should be another test, but it would be too much to setup just for that and it affects sync
self.assertIsNone(await self.ledger.network.retriable_call(self.ledger.network.get_transaction, '1'*64))
+113 -36
View File
@@ -1,5 +1,7 @@
import unittest
import sqlite3
import tempfile
import os
from torba.client.wallet import Wallet
from torba.client.constants import COIN
@@ -255,11 +257,11 @@ class TestQueries(AsyncioTestCase):
self.ledger.db.db.execute_fetchall = check_parameters_length
account = await self.create_account()
tx = await self.create_tx_from_nothing(account, 0)
for height in range(1200):
for height in range(1, 1200):
tx = await self.create_tx_from_txo(tx.outputs[0], account, height=height)
variable_limit = self.ledger.db.MAX_QUERY_VARIABLES
for limit in range(variable_limit-2, variable_limit+2):
txs = await self.ledger.db.get_transactions(limit=limit, order_by='height asc')
txs = await self.ledger.get_transactions(limit=limit, order_by='height asc')
self.assertEqual(len(txs), limit)
inputs, outputs, last_tx = set(), set(), txs[0]
for tx in txs[1:]:
@@ -268,7 +270,6 @@ class TestQueries(AsyncioTestCase):
self.assertEqual(len(tx.outputs), 1)
last_tx = tx
async def test_queries(self):
self.assertEqual(0, await self.ledger.db.get_address_count())
account1 = await self.create_account()
@@ -276,73 +277,73 @@ class TestQueries(AsyncioTestCase):
account2 = await self.create_account()
self.assertEqual(52, await self.ledger.db.get_address_count())
self.assertEqual(0, await self.ledger.db.get_transaction_count())
self.assertEqual(0, await self.ledger.db.get_transaction_count(accounts=[account1, account2]))
self.assertEqual(0, await self.ledger.db.get_utxo_count())
self.assertEqual([], await self.ledger.db.get_utxos())
self.assertEqual(0, await self.ledger.db.get_txo_count())
self.assertEqual(0, await self.ledger.db.get_balance())
self.assertEqual(0, await self.ledger.db.get_balance(account=account1))
self.assertEqual(0, await self.ledger.db.get_balance(account=account2))
self.assertEqual(0, await self.ledger.db.get_balance(accounts=[account1]))
self.assertEqual(0, await self.ledger.db.get_balance(accounts=[account2]))
tx1 = await self.create_tx_from_nothing(account1, 1)
self.assertEqual(1, await self.ledger.db.get_transaction_count(account=account1))
self.assertEqual(0, await self.ledger.db.get_transaction_count(account=account2))
self.assertEqual(1, await self.ledger.db.get_utxo_count(account=account1))
self.assertEqual(1, await self.ledger.db.get_txo_count(account=account1))
self.assertEqual(0, await self.ledger.db.get_txo_count(account=account2))
self.assertEqual(1, await self.ledger.db.get_transaction_count(accounts=[account1]))
self.assertEqual(0, await self.ledger.db.get_transaction_count(accounts=[account2]))
self.assertEqual(1, await self.ledger.db.get_utxo_count(accounts=[account1]))
self.assertEqual(1, await self.ledger.db.get_txo_count(accounts=[account1]))
self.assertEqual(0, await self.ledger.db.get_txo_count(accounts=[account2]))
self.assertEqual(10**8, await self.ledger.db.get_balance())
self.assertEqual(10**8, await self.ledger.db.get_balance(account=account1))
self.assertEqual(0, await self.ledger.db.get_balance(account=account2))
self.assertEqual(10**8, await self.ledger.db.get_balance(accounts=[account1]))
self.assertEqual(0, await self.ledger.db.get_balance(accounts=[account2]))
tx2 = await self.create_tx_from_txo(tx1.outputs[0], account2, 2)
self.assertEqual(2, await self.ledger.db.get_transaction_count(account=account1))
self.assertEqual(1, await self.ledger.db.get_transaction_count(account=account2))
self.assertEqual(0, await self.ledger.db.get_utxo_count(account=account1))
self.assertEqual(1, await self.ledger.db.get_txo_count(account=account1))
self.assertEqual(1, await self.ledger.db.get_utxo_count(account=account2))
self.assertEqual(1, await self.ledger.db.get_txo_count(account=account2))
self.assertEqual(2, await self.ledger.db.get_transaction_count(accounts=[account1]))
self.assertEqual(1, await self.ledger.db.get_transaction_count(accounts=[account2]))
self.assertEqual(0, await self.ledger.db.get_utxo_count(accounts=[account1]))
self.assertEqual(1, await self.ledger.db.get_txo_count(accounts=[account1]))
self.assertEqual(1, await self.ledger.db.get_utxo_count(accounts=[account2]))
self.assertEqual(1, await self.ledger.db.get_txo_count(accounts=[account2]))
self.assertEqual(10**8, await self.ledger.db.get_balance())
self.assertEqual(0, await self.ledger.db.get_balance(account=account1))
self.assertEqual(10**8, await self.ledger.db.get_balance(account=account2))
self.assertEqual(0, await self.ledger.db.get_balance(accounts=[account1]))
self.assertEqual(10**8, await self.ledger.db.get_balance(accounts=[account2]))
tx3 = await self.create_tx_to_nowhere(tx2.outputs[0], 3)
self.assertEqual(2, await self.ledger.db.get_transaction_count(account=account1))
self.assertEqual(2, await self.ledger.db.get_transaction_count(account=account2))
self.assertEqual(0, await self.ledger.db.get_utxo_count(account=account1))
self.assertEqual(1, await self.ledger.db.get_txo_count(account=account1))
self.assertEqual(0, await self.ledger.db.get_utxo_count(account=account2))
self.assertEqual(1, await self.ledger.db.get_txo_count(account=account2))
self.assertEqual(2, await self.ledger.db.get_transaction_count(accounts=[account1]))
self.assertEqual(2, await self.ledger.db.get_transaction_count(accounts=[account2]))
self.assertEqual(0, await self.ledger.db.get_utxo_count(accounts=[account1]))
self.assertEqual(1, await self.ledger.db.get_txo_count(accounts=[account1]))
self.assertEqual(0, await self.ledger.db.get_utxo_count(accounts=[account2]))
self.assertEqual(1, await self.ledger.db.get_txo_count(accounts=[account2]))
self.assertEqual(0, await self.ledger.db.get_balance())
self.assertEqual(0, await self.ledger.db.get_balance(account=account1))
self.assertEqual(0, await self.ledger.db.get_balance(account=account2))
self.assertEqual(0, await self.ledger.db.get_balance(accounts=[account1]))
self.assertEqual(0, await self.ledger.db.get_balance(accounts=[account2]))
txs = await self.ledger.db.get_transactions()
txs = await self.ledger.db.get_transactions(accounts=[account1, account2])
self.assertEqual([tx3.id, tx2.id, tx1.id], [tx.id for tx in txs])
self.assertEqual([3, 2, 1], [tx.height for tx in txs])
txs = await self.ledger.db.get_transactions(account=account1)
txs = await self.ledger.db.get_transactions(accounts=[account1])
self.assertEqual([tx2.id, tx1.id], [tx.id for tx in txs])
self.assertEqual(txs[0].inputs[0].is_my_account, True)
self.assertEqual(txs[0].outputs[0].is_my_account, False)
self.assertEqual(txs[1].inputs[0].is_my_account, False)
self.assertEqual(txs[1].outputs[0].is_my_account, True)
txs = await self.ledger.db.get_transactions(account=account2)
txs = await self.ledger.db.get_transactions(accounts=[account2])
self.assertEqual([tx3.id, tx2.id], [tx.id for tx in txs])
self.assertEqual(txs[0].inputs[0].is_my_account, True)
self.assertEqual(txs[0].outputs[0].is_my_account, False)
self.assertEqual(txs[1].inputs[0].is_my_account, False)
self.assertEqual(txs[1].outputs[0].is_my_account, True)
self.assertEqual(2, await self.ledger.db.get_transaction_count(account=account2))
self.assertEqual(2, await self.ledger.db.get_transaction_count(accounts=[account2]))
tx = await self.ledger.db.get_transaction(txid=tx2.id)
self.assertEqual(tx.id, tx2.id)
self.assertEqual(tx.inputs[0].is_my_account, False)
self.assertEqual(tx.outputs[0].is_my_account, False)
tx = await self.ledger.db.get_transaction(txid=tx2.id, account=account1)
tx = await self.ledger.db.get_transaction(txid=tx2.id, accounts=[account1])
self.assertEqual(tx.inputs[0].is_my_account, True)
self.assertEqual(tx.outputs[0].is_my_account, False)
tx = await self.ledger.db.get_transaction(txid=tx2.id, account=account2)
tx = await self.ledger.db.get_transaction(txid=tx2.id, accounts=[account2])
self.assertEqual(tx.inputs[0].is_my_account, False)
self.assertEqual(tx.outputs[0].is_my_account, True)
@@ -351,6 +352,82 @@ class TestQueries(AsyncioTestCase):
txos = await self.ledger.db.get_txos()
self.assertEqual([0, 2, 1], [txo.tx_ref.height for txo in txos])
self.assertEqual([tx4.id, tx2.id, tx1.id], [txo.tx_ref.id for txo in txos])
txs = await self.ledger.db.get_transactions()
txs = await self.ledger.db.get_transactions(accounts=[account1, account2])
self.assertEqual([0, 3, 2, 1], [tx.height for tx in txs])
self.assertEqual([tx4.id, tx3.id, tx2.id, tx1.id], [tx.id for tx in txs])
class TestUpgrade(AsyncioTestCase):
def setUp(self) -> None:
self.path = tempfile.mktemp()
def tearDown(self) -> None:
os.remove(self.path)
def get_version(self):
with sqlite3.connect(self.path) as conn:
versions = conn.execute('select version from version').fetchall()
assert len(versions) == 1
return versions[0][0]
def get_tables(self):
with sqlite3.connect(self.path) as conn:
sql = "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;"
return [col[0] for col in conn.execute(sql).fetchall()]
def add_address(self, address):
with sqlite3.connect(self.path) as conn:
conn.execute("""
INSERT INTO pubkey_address (address, account, chain, position, pubkey)
VALUES (?, 'account1', 0, 0, 'pubkey blob')
""", (address,))
def get_addresses(self):
with sqlite3.connect(self.path) as conn:
sql = "SELECT address FROM pubkey_address ORDER BY address;"
return [col[0] for col in conn.execute(sql).fetchall()]
async def test_reset_on_version_change(self):
self.ledger = ledger_class({
'db': ledger_class.database_class(self.path),
'headers': ledger_class.headers_class(':memory:'),
})
# initial open, pre-version enabled db
self.ledger.db.SCHEMA_VERSION = None
self.assertEqual(self.get_tables(), [])
await self.ledger.db.open()
self.assertEqual(self.get_tables(), ['pubkey_address', 'tx', 'txi', 'txo'])
self.assertEqual(self.get_addresses(), [])
self.add_address('address1')
await self.ledger.db.close()
# initial open after version enabled
self.ledger.db.SCHEMA_VERSION = '1.0'
await self.ledger.db.open()
self.assertEqual(self.get_version(), '1.0')
self.assertEqual(self.get_tables(), ['pubkey_address', 'tx', 'txi', 'txo', 'version'])
self.assertEqual(self.get_addresses(), []) # address1 deleted during version upgrade
self.add_address('address2')
await self.ledger.db.close()
# nothing changes
self.assertEqual(self.get_version(), '1.0')
self.assertEqual(self.get_tables(), ['pubkey_address', 'tx', 'txi', 'txo', 'version'])
await self.ledger.db.open()
self.assertEqual(self.get_version(), '1.0')
self.assertEqual(self.get_tables(), ['pubkey_address', 'tx', 'txi', 'txo', 'version'])
self.assertEqual(self.get_addresses(), ['address2'])
await self.ledger.db.close()
# upgrade version, database reset
self.ledger.db.SCHEMA_VERSION = '1.1'
self.ledger.db.CREATE_TABLES_QUERY += """
create table if not exists foo (bar text);
"""
await self.ledger.db.open()
self.assertEqual(self.get_version(), '1.1')
self.assertEqual(self.get_tables(), ['foo', 'pubkey_address', 'tx', 'txi', 'txo', 'version'])
self.assertEqual(self.get_addresses(), []) # all tables got reset
await self.ledger.db.close()
@@ -94,6 +94,17 @@ class BasicHeadersTests(BitcoinHeadersTestCase):
await headers.connect(len(headers), remainder)
self.assertEqual(headers.height, 32259)
async def test_bounds(self):
headers = MainHeaders(':memory:')
await headers.connect(0, self.get_bytes(block_bytes(3001)))
self.assertEqual(headers.height, 3000)
with self.assertRaises(IndexError):
_ = headers[3001]
with self.assertRaises(IndexError):
_ = headers[-1]
self.assertIsNotNone(headers[3000])
self.assertIsNotNone(headers[0])
async def test_repair(self):
headers = MainHeaders(':memory:')
await headers.connect(0, self.get_bytes(block_bytes(3001)))
+6 -2
View File
@@ -18,6 +18,9 @@ class MockNetwork:
self.get_transaction_called = []
self.is_connected = False
def retriable_call(self, function, *args, **kwargs):
return function(*args, **kwargs)
async def get_history(self, address):
self.get_history_called.append(address)
self.address = address
@@ -26,7 +29,7 @@ class MockNetwork:
async def get_merkle(self, txid, height):
return {'merkle': ['abcd01'], 'pos': 1}
async def get_transaction(self, tx_hash):
async def get_transaction(self, tx_hash, _=None):
self.get_transaction_called.append(tx_hash)
return self.transaction[tx_hash]
@@ -121,8 +124,9 @@ class TestSynchronization(LedgerTestCase):
)
class MocHeaderNetwork:
class MocHeaderNetwork(MockNetwork):
def __init__(self, responses):
super().__init__(None, None)
self.responses = responses
async def get_headers(self, height, blocks):
@@ -0,0 +1,20 @@
from torba.stream import StreamController
from torba.testcase import AsyncioTestCase
class StreamControllerTestCase(AsyncioTestCase):
def test_non_unique_events(self):
events = []
controller = StreamController()
controller.stream.listen(on_data=events.append)
controller.add("yo")
controller.add("yo")
self.assertEqual(events, ["yo", "yo"])
def test_unique_events(self):
events = []
controller = StreamController(merge_repeated_events=True)
controller.stream.listen(on_data=events.append)
controller.add("yo")
controller.add("yo")
self.assertEqual(events, ["yo"])
+9 -9
View File
@@ -50,7 +50,7 @@ class AddressManager:
def _query_addresses(self, **constraints):
return self.account.ledger.db.get_addresses(
account=self.account,
accounts=[self.account],
chain=self.chain_number,
**constraints
)
@@ -386,14 +386,14 @@ class BaseAccount:
return addresses
async def get_addresses(self, **constraints) -> List[str]:
rows = await self.ledger.db.select_addresses('address', account=self, **constraints)
rows = await self.ledger.db.select_addresses('address', accounts=[self], **constraints)
return [r[0] for r in rows]
def get_address_records(self, **constraints):
return self.ledger.db.get_addresses(account=self, **constraints)
return self.ledger.db.get_addresses(accounts=[self], **constraints)
def get_address_count(self, **constraints):
return self.ledger.db.get_address_count(account=self, **constraints)
return self.ledger.db.get_address_count(accounts=[self], **constraints)
def get_private_key(self, chain: int, index: int) -> PrivateKey:
assert not self.encrypted, "Cannot get private key on encrypted wallet account."
@@ -406,7 +406,7 @@ class BaseAccount:
if confirmations > 0:
height = self.ledger.headers.height - (confirmations-1)
constraints.update({'height__lte': height, 'height__gt': 0})
return self.ledger.db.get_balance(account=self, **constraints)
return self.ledger.db.get_balance(accounts=[self], **constraints)
async def get_max_gap(self):
change_gap = await self.change.get_max_gap()
@@ -417,16 +417,16 @@ class BaseAccount:
}
def get_utxos(self, **constraints):
return self.ledger.db.get_utxos(account=self, **constraints)
return self.ledger.get_utxos(account=self, **constraints)
def get_utxo_count(self, **constraints):
return self.ledger.db.get_utxo_count(account=self, **constraints)
return self.ledger.get_utxo_count(account=self, **constraints)
def get_transactions(self, **constraints):
return self.ledger.db.get_transactions(account=self, **constraints)
return self.ledger.get_transactions(account=self, **constraints)
def get_transaction_count(self, **constraints):
return self.ledger.db.get_transaction_count(account=self, **constraints)
return self.ledger.get_transaction_count(account=self, **constraints)
async def fund(self, to_account, amount=None, everything=False,
outputs=1, broadcast=False, **constraints):
+125 -79
View File
@@ -1,10 +1,9 @@
import logging
import asyncio
from asyncio import wrap_future
from binascii import hexlify
from concurrent.futures.thread import ThreadPoolExecutor
from typing import Tuple, List, Union, Callable, Any, Awaitable, Iterable
from typing import Tuple, List, Union, Callable, Any, Awaitable, Iterable, Optional
import sqlite3
@@ -23,8 +22,10 @@ class AIOSQLite:
@classmethod
async def connect(cls, path: Union[bytes, str], *args, **kwargs):
def _connect():
return sqlite3.connect(path, *args, **kwargs)
db = cls()
db.connection = await wrap_future(db.executor.submit(sqlite3.connect, path, *args, **kwargs))
db.connection = await asyncio.get_event_loop().run_in_executor(db.executor, _connect)
return db
async def close(self):
@@ -38,25 +39,29 @@ class AIOSQLite:
return asyncio.get_event_loop_policy().get_event_loop().call_later(0.01, __close, conn)
def executemany(self, sql: str, params: Iterable):
def __executemany_in_a_transaction(conn: sqlite3.Connection, *args, **kwargs):
return conn.executemany(*args, **kwargs)
return self.run(__executemany_in_a_transaction, sql, params)
params = params if params is not None else []
# this fetchall is needed to prevent SQLITE_MISUSE
return self.run(lambda conn: conn.executemany(sql, params).fetchall())
def executescript(self, script: str) -> Awaitable:
return wrap_future(self.executor.submit(self.connection.executescript, script))
return self.run(lambda conn: conn.executescript(script))
def execute_fetchall(self, sql: str, parameters: Iterable = None) -> Awaitable[Iterable[sqlite3.Row]]:
parameters = parameters if parameters is not None else []
def __fetchall(conn: sqlite3.Connection, *args, **kwargs):
return conn.execute(*args, **kwargs).fetchall()
return wrap_future(self.executor.submit(__fetchall, self.connection, sql, parameters))
return self.run(lambda conn: conn.execute(sql, parameters).fetchall())
def execute_fetchone(self, sql: str, parameters: Iterable = None) -> Awaitable[Iterable[sqlite3.Row]]:
parameters = parameters if parameters is not None else []
return self.run(lambda conn: conn.execute(sql, parameters).fetchone())
def execute(self, sql: str, parameters: Iterable = None) -> Awaitable[sqlite3.Cursor]:
parameters = parameters if parameters is not None else []
return self.run(lambda conn, sql, parameters: conn.execute(sql, parameters), sql, parameters)
return self.run(lambda conn: conn.execute(sql, parameters))
def run(self, fun, *args, **kwargs) -> Awaitable:
return wrap_future(self.executor.submit(self.__run_transaction, fun, *args, **kwargs))
return asyncio.get_event_loop().run_in_executor(
self.executor, lambda: self.__run_transaction(fun, *args, **kwargs)
)
def __run_transaction(self, fun: Callable[[sqlite3.Connection, Any, Any], Any], *args, **kwargs):
self.connection.execute('begin')
@@ -64,19 +69,20 @@ class AIOSQLite:
result = fun(self.connection, *args, **kwargs) # type: ignore
self.connection.commit()
return result
except (Exception, OSError): # as e:
#log.exception('Error running transaction:', exc_info=e)
except (Exception, OSError) as e:
log.exception('Error running transaction:', exc_info=e)
self.connection.rollback()
log.warning("rolled back")
raise
def run_with_foreign_keys_disabled(self, fun, *args, **kwargs) -> Awaitable:
return wrap_future(
self.executor.submit(self.__run_transaction_with_foreign_keys_disabled, fun, *args, **kwargs)
return asyncio.get_event_loop().run_in_executor(
self.executor, self.__run_transaction_with_foreign_keys_disabled, fun, args, kwargs
)
def __run_transaction_with_foreign_keys_disabled(self,
fun: Callable[[sqlite3.Connection, Any, Any], Any],
*args, **kwargs):
args, kwargs):
foreign_keys_enabled, = self.connection.execute("pragma foreign_keys").fetchone()
if not foreign_keys_enabled:
raise sqlite3.IntegrityError("foreign keys are disabled, use `AIOSQLite.run` instead")
@@ -160,14 +166,10 @@ def query(select, **constraints):
offset = constraints.pop('offset', None)
order_by = constraints.pop('order_by', None)
constraints.pop('my_account', None)
account = constraints.pop('account', None)
if account is not None:
if not isinstance(account, list):
account = [account]
constraints['account__in'] = [
(a.public_key.address if isinstance(a, BaseAccount) else a) for a in account
]
constraints.pop('my_accounts', None)
accounts = constraints.pop('accounts', None)
if accounts is not None:
constraints['account__in'] = [a.public_key.address for a in accounts]
where, values = constraints_to_sql(constraints)
if where:
@@ -214,9 +216,16 @@ def rows_to_dict(rows, fields):
class SQLiteMixin:
SCHEMA_VERSION: Optional[str] = None
CREATE_TABLES_QUERY: str
MAX_QUERY_VARIABLES = 900
CREATE_VERSION_TABLE = """
create table if not exists version (
version text
);
"""
def __init__(self, path):
self._db_path = path
self.db: AIOSQLite = None
@@ -224,23 +233,40 @@ class SQLiteMixin:
async def open(self):
log.info("connecting to database: %s", self._db_path)
self.db = await AIOSQLite.connect(self._db_path)
self.db = await AIOSQLite.connect(self._db_path, isolation_level=None)
if self.SCHEMA_VERSION:
tables = [t[0] for t in await self.db.execute_fetchall(
"SELECT name FROM sqlite_master WHERE type='table';"
)]
if tables:
if 'version' in tables:
version = await self.db.execute_fetchone("SELECT version FROM version LIMIT 1;")
if version == (self.SCHEMA_VERSION,):
return
await self.db.executescript('\n'.join(
f"DROP TABLE {table};" for table in tables
))
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)
async def close(self):
await self.db.close()
@staticmethod
def _insert_sql(table: str, data: dict, ignore_duplicate: bool = False) -> Tuple[str, List]:
def _insert_sql(table: str, data: dict, ignore_duplicate: bool = False,
replace: bool = False) -> Tuple[str, List]:
columns, values = [], []
for column, value in data.items():
columns.append(column)
values.append(value)
or_ignore = ""
policy = ""
if ignore_duplicate:
or_ignore = " OR IGNORE"
policy = " OR IGNORE"
if replace:
policy = " OR REPLACE"
sql = "INSERT{} INTO {} ({}) VALUES ({})".format(
or_ignore, table, ', '.join(columns), ', '.join(['?'] * len(values))
policy, table, ', '.join(columns), ', '.join(['?'] * len(values))
)
return sql, values
@@ -260,6 +286,8 @@ class SQLiteMixin:
class BaseDatabase(SQLiteMixin):
SCHEMA_VERSION = "1.0"
PRAGMAS = """
pragma journal_mode=WAL;
"""
@@ -338,49 +366,59 @@ class BaseDatabase(SQLiteMixin):
'script': sqlite3.Binary(txo.script.source)
}
async def insert_transaction(self, tx):
await self.db.execute(*self._insert_sql('tx', {
@staticmethod
def tx_to_row(tx):
return {
'txid': tx.id,
'raw': sqlite3.Binary(tx.raw),
'height': tx.height,
'position': tx.position,
'is_verified': tx.is_verified
}))
}
async def insert_transaction(self, tx):
await self.db.execute(*self._insert_sql('tx', self.tx_to_row(tx)))
async def update_transaction(self, tx):
await self.db.execute(*self._update_sql("tx", {
'height': tx.height, 'position': tx.position, 'is_verified': tx.is_verified
}, 'txid = ?', (tx.id,)))
def _transaction_io(self, conn: sqlite3.Connection, tx: BaseTransaction, address, txhash, history):
conn.execute(*self._insert_sql('tx', self.tx_to_row(tx), replace=True))
for txo in tx.outputs:
if txo.script.is_pay_pubkey_hash and txo.script.values['pubkey_hash'] == txhash:
conn.execute(*self._insert_sql(
"txo", self.txo_to_row(tx, address, txo), ignore_duplicate=True
))
elif txo.script.is_pay_script_hash:
# TODO: implement script hash payments
log.warning('Database.save_transaction_io: pay script hash is not implemented!')
for txi in tx.inputs:
if txi.txo_ref.txo is not None:
txo = txi.txo_ref.txo
if txo.get_address(self.ledger) == address:
conn.execute(*self._insert_sql("txi", {
'txid': tx.id,
'txoid': txo.id,
'address': address,
}, ignore_duplicate=True))
conn.execute(
"UPDATE pubkey_address SET history = ?, used_times = ? WHERE address = ?",
(history, history.count(':') // 2, address)
)
def save_transaction_io(self, tx: BaseTransaction, address, txhash, history):
return self.db.run(self._transaction_io, tx, address, txhash, history)
def _transaction(conn: sqlite3.Connection, tx: BaseTransaction, address, txhash, history):
for txo in tx.outputs:
if txo.script.is_pay_pubkey_hash and txo.script.values['pubkey_hash'] == txhash:
conn.execute(*self._insert_sql(
"txo", self.txo_to_row(tx, address, txo), ignore_duplicate=True
))
elif txo.script.is_pay_script_hash:
# TODO: implement script hash payments
log.warning('Database.save_transaction_io: pay script hash is not implemented!')
for txi in tx.inputs:
if txi.txo_ref.txo is not None:
txo = txi.txo_ref.txo
if txo.get_address(self.ledger) == address:
conn.execute(*self._insert_sql("txi", {
'txid': tx.id,
'txoid': txo.id,
'address': address,
}, ignore_duplicate=True))
conn.execute(
"UPDATE pubkey_address SET history = ?, used_times = ? WHERE address = ?",
(history, history.count(':')//2, address)
)
return self.db.run(_transaction, tx, address, txhash, history)
def save_transaction_io_batch(self, txs: Iterable[BaseTransaction], address, txhash, history):
def __many(conn):
for tx in txs:
self._transaction_io(conn, tx, address, txhash, history)
return self.db.run(__many)
async def reserve_outputs(self, txos, is_reserved=True):
txoids = ((is_reserved, txo.id) for txo in txos)
@@ -395,22 +433,26 @@ class BaseDatabase(SQLiteMixin):
# 2. update address histories removing deleted TXs
return True
async def select_transactions(self, cols, account=None, **constraints):
if 'txid' not in constraints and account is not None:
constraints['$account'] = account.public_key.address
constraints['txid__in'] = """
async def select_transactions(self, cols, accounts=None, **constraints):
if not set(constraints) & {'txid', 'txid__in'}:
assert accounts is not None, "'accounts' argument required when no 'txid' constraint"
constraints.update({
f'$account{i}': a.public_key.address for i, a in enumerate(accounts)
})
account_values = ', '.join([f':$account{i}' for i in range(len(accounts))])
constraints['txid__in'] = f"""
SELECT txo.txid FROM txo
JOIN pubkey_address USING (address) WHERE pubkey_address.account = :$account
INNER JOIN pubkey_address USING (address) WHERE pubkey_address.account IN ({account_values})
UNION
SELECT txi.txid FROM txi
JOIN pubkey_address USING (address) WHERE pubkey_address.account = :$account
INNER JOIN pubkey_address USING (address) WHERE pubkey_address.account IN ({account_values})
"""
return await self.db.execute_fetchall(
*query("SELECT {} FROM tx".format(cols), **constraints)
)
async def get_transactions(self, my_account=None, **constraints):
my_account = my_account or constraints.get('account', None)
async def get_transactions(self, **constraints):
accounts = constraints.get('accounts', None)
tx_rows = await self.select_transactions(
'txid, raw, height, position, is_verified',
@@ -436,7 +478,7 @@ class BaseDatabase(SQLiteMixin):
annotated_txos.update({
txo.id: txo for txo in
(await self.get_txos(
my_account=my_account,
my_accounts=accounts,
txid__in=txids[offset:offset+step],
))
})
@@ -446,7 +488,7 @@ class BaseDatabase(SQLiteMixin):
referenced_txos.update({
txo.id: txo for txo in
(await self.get_txos(
my_account=my_account,
my_accounts=accounts,
txoid__in=txi_txoids[offset:offset+step],
))
})
@@ -484,12 +526,14 @@ class BaseDatabase(SQLiteMixin):
" JOIN tx USING (txid)".format(cols), **constraints
))
async def get_txos(self, my_account=None, no_tx=False, **constraints):
my_account = my_account or constraints.get('account', None)
if isinstance(my_account, BaseAccount):
my_account = my_account.public_key.address
async def get_txos(self, my_accounts=None, no_tx=False, **constraints):
my_accounts = [
(a.public_key.address if isinstance(a, BaseAccount) else a)
for a in (my_accounts or constraints.get('accounts', []))
]
if 'order_by' not in constraints:
constraints['order_by'] = ["tx.height=0 DESC", "tx.height DESC", "tx.position DESC"]
constraints['order_by'] = [
"tx.height=0 DESC", "tx.height DESC", "tx.position DESC", "txo.position"]
rows = await self.select_txos(
"tx.txid, raw, tx.height, tx.position, tx.is_verified, "
"txo.position, chain, account, amount, script",
@@ -513,7 +557,7 @@ class BaseDatabase(SQLiteMixin):
)
txo = txs[row[0]].outputs[row[5]]
txo.is_change = row[6] == 1
txo.is_my_account = row[7] == my_account
txo.is_my_account = row[7] in my_accounts
txos.append(txo)
return txos
@@ -567,9 +611,11 @@ class BaseDatabase(SQLiteMixin):
async def add_keys(self, account, chain, keys):
await self.db.executemany(
"insert into pubkey_address (address, account, chain, position, pubkey) values (?, ?, ?, ?, ?)",
((pubkey.address, account.public_key.address, chain,
position, sqlite3.Binary(pubkey.pubkey_bytes))
for position, pubkey in keys)
(
(pubkey.address, account.public_key.address, chain, position,
sqlite3.Binary(pubkey.pubkey_bytes))
for position, pubkey in keys
)
)
async def _set_address_history(self, address, history):
+4 -2
View File
@@ -70,8 +70,10 @@ class BaseHeaders:
return True
def __getitem__(self, height) -> dict:
assert not isinstance(height, slice), \
"Slicing of header chain has not been implemented yet."
if isinstance(height, slice):
raise NotImplementedError("Slicing of header chain has not been implemented yet.")
if not 0 <= height <= self.height:
raise IndexError(f"{height} is out of bounds, current height: {self.height}")
return self.deserialize(height, self.get_raw_header(height))
def get_raw_header(self, height) -> bytes:
+78 -30
View File
@@ -10,6 +10,7 @@ from operator import itemgetter
from collections import namedtuple
import pylru
from torba.client.basetransaction import BaseTransaction
from torba.tasks import TaskGroup
from torba.client import baseaccount, basenetwork, basetransaction
from torba.client.basedatabase import BaseDatabase
@@ -142,6 +143,7 @@ class BaseLedger(metaclass=LedgerRegistry):
self._address_update_locks: Dict[str, asyncio.Lock] = {}
self.coin_selection_strategy = None
self._known_addresses_out_of_sync = set()
@classmethod
def get_id(cls):
@@ -227,9 +229,35 @@ class BaseLedger(metaclass=LedgerRegistry):
def release_tx(self, tx):
return self.release_outputs([txi.txo_ref.txo for txi in tx.inputs])
async def get_local_status_and_history(self, address):
address_details = await self.db.get_address(address=address)
history = address_details['history'] or ''
def constraint_account_or_all(self, constraints):
if 'accounts' in constraints:
return
account = constraints.pop('account', None)
if account:
constraints['accounts'] = [account]
else:
constraints['accounts'] = self.accounts
def get_utxos(self, **constraints):
self.constraint_account_or_all(constraints)
return self.db.get_utxos(**constraints)
def get_utxo_count(self, **constraints):
self.constraint_account_or_all(constraints)
return self.db.get_utxo_count(**constraints)
def get_transactions(self, **constraints):
self.constraint_account_or_all(constraints)
return self.db.get_transactions(**constraints)
def get_transaction_count(self, **constraints):
self.constraint_account_or_all(constraints)
return self.db.get_transaction_count(**constraints)
async def get_local_status_and_history(self, address, history=None):
if not history:
address_details = await self.db.get_address(address=address)
history = address_details['history'] or ''
parts = history.split(':')[:-1]
return (
hexlify(sha256(history.encode())).decode() if history else None,
@@ -261,7 +289,7 @@ class BaseLedger(metaclass=LedgerRegistry):
await self.join_network()
self.network.on_connected.listen(self.join_network)
async def join_network(self, *args):
async def join_network(self, *_):
log.info("Subscribing and updating accounts.")
async with self._header_processing_lock:
await self.update_headers()
@@ -287,7 +315,7 @@ class BaseLedger(metaclass=LedgerRegistry):
subscription_update = False
if not headers:
header_response = await self.network.get_headers(height, 2001)
header_response = await self.network.retriable_call(self.network.get_headers, height, 2001)
headers = header_response['hex']
if not headers:
@@ -388,24 +416,31 @@ class BaseLedger(metaclass=LedgerRegistry):
address_manager: baseaccount.AddressManager = None):
async with self._address_update_locks.setdefault(address, asyncio.Lock()):
self._known_addresses_out_of_sync.discard(address)
local_status, local_history = await self.get_local_status_and_history(address)
if local_status == remote_status:
return
return True
remote_history = await self.network.get_history(address)
remote_history = await self.network.retriable_call(self.network.get_history, address)
remote_history = list(map(itemgetter('tx_hash', 'height'), remote_history))
we_need = set(remote_history) - set(local_history)
if not we_need:
return True
cache_tasks = []
cache_tasks: List[asyncio.Future[BaseTransaction]] = []
synced_history = StringIO()
for i, (txid, remote_height) in enumerate(map(itemgetter('tx_hash', 'height'), remote_history)):
if i < len(local_history) and local_history[i] == (txid, remote_height):
for i, (txid, remote_height) in enumerate(remote_history):
if i < len(local_history) and local_history[i] == (txid, remote_height) and not cache_tasks:
synced_history.write(f'{txid}:{remote_height}:')
else:
check_local = (txid, remote_height) not in we_need
cache_tasks.append(asyncio.ensure_future(
self.cache_transaction(txid, remote_height)
self.cache_transaction(txid, remote_height, check_local=check_local)
))
synced_txs = []
for task in cache_tasks:
tx = await task
@@ -434,12 +469,15 @@ class BaseLedger(metaclass=LedgerRegistry):
txi.txo_ref = referenced_txo.ref
synced_history.write(f'{tx.id}:{tx.height}:')
synced_txs.append(tx)
await self.db.save_transaction_io(
tx, address, self.address_to_hash160(address), synced_history.getvalue()
)
await self._on_transaction_controller.add(TransactionEvent(address, tx))
await self.db.save_transaction_io_batch(
synced_txs, address, self.address_to_hash160(address), synced_history.getvalue()
)
await asyncio.wait([
self._on_transaction_controller.add(TransactionEvent(address, tx))
for tx in synced_txs
])
if address_manager is None:
address_manager = await self.get_address_manager_for_address(address)
@@ -447,7 +485,23 @@ class BaseLedger(metaclass=LedgerRegistry):
if address_manager is not None:
await address_manager.ensure_address_gap()
async def cache_transaction(self, txid, remote_height):
local_status, local_history = \
await self.get_local_status_and_history(address, synced_history.getvalue())
if local_status != remote_status:
if local_history == remote_history:
return True
log.warning(
"Wallet is out of sync after syncing. Remote: %s with %d items, local: %s with %d items",
remote_status, len(remote_history), local_status, len(local_history)
)
log.warning("local: %s", local_history)
log.warning("remote: %s", remote_history)
self._known_addresses_out_of_sync.add(address)
return False
else:
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()
@@ -460,34 +514,27 @@ class BaseLedger(metaclass=LedgerRegistry):
tx = cache_item.tx
if tx is None:
if tx is None and check_local:
# check local db
tx = cache_item.tx = await self.db.get_transaction(txid=txid)
if tx is None:
# fetch from network
_raw = await self.network.get_transaction(txid)
_raw = await self.network.retriable_call(self.network.get_transaction, txid, remote_height)
if _raw:
tx = self.transaction_class(unhexlify(_raw))
await self.maybe_verify_transaction(tx, remote_height)
await self.db.insert_transaction(tx)
cache_item.tx = tx # make sure it's saved before caching it
return tx
if tx is None:
raise ValueError(f'Transaction {txid} was not in database and not on network.')
if remote_height > 0 and not tx.is_verified:
# tx from cache / db is not up-to-date
await self.maybe_verify_transaction(tx, remote_height)
await self.db.update_transaction(tx)
await self.maybe_verify_transaction(tx, remote_height)
return tx
async def maybe_verify_transaction(self, tx, remote_height):
tx.height = remote_height
if 0 < remote_height <= len(self.headers):
merkle = await self.network.get_merkle(tx.id, remote_height)
if 0 < remote_height < len(self.headers):
merkle = await self.network.retriable_call(self.network.get_merkle, tx.id, remote_height)
merkle_root = self.get_root_of_merkle_tree(merkle['merkle'], merkle['pos'], tx.hash)
header = self.headers[remote_height]
tx.position = merkle['pos']
@@ -501,6 +548,7 @@ class BaseLedger(metaclass=LedgerRegistry):
return None
def broadcast(self, tx):
# broadcast cant be a retriable call yet
return self.network.broadcast(hexlify(tx.raw).decode())
async def wait(self, tx: basetransaction.BaseTransaction, height=-1, timeout=None):
@@ -522,4 +570,4 @@ class BaseLedger(metaclass=LedgerRegistry):
)) for address_record in records
], timeout=timeout)
if pending:
raise TimeoutError('Timed out waiting for transaction.')
raise asyncio.TimeoutError('Timed out waiting for transaction.')
+253 -156
View File
@@ -1,11 +1,10 @@
import logging
import asyncio
from asyncio import CancelledError
from time import time
from typing import List
import socket
from operator import itemgetter
from typing import Dict, Optional, Tuple
from time import perf_counter
from torba.rpc import RPCSession as BaseClientSession, Connector, RPCError
from torba.rpc import RPCSession as BaseClientSession, Connector, RPCError, ProtocolError
from torba import __version__
from torba.stream import StreamController
@@ -14,71 +13,151 @@ log = logging.getLogger(__name__)
class ClientSession(BaseClientSession):
def __init__(self, *args, network, server, timeout=30, **kwargs):
def __init__(self, *args, network, server, timeout=30, on_connect_callback=None, **kwargs):
self.network = network
self.server = server
super().__init__(*args, **kwargs)
self._on_disconnect_controller = StreamController()
self.on_disconnected = self._on_disconnect_controller.stream
self.bw_limit = self.framer.max_size = self.max_errors = 1 << 32
self.framer.max_size = self.max_errors = 1 << 32
self.bw_limit = -1
self.timeout = timeout
self.max_seconds_idle = timeout * 2
self.ping_task = None
self.response_time: Optional[float] = None
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()
# one request per second of timeout, conservative default
self._semaphore = asyncio.Semaphore(self.timeout * 2)
@property
def available(self):
return not self.is_closing() and self.response_time is not None
@property
def server_address_and_port(self) -> Optional[Tuple[str, int]]:
if not self.transport:
return None
return self.transport.get_extra_info('peername')
async def send_timed_server_version_request(self, args=(), timeout=None):
timeout = timeout or self.timeout
log.debug("send version request to %s:%i", *self.server)
start = perf_counter()
result = await asyncio.wait_for(
super().send_request('server.version', args), timeout=timeout
)
current_response_time = perf_counter() - start
response_sum = (self.response_time or 0) * self._response_samples + current_response_time
self.response_time = response_sum / (self._response_samples + 1)
self._response_samples += 1
return result
async def send_request(self, method, args=()):
try:
return await asyncio.wait_for(super().send_request(method, args), timeout=self.timeout)
except RPCError as e:
log.warning("Wallet server returned an error. Code: %s Message: %s", *e.args)
raise e
except asyncio.TimeoutError:
self.abort()
raise
self.pending_amount += 1
async with self._semaphore:
return await self._send_request(method, args)
async def ping_forever(self):
async def _send_request(self, method, args=()):
log.debug("send %s to %s:%i", method, *self.server)
try:
if method == 'server.version':
reply = await self.send_timed_server_version_request(args, self.timeout)
else:
reply = await asyncio.wait_for(
super().send_request(method, args), timeout=self.timeout
)
log.debug("got reply for %s from %s:%i", method, *self.server)
return reply
except (RPCError, ProtocolError) as e:
if str(e).find('.*no such .*transaction.*'):
# shouldnt the server return none instead?
return None
log.warning("Wallet server (%s:%i) returned an error. Code: %s Message: %s",
*self.server, *e.args)
raise e
except ConnectionError:
log.warning("connection to %s:%i lost", *self.server)
self.synchronous_close()
raise
except asyncio.TimeoutError:
log.info("timeout sending %s to %s:%i", method, *self.server)
raise
except asyncio.CancelledError:
log.info("cancelled sending %s to %s:%i", method, *self.server)
self.synchronous_close()
raise
finally:
self.pending_amount -= 1
async def ensure_session(self):
# Handles reconnecting and maintaining a session alive
# TODO: change to 'ping' on newer protocol (above 1.2)
while not self.is_closing():
if (time() - self.last_send) > self.max_seconds_idle:
try:
await self.send_request('server.banner')
except:
self.abort()
raise
await asyncio.sleep(self.max_seconds_idle//3)
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 (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='1.2', timeout=3):
return await asyncio.wait_for(
self.send_request('server.version', [__version__, required]), timeout=timeout
)
async def create_connection(self, timeout=6):
connector = Connector(lambda: self, *self.server)
start = perf_counter()
await asyncio.wait_for(connector.create_connection(), timeout=timeout)
self.ping_task = asyncio.create_task(self.ping_forever())
self.connection_latency = perf_counter() - start
async def handle_request(self, request):
controller = self.network.subscription_controllers[request.method]
controller.add(request.args)
def connection_lost(self, exc):
log.debug("Connection lost: %s:%d", *self.server)
super().connection_lost(exc)
self.response_time = None
self.connection_latency = None
self._response_samples = 0
self.pending_amount = 0
self._on_disconnect_controller.add(True)
if self.ping_task:
self.ping_task.cancel()
class BaseNetwork:
def __init__(self, ledger):
self.config = ledger.config
self.client: ClientSession = None
self.session_pool: SessionPool = None
self.session_pool = SessionPool(network=self, timeout=self.config.get('connect_timeout', 6))
self.client: Optional[ClientSession] = None
self._switch_task: Optional[asyncio.Task] = None
self.running = False
self.remote_height: int = 0
self._on_connected_controller = StreamController()
self.on_connected = self._on_connected_controller.stream
self._on_header_controller = StreamController()
self._on_header_controller = StreamController(merge_repeated_events=True)
self.on_header = self._on_header_controller.stream
self._on_status_controller = StreamController()
self._on_status_controller = StreamController(merge_repeated_events=True)
self.on_status = self._on_status_controller.stream
self.subscription_controllers = {
@@ -86,169 +165,187 @@ class BaseNetwork:
'blockchain.address.subscribe': self._on_status_controller,
}
async def switch_forever(self):
while self.running:
if self.is_connected:
await self.client.on_disconnected.first
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)
self._on_connected_controller.add(True)
try:
self._update_remote_height((await self.subscribe_headers(),))
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.client = None
async def start(self):
self.running = True
connect_timeout = self.config.get('connect_timeout', 6)
self.session_pool = SessionPool(network=self, timeout=connect_timeout)
self._switch_task = asyncio.ensure_future(self.switch_forever())
self.session_pool.start(self.config['default_servers'])
self.on_header.listen(self._update_remote_height)
while True:
try:
self.client = await self.pick_fastest_session()
if self.is_connected:
await self.ensure_server_version()
self._update_remote_height((await self.subscribe_headers(),))
log.info("Successfully connected to SPV wallet server: %s:%d", *self.client.server)
self._on_connected_controller.add(True)
await self.client.on_disconnected.first
except CancelledError:
self.running = False
except asyncio.TimeoutError:
log.warning("Timed out while trying to find a server!")
except Exception: # pylint: disable=broad-except
log.exception("Exception while trying to find a server!")
if not self.running:
return
elif self.client:
await self.client.close()
self.client.connection.cancel_pending_requests()
async def stop(self):
self.running = False
if self.session_pool:
if self.running:
self.running = False
self._switch_task.cancel()
self.session_pool.stop()
if self.is_connected:
disconnected = self.client.on_disconnected.first
await self.client.close()
await disconnected
@property
def is_connected(self):
return self.client is not None and not self.client.is_closing()
return self.client and not self.client.is_closing()
def rpc(self, list_or_method, args):
if self.is_connected:
return self.client.send_request(list_or_method, args)
def rpc(self, list_or_method, args, restricted=True):
session = self.client if restricted else self.session_pool.fastest_session
if session and not session.is_closing():
return session.send_request(list_or_method, args)
else:
self.session_pool.trigger_nodelay_connect()
raise ConnectionError("Attempting to send rpc request when connection is not available.")
async def pick_fastest_session(self):
sessions = await self.session_pool.get_online_sessions()
done, pending = await asyncio.wait([
self.probe_session(session)
for session in sessions if not session.is_closing()
], return_when='FIRST_COMPLETED')
for task in pending:
task.cancel()
for session in done:
return await session
async def probe_session(self, session: ClientSession):
await session.send_request('server.banner')
return session
async def retriable_call(self, function, *args, **kwargs):
while self.running:
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()
try:
return await function(*args, **kwargs)
except asyncio.TimeoutError:
log.warning("Wallet server call timed out, retrying.")
except ConnectionError:
pass
raise asyncio.CancelledError() # if we got here, we are shutting down
def _update_remote_height(self, header_args):
self.remote_height = header_args[0]["height"]
def ensure_server_version(self, required='1.2'):
return self.rpc('server.version', [__version__, required])
def get_transaction(self, tx_hash, known_height=None):
# use any server if its old, otherwise restrict to who gave us the history
restricted = not known_height or 0 > known_height > self.remote_height - 10
return self.rpc('blockchain.transaction.get', [tx_hash], restricted)
def broadcast(self, raw_transaction):
return self.rpc('blockchain.transaction.broadcast', [raw_transaction])
def get_history(self, address):
return self.rpc('blockchain.address.get_history', [address])
def get_transaction(self, tx_hash):
return self.rpc('blockchain.transaction.get', [tx_hash])
def get_transaction_height(self, tx_hash):
return self.rpc('blockchain.transaction.get_height', [tx_hash])
def get_transaction_height(self, tx_hash, known_height=None):
restricted = not known_height or 0 > known_height > self.remote_height - 10
return self.rpc('blockchain.transaction.get_height', [tx_hash], restricted)
def get_merkle(self, tx_hash, height):
return self.rpc('blockchain.transaction.get_merkle', [tx_hash, height])
restricted = 0 > height > self.remote_height - 10
return self.rpc('blockchain.transaction.get_merkle', [tx_hash, height], restricted)
def get_headers(self, height, count=10000):
return self.rpc('blockchain.block.headers', [height, count])
def subscribe_headers(self):
return self.rpc('blockchain.headers.subscribe', [True])
# --- Subscribes, history and broadcasts are always aimed towards the master client directly
def get_history(self, address):
return self.rpc('blockchain.address.get_history', [address], True)
def subscribe_address(self, address):
return self.rpc('blockchain.address.subscribe', [address])
def broadcast(self, raw_transaction):
return self.rpc('blockchain.transaction.broadcast', [raw_transaction], True)
def subscribe_headers(self):
return self.rpc('blockchain.headers.subscribe', [True], True)
async def subscribe_address(self, address):
try:
return await self.rpc('blockchain.address.subscribe', [address], True)
except asyncio.TimeoutError:
# abort and cancel, we cant lose a subscription, it will happen again on reconnect
if self.client:
self.client.abort()
raise asyncio.CancelledError()
class SessionPool:
def __init__(self, network: BaseNetwork, timeout: float):
self.network = network
self.sessions: List[ClientSession] = []
self._dead_servers: List[ClientSession] = []
self.maintain_connections_task = None
self.sessions: Dict[ClientSession, Optional[asyncio.Task]] = dict()
self.timeout = timeout
# triggered when the master server is out, to speed up reconnect
self._lost_master = asyncio.Event()
self.new_connection_event = asyncio.Event()
@property
def online(self):
for session in self.sessions:
if not session.is_closing():
return True
return False
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],
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):
self.sessions = [
ClientSession(network=self.network, server=server)
for server in default_servers
]
self.maintain_connections_task = asyncio.create_task(self.ensure_connections())
for server in default_servers:
self._connect_session(server)
def stop(self):
if self.maintain_connections_task:
self.maintain_connections_task.cancel()
for session, task in self.sessions.items():
task.cancel()
session.synchronous_close()
self.sessions.clear()
def ensure_connections(self):
for session in self.sessions:
if not session.is_closing():
session.abort()
self.sessions, self._dead_servers, self.maintain_connections_task = [], [], None
self._connect_session(session.server)
async def ensure_connections(self):
while True:
await asyncio.gather(*[
self.ensure_connection(session)
for session in self.sessions
], return_exceptions=True)
try:
await asyncio.wait_for(self._lost_master.wait(), timeout=3)
except asyncio.TimeoutError:
pass
self._lost_master.clear()
if not self.sessions:
self.sessions.extend(self._dead_servers)
self._dead_servers = []
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 ensure_connection(self, session):
self._dead_servers.append(session)
self.sessions.remove(session)
try:
if session.is_closing():
await session.create_connection(self.timeout)
await asyncio.wait_for(session.send_request('server.banner'), timeout=self.timeout)
self.sessions.append(session)
self._dead_servers.remove(session)
except asyncio.TimeoutError:
log.warning("Timeout connecting to %s:%d", *session.server)
except asyncio.CancelledError: # pylint: disable=try-except-raise
raise
except socket.gaierror:
log.warning("Could not resolve IP for %s", session.server[0])
except Exception as err: # pylint: disable=broad-except
if 'Connect call failed' in str(err):
log.warning("Could not connect to %s:%d", *session.server)
else:
log.exception("Connecting to %s:%d raised an exception:", *session.server)
async def get_online_sessions(self):
while not self.online:
self._lost_master.set()
await asyncio.sleep(0.5)
return self.sessions
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
+5 -1
View File
@@ -255,7 +255,7 @@ class Template:
self.opcodes = opcodes
def parse(self, tokens):
return Parser(self.opcodes, tokens).parse().values
return Parser(self.opcodes, tokens).parse().values if self.opcodes else {}
def generate(self, values):
source = BCDataStream()
@@ -288,6 +288,8 @@ class Script:
templates: List[Template] = []
NO_SCRIPT = Template('no_script', None) # special case
def __init__(self, source=None, template=None, values=None, template_hint=None):
self.source = source
self._template = template
@@ -318,6 +320,8 @@ class Script:
def parse(self, template_hint=None):
tokens = self.tokens
if not tokens and not template_hint:
template_hint = self.NO_SCRIPT
for template in chain((template_hint,), self.templates):
if not template:
continue
+13 -6
View File
@@ -67,12 +67,14 @@ def set_logging(ledger_module, level, handler=None):
class Conductor:
def __init__(self, ledger_module=None, manager_module=None, verbosity=logging.WARNING):
def __init__(self, ledger_module=None, manager_module=None, verbosity=logging.WARNING,
enable_segwit=False):
self.ledger_module = ledger_module or get_ledger_from_environment()
self.manager_module = manager_module or get_manager_from_environment()
self.spv_module = get_spvserver_from_ledger(self.ledger_module)
self.blockchain_node = get_blockchain_node_from_ledger(self.ledger_module)
self.blockchain_node.segwit_enabled = enable_segwit
self.spv_node = SPVNode(self.spv_module)
self.wallet_node = WalletNode(self.manager_module, self.ledger_module.RegTestLedger)
@@ -188,14 +190,15 @@ class WalletNode:
class SPVNode:
def __init__(self, coin_class):
def __init__(self, coin_class, node_number=1):
self.coin_class = coin_class
self.controller = None
self.data_path = None
self.server = None
self.hostname = 'localhost'
self.port = 50001 + 1 # avoid conflict with default daemon
self.port = 50001 + node_number # avoid conflict with default daemon
self.session_timeout = 600
self.rpc_port = '0' # disabled by default
async def start(self, blockchain_node: 'BlockchainNode'):
self.data_path = tempfile.mkdtemp()
@@ -208,6 +211,7 @@ class SPVNode:
'SESSION_TIMEOUT': str(self.session_timeout),
'MAX_QUERY_WORKERS': '0',
'INDIVIDUAL_TAG_INDEXES': '',
'RPC_PORT': self.rpc_port
}
# TODO: don't use os.environ
os.environ.update(conf)
@@ -256,7 +260,7 @@ class BlockchainProcess(asyncio.SubprocessProtocol):
class BlockchainNode:
def __init__(self, url, daemon, cli):
def __init__(self, url, daemon, cli, segwit_enabled=False):
self.latest_release_url = url
self.project_dir = os.path.dirname(os.path.dirname(__file__))
self.bin_dir = os.path.join(self.project_dir, 'bin')
@@ -272,6 +276,7 @@ class BlockchainNode:
self.rpcport = 9245 + 2 # avoid conflict with default rpc port
self.rpcuser = 'rpcuser'
self.rpcpassword = 'rpcpassword'
self.segwit_enabled = segwit_enabled
@property
def rpc_url(self):
@@ -325,12 +330,14 @@ class BlockchainNode:
self.data_path = tempfile.mkdtemp()
loop = asyncio.get_event_loop()
asyncio.get_child_watcher().attach_loop(loop)
command = (
command = [
self.daemon_bin,
f'-datadir={self.data_path}', '-printtoconsole', '-regtest', '-server', '-txindex',
f'-rpcuser={self.rpcuser}', f'-rpcpassword={self.rpcpassword}', f'-rpcport={self.rpcport}',
f'-port={self.peerport}'
)
]
if not self.segwit_enabled:
command.extend(['-addresstype=legacy', '-vbparams=segwit:0:999999999999'])
self.log.info(' '.join(command))
self.transport, self.protocol = await loop.subprocess_exec(
BlockchainProcess, *command
+3 -3
View File
@@ -33,6 +33,7 @@ __all__ = ('JSONRPC', 'JSONRPCv1', 'JSONRPCv2', 'JSONRPCLoose',
import itertools
import json
import typing
import asyncio
from functools import partial
from numbers import Number
@@ -745,9 +746,8 @@ class JSONRPCConnection(object):
self._protocol = item
return self.receive_message(message)
def cancel_pending_requests(self):
"""Cancel all pending requests."""
exception = CancelledError()
def raise_pending_requests(self, exception):
exception = exception or asyncio.TimeoutError()
for request, event in self._requests.values():
event.result = exception
event.set()
+17 -8
View File
@@ -103,7 +103,7 @@ class SessionBase(asyncio.Protocol):
# Force-close a connection if a send doesn't succeed in this time
self.max_send_delay = 60
# Statistics. The RPC object also keeps its own statistics.
self.start_time = time.time()
self.start_time = time.perf_counter()
self.errors = 0
self.send_count = 0
self.send_size = 0
@@ -123,7 +123,7 @@ class SessionBase(asyncio.Protocol):
# A non-positive value means not to limit concurrency
if self.bw_limit <= 0:
return
now = time.time()
now = time.perf_counter()
# Reduce the recorded usage in proportion to the elapsed time
refund = (now - self.bw_time) * (self.bw_limit / 3600)
self.bw_charge = max(0, self.bw_charge - int(refund))
@@ -146,7 +146,7 @@ class SessionBase(asyncio.Protocol):
await asyncio.wait_for(self._can_send.wait(), secs)
except asyncio.TimeoutError:
self.abort()
raise asyncio.CancelledError(f'task timed out after {secs}s')
raise asyncio.TimeoutError(f'task timed out after {secs}s')
async def _send_message(self, message):
if not self._can_send.is_set():
@@ -156,7 +156,7 @@ class SessionBase(asyncio.Protocol):
self.send_size += len(framed_message)
self._using_bandwidth(len(framed_message))
self.send_count += 1
self.last_send = time.time()
self.last_send = time.perf_counter()
if self.verbosity >= 4:
self.logger.debug(f'Sending framed message {framed_message}')
self.transport.write(framed_message)
@@ -215,7 +215,8 @@ class SessionBase(asyncio.Protocol):
self._address = None
self.transport = None
self._task_group.cancel()
self._pm_task.cancel()
if self._pm_task:
self._pm_task.cancel()
# Release waiting tasks
self._can_send.set()
@@ -253,6 +254,7 @@ class SessionBase(asyncio.Protocol):
if self.transport:
self.transport.abort()
# TODO: replace with synchronous_close
async def close(self, *, force_after=30):
"""Close the connection and return when closed."""
self._close()
@@ -262,6 +264,11 @@ class SessionBase(asyncio.Protocol):
self.abort()
await self._pm_task
def synchronous_close(self):
self._close()
if self._pm_task and not self._pm_task.done():
self._pm_task.cancel()
class MessageSession(SessionBase):
"""Session class for protocols where messages are not tied to responses,
@@ -296,7 +303,7 @@ class MessageSession(SessionBase):
)
self._bump_errors()
else:
self.last_recv = time.time()
self.last_recv = time.perf_counter()
self.recv_count += 1
if self.recv_count % 10 == 0:
await self._update_concurrency()
@@ -416,7 +423,7 @@ class RPCSession(SessionBase):
self.logger.warning(f'{e!r}')
continue
self.last_recv = time.time()
self.last_recv = time.perf_counter()
self.recv_count += 1
if self.recv_count % 10 == 0:
await self._update_concurrency()
@@ -456,7 +463,7 @@ class RPCSession(SessionBase):
def connection_lost(self, exc):
# Cancel pending requests and message processing
self.connection.cancel_pending_requests()
self.connection.raise_pending_requests(exc)
super().connection_lost(exc)
# External API
@@ -473,6 +480,8 @@ class RPCSession(SessionBase):
async def send_request(self, method, args=()):
"""Send an RPC request over the network."""
if self.is_closing():
raise asyncio.TimeoutError("Trying to send request on a recently dropped connection.")
message, event = self.connection.send_request(Request(method, args))
await self._send_message(message)
await event.wait()
+2 -1
View File
@@ -10,7 +10,8 @@ def get_argument_parser():
parser = argparse.ArgumentParser(
prog="torba-server"
)
parser.add_argument("spvserver", type=str, help="Python class path to SPV server implementation.")
parser.add_argument("spvserver", type=str, help="Python class path to SPV server implementation.",
nargs="?", default="lbry.wallet.server.coin.LBC")
return parser
+11 -9
View File
@@ -17,6 +17,7 @@ import time
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
@@ -72,9 +73,8 @@ class DB:
self.header_len = self.dynamic_header_len
self.logger.info(f'switching current directory to {env.db_dir}')
os.chdir(env.db_dir)
self.db_class = db_class(self.env.db_engine)
self.db_class = db_class(env.db_dir, self.env.db_engine)
self.history = History()
self.utxo_db = None
self.tx_counts = None
@@ -86,12 +86,13 @@ class DB:
self.merkle = Merkle()
self.header_mc = MerkleCache(self.merkle, self.fs_block_hashes)
self.headers_file = util.LogicalFile('meta/headers', 2, 16000000)
self.tx_counts_file = util.LogicalFile('meta/txcounts', 2, 2000000)
self.hashes_file = util.LogicalFile('meta/hashes', 4, 16000000)
path = partial(os.path.join, self.env.db_dir)
self.headers_file = util.LogicalFile(path('meta/headers'), 2, 16000000)
self.tx_counts_file = util.LogicalFile(path('meta/txcounts'), 2, 2000000)
self.hashes_file = util.LogicalFile(path('meta/hashes'), 4, 16000000)
if not self.coin.STATIC_BLOCK_HEADERS:
self.headers_offsets_file = util.LogicalFile(
'meta/headers_offsets', 2, 16000000)
path('meta/headers_offsets'), 2, 16000000)
async def _read_tx_counts(self):
if self.tx_counts is not None:
@@ -115,8 +116,9 @@ class DB:
if self.utxo_db.is_new:
self.logger.info('created new database')
self.logger.info('creating metadata directory')
os.mkdir('meta')
with util.open_file('COIN', create=True) as f:
os.mkdir(os.path.join(self.env.db_dir, 'meta'))
coin_path = os.path.join(self.env.db_dir, 'meta', 'COIN')
with util.open_file(coin_path, create=True) as f:
f.write(f'ElectrumX databases and metadata for '
f'{self.coin.NAME} {self.coin.NET}'.encode())
if not self.coin.STATIC_BLOCK_HEADERS:
@@ -474,7 +476,7 @@ class DB:
return 'meta/block'
def raw_block_path(self, height):
return f'{self.raw_block_prefix()}{height:d}'
return os.path.join(self.env.db_dir, f'{self.raw_block_prefix()}{height:d}')
def read_raw_block(self, height):
"""Returns a raw block read from disk. Raises FileNotFoundError
+1 -1
View File
@@ -258,7 +258,7 @@ class SessionManager:
session_timeout = self.env.session_timeout
while True:
await sleep(session_timeout // 10)
stale_cutoff = time.time() - session_timeout
stale_cutoff = time.perf_counter() - session_timeout
stale_sessions = [session for session in self.sessions
if session.last_recv < stale_cutoff]
if stale_sessions:
+9 -6
View File
@@ -13,20 +13,21 @@ from functools import partial
from torba.server import util
def db_class(name):
def db_class(db_dir, name):
"""Returns a DB engine class."""
for db_class in util.subclasses(Storage):
if db_class.__name__.lower() == name.lower():
db_class.import_module()
return db_class
return partial(db_class, db_dir)
raise RuntimeError('unrecognised DB engine "{}"'.format(name))
class Storage:
"""Abstract base class of the DB backend abstraction."""
def __init__(self, name, for_sync):
self.is_new = not os.path.exists(name)
def __init__(self, db_dir, name, for_sync):
self.db_dir = db_dir
self.is_new = not os.path.exists(os.path.join(db_dir, name))
self.for_sync = for_sync or self.is_new
self.open(name, create=self.is_new)
@@ -78,8 +79,9 @@ class LevelDB(Storage):
def open(self, name, create):
mof = 512 if self.for_sync else 128
path = os.path.join(self.db_dir, name)
# Use snappy compression (the default)
self.db = self.module.DB(name, create_if_missing=create,
self.db = self.module.DB(path, create_if_missing=create,
max_open_files=mof)
self.close = self.db.close
self.get = self.db.get
@@ -99,12 +101,13 @@ class RocksDB(Storage):
def open(self, name, create):
mof = 512 if self.for_sync else 128
path = os.path.join(self.db_dir, name)
# Use snappy compression (the default)
options = self.module.Options(create_if_missing=create,
use_fsync=True,
target_file_size_base=33554432,
max_open_files=mof)
self.db = self.module.DB(name, options)
self.db = self.module.DB(path, options)
self.get = self.db.get
self.put = self.db.put
+8 -4
View File
@@ -45,10 +45,12 @@ class BroadcastSubscription:
class StreamController:
def __init__(self):
def __init__(self, merge_repeated_events=False):
self.stream = Stream(self)
self._first_subscription = None
self._last_subscription = None
self._last_event = None
self._merge_repeated = merge_repeated_events
@property
def has_listener(self):
@@ -76,8 +78,10 @@ class StreamController:
return f
def add(self, event):
skip = self._merge_repeated and event == self._last_event
self._last_event = event
return self._notify_and_ensure_future(
lambda subscription: subscription._add(event)
lambda subscription: None if skip else subscription._add(event)
)
def add_error(self, exception):
@@ -141,8 +145,8 @@ class Stream:
def first(self):
future = asyncio.get_event_loop().create_future()
subscription = self.listen(
lambda value: self._cancel_and_callback(subscription, future, value),
lambda exception: self._cancel_and_error(subscription, future, exception)
lambda value: not future.done() and self._cancel_and_callback(subscription, future, value),
lambda exception: not future.done() and self._cancel_and_error(subscription, future, exception)
)
return future
+3 -1
View File
@@ -185,6 +185,7 @@ class IntegrationTestCase(AsyncioTestCase):
LEDGER = None
MANAGER = None
ENABLE_SEGWIT = False
VERBOSITY = logging.WARN
def __init__(self, *args, **kwargs):
@@ -199,7 +200,8 @@ class IntegrationTestCase(AsyncioTestCase):
async def asyncSetUp(self):
self.conductor = Conductor(
ledger_module=self.LEDGER, manager_module=self.MANAGER, verbosity=self.VERBOSITY
ledger_module=self.LEDGER, manager_module=self.MANAGER, verbosity=self.VERBOSITY,
enable_segwit=self.ENABLE_SEGWIT
)
await self.conductor.start_blockchain()
self.addCleanup(self.conductor.stop_blockchain)