Introduces WalletService object which is in control of
blockchain and wallet access.
The service manages a single transaction monitoring loop,
instead of multiple, and allows updates to the wallet from
external sources to be handled in real time, so that both Qt
and other apps (yg) can respond to deposits or withdrawals
automatically.
The refactoring also controls access to both wallet and
blockchain so that client apps (Taker, Maker) will not need
to be changed for future new versions e.g. client-side filtering.
Also updates and improves Wallet Tab behaviour in Qt (memory
of expansion state).
Additionally, blockchain sync is now --fast by default, with
the former default of detailed sync being renamed --recoversync.
This refactors YieldGeneratorBasic a bit. In particular, we move things
that custom algorithms will most likely want to change to separate
functions. That way, it is easy to define the behaviour of inputs
and outputs for the join without the need to duplicate the other, more
general logic of create_my_orders and oid_to_order.
This adds simple unit tests for the core functionality of
YieldGeneratorBasic in the new file jmclient/test/test_yieldgenerator.py.
The tests verify that offer creation, reannouncement of offers when a
change is made to the maxsize and translation of offers to orders works
as it should.
remove unused import
This reverts commit 4b4f8c97f4.
Due to a flawed assumption where sometimes importing addresses does
take a significant amount of time. For example on machines with HDD
importing 1-2 addresses can last a second or two, and importing 60
addresses lasts about 30 seconds. The commit makes running a maker
impossible on such a machine.
Prior to this commit, addresses imported on tx creation
were at the tip of the index only, but detailed sync
requires all address gap-forwards to be imported, else
it requires a restart.
The particular fix approach taken her is aggression
because import is cheap; we import wallet.gaplimit forwards
on all branches, taking advantage of the bci's function
_collect_addresses_gap, thus ensuring that unless the gap
limit changes, we will definitely not need a restart.
Fast sync did not suffer from this and is unchanged.
Prior to this commit, there was duplicated code in maker
and taker modules to import addresses, now all calls to
the wallet for fresh addresses can optionally pass a
blockchaininterface instance and if this is done, the
new address will be imported to the BCI at the same time.
Currently, only 'self' works until the other options for tx_broadcast are implemented. Update the docs accordingly, because there was someone wondering on IRC today why his transaction failed to broadcast; the reason was he changed this setting, which currently only works for 'self'.
If the other options are implemented (tagging #368 ), this documentation should be changed along with it.
Fixes#362. Prior to this commit, if tumbler was invoked with
the --restart flag, it waited for the presence of the 0 index
output of the last seen tumbler transaction in the utxo set,
which was an unreliable indicator as that output could have,
in the meantime, been spent.
After this commit, we utilise the fact that the transaction
must be an in-wallet transaction, and use the rpc gettransaction
to check whether it has 1 or more confirmations, instead, which
should always work whether any outputs are spent or not.
Ran into a crash with sendpayment today, when tx_broadcast in joinmarket.cfg is set to not-self.
Before the change, it crashed on the modified line because type dict_keys is returned here, which cannot be used with an index.
The hostid upper/lowercase seems can be different depending
on how someone connects to an IRC server (via TOR, clearnet,
etc.). This leads to message signature verification failures,
if the receiving counterparty has a differently capitalized id.
Prior to this commit, the regtest testing framework
used the bitcoin rpc command `generate` to mine coins
in preparation for tests, and to tick forward the
chain for confirmations. This rpc command is deprecated
and will be removed in 0.19. Hence this commit changes
the two usages of `generate` to `generatetoaddress` and
specifies a mining address created with `getnewaddress`.
Wallet persists utxo metadata; currently only
contains a field 'disabled' indexed by utxo.
User can switch this on or off (enabled) via
wallet-tool 'freeze' method.
Disabled utxos will not be used in coin
selection in any transaction.
Wallet still displays all utxo balances in
display method (and in GUI).
Add tests of disabling to test_utxomanager
Add Coins tab to Qt, with freeze/unfreeze feature.
Coins tab shows updated utxo info txid:n, amt, address and
enabled/disabled, which can be toggled from right click menu.
Prior to this commit, if the call to the bitcoin rpc
gettransaction resulted in an exception other than JsonRpcError,
the code would crash as the variable `res` was uninitialized.
This fixes that by always setting res to None in this case, and
also promotes the logging messages for such errors to warning.
While testing/debugging #105 we found that agora disconnects our taker about 1 minute after joining the pit, just before starting the CJ. Only that IRC server seems to be affected.
transaction from receiver to sender. Also add note about
implicit defence against attack mentioned in BIP79; we only
ever sign the predetermined set of inputs.
If the user manually chooses a bitcoin tx fee, it could end up below the bitcoin network's min relay fee.
This PR get the bitcoin core instance's configured min relay fee and uses it as a floor value (btccore) or uses 1000 as floor otherwise (btc as fallback when RPC call returns no good value and for electrum interface).
Prior to this commit, if at least one sender utxo was larger
than the payment amount, the algorithm used by the receiver
to attempt to find coins to avoid triggering the UIH2 condition
was wrong, resulting in UIH2 being triggered where it was not
necessary, in a reasonable fraction of cases. This fixes the
algorithm to be in line with what was written in the linked gist
(see comment to P2EPMaker.on_tx_received).
The code prior to this commit incorrectly only chose the
no-coins fallback in PayJoin on receiver side if the call
to wallet.get_utxos_by_mixdepth()[mixdepth] resulted in a
raised exception, but of course it returns an empty dict,
so after this commit the self.no_coins_fallback is called in
case an empty dict is returned; note that the prior case
still resulted in the same behaviour of publishing a non-CJ
transaction, but now the info messages/prompts are clear.
Prior to this commit, running joinmarketd as an isolated
process only supported serving the Joinmarket protocol;
attempting PayJoin would result in silent failure as the
receiver would reject the !pubkey message.
After this commit, the joinmarketd daemon serves both
protocols with the PayJoin protocol being served at port+1
- update mktx() to allow optional locktime setting (and sequence)
- add a mk_shuffled_tx method to the wallet module
- add a P2EPTaker and P2EPMaker class (inherit from Taker, Maker)
- add a -T option to sendpayment script for doing payjoins
- add a receive_payjoin script for receivers.
- add payjoin tests in jmclient/test/test_payjoin.py
- add a custom utxo selection method select_one_utxo to support.py
- support bech32 wallets (SegwitWallet, p2wpkh) with native=true
in config POLICY for PayJoin and direct send (not Joinmarket CJ)
- add a PayJoin.md usage guide in docs/
- include version bytes in pubkey message for forward compat
- taker pays fees but controls size (utxo number and fee/kB)
- add P2WPKH fee estimator
- Enforce INFO level logging in payjoin
- refactors regtest config settings into one place
- bugfix: script_to_address vbyte argument is bytes not integer
Bug introduced with c139067be4
Return empty string instead of None from wallet_fetch_history() as wallet-tool.py prints the result
all wallet_tool_main return vals as string