Replace Sapling support-related asserts with JSON errors
This helps prevent users from triggering an assert if they pass in Sapling addresses to RPC calls which do not fully support Sapling yet: z_mergetoaddress, z_importviewingkey and z_exportviewingkey.
Part of #3533.
This helps prevent users from triggering an assert if they pass in
Sapling addresses to RPC calls: z_mergetoaddress, z_importviewingkey
and z_exportviewingkey.
Fix signing raw transactions with unsynced offline nodes
This PR address the issue in two different ways:
- In `signrawtransaction` we determine the consensus branch ID (which we then later use to construct the transaction) using the chain height. We now also consider the `APPROX_RELEASE_HEIGHT` as this is a better estimation than 0 for the height of the chain if we are unsynced. (This in and of itself solves the Overwinter signing issue).
- We have added an additional parameter to `signrawtransaction` to allow manually overriding the consensus branch ID that zcashd determines we are on. This allows users to work around corner cases where the first strategy is still insufficient.
Closes#3327.
Test peer banning logic in both pre- and post-initial block download states
The DoS ban scores are different for each, and it's nice to test both.
Follow-on from #3410.
Rpc test cleanup
The main purpose of this PR was to inline the method 'wait_for_async_operation_id' from util.py in tests where we were doing this manually. To make it work in all cases, I had to change the method to return the result in the case where the call failed. I also did a bit of general clean up (removing semicolons) in the files which I changed.
Fix assertion failure in circuit.merkle_tree_gadget_weirdness test on Windows
zcash-gtest.exe fails
```
[ RUN ] circuit.merkle_tree_gadget_weirdness
Assertion failed!
Program: C:\zcash-gtest.exe
File: ./snark/libsnark/gadgetlib1/gadgets/basic_gadgets.tcc, Line 50
Expression: this->pb.lc_val(packed).as_bigint().num_bits() <= bits.size()
```
The argument type of `__builtin_clzl()` function is unsigned long.
So, we need to replace `__builtin_clzl` with `__builtin_clzll`. (The argument type of `__builtin_clzll()` is unsigned long long (64bit)).