Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement sapling viewing keys | 2.0.8 #69

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# BitcoinZ 2.0.7-10
# BitcoinZ 2.0.8
**Keep running wallet to strengthen the BitcoinZ network. Backup your wallet in many locations & keep your coins wallet offline.**

### Ports:
Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 2)
define(_CLIENT_VERSION_MINOR, 0)
define(_CLIENT_VERSION_REVISION, 7)
define(_CLIENT_VERSION_BUILD, 60)
define(_CLIENT_VERSION_REVISION, 8)
define(_CLIENT_VERSION_BUILD, 50)
define(_ZC_BUILD_VAL, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD), m4_eval(_CLIENT_VERSION_BUILD < 50), 1, m4_eval(_CLIENT_VERSION_BUILD - 24), m4_eval(_CLIENT_VERSION_BUILD == 50), 1, , m4_eval(_CLIENT_VERSION_BUILD - 50)))
define(_CLIENT_VERSION_SUFFIX, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, _CLIENT_VERSION_REVISION-beta$1, m4_eval(_CLIENT_VERSION_BUILD < 50), 1, _CLIENT_VERSION_REVISION-rc$1, m4_eval(_CLIENT_VERSION_BUILD == 50), 1, _CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION-$1)))
define(_CLIENT_VERSION_IS_RELEASE, true)
Expand Down
6 changes: 6 additions & 0 deletions contrib/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
bitcoinz (2.0.8) stable; urgency=low

* 2.0.8 release.

-- The BitcoinZ Community <bitcoinzcommunity@gmail.com> Sep 2022

bitcoinz (2.0.7-10) stable; urgency=medium

* 2.0.7-10 release.
Expand Down
7 changes: 5 additions & 2 deletions contrib/debian/copyright
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ Files: depends/sources/qpid-proton-*.tar.gz
Copyright: 2012-2017 The Apache Software Foundation
License: Apache-Qpid-Proton-with-BSD-Subcomponents

Files: depends/sources/utfcpp-*.tar.gz
Copyright: 2006 Nemanja Trifunovic
License: Boost-Software-License-1.0

Files: src/secp256k1/build-aux/m4/ax_jni_include_dir.m4
Copyright: 2008 Don Anderson <dda@sleepycat.com>
License: GNU-All-permissive-License
Expand Down Expand Up @@ -1095,7 +1099,7 @@ License: LGPL-with-ZeroMQ-exception
the license of that module. An independent module is a module which is not
derived from or based on this library. If you modify this library, you must
extend this exception to your version of the library.

Note: this exception relieves you of any obligations under sections 4 and 5
of this license, and section 6 of the GNU General Public License.
Comment:
Expand Down Expand Up @@ -1323,4 +1327,3 @@ License: GNU-All-permissive-License
permitted in any medium without royalty provided the copyright notice
and this notice are preserved. This file is offered as-is, without any
warranty.

2 changes: 1 addition & 1 deletion contrib/gitian-descriptors/gitian-linux.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: "bitcoinz-2.0.7-10"
name: "bitcoinz-2.0.8"
enable_cache: true
distro: "debian"
suites:
Expand Down
2 changes: 1 addition & 1 deletion depends/packages/packages.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ rust_crates := \
crate_winapi_x86_64_pc_windows_gnu
rust_packages := rust $(rust_crates) librustzcash
proton_packages := proton
zcash_packages := libgmp libsodium
zcash_packages := libgmp libsodium utfcpp
packages := boost openssl libevent zeromq $(zcash_packages) googletest
native_packages := native_ccache

Expand Down
10 changes: 10 additions & 0 deletions depends/packages/utfcpp.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package=utfcpp
$(package)_version=3.1
$(package)_download_path=https://github.com/nemtrif/$(package)/archive/
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_download_file=v$($(package)_version).tar.gz
$(package)_sha256_hash=ab531c3fd5d275150430bfaca01d7d15e017a188183be932322f2f651506b096

define $(package)_stage_cmds
cp -a ./source $($(package)_staging_dir)$(host_prefix)/include
endef
6 changes: 3 additions & 3 deletions doc/man/bitcoinz-cli.1
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.6.
.TH BITCOINZ-CLI "1" "May 2022" "bitcoinz-cli v2.0.7-10" "User Commands"
.TH BITCOINZ-CLI "1" "Sep 2022" "bitcoinz-cli v2.0.8" "User Commands"
.SH NAME
bitcoinz-cli \- manual page for bitcoinz-cli v2.0.7-10
bitcoinz-cli \- manual page for bitcoinz-cli v2.0.8
.SH DESCRIPTION
BitcoinZ RPC client version v2.0.7-10
BitcoinZ RPC client version v2.0.8
.PP
In order to ensure you are adequately protecting your privacy when using
BitcoinZ, please see <https://z.cash/support/security/index.html>.
Expand Down
6 changes: 3 additions & 3 deletions doc/man/bitcoinz-tx.1
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.6.
.TH BITCOINZ-TX "1" "May 2022" "bitcoinz-tx v2.0.7-10" "User Commands"
.TH BITCOINZ-TX "1" "Sep 2022" "bitcoinz-tx v2.0.8" "User Commands"
.SH NAME
bitcoinz-tx \- manual page for bitcoinz-tx v2.0.7-10
bitcoinz-tx \- manual page for bitcoinz-tx v2.0.8
.SH DESCRIPTION
BitcoinZ bitcoinz\-tx utility version v2.0.7-10
BitcoinZ bitcoinz\-tx utility version v2.0.8
.SS "Usage:"
.TP
bitcoinz\-tx [options] <hex\-tx> [commands]
Expand Down
6 changes: 3 additions & 3 deletions doc/man/bitcoinzd.1
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.6.
.TH BITCOINZD "1" "May 2022" "bitcoinzd v2.0.7-10" "User Commands"
.TH BITCOINZD "1" "Sep 2022" "bitcoinzd v2.0.8" "User Commands"
.SH NAME
bitcoinzd \- manual page for bitcoinzd v2.0.7-10
bitcoinzd \- manual page for bitcoinzd v2.0.8
.SH DESCRIPTION
BitcoinZ Daemon version v2.0.7-10
BitcoinZ Daemon version v2.0.8
.PP
In order to ensure you are adequately protecting your privacy when using
BitcoinZ, please see <https://z.cash/support/security/>.
Expand Down
2 changes: 2 additions & 0 deletions doc/release-notes/release-notes-2.0.8-RC1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Notable changes
===============
88 changes: 86 additions & 2 deletions qa/rpc-tests/finalsaplingroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from decimal import Decimal

SPROUT_TREE_EMPTY_ROOT = "59d2cde5e65c1414c32ba54f0fe4bdb3d67618125286e6a191317917c812c6d7"
SAPLING_TREE_EMPTY_ROOT = "3e49b5f954aa9d3545bc6c37744661eea48d7c34e3000d82b7f0010c30f4c2fb"
NULL_FIELD = "0000000000000000000000000000000000000000000000000000000000000000"

Expand Down Expand Up @@ -50,12 +51,42 @@ def run_test(self):
blk = self.nodes[0].getblock("0")
assert_equal(blk["finalsaplingroot"], NULL_FIELD)



treestate = self.nodes[0].z_gettreestate("0")
assert_equal(treestate["height"], 0)
assert_equal(treestate["hash"], self.nodes[0].getblockhash(0))

assert_equal(treestate["sprout"]["commitments"]["finalRoot"], SPROUT_TREE_EMPTY_ROOT)
assert_equal(treestate["sprout"]["commitments"]["finalState"], "000000")
assert("skipHash" not in treestate["sprout"])

assert_equal(treestate["sapling"]["commitments"]["finalRoot"], NULL_FIELD)
# There is no sapling state tree yet, and trying to find it in an earlier
# block won't succeed (we're at genesis block), so skipHash is absent.
assert("finalState" not in treestate["sapling"])
assert("skipHash" not in treestate["sapling"])



# Verify all generated blocks contain the empty root of the Sapling tree.
blockcount = self.nodes[0].getblockcount()
for height in xrange(1, blockcount + 1):
blk = self.nodes[0].getblock(str(height))
assert_equal(blk["finalsaplingroot"], SAPLING_TREE_EMPTY_ROOT)

treestate = self.nodes[0].z_gettreestate(str(height))
assert_equal(treestate["height"], height)
assert_equal(treestate["hash"], self.nodes[0].getblockhash(height))

assert("skipHash" not in treestate["sprout"])
assert_equal(treestate["sprout"]["commitments"]["finalRoot"], SPROUT_TREE_EMPTY_ROOT)
assert_equal(treestate["sprout"]["commitments"]["finalState"], "000000")

assert("skipHash" not in treestate["sapling"])
assert_equal(treestate["sapling"]["commitments"]["finalRoot"], SAPLING_TREE_EMPTY_ROOT)
assert_equal(treestate["sapling"]["commitments"]["finalState"], "000000")

# Node 0 shields some funds
taddr0 = get_coinbase_address(self.nodes[0])
saplingAddr0 = self.nodes[0].z_getnewaddress('sapling')
Expand All @@ -71,13 +102,30 @@ def run_test(self):
# Verify the final Sapling root has changed
blk = self.nodes[0].getblock("201")
root = blk["finalsaplingroot"]
assert(root is not SAPLING_TREE_EMPTY_ROOT)
assert(root is not NULL_FIELD)
assert(root is not SAPLING_TREE_EMPTY_ROOT)
assert(root is not NULL_FIELD)

