Browse Source
masterf5e27c3Add test code for no-history sync (chris-belcher)cbf69c6Implement no-history synchronization (chris-belcher) Tree-SHA512: 681efc9cf0a37da8438f8401caaed13fdae40d57e4457a20a1258fdc80483ce1b2d366d222eee63da81056e3c8487d13ce7fb1fadb9ae7bd007bff7e54a94c1f
7 changed files with 262 additions and 74 deletions
@ -0,0 +1,12 @@
|
||||
Notable changes |
||||
=============== |
||||
|
||||
### No-history wallet synchronization |
||||
|
||||
The no-history synchronization method is enabled by setting `blockchain_source = bitcoin-rpc-no-history` in the `joinmarket.cfg` file. |
||||
|
||||
The method can be used to import a seed phrase to see whether it has any money on it within just 5-10 minutes. No-history sync doesn't require a long blockchain rescan, although it needs a full node which can be pruned. |
||||
|
||||
No-history sync works by scanning the full node's UTXO set. The downside is that it cannot find the history but only the current unspent balance, so it cannot avoid address reuse. Therefore when using no-history synchronization the wallet cannot generate new addresses. Any found money can only be spent by fully-sweeping the funds but not partially spending them which requires a change address. When using the method make sure to increase the gap limit to a large amount to cover all the possible bitcoin addresses where coins might be. |
||||
|
||||
The mode does not work with the Joinmarket-Qt GUI application but might do in future. |
||||
@ -0,0 +1,51 @@
|
||||
#! /usr/bin/env python |
||||
from __future__ import (absolute_import, division, |
||||
print_function, unicode_literals) |
||||
from builtins import * # noqa: F401 |
||||
'''Wallet functionality tests.''' |
||||
|
||||
"""BitcoinCoreNoHistoryInterface functionality tests.""" |
||||
|
||||
from commontest import create_wallet_for_sync |
||||
|
||||
import pytest |
||||
from jmbase import get_log |
||||
from jmclient import load_program_config |
||||
|
||||
log = get_log() |
||||
|
||||
def test_fast_sync_unavailable(setup_sync): |
||||
load_program_config(bs="bitcoin-rpc-no-history") |
||||
wallet_service = create_wallet_for_sync([0, 0, 0, 0, 0], |
||||
['test_fast_sync_unavailable']) |
||||
with pytest.raises(RuntimeError) as e_info: |
||||
wallet_service.sync_wallet(fast=True) |
||||
|
||||
@pytest.mark.parametrize('internal', (False, True)) |
||||
def test_sync(setup_sync, internal): |
||||
load_program_config(bs="bitcoin-rpc-no-history") |
||||
used_count = [1, 3, 6, 2, 23] |
||||
wallet_service = create_wallet_for_sync(used_count, ['test_sync'], |
||||
populate_internal=internal) |
||||
##the gap limit should be not zero before sync |
||||
assert wallet_service.gap_limit > 0 |
||||
for md in range(len(used_count)): |
||||
##obtaining an address should be possible without error before sync |
||||
wallet_service.get_new_script(md, internal) |
||||
|
||||
wallet_service.sync_wallet(fast=False) |
||||
|
||||
for md in range(len(used_count)): |
||||
##plus one to take into account the one new script obtained above |
||||
assert used_count[md] + 1 == wallet_service.get_next_unused_index(md, |
||||
internal) |
||||
#gap limit is zero after sync |
||||
assert wallet_service.gap_limit == 0 |
||||
#obtaining an address leads to an error after sync |
||||
with pytest.raises(RuntimeError) as e_info: |
||||
wallet_service.get_new_script(0, internal) |
||||
|
||||
|
||||
@pytest.fixture(scope='module') |
||||
def setup_sync(): |
||||
pass |
||||
Loading…
Reference in new issue