diff --git a/src/init.cpp b/src/init.cpp index da66d1a16b..da5af353a6 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -888,11 +888,6 @@ void InitParameterInteraction() for (const auto& arg : gArgs.GetUnsuitableSectionOnlyArgs()) { InitWarning(strprintf(_("Config setting for %s only applied on %s network when in [%s] section."), arg, network, network)); } - - // Warn if unrecognized section name are present in the config file. - for (const auto& section : gArgs.GetUnrecognizedSections()) { - InitWarning(strprintf(_("Section [%s] is not recognized."), section)); - } } static std::string ResolveErrMsg(const char * const optname, const std::string& strBind) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index e71cc6db3a..4914161c8c 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -2371,6 +2371,7 @@ UniValue scantxoutset(const JSONRPCRequest& request) unspent.pushKV("txid", outpoint.hash.GetHex()); unspent.pushKV("vout", (int32_t)outpoint.n); unspent.pushKV("scriptPubKey", HexStr(txo.scriptPubKey.begin(), txo.scriptPubKey.end())); + unspent.pushKV("desc", descriptors[txo.scriptPubKey]); if (txo.nValue.IsExplicit()) { unspent.pushKV("amount", ValueFromAmount(txo.nValue.GetAmount())); } else { diff --git a/test/functional/data/invalid_txs.py b/test/functional/data/invalid_txs.py index 02deae92f3..0948e69008 100644 --- a/test/functional/data/invalid_txs.py +++ b/test/functional/data/invalid_txs.py @@ -47,7 +47,7 @@ class BadTxTemplate: def __init__(self, *, spend_tx=None, spend_block=None): self.spend_tx = spend_block.vtx[0] if spend_block else spend_tx - self.spend_avail = sum(o.nValue for o in self.spend_tx.vout) + self.spend_avail = sum(o.nValue.getAmount() for o in self.spend_tx.vout) self.valid_txin = CTxIn(COutPoint(self.spend_tx.sha256, 0), b"", 0xffffffff) @abc.abstractmethod @@ -78,17 +78,19 @@ class InputMissing(BadTxTemplate): return tx -class SizeTooSmall(BadTxTemplate): - reject_reason = "tx-size-small" - expect_disconnect = False - valid_in_block = True - - def get_tx(self): - tx = CTransaction() - tx.vin.append(self.valid_txin) - tx.vout.append(CTxOut(0, sc.CScript([sc.OP_TRUE]))) - tx.calc_sha256() - return tx +# ELEMENTS: disabled because we don't want to increase the minimal tx size and +# the value and asset size crosses the minimum value +#class SizeTooSmall(BadTxTemplate): +# reject_reason = "tx-size-small" +# expect_disconnect = False +# valid_in_block = True +# +# def get_tx(self): +# tx = CTransaction() +# tx.vin.append(self.valid_txin) +# tx.vout.append(CTxOut(0, sc.CScript([sc.OP_TRUE]))) +# tx.calc_sha256() +# return tx class BadInputOutpointIndex(BadTxTemplate): @@ -135,7 +137,8 @@ class NonexistentInput(BadTxTemplate): class SpendTooMuch(BadTxTemplate): - reject_reason = 'bad-txns-in-belowout' + reject_reason = 'bad-txns-in-ne-out' + block_reject_reason = 'block-validation-failed' expect_disconnect = True def get_tx(self): @@ -159,7 +162,7 @@ class InvalidOPIFConstruction(BadTxTemplate): def get_tx(self): return create_tx_with_script( self.spend_tx, 0, script_sig=b'\x64' * 35, - amount=(self.spend_avail // 2)) + amount=self.spend_avail) class TooManySigops(BadTxTemplate): @@ -172,7 +175,7 @@ class TooManySigops(BadTxTemplate): return create_tx_with_script( self.spend_tx, 0, script_pub_key=lotsa_checksigs, - amount=1) + amount=self.spend_avail) def iter_all_templates(): diff --git a/test/functional/feature_block_subsidy.py b/test/functional/feature_block_subsidy.py index 1599a52293..017f9b9bab 100755 --- a/test/functional/feature_block_subsidy.py +++ b/test/functional/feature_block_subsidy.py @@ -37,7 +37,7 @@ class BlockSubsidyTest(BitcoinTestFramework): # Block will have 10 satoshi output, node 1 will ban addr = self.nodes[0].getnewaddress() sub_block = self.nodes[0].generatetoaddress(1, addr) - raw_coinbase = self.nodes[0].getrawtransaction(self.nodes[0].getblock(sub_block[0])["tx"][0]) + raw_coinbase = self.nodes[0].getrawtransaction(self.nodes[0].getblock(sub_block[0])["tx"][0], False, sub_block[0]) decoded_coinbase = self.nodes[0].decoderawtransaction(raw_coinbase) found_ten = False @@ -53,13 +53,13 @@ class BlockSubsidyTest(BitcoinTestFramework): # Block will have 0 satoshis outputs only at height 1 no_sub_block = self.nodes[1].generatetoaddress(1, addr) - raw_coinbase = self.nodes[1].getrawtransaction(self.nodes[1].getblock(no_sub_block[0])["tx"][0]) + raw_coinbase = self.nodes[1].getrawtransaction(self.nodes[1].getblock(no_sub_block[0])["tx"][0], False, no_sub_block[0]) decoded_coinbase = self.nodes[1].decoderawtransaction(raw_coinbase) for vout in decoded_coinbase["vout"]: if vout["value"] != 0: raise Exception("Invalid output amount in coinbase") - tmpl = self.nodes[0].getblocktemplate() + tmpl = self.nodes[0].getblocktemplate({"rules": ["segwit"]}) # Template with invalid amount(50*COIN) will be invalid in both coinbase_tx = create_coinbase(height=int(tmpl["height"])) diff --git a/test/functional/feature_blocksdir.py b/test/functional/feature_blocksdir.py index 6868b5fa64..66a0da2de4 100755 --- a/test/functional/feature_blocksdir.py +++ b/test/functional/feature_blocksdir.py @@ -18,7 +18,7 @@ class BlocksdirTest(BitcoinTestFramework): def run_test(self): self.stop_node(0) - assert os.path.isdir(os.path.join(self.nodes[0].datadir, "regtest", "blocks")) + assert os.path.isdir(os.path.join(self.nodes[0].datadir, "elementsregtest", "blocks")) assert not os.path.isdir(os.path.join(self.nodes[0].datadir, "blocks")) shutil.rmtree(self.nodes[0].datadir) initialize_datadir(self.options.tmpdir, 0, self.chain) diff --git a/test/functional/feature_confidential_transactions.py b/test/functional/feature_confidential_transactions.py index 1d0dcdbb0b..9c1877bb17 100755 --- a/test/functional/feature_confidential_transactions.py +++ b/test/functional/feature_confidential_transactions.py @@ -567,7 +567,7 @@ class CTTest (BitcoinTestFramework): stx = self.nodes[0].signrawtransactionwithwallet(stx2['hex']) txid = self.nodes[2].sendrawtransaction(stx['hex']) self.nodes[2].generate(1) - assert self.nodes[2].getrawtransaction(txid, 1)['confirmations'] == 1 + assert self.nodes[2].gettransaction(txid)['confirmations'] == 1 self.sync_all() # Check that the sent asset has reached its destination diff --git a/test/functional/feature_config_args.py b/test/functional/feature_config_args.py index d7b5b417cd..ee4597671d 100755 --- a/test/functional/feature_config_args.py +++ b/test/functional/feature_config_args.py @@ -41,10 +41,11 @@ class ConfArgsTest(BitcoinTestFramework): conf.write('server=1\nrpcuser=someuser\n[main]\nrpcpassword=some#pass') self.nodes[0].assert_start_raises_init_error(expected_msg='Error reading configuration file: parse error on line 4, using # in rpcpassword can be ambiguous and should be avoided') - with open(inc_conf_file_path, 'w', encoding='utf-8') as conf: - conf.write('testnot.datadir=1\n[testnet]\n') - self.restart_node(0) - self.nodes[0].stop_node(expected_stderr='Warning: Section [testnet] is not recognized.' + os.linesep + 'Warning: Section [testnot] is not recognized.') + # ELEMENTS: allows custom chains + #with open(inc_conf_file_path, 'w', encoding='utf-8') as conf: + # conf.write('testnot.datadir=1\n[testnet]\n') + #self.restart_node(0) + #self.nodes[0].stop_node(expected_stderr='Warning: Section [testnet] is not recognized.' + os.linesep + 'Warning: Section [testnot] is not recognized.') with open(inc_conf_file_path, 'w', encoding='utf-8') as conf: conf.write('') # clear diff --git a/test/functional/feature_connect_coinbase.py b/test/functional/feature_connect_coinbase.py index 03a8f02a4a..9340a1e4bf 100755 --- a/test/functional/feature_connect_coinbase.py +++ b/test/functional/feature_connect_coinbase.py @@ -57,7 +57,7 @@ class ConnectGenesisTest(BitcoinTestFramework): # Issuance transaction is an OP_TRUE, so will be available to second node assert_raises_rpc_error(-5, "No such mempool transaction. Use -txindex to enable blockchain transaction queries. Use gettransaction for wallet transactions.", self.nodes[0].getrawtransaction, issuance_tx) - self.nodes[1].getrawtransaction(issuance_tx) + self.nodes[1].getrawtransaction(issuance_tx, False, self.nodes[0].getblockhash(0)) if __name__ == '__main__': ConnectGenesisTest().main() diff --git a/test/functional/feature_fedpeg.py b/test/functional/feature_fedpeg.py index 78b7df497a..584ad54e7c 100755 --- a/test/functional/feature_fedpeg.py +++ b/test/functional/feature_fedpeg.py @@ -54,7 +54,7 @@ class FedPegTest(BitcoinTestFramework): self.nodes = [] # Setup parent nodes - parent_chain = "parent" if not self.options.parent_bitcoin else "regtest" + parent_chain = "elementsregtest" if not self.options.parent_bitcoin else "regtest" parent_binary = [self.options.parent_binpath] if self.options.parent_binpath != "" else None for n in range(2): extra_args = [ @@ -76,9 +76,8 @@ class FedPegTest(BitcoinTestFramework): extra_args.extend([ "-validatepegin=0", "-initialfreecoins=0", - "-anyonecanspendaremine", + "-anyonecanspendaremine=1", "-signblockscript=51", # OP_TRUE - '-con_blocksubsidy=5000000000', ]) self.add_nodes(1, [extra_args], chain=[parent_chain], binary=parent_binary, chain_in_args=[not self.options.parent_bitcoin]) @@ -101,10 +100,8 @@ class FedPegTest(BitcoinTestFramework): "-printtoconsole=0", "-port="+str(p2p_port(2+n)), "-rpcport="+str(rpc_port(2+n)), - '-parentgenesisblockhash=%s' % self.parentgenesisblockhash, '-validatepegin=1', '-fedpegscript=%s' % self.fedpeg_script, - '-anyonecanspendaremine=0', '-minrelaytxfee=0', '-blockmintxfee=0', '-initialfreecoins=0', @@ -112,6 +109,7 @@ class FedPegTest(BitcoinTestFramework): '-mainchainrpchost=127.0.0.1', '-mainchainrpcport=%s' % rpc_port(n), '-recheckpeginblockinterval=15', # Long enough to allow failure and repair before timeout + '-parentgenesisblockhash=%s' % self.parentgenesisblockhash, '-parentpubkeyprefix=111', '-parentscriptprefix=196', '-parent_bech32_hrp=bcrt', @@ -142,7 +140,7 @@ class FedPegTest(BitcoinTestFramework): datadir = get_datadir_path(self.options.tmpdir, n) extra_args.append('-mainchainrpccookiefile='+datadir+"/" + parent_chain + "/.cookie") - self.add_nodes(1, [extra_args], chain=["sidechain"]) + self.add_nodes(1, [extra_args], chain=["elementsregtest"]) self.start_node(2+n) print("Node {} started".format(2+n)) diff --git a/test/functional/feature_mandatory_coinbase.py b/test/functional/feature_mandatory_coinbase.py index 488ec01cc0..43e9dc3f8f 100755 --- a/test/functional/feature_mandatory_coinbase.py +++ b/test/functional/feature_mandatory_coinbase.py @@ -23,7 +23,7 @@ def b2x(b): def assert_template(node, block, expect, rehash=True): if rehash: block.hashMerkleRoot = block.calc_merkle_root() - rsp = node.getblocktemplate({'data': b2x(block.serialize()), 'mode': 'proposal'}) + rsp = node.getblocktemplate({'data': b2x(block.serialize()), 'mode': 'proposal', 'rules': 'segwit'}) assert_equal(rsp, expect) class MandatoryCoinbaseTest(BitcoinTestFramework): @@ -51,7 +51,7 @@ class MandatoryCoinbaseTest(BitcoinTestFramework): # Have non-mandatory node make a template self.sync_all() - tmpl = node1.getblocktemplate() + tmpl = node1.getblocktemplate({'rules': ['segwit']}) # We make a block with OP_TRUE coinbase output that will fail on node0 coinbase_tx = create_coinbase(height=int(tmpl["height"])) @@ -86,7 +86,7 @@ class MandatoryCoinbaseTest(BitcoinTestFramework): # # Also test that coinbases can't have fees. self.sync_all() - tmpl = node1.getblocktemplate() + tmpl = node1.getblocktemplate({'rules': ['segwit']}) coinbase_tx = create_coinbase(height=int(tmpl["height"])) # sequence numbers must not be max for nLockTime to have effect coinbase_tx.vin[0].nSequence = 2 ** 32 - 2 diff --git a/test/functional/interface_rest.py b/test/functional/interface_rest.py index cfa29f2579..521630eecc 100755 --- a/test/functional/interface_rest.py +++ b/test/functional/interface_rest.py @@ -91,8 +91,6 @@ class RESTTest (BitcoinTestFramework): txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1) self.sync_all() - assert_equal(self.nodes[1].getbalance()['bitcoin'], Decimal("0.1")) - self.log.info("Test the /tx URI") json_obj = self.test_rest_request("/tx/{}".format(txid)) @@ -114,7 +112,7 @@ class RESTTest (BitcoinTestFramework): self.sync_all() bb_hash = self.nodes[0].getbestblockhash() - assert_equal(self.nodes[1].getbalance(), Decimal("0.1")) + assert_equal(self.nodes[1].getbalance()['bitcoin'], Decimal("0.1")) # Check chainTip response json_obj = self.test_rest_request("/getutxos/{}-{}".format(*spending)) diff --git a/test/functional/mempool_accept.py b/test/functional/mempool_accept.py index bce2ad09d3..7769b68407 100755 --- a/test/functional/mempool_accept.py +++ b/test/functional/mempool_accept.py @@ -99,7 +99,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework): coin = coins.pop() # Pick a random coin(base) to spend raw_tx_final = node.signrawtransactionwithwallet(node.createrawtransaction( inputs=[{'txid': coin['txid'], 'vout': coin['vout'], "sequence": 0xffffffff}], # SEQUENCE_FINAL - outputs=[{node.getnewaddress(): 0.025}], + outputs=[{node.getnewaddress(): 0.025}, {"fee": coin["amount"]-Decimal("0.025")}], locktime=node.getblockcount() + 2000, # Can be anything ))['hex'] tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_final))) diff --git a/test/functional/mining_basic.py b/test/functional/mining_basic.py index fb98af5d54..465b18d806 100755 --- a/test/functional/mining_basic.py +++ b/test/functional/mining_basic.py @@ -52,7 +52,7 @@ class MiningTest(BitcoinTestFramework): mining_info = self.nodes[0].getmininginfo() assert_equal(mining_info['blocks'], 200) assert_equal(mining_info['currentblocktx'], 0) - assert_equal(mining_info['currentblockweight'], 4000) + assert_equal(mining_info['currentblockweight'], 4300) self.restart_node(0) connect_nodes_bi(self.nodes, 0, 1) @@ -70,11 +70,8 @@ class MiningTest(BitcoinTestFramework): mining_info = node.getmininginfo() assert_equal(mining_info['blocks'], 200) assert_equal(mining_info['chain'], self.chain) - //TODO(stevenroose) this changed, should it be 0 or not included? - assert_equal(mining_info['currentblocktx'], 0) - assert_equal(mining_info['currentblockweight'], 0) - #assert 'currentblocktx' not in mining_info - #assert 'currentblockweight' not in mining_info + assert 'currentblocktx' not in mining_info + assert 'currentblockweight' not in mining_info assert_equal(mining_info['pooledtx'], 0) # Mine a block to leave initial block download diff --git a/test/functional/p2p_invalid_block.py b/test/functional/p2p_invalid_block.py index b0ae4882a2..4b9e9cca97 100755 --- a/test/functional/p2p_invalid_block.py +++ b/test/functional/p2p_invalid_block.py @@ -99,7 +99,7 @@ class InvalidBlockRequestTest(BitcoinTestFramework): block2_orig.hashMerkleRoot = block2_orig.calc_merkle_root() block2_orig.rehash() block2_orig.solve() - node.p2p.send_blocks_and_test([block2_orig], node, success=False, request_block=False, reject_reason='bad-txns-inputs-duplicate') + node.p2p.send_blocks_and_test([block2_orig], node, success=False, reject_reason='bad-txns-inputs-duplicate') self.log.info("Test very broken block.") diff --git a/test/functional/rpc_deriveaddresses.py b/test/functional/rpc_deriveaddresses.py index c8b58cfc74..c879dd6067 100755 --- a/test/functional/rpc_deriveaddresses.py +++ b/test/functional/rpc_deriveaddresses.py @@ -16,18 +16,18 @@ class DeriveaddressesTest(BitcoinTestFramework): assert_raises_rpc_error(-5, "Invalid descriptor", self.nodes[0].deriveaddresses, "a") descriptor = "wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/0)#t6wfjs64" - address = "bcrt1qjqmxmkpmxt80xz4y3746zgt0q3u3ferr34acd5" + address = "ert1qjqmxmkpmxt80xz4y3746zgt0q3u3ferrfpgxn5" assert_equal(self.nodes[0].deriveaddresses(descriptor), [address]) descriptor = descriptor[:-9] assert_raises_rpc_error(-5, "Invalid descriptor", self.nodes[0].deriveaddresses, descriptor) descriptor_pubkey = "wpkh(tpubD6NzVbkrYhZ4WaWSyoBvQwbpLkojyoTZPRsgXELWz3Popb3qkjcJyJUGLnL4qHHoQvao8ESaAstxYSnhyswJ76uZPStJRJCTKvosUCJZL5B/1/1/0)#s9ga3alw" - address = "bcrt1qjqmxmkpmxt80xz4y3746zgt0q3u3ferr34acd5" + address = "ert1qjqmxmkpmxt80xz4y3746zgt0q3u3ferrfpgxn5" assert_equal(self.nodes[0].deriveaddresses(descriptor_pubkey), [address]) ranged_descriptor = "wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/*)#kft60nuy" - assert_equal(self.nodes[0].deriveaddresses(ranged_descriptor, 0, 2), [address, "bcrt1qhku5rq7jz8ulufe2y6fkcpnlvpsta7rq4442dy", "bcrt1qpgptk2gvshyl0s9lqshsmx932l9ccsv265tvaq"]) + assert_equal(self.nodes[0].deriveaddresses(ranged_descriptor, 0, 2), [address, "ert1qhku5rq7jz8ulufe2y6fkcpnlvpsta7rqdpq5ny", "ert1qpgptk2gvshyl0s9lqshsmx932l9ccsv2zq7jrq"]) assert_raises_rpc_error(-8, "Range should not be specified for an un-ranged descriptor", self.nodes[0].deriveaddresses, descsum_create("wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/0)"), 0, 2) @@ -40,7 +40,7 @@ class DeriveaddressesTest(BitcoinTestFramework): assert_raises_rpc_error(-8, "Range should be greater or equal than 0", self.nodes[0].deriveaddresses, descsum_create("wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/*)"), -1, 0) combo_descriptor = descsum_create("combo(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/0)") - assert_equal(self.nodes[0].deriveaddresses(combo_descriptor), ["mtfUoUax9L4tzXARpw1oTGxWyoogp52KhJ", "mtfUoUax9L4tzXARpw1oTGxWyoogp52KhJ", address, "2NDvEwGfpEqJWfybzpKPHF2XH3jwoQV3D7x"]) + assert_equal(self.nodes[0].deriveaddresses(combo_descriptor), ["2dnaGtwYgBhXYQGTArxKKapi52Mkf3KTQhb", "2dnaGtwYgBhXYQGTArxKKapi52Mkf3KTQhb", address, "XY2Fo8bxL1EViXjWrZ5iZrb5thmfPvWJxw"]) hardened_without_privkey_descriptor = descsum_create("wpkh(tpubD6NzVbkrYhZ4WaWSyoBvQwbpLkojyoTZPRsgXELWz3Popb3qkjcJyJUGLnL4qHHoQvao8ESaAstxYSnhyswJ76uZPStJRJCTKvosUCJZL5B/1'/1/0)") assert_raises_rpc_error(-5, "Cannot derive script without private keys", self.nodes[0].deriveaddresses, hardened_without_privkey_descriptor) diff --git a/test/functional/rpc_signrawtransaction.py b/test/functional/rpc_signrawtransaction.py index 9b3807426b..0157b08530 100755 --- a/test/functional/rpc_signrawtransaction.py +++ b/test/functional/rpc_signrawtransaction.py @@ -171,6 +171,9 @@ class SignRawTransactionsTest(BitcoinTestFramework): assert_equal(spending_tx_signed['complete'], True) def run_test(self): + self.nodes[0].set_deterministic_priv_key('2Mysp7FKKe52eoC2JmU46irt1dt58TpCvhQ', 'cTNbtVJmhx75RXomhYWSZAafuNNNKPd1cr2ZiUcAeukLNGrHWjvJ') + self.nodes[0].importprivkey("cTNbtVJmhx75RXomhYWSZAafuNNNKPd1cr2ZiUcAeukLNGrHWjvJ") + self.successful_signing_test() self.script_verification_error_test() self.witness_script_test() diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index af16e3a352..02b0f35250 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -716,7 +716,6 @@ class CTransaction: self.wit = CTxWitness() if flags > 1: raise TypeError('Extra witness flags:' + str(flags)) - self.nLockTime = struct.unpack(" amt: + if ins_total + max(fees) > amt: break + # make sure there was enough utxos + assert ins_total >= amt + max(fees) txs = [] for fee in fees: - outputs = {address: amt, node.getrawchangeaddress(): ins_total - amt - fee} + outputs = {address: amt} + # prevent 0 change output + if ins_total > amt + fee: + outputs[node.getrawchangeaddress()] = ins_total - amt - fee + if fee > 0: + outputs["fee"] = fee raw_tx = node.createrawtransaction(inputs, outputs, 0, True) raw_tx = node.signrawtransactionwithwallet(raw_tx) txs.append(raw_tx) @@ -58,14 +67,14 @@ class WalletTest(BitcoinTestFramework): self.nodes[1].generatetoaddress(100, RANDOM_COINBASE_ADDRESS) self.sync_all() - assert_equal(self.nodes[0].getbalance(), 50) - assert_equal(self.nodes[1].getbalance(), 50) + assert_equal(self.nodes[0].getbalance()['bitcoin'], 50) + assert_equal(self.nodes[1].getbalance()['bitcoin'], 50) self.log.info("Test getbalance with different arguments") - assert_equal(self.nodes[0].getbalance("*"), 50) - assert_equal(self.nodes[0].getbalance("*", 1), 50) - assert_equal(self.nodes[0].getbalance("*", 1, True), 50) - assert_equal(self.nodes[0].getbalance(minconf=1), 50) + assert_equal(self.nodes[0].getbalance("*")['bitcoin'], 50) + assert_equal(self.nodes[0].getbalance("*", 1)['bitcoin'], 50) + assert_equal(self.nodes[0].getbalance("*", 1, True)['bitcoin'], 50) + assert_equal(self.nodes[0].getbalance(minconf=1)['bitcoin'], 50) # Send 40 BTC from 0 to 1 and 60 BTC from 1 to 0. txs = create_transactions(self.nodes[0], self.nodes[1].getnewaddress(), 40, [Decimal('0.01')]) @@ -84,18 +93,18 @@ class WalletTest(BitcoinTestFramework): self.log.info("Test getbalance and getunconfirmedbalance with unconfirmed inputs") # getbalance without any arguments includes unconfirmed transactions, but not untrusted transactions - assert_equal(self.nodes[0].getbalance(), Decimal('9.99')) # change from node 0's send - assert_equal(self.nodes[1].getbalance(), Decimal('29.99')) # change from node 1's send + assert_equal(self.nodes[0].getbalance()['bitcoin'], Decimal('9.99')) # change from node 0's send + assert_equal(self.nodes[1].getbalance()['bitcoin'], Decimal('29.99')) # change from node 1's send # Same with minconf=0 - assert_equal(self.nodes[0].getbalance(minconf=0), Decimal('9.99')) - assert_equal(self.nodes[1].getbalance(minconf=0), Decimal('29.99')) + assert_equal(self.nodes[0].getbalance(minconf=0)['bitcoin'], Decimal('9.99')) + assert_equal(self.nodes[1].getbalance(minconf=0)['bitcoin'], Decimal('29.99')) # getbalance with a minconf incorrectly excludes coins that have been spent more recently than the minconf blocks ago # TODO: fix getbalance tracking of coin spentness depth - assert_equal(self.nodes[0].getbalance(minconf=1), Decimal('0')) - assert_equal(self.nodes[1].getbalance(minconf=1), Decimal('0')) + assert_equal(self.nodes[0].getbalance(minconf=1)['bitcoin'], Decimal('0')) + assert_equal(self.nodes[1].getbalance(minconf=1)['bitcoin'], Decimal('0')) # getunconfirmedbalance - assert_equal(self.nodes[0].getunconfirmedbalance(), Decimal('60')) # output of node 1's spend - assert_equal(self.nodes[1].getunconfirmedbalance(), Decimal('0')) # Doesn't include output of node 0's send since it was spent + assert_equal(self.nodes[0].getunconfirmedbalance()['bitcoin'], Decimal('60')) # output of node 1's spend + assert_equal(self.nodes[1].getunconfirmedbalance()['bitcoin'], Decimal('0')) # Doesn't include output of node 0's send since it was spent # Node 1 bumps the transaction fee and resends self.nodes[1].sendrawtransaction(txs[1]['hex']) @@ -103,17 +112,17 @@ class WalletTest(BitcoinTestFramework): self.log.info("Test getbalance and getunconfirmedbalance with conflicted unconfirmed inputs") - assert_equal(self.nodes[0].getwalletinfo()["unconfirmed_balance"], Decimal('60')) # output of node 1's send - assert_equal(self.nodes[0].getunconfirmedbalance(), Decimal('60')) - assert_equal(self.nodes[1].getwalletinfo()["unconfirmed_balance"], Decimal('0')) # Doesn't include output of node 0's send since it was spent - assert_equal(self.nodes[1].getunconfirmedbalance(), Decimal('0')) + assert_equal(self.nodes[0].getwalletinfo()["unconfirmed_balance"]['bitcoin'], Decimal('60')) # output of node 1's send + assert_equal(self.nodes[0].getunconfirmedbalance()['bitcoin'], Decimal('60')) + assert_equal(self.nodes[1].getwalletinfo()["unconfirmed_balance"]['bitcoin'], Decimal('0')) # Doesn't include output of node 0's send since it was spent + assert_equal(self.nodes[1].getunconfirmedbalance()['bitcoin'], Decimal('0')) self.nodes[1].generatetoaddress(1, RANDOM_COINBASE_ADDRESS) self.sync_all() # balances are correct after the transactions are confirmed - assert_equal(self.nodes[0].getbalance(), Decimal('69.99')) # node 1's send plus change from node 0's send - assert_equal(self.nodes[1].getbalance(), Decimal('29.98')) # change from node 0's send + assert_equal(self.nodes[0].getbalance()['bitcoin'], Decimal('69.99')) # node 1's send plus change from node 0's send + assert_equal(self.nodes[1].getbalance()['bitcoin'], Decimal('29.98')) # change from node 0's send # Send total balance away from node 1 txs = create_transactions(self.nodes[1], self.nodes[0].getnewaddress(), Decimal('29.97'), [Decimal('0.01')]) @@ -124,10 +133,10 @@ class WalletTest(BitcoinTestFramework): # getbalance with a minconf incorrectly excludes coins that have been spent more recently than the minconf blocks ago # TODO: fix getbalance tracking of coin spentness depth # getbalance with minconf=3 should still show the old balance - assert_equal(self.nodes[1].getbalance(minconf=3), Decimal('0')) + assert_equal(self.nodes[1].getbalance(minconf=3)['bitcoin'], Decimal('0')) # getbalance with minconf=2 will show the new balance. - assert_equal(self.nodes[1].getbalance(minconf=2), Decimal('0')) + assert_equal(self.nodes[1].getbalance(minconf=2)['bitcoin'], Decimal('0')) if __name__ == '__main__': WalletTest().main() diff --git a/test/functional/wallet_importmulti.py b/test/functional/wallet_importmulti.py index 4abb9cd324..4bd8788c39 100755 --- a/test/functional/wallet_importmulti.py +++ b/test/functional/wallet_importmulti.py @@ -82,7 +82,7 @@ class ImportMultiTest(BitcoinTestFramework): self.log.info("Should import an address") key = get_key(self.nodes[0]) self.test_importmulti({"scriptPubKey": {"address": key.p2pkh_addr}, - "timestamp": "now" + "timestamp": "now", # ELEMENTS: Also import blinding key "blinding_privkey": key.blinding_privkey, }, @@ -816,11 +816,11 @@ class ImportMultiTest(BitcoinTestFramework): assert_equal(wrpc.getwalletinfo()["private_keys_enabled"], False) xpub = "tpubDAXcJ7s7ZwicqjprRaEWdPoHKrCS215qxGYxpusRLLmJuT69ZSicuGdSfyvyKpvUNYBW1s2U3NSrT6vrCYB9e6nZUEvrqnwXPF8ArTCRXMY" addresses = [ - 'bcrt1qtmp74ayg7p24uslctssvjm06q5phz4yrxucgnv', # m/0'/0'/0 - 'bcrt1q8vprchan07gzagd5e6v9wd7azyucksq2xc76k8', # m/0'/0'/1 - 'bcrt1qtuqdtha7zmqgcrr26n2rqxztv5y8rafjp9lulu', # m/0'/0'/2 - 'bcrt1qau64272ymawq26t90md6an0ps99qkrse58m640', # m/0'/0'/3 - 'bcrt1qsg97266hrh6cpmutqen8s4s962aryy77jp0fg0', # m/0'/0'/4 + 'ert1qtmp74ayg7p24uslctssvjm06q5phz4yr7gdkdv', # m/0'/0'/0 + 'ert1q8vprchan07gzagd5e6v9wd7azyucksq27vtyg8', # m/0'/0'/1 + 'ert1qtuqdtha7zmqgcrr26n2rqxztv5y8rafje32zpu', # m/0'/0'/2 + 'ert1qau64272ymawq26t90md6an0ps99qkrsevnwyt0', # m/0'/0'/3 + 'ert1qsg97266hrh6cpmutqen8s4s962aryy77246hk0', # m/0'/0'/4 ] result = wrpc.importmulti( [{