# Verify there is a Sapling output description (its commitment was added to tree)
result = self.nodes[0].getrawtransaction(mytxid, 1)
assert_equal(len(result["vShieldedOutput"]), 1)




# Since there is a now sapling shielded input in the blockchain,
# the sapling values should have changed
new_treestate = self.nodes[0].z_gettreestate(str(-1))
assert_equal(new_treestate["sapling"]["commitments"]["finalRoot"], root)
assert_equal(new_treestate["sprout"], treestate["sprout"])
assert(new_treestate["sapling"]["commitments"]["finalRoot"] != treestate["sapling"]["commitments"]["finalRoot"])
assert(new_treestate["sapling"]["commitments"]["finalState"] != treestate["sapling"]["commitments"]["finalState"])
assert_equal(len(new_treestate["sapling"]["commitments"]["finalRoot"]), 64)
assert_equal(len(new_treestate["sapling"]["commitments"]["finalState"]), 70)
treestate = new_treestate




# Mine an empty block and verify the final Sapling root does not change
self.sync_all()
self.nodes[0].generate(1)
Expand Down Expand Up @@ -111,6 +159,22 @@ def run_test(self):
assert_equal(self.nodes[1].z_getbalance(zaddr1), Decimal("10"))
assert_equal(root, self.nodes[0].getblock("204")["finalsaplingroot"])




new_treestate = self.nodes[0].z_gettreestate(str(-1))
assert_equal(new_treestate["sapling"]["commitments"]["finalRoot"], root)
assert_equal(new_treestate["sapling"], treestate["sapling"])
assert(new_treestate["sprout"]["commitments"]["finalRoot"] != treestate["sprout"]["commitments"]["finalRoot"])
assert(new_treestate["sprout"]["commitments"]["finalState"] != treestate["sprout"]["commitments"]["finalState"])
assert_equal(len(new_treestate["sprout"]["commitments"]["finalRoot"]), 64)
assert_equal(len(new_treestate["sprout"]["commitments"]["finalState"]), 134)
treestate = new_treestate





# Mine a block with a Sapling shielded recipient and verify the final Sapling root changes
saplingAddr1 = self.nodes[1].z_getnewaddress("sapling")
recipients = []
Expand All @@ -130,6 +194,19 @@ def run_test(self):
result = self.nodes[0].getrawtransaction(mytxid, 1)
assert_equal(len(result["vShieldedOutput"]), 2) # there is Sapling shielded change



new_treestate = self.nodes[0].z_gettreestate(str(-1))
assert_equal(new_treestate["sprout"], treestate["sprout"])
assert(new_treestate["sapling"]["commitments"]["finalRoot"] != treestate["sapling"]["commitments"]["finalRoot"])
assert(new_treestate["sapling"]["commitments"]["finalState"] != treestate["sapling"]["commitments"]["finalState"])
assert_equal(len(new_treestate["sapling"]["commitments"]["finalRoot"]), 64)
assert_equal(len(new_treestate["sapling"]["commitments"]["finalState"]), 136)
treestate = new_treestate




# Mine a block with a Sapling shielded sender and transparent recipient and verify the final Sapling root doesn't change
taddr2 = self.nodes[0].getnewaddress()
recipients = []
Expand All @@ -149,5 +226,12 @@ def run_test(self):
assert_equal(root, self.nodes[0].getblock("205")["finalsaplingroot"])



new_treestate = self.nodes[0].z_gettreestate(str(-1))
assert_equal(new_treestate["sprout"], treestate["sprout"])
assert_equal(new_treestate["sapling"], treestate["sapling"])



if __name__ == '__main__':
FinalSaplingRootTest().main()
60 changes: 56 additions & 4 deletions qa/rpc-tests/fundrawtransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ class RawTransactionsTest(BitcoinTestFramework):

def setup_chain(self):
print("Initializing test directory "+self.options.tmpdir)
initialize_chain_clean(self.options.tmpdir, 3)
initialize_chain_clean(self.options.tmpdir, 4)

def setup_network(self, split=False):
self.nodes = start_nodes(3, self.options.tmpdir,
self.nodes = start_nodes(4, self.options.tmpdir,
extra_args=[['-experimentalfeatures', '-developerencryptwallet']] * 4)

connect_nodes_bi(self.nodes,0,1)
connect_nodes_bi(self.nodes,1,2)
connect_nodes_bi(self.nodes,0,2)
connect_nodes_bi(self.nodes,0,3)

self.is_network_split=False
self.sync_all()
Expand All @@ -37,11 +38,20 @@ def run_test(self):

self.nodes[2].generate(1)
self.sync_all()
self.nodes[0].generate(101)
self.nodes[0].generate(201)
self.sync_all()

watchonly_address = self.nodes[0].getnewaddress()
watchonly_pubkey = self.nodes[0].validateaddress(watchonly_address)["pubkey"]
watchonly_amount = 200
self.nodes[3].importpubkey(watchonly_pubkey, "", True)
watchonly_txid = self.nodes[0].sendtoaddress(watchonly_address, watchonly_amount)
self.nodes[0].sendtoaddress(self.nodes[3].getnewaddress(), watchonly_amount / 10);

self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.5);
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.0);
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),5.0);

