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 general purpose watch only wallet, take 2 #1632

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kristapsk
Copy link
Member

Taking over #989. Rebased and now it works for me too (tested with signet).

Needed for #663 and #792.

From original PR:

Renamed the original createwatchonly command to createfbwatchonly, and repurposed the createwatchonly command to instead create a general purpose watch only wallet.

  1. To create a new watch only wallet:
    python wallet-tool.py createwatchonly [xpub/ypub/zpub]
  2. A rescan is needed after the wallet creation:
    bitcoin-cli -rpcwallet=[jm_wallet] rescanblockchain [starting_block_height]
  3. The joinmarket commands can then be used directly on this watch only wallet:
python wallet-tool.py watchonly.jmdat
python wallet-tool.py watchonly.jmdat history
python wallet-tool.py watchonly.jmdat displayall

Renamed the original createwatchonly command to createfbwatchonly, and
repurposed the createwatchonly command to instead create a general
purpose watch only wallet.

Co-authored-by: wukong1971 <[email protected]>
@kristapsk
Copy link
Member Author

Rebased to update CI checks.

@kristapsk
Copy link
Member Author

kristapsk commented Feb 20, 2024

Sending payments from watch only wallets should not be allowed until external signer support is added. Currently sendpayment.py tries to do it and then ends up with AssertionError. Same error if you try to start yg-privacyenhanced.py.

$ ./scripts/sendpayment.py wasabi-testnet-test-123.jmdat -N 0 0.001 tb1qe9zv986q03vdllg7yuwhn9ash8dmsa6z09uymc
User data location: /home/user/.joinmarket/
2024-02-20 19:37:36,919 [DEBUG]  rpc: getblockchaininfo []
2024-02-20 19:37:36,920 [DEBUG]  rpc: listwallets []
2024-02-20 19:37:36,921 [DEBUG]  rpc: getwalletinfo []
2024-02-20 19:37:36,923 [INFO]  starting sendpayment
Enter passphrase to decrypt wallet: 
2024-02-20 19:37:38,380 [DEBUG]  rpc: listaddressgroupings []
2024-02-20 19:37:38,383 [DEBUG]  Fast sync in progress. Got this many used addresses: 28
2024-02-20 19:37:43,412 [DEBUG]  rpc: listunspent []
2024-02-20 19:37:43,456 [DEBUG]  bitcoind sync_unspent took 0.04426431655883789sec
Traceback (most recent call last):
  File "/home/user/git/joinmarket-clientserver/./scripts/sendpayment.py", line 399, in <module>
    main()
  File "/home/user/git/joinmarket-clientserver/./scripts/sendpayment.py", line 273, in main
    tx = direct_send(wallet_service, amount, mixdepth, destaddr,
  File "/home/user/git/joinmarket-clientserver/src/jmclient/taker_utils.py", line 100, in direct_send
    txtype = wallet_service.get_txtype()
  File "/home/user/git/joinmarket-clientserver/src/jmclient/wallet.py", line 520, in get_txtype
    assert False
AssertionError

@kristapsk
Copy link
Member Author

If you try to run receive-payjoin.py with watch only wallet, it messes something up, gives error, afterwards every other command gives same error too, until you do --recoversync. Of course, it should also just abort at the start.

2024-02-20 19:52:14,846 [DEBUG]  Fast sync in progress. Got this many used addresses: 38
Traceback (most recent call last):
  File "/home/user/git/joinmarket-clientserver/./scripts/receive-payjoin.py", line 84, in <module>
    receive_payjoin_main()
  File "/home/user/git/joinmarket-clientserver/./scripts/receive-payjoin.py", line 65, in receive_payjoin_main
    wallet_service.sync_wallet(fast=not options.recoversync)
  File "/home/user/git/joinmarket-clientserver/src/jmclient/wallet_service.py", line 491, in sync_wallet
    self.sync_wallet_fast()
  File "/home/user/git/joinmarket-clientserver/src/jmclient/wallet_service.py", line 519, in sync_wallet_fast
    self.sync_addresses_fast()
  File "/home/user/git/joinmarket-clientserver/src/jmclient/wallet_service.py", line 618, in sync_addresses_fast
    raise Exception("Failed to sync in fast mode after 20 batches; "
Exception: Failed to sync in fast mode after 20 batches; please re-try wallet sync with --recoversync flag.

@kristapsk
Copy link
Member Author

Need to also look how this affects RPC API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant