Commit graph

83 commits

Author SHA1 Message Date
csH7KmCC9
ad8cd74ee9
Enable external/custom change addresses.
Fixes #797.

Adds `custom_change_addr` argument to `direct_send()`
joinmarket-qt: Adds input field for optional external change address
joinmarket-qt: Better handle PayJoin/CoinJoin state changes for changeInput widget
Adds `custom_change_address` argument to Taker constructor and use it in joinmarket-qt
Custom change also allowed in sendpayment CLI with `-u` flag (not
supported in tumbler).
Explicitly disallows using custom change with BIP78 Payjoin, though that
could change later.
Both sendpayment and CLI provide detailed warnings to avoid misuse. In
particular, they have an extra warning for using a nonstandard or
non-wallet scriptpubkey type.
Setting custom change to the recipient address is explicitly forbidden.

Tests: Adds custom_change usage test in test_taker.
2021-06-01 12:29:59 +01:00
Kristaps Kaupe
fde23c3cc5
Remove unused imports 2021-04-14 15:54:18 +03:00
Adam Gibson
b6e2576c3a
BIP78 sender protocol via daemon
This PR creates a client-daemon protocol for
the BIP78 sender, using the base protocol
`HTTPPassThrough` which provides tor and non-tor
agents with POST and GET request functionality.
As for Joinmarket coinjoins, the use of an in-process
daemon is the default option, but it can be isolated
by changing the `[DAEMON]` section of the config.
The receiver side of BIP78 will be addressed in a
future PR.
2021-03-14 11:53:51 +00:00
Adam Gibson
462a95db1e
Allow schedule files without payment arguments.
Fixes #778. Prior to this commit, attempting to run
sendpayment with a schedule specified with -S would
fail due to a bug. This is now fixed, and the
sendpayment help message now accurately reflects the
facts that no arguments other than the wallet name are
needed in case -S is used.
2021-01-13 16:47:41 +00:00
Adam Gibson
8cdf3e0a4a
address comments of @kristapsk and @PulpCattel 2020-12-01 16:25:45 +00:00
Adam Gibson
bb15aa0312
Quiet/make more accurate fee information in sends
Fixes #736. Prior to this commit, the 'relay fee floor'
was being shown at INFO level in the command line output,
but not the actual feerate paid (in direct send scenarios;
the coinjoin scenario is rather more complex since fees are
not known before negotiation flow, but estimates are printed).
After this commit, the output at INFO level for direct
sends shows specifically the feerate and then the actual fee,
with min relay feerate relegated to DEBUG messages only, for
cases of manual feerate setting.
There is also some minor cleanup in comments and coinjoin fee
estimate messages are removed for non-coinjoins.
2020-11-30 16:43:50 +00:00
Kristaps Kaupe
44c9dcde65
Remove twisted logging on testnet 2020-11-11 04:33:41 +02:00
Jules Comte
ab87db2477 Create native segwit v0 order type
Note: The defaults for the fake offer and yg-privacyenhanced remain
on nested segwit
2020-11-06 18:34:27 -05:00
Adam Gibson
5604857ec1
quit scripts gracefully on walletservice rpc startup failure 2020-10-07 16:05:37 +02:00
Adam Gibson
23d0b8f39c
BIP78 receiver over a Tor hidden service.
This commit implements a command line script and a GUI
dialog to receive a payment using the BIP78 protocol,
by setting up an ephemeral hidden service.

It also deprecates the pre-existing inter-Joinmarket
protocol for payjoin payments, since we now have
both sending and receiving support for BIP78. Thus,
much code in Maker, Taker and client-daemon protocol
is removed, as is some documentation in docs/PAYJOIN.md.
Also the script `sendpayment.py` is altered to support
only the BIP78 variant.

The test in jmclient/test/test_payjoin now implements
BIP78 over a TCP connection, while the custom tests in
test/payjoinserver.py can support hidden service based
tests, but the latter is not included in the test suite
and may not always work (it is only for manual
investigations).

The following features of BIP78 are supported:
minfeerate
additionalfeeoutputindex - but *only* for single
change output transactions
maxadditionalfeecontribution

The receiver does not have nor request payment
output substitution.

Utxo selection is no longer sophisticated, instead
we only choose a single utxo to keep the size
increase of the transaction minimal. Thus UIH is
not addressed at the moment.

Errors returned are in line with BIP78.

Sequence numbers are checked by receiver, and
kept identical if uniform, otherwise respected.
Receiver uses transaction monitor to shut down
when the payment is seen.

The workflow is almost entirely implemented in
jmclient/payjoin.py and the command line script
is in scripts/receive-payjoin.py. The setup, including
configuration changes for Tor, are documented in
docs/PAYJOIN.md, including a user guide video linked.
2020-09-23 15:04:59 +01:00
Kristaps Kaupe
2401c83c45
Implement BIP78 payjoin in JoinMarketQt GUI
Co-authored-by: Adam Gibson <ekaggata@gmail.com>
2020-08-19 22:20:17 +03:00
Adam Gibson
41540ab53e
Modify Payjoin code for BIP78 changes.
This is now tested as compatible with BIP78 as
implemented by BTCPayServer.
An additional config section [PAYJOIN] is added to
manage settings for fee control in payjoin as
described in the BIP. These settings are marked as
advanced usage as they're rather complex for users
to understand and the defaults should be very safe.
2020-07-10 12:32:42 +01:00
Adam Gibson
4cf77ed774
Various bugfixes:
Fix bug in Coins tab, get_utxos_by_mixdepth calls

Fix bug in jmbitcoin.mktx, now respects nVersion choice

Fix bug in tumbler restart wait

Fix bug in makercount for payjoin for fee check, set to 0:
The value of `options.makercount` is set to zero
so that the fee sanity check in the sendpayment script
operates approximately correctly (the receiver will bump
the fee to keep the fee rate the same if necessary).
Also the `bip79` variable is better named `payjoinurl`.

Fix bug in "freeze" context menu function in Qt
2020-07-06 16:51:12 +01:00
Adam Gibson
ca0de5c312
Add bip78 payjoin module and client-server test:
See:
https://github.com/bitcoin/bips/blob/master/bip-0078.mediawiki

Adds a new module jmclient.payjoin which implements
the full sender workflow from a BIP21 uri to a
payjoin broadcast, state is managed in JMPayjoinManager,
includes all checks as per documentation of
btcpayserver (and later, BIP78).
Added simple client and server implementations in
test/payjoinclient.py and test/payjoinserver.py
which allow a full end to end test on regtest.

Add TLS support to payjoin tests:
Note: the jmclient.payjoin module already
supports TLS by default (Agent object), but
here we add the ability to test without
certificate verification. Both test/payjoinclient.py
and test/payjoinserver.py now support TLS, but
the server needs a key and certificate in its
directory to run.

Adds BIP78 payjoin option to sendpayment.py

Users can use a bip21 uri with the "pj" field to
send a payment to a remote server.

Removes require_path_templates setting from KeyStore call
in PSBTWalletMixin.sign_psbt
2020-07-06 16:46:50 +01:00
Adam Gibson
de3ad53226
Support output of PSBT instead of broadcast in direct_send 2020-07-06 16:36:29 +01:00
chris-belcher
c1f34f08c5
Merge #544: Fidelity bond wallets
6b41b8b Disable creation of fidelity bond wallets (chris-belcher)
869ef55 Disable loading of fidelity bond wallets by Qt (chris-belcher)
14f086b Add usage guide for fidelity bond wallets (chris-belcher)
2860c4f Freeze timelocked UTXOs with locktimes in future (chris-belcher)
ddb32ce Rename functions to say "key" instead of "privkey" (chris-belcher)
c70183b Create tests for fidelity bond wallets (chris-belcher)
a0a0d28 Add support for spending timelocked UTXOs (chris-belcher)
762b1f6 Add watch only wallets for fidelity bonds (chris-belcher)
a937c44 Add wallet-tool addtxoutproof method (chris-belcher)
97216d3 Sync burner outputs and display in wallet-tool (chris-belcher)
255d155 Add merkle proof functions to BitcoinCoreInterface (chris-belcher)
2271ce0 Add support for burning coins with sendpayment (chris-belcher)
dc715c9 Add timelock fidelity bond wallet sync and display (chris-belcher)
ee70cd7 Add support for OP_CLTV timelock addresses (chris-belcher)
d86df33 Rename functions which create multisig scripts (chris-belcher)
53b056e Rename variable internal to address_type (chris-belcher)

