jonasschnelli / libbtc

bitcoin c library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Test Suite Fails: "Wallet file: xpub check failed, corrupt wallet detected."

cadaniluk opened this issue · comments

Branch is wallet_new.

Test Log:

PASSED - test_sha_256()
PASSED - test_sha_512()
PASSED - test_sha_hmac()
PASSED - test_utils()
PASSED - test_cstr()
PASSED - test_buffer()
PASSED - test_serialize()
PASSED - test_memory()
PASSED - test_random()
PASSED - test_bitcoin_hash()
PASSED - test_base58check()
PASSED - test_aes()
PASSED - test_bip32()
PASSED - test_ecc()
PASSED - test_vector()
PASSED - test_tx_serialization()
PASSED - test_invalid_tx_deser()
PASSED - test_tx_sign()
PASSED - test_tx_sighash()
PASSED - test_tx_sighash_ext()
PASSED - test_tx_negative_version()
PASSED - test_block_header()
PASSED - test_script_parse()
PASSED - test_script_op_codeseperator()
PASSED - test_eckey()
xpub: tpubDAenfwNu5GyCJWv8oqRAckdKMSUoZjgVF5p8WvQwHQeXjDhAHmGrPa4a4y2Fn7HF2nfCLefJanHV3ny1UY25MRVogizB2zRUdAo7Tr9XAjm
Wallet file: xpub check failed, corrupt wallet detected.
FAILED - test_wallet_basics() - Line 207
	Expect: 	1
	Receive:	0
PASSED - test_wallet()
ext key: xprv9s21ZrQH143K2V8XUg6RatYXYb3jro7W2BKSmRbBSCpfvH4CCtjNKoqNddHkEzVPjV7EYpeNbKGFoSX5v7cEz7sP3Mf4kFSRom8HqRtVKBH
privatekey WIF: L37ZfmLCVAvScHqEnPLcVDjUpdvDEd2vCvBQMZMuByCZhPi39wPq
depth: 0
child index: 0
p2pkh address: 1JJfiq8iyXfzo4GPQX7qzchGGGwqBvAc6A
p2wpkh address: 1JJfiq8iyXfzo4GPQX7qzchGGGwqBvAc6A
pubkey hex: 0322415404243ea5a0d5e771b901923a1931f5d14f8ca5aeb1e971b87bcdab4368
extended pubkey: xpub661MyMwAqRbcEyCzahdRx2VG6ctEGFqMPQF3ZoznzYMeo5PLkS3csc9rUuBthV7r5D4DeJenJuT1FYmxmTXpxeH49gRzSge1W6FhfRY7w8c
PASSED - test_tool()
Connected 0 headers, now at height: 0
Discover peers...done
Start interacting with the p2p network...
PASSED - test_netspv()
PASSED - test_protocol()
DEBUG :Event callback on node 1
DEBUG :Error connecting to node 1.
DEBUG :Trying to connect to 2...
DEBUG :Trying to connect to 3...
DEBUG :Trying to connect to 4...
DEBUG :Connected nodes: 0
DEBUG :Event callback on node 2
DEBUG :Error connecting to node 2.
DEBUG :Connected nodes: 0
DEBUG :Event callback on node 4
DEBUG :Successfull connected to node 4.
DEBUG :sending message to node 4: version
DEBUG :Connected nodes: 1
DEBUG :received command from node 4: version
DEBUG :Connected to node 4: /Satoshi:0.16.99/ (521966)
DEBUG :sending message to node 4: verack
DEBUG :received command from node 4: verack
DEBUG :sending message to node 4: getheaders
DEBUG :received command from node 4: sendheaders
DEBUG :received command from node 4: sendcmpct
DEBUG :received command from node 4: sendcmpct
DEBUG :received command from node 4: ping
DEBUG :sending message to node 4: pong
DEBUG :received command from node 4: addr
DEBUG :received command from node 4: feefilter
DEBUG :received command from node 4: headers
DEBUG :sending message to node 4: getblocks
DEBUG :received command from node 4: inv
DEBUG :sending message to node 4: getdata
DEBUG :received command from node 4: block
DEBUG :Disconnect node 4
PASSED - test_net_basics_plus_download_block()

Note those lines:

Wallet file: xpub check failed, corrupt wallet detected.
FAILED - test_wallet_basics() - Line 207
	Expect: 	1
	Receive:	0

System Spec:
Fedora 27, 64 Bit
uname -r: 4.15.15-300.fc27.x86_64


Seems to be a classic lack of null terminators. fread reads data and strcmp tries to compare them, but strcmp works on strings, which must be null-terminated. Using memcmp or appending null terminators are easy, viable fixes.