self.sync_all()
self.nodes[0].generate(1)
self.sync_all()
Expand Down Expand Up @@ -434,11 +444,12 @@ def run_test(self):
stop_nodes(self.nodes)
wait_bitcoinds()

self.nodes = start_nodes(3, self.options.tmpdir)
self.nodes = start_nodes(4, self.options.tmpdir)

connect_nodes_bi(self.nodes,0,1)
connect_nodes_bi(self.nodes,1,2)
connect_nodes_bi(self.nodes,0,2)
connect_nodes_bi(self.nodes,0,3)
self.is_network_split=False
self.sync_all()

Expand Down Expand Up @@ -547,5 +558,46 @@ def run_test(self):
assert_equal(len(dec_tx['vout']), 2) # one change output added


##################################################
# test a fundrawtransaction using only watchonly #
##################################################

inputs = []
outputs = {self.nodes[2].getnewaddress() : watchonly_amount / 2}
rawtx = self.nodes[3].createrawtransaction(inputs, outputs)

result = self.nodes[3].fundrawtransaction(rawtx, True)
res_dec = self.nodes[0].decoderawtransaction(result["hex"])
assert_equal(len(res_dec["vin"]), 1)
assert_equal(res_dec["vin"][0]["txid"], watchonly_txid)

assert_equal("fee" in result.keys(), True)
assert_greater_than(result["changepos"], -1)

###############################################################
# test fundrawtransaction using the entirety of watched funds #
###############################################################

inputs = []
outputs = {self.nodes[2].getnewaddress() : watchonly_amount}
rawtx = self.nodes[3].createrawtransaction(inputs, outputs)

result = self.nodes[3].fundrawtransaction(rawtx, True)
res_dec = self.nodes[0].decoderawtransaction(result["hex"])
assert_equal(len(res_dec["vin"]), 2)
assert(res_dec["vin"][0]["txid"] == watchonly_txid or res_dec["vin"][1]["txid"] == watchonly_txid)

assert_greater_than(result["fee"], 0)
assert_greater_than(result["changepos"], -1)
assert_equal(result["fee"] + res_dec["vout"][result["changepos"]]["value"], watchonly_amount / 10)

signedtx = self.nodes[3].signrawtransaction(result["hex"])
assert(not signedtx["complete"])
signedtx = self.nodes[0].signrawtransaction(signedtx["hex"])
assert(signedtx["complete"])
self.nodes[0].sendrawtransaction(signedtx["hex"])



if __name__ == '__main__':
RawTransactionsTest().main()
11 changes: 10 additions & 1 deletion qa/rpc-tests/listtransactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ def run_test(self):
{"category":"receive","amount":Decimal("0.44")},
{"txid":txid, "account" : ""} )

multisig = self.nodes[1].createmultisig(1, [self.nodes[1].getnewaddress()])
self.nodes[0].importaddress(multisig["redeemScript"], "watchonly", False, True)
txid = self.nodes[1].sendtoaddress(multisig["address"], 0.1)
self.nodes[1].generate(1)
self.sync_all()
assert(len(self.nodes[0].listtransactions("watchonly", 100, 0, False)) == 0)
check_array_result(self.nodes[0].listtransactions("watchonly", 100, 0, True),
{"category":"receive","amount":Decimal("0.1")},
{"txid":txid, "account" : "watchonly"} )

if __name__ == '__main__':
ListTransactionsTest().main()

3 changes: 3 additions & 0 deletions qa/rpc-tests/mempool_resurrect_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def run_test(self):
spends2_id = [ self.nodes[0].sendrawtransaction(tx) for tx in spends2_raw ]

blocks.extend(self.nodes[0].generate(1))
self.sync_all()

# mempool should be empty, all txns confirmed
assert_equal(set(self.nodes[0].getrawmempool()), set())
Expand All @@ -76,6 +77,8 @@ def run_test(self):

# Generate another block, they should all get mined
self.nodes[0].generate(1)
self.sync_all()

# mempool should be empty, all txns confirmed
assert_equal(set(self.nodes[0].getrawmempool()), set())
for txid in spends1_id+spends2_id:
Expand Down
Loading