Tree-SHA512: 9f24000b0ebb4524b30c8afaa4416e516c7241c565dd21a96f83b70d6b6c42e83ad20bfd4f6e85545a855af4fcfd6065feb674f5ed270ca51ac814b4c3684ab4
2020-06-02 22:25:36 +01:00
chris-belcher
2271ce05d7
Add support for burning coins with sendpayment
Users burn coins by passing "BURN" as an address to sendpayment
2020-06-02 21:33:17 +01:00
Adam Gibson
ec2fd725ad
Change initial fee guess logic in taker scripts
As per discussion in #569 the use of options.txfee
to set fee rates conflicted with its earlier use
to make a first guess of fees for user warnings.
Now this connection is removed, the guess for warning
calculation is done independent of this option setting.
2020-05-11 11:22:11 +01:00
Kristaps Kaupe
3876c1cf97 Change shebang to python3 and +x for scripts 2020-05-04 23:48:19 +03:00
Kristaps Kaupe
4eced504b2
Add BIP21 support for Payjoin 2020-05-03 12:13:55 +03:00
Kristaps Kaupe
faaf51eada
Add BIP21 bitcoin payment URI support to sendpayment.py 2020-04-26 23:34:11 +03:00
Kristaps Kaupe
5976db7d4f
Abort single join early if maker count below minimum_makers 2020-03-29 02:19:48 +02:00
James Hilliard
b3e9a6f270 Fix sweep in scripts/sendpayment.py 2020-03-05 13:16:23 -07:00
Kristaps Kaupe
f51990900f
Check against dust threshold for single joins 2020-02-29 19:04:58 +02:00
James Hilliard
4bf1f50d4e Remove Python 2 compatibility imports and disable Python 2 installation in setuptools. 2020-01-19 11:31:57 -07:00
Adam Gibson
8c8e6e2fa8
Move all user data to home directory
To facilitate easier management by users and to
follow generally accepted standards, this PR moves
the following all to user home directory, subdir
.joinmarket :
joinmarket.cfg file
wallets/ directory
logs/ directory
cmtdata/ directory
commitmentlist file

User can override location with --datadir option.
An info message is added on startup showing location.
2020-01-06 13:49:47 +00:00
chris-belcher
c52d1fb0d6
Merge #387: Implement 2/2019 plan to improve tumbler privacy
32479ae Modify tumbler defaults to improve privacy (chris-belcher)
b79d34a Remove amountpower and use uniform distn instead (chris-belcher)
f40ef2c Occasionally round amounts in tumbler schedule (chris-belcher)
35f23eb Add sweep coinjoins to start of tumbler schedule (chris-belcher)

Tree-SHA512: 8b1dc978b69deccc62cec43d22254a18f4860aae6fd87026e7b86d8f537a302ec5ed34f26efa04e1e29648cabe9dac57e0b452fa9fe6f74f6a22b0ce6b2be04a
2019-11-23 11:07:27 +00:00
Adam Gibson
d9bcca3901
Allow custom schedules to work again after #367
PR #367 and follow up edits were designed to give a sanity
check to users for fees, but require specifying a payment
amount, this could be generalised to custom schedules but
for now the simplest change is to remove this check for
schedules. Thanks to @roshii for flagging the error.
2019-11-18 17:17:46 +00:00
cindiv
52108b62d8 Update exit codes
Many exit codes were 0 (success) when they should have been 1
(general failure) or 2 (argument error). This corrects that.

Related: #409
2019-11-17 03:51:04 +00:00
chris-belcher
f40ef2c795
Occasionally round amounts in tumbler schedule
The schedule format gets an extra field added denoting the number of
significant figures to round the coinjoin amounts to, with 16 meaning
no rounding.

This is part of the 2/2019 Plan to improve the privacy of JoinMarket's
tumbler script:
https://gist.github.com/chris-belcher/7e92810f07328fdfdef2ce444aad0968
2019-11-14 17:49:06 +00:00
Kristaps Kaupe
b2e4308a90
Allow both BTC and sat amounts for single send / CJ 2019-11-08 00:37:09 +02:00
cindiv
b83e27c391 Add --wallet-password-stdin
Related: Issue #409
2019-11-02 19:01:08 +00:00
AlexCato
0ab5b6560c Redefine cli-option --txfee: Treat it as txfee to be used
in the JM TX's instead of just for preliminary
    estimations. Now it is a way to temporarily override
    the tx_fees setting in joinmarket.cfg and behaves
    exactly the same way as describes there.
2019-10-30 08:58:13 +01:00
AdamISZ
c654de05ff
Wallet and blockchain refactoring
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.
2019-10-25 11:33:39 +01:00
AlexCato
d62a3001bc Fix sweeps with N=0 counterparties, which otherwise fails because the amount was changed from 0 too early 2019-08-21 17:24:30 +02:00
AlexCato
b656f85344 Sendpayment/Tumbler: fix division by 0 error on sweeps 2019-08-20 22:42:17 +02:00
AlexCato
af11116ad7 Estimate tx fees for sendpayment or full tumbler run and
warn the user if the tx fee estimation exceeds 5% of
the funds to be coinjoined/tumbled.
2019-08-18 12:13:37 +02:00
Kristaps Kaupe
5026809a5a Don't ask for maxcjfee limits when manual order picking is selected 2019-02-11 01:02:05 +02:00
AdamISZ
1c3a15343c
graceful sender-side timeout of PayJoin if fails 2019-01-25 18:12:39 +01:00
AdamISZ
9e7b619aff
bugfix jmprint call in taker_finished 2019-01-24 14:18:10 +01:00
AdamISZ
fd5e6d8d8b
Fixes #305
Previous to this commit, a user could create a direct payment or
Joinmarket coinjoin inadvertently by not using the correct arguments
to sendpayment.py (missing -T or setting -N0). After this commit,
the correct number of arguments (3) are insisted on, and -T takes
precedence over -N 0.
2019-01-21 16:17:21 +01:00
AdamISZ
28abddf062
Implement payjoin (p2ep) direct payment joins
- 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
2019-01-19 16:46:40 +01:00
AdamISZ
c139067be4
Include chromalog package for colorized logs
Also use this lib to print non-log messages with
standardized color formats.
Some clean up in jmbase, remove unused objects/methods.
2019-01-14 15:25:59 +01:00
James Hilliard
6dc3504f8a Convert jmclient to py3 style 2018-12-06 02:40:36 +08:00
undeath
a2c74ee563
add random-under-max order chooser 2018-11-01 23:44:54 +01:00
AdamISZ
697d8d7691
bugfix: sendpayment invalid reference to userpcwallet 2018-10-28 17:28:59 +01:00
undeath
392188209c change wallet mixdepth behaviour 2018-10-27 19:02:59 +02:00
undeath
bdbf62b3c0 fix flake8 warning 2018-10-27 14:01:14 +02:00
undeath
03ee77b96b
fix issues highlighted by flake8 2018-10-08 00:07:28 +02:00
undeath
1451c9e3ae remove unused imports 2018-08-19 18:21:28 +02:00