lightwalletd
lightwalletd copied to clipboard
Provide grpcurl examples in docs/darksidewalletd.md
The darksidewalletd RPC interface is documented in both docs/darksidewalletd.md and the definition file walletrpc/darkside.proto, but it would be very helpful for people trying to learn this API to have some working examples.
Something like this (from a slack conversation) should be added to the README.md:
grpcurl -plaintext -d '{"saplingActivation": 1000,"branchID": "bad", "chainName":"x"}' localhost:9067 cash.z.wallet.sdk.rpc.DarksideStreamer/Reset
grpcurl -plaintext -d '{"height":1000,"nonce":7,"count":10}' localhost:9067 cash.z.wallet.sdk.rpc.DarksideStreamer/StageBlocksCreate
grpcurl -plaintext -d '{"height":1004}' localhost:9067 cash.z.wallet.sdk.rpc.DarksideStreamer/ApplyStaged
That created 10 "synthetic" (manufactured like genblocks.sh can do) blocks starting at 1000, and in the log file we see:
{"app":"lightwalletd","level":"info","msg":"active blocks from 1000 to 1009, latest height 1004","time":"2020-05-18T16:41:35-06:00"}
{"app":"lightwalletd","level":"info","msg":"Ingestor: waiting for block: 1005","time":"2020-05-18T16:49:34-06:00"}
Now let's expose out to 1009:
grpcurl -plaintext -d '{"height":1009}' localhost:9067 cash.z.wallet.sdk.rpc.DarksideStreamer/ApplyStaged
and in the log file:
{"app":"lightwalletd","level":"info","msg":"active blocks from 1000 to 1009, latest height 1009","time":"2020-05-18T16:50:48-06:00"}
{"app":"lightwalletd","level":"info","msg":"Ingestor adding block to cache: 1005","time":"2020-05-18T16:50:48-06:00"}
{"app":"lightwalletd","level":"info","msg":"Ingestor: waiting for block: 1010","time":"2020-05-18T16:50:48-06:00"}
Now let's create more blocks, but this time starting at 1005, and notice the different nonce (8):
grpcurl -plaintext -d '{"height":1005,"nonce":8,"count":10}' localhost:9067 cash.z.wallet.sdk.rpc.DarksideStreamer/StageBlocksCreate
grpcurl -plaintext -d '{"height":1009}' localhost:9067 cash.z.wallet.sdk.rpc.DarksideStreamer/ApplyStaged
in the log file:
{"app":"lightwalletd","level":"info","msg":"active blocks from 1000 to 1014, latest height 1009","time":"2020-05-18T16:53:31-06:00"}
{"app":"lightwalletd","hash":"6f5f24f05661ca2522a47c1a04a2c122901d7ffee703a47afd3d574c89acc31c","height":1009,"level":"warning","msg":"REORG","phash":"bae7626c61ccfb5acffd68820769dba08f2dc69b3800ea34abb6b32931843129","reorg":2,"time":"2020-05-18T16:53:31-06:00"}
{"app":"lightwalletd","hash":"fbf6efd558210729f7ce0bdc5a4bc5d16888a40cb2776fcace985f499d01ecff","height":1008,"level":"warning","msg":"REORG","phash":"d278db1f8b5756b832cd94b27d5d48a59b6b4fd6bc10815e2d58f4fc29f39424","reorg":3,"time":"2020-05-18T16:53:31-06:00"}
{"app":"lightwalletd","hash":"04df3ac2ad89e9c672285738190e61580ce6c6a549baf818623995c2a15abed5","height":1007,"level":"warning","msg":"REORG","phash":"e8e040ca90d5cc24988163a58a34240a97728c5c2d62ab645c106e8df5301f5d","reorg":4,"time":"2020-05-18T16:53:31-06:00"}
{"app":"lightwalletd","hash":"88c8bc75431afddf74a23bff65a2fc00fed25bc0c6a61acf91680fa0304b526f","height":1006,"level":"warning","msg":"REORG","phash":"b1a529e41d50096d91f83ccd9dcb66ff25eaffec7b0e83c1bee7df1934aea0c9","reorg":5,"time":"2020-05-18T16:53:31-06:00"}
{"app":"lightwalletd","level":"info","msg":"Ingestor adding block to cache: 1005","time":"2020-05-18T16:53:31-06:00"}
{"app":"lightwalletd","level":"info","msg":"Ingestor: waiting for block: 1010","time":"2020-05-18T16:53:31-06:00"}
So we created a reorg without even using any saved blocks! (Notice, this happened within the same second.)