square / subzero

Block's Bitcoin Cold Storage solution.
Apache License 2.0
685 stars 96 forks source link

[java] set the currency field correctly when finalizing wallet #693

Closed ivmaykov closed 1 year ago

ivmaykov commented 1 year ago

We can determine the currency (MAIN_NET or TEST_NET) by looking at the Base58-checked encoding of the public key returned from subzero core.

This addresses https://github.com/square/subzero/issues/254

Manually tested with a core binary built with both CURRENCY=btc-testnet and CURRENCY=btc-mainnet.

Test plan for TEST_NET:

  1. cd core && rm -rf build && mkdir build && cd build && TARGET=dev CURRENCY=btc-testnet cmake ../ && ./subzero (leave this running)
  2. cd java && rm -rf test-wallets && mkdir test-wallets && touch test-wallets/.subzero_702e63a9 && ./gradlew clean build && java -jar ./gui/build/libs/gui-1.0.0-SNAPSHOT-shaded.jar --wallet-dir ./test-wallets --generate-wallet-files-test (then type "yes" a bunch of times, ctrl-C when done)
  3. Check that the wallet files in test-wallets/finalized/ have a currency field with the value "TEST_NET"

Test plan for MAIN_NET:

  1. Edit core/src/checks/self_checks.c and disable the verify_sign_tx check (it appears to be broken with CURRENCY=btc-mainnet).
  2. cd core && rm -rf build && mkdir build && cd build && TARGET=dev CURRENCY=btc-mainnet cmake ../ && ./subzero (leave this running)
  3. cd java && rm -rf test-wallets && mkdir test-wallets && touch test-wallets/.subzero_702e63a9 && ./gradlew clean build && java -jar ./gui/build/libs/gui-1.0.0-SNAPSHOT-shaded.jar --wallet-dir ./test-wallets --generate-wallet-files-test (then type "yes" a bunch of times, ctrl-C when done)
  4. Check that the wallet files in test-wallets/finalized/ have a currency field with the value "MAIN_NET"