Browse Source

Merge JoinMarket-Org/joinmarket-clientserver#1597: Add optional `txfee` property for `direct-send` wallet RPC

d8f1fc42d4 Add optional txfee property for direct-send wallet RPC (Kristaps Kaupe)

Pull request description:

  Resolves #1360. Jam wants it for https://github.com/joinmarket-webui/jam/pull/678.

ACKs for top commit:
  AdamISZ:
    tACK d8f1fc42d4

Tree-SHA512: aa5afc17c0a39d65094c69d847841295c101ed74518be25610378aa7eda95ee3e609f7ae49be75c3e9d148dd8f7787ac1ccc17aa8ee624d1cef3508fa70af114
master
Kristaps Kaupe 2 years ago
parent
commit
8e271205b8
No known key found for this signature in database
GPG Key ID: 33E472FE870C7E5D
  1. 4
      docs/api/wallet-rpc.yaml
  2. 12
      src/jmclient/wallet_rpc.py

4
docs/api/wallet-rpc.yaml

@ -1113,6 +1113,10 @@ components:
destination:
type: string
example: bcrt1qu7k4dppungsqp95nwc7ansqs9m0z95h72j9mze
txfee:
type: integer
example: 6
description: Bitcoin miner fee to use for transaction. A number higher than 1000 is used as satoshi per kvB tx fee. The number lower than that uses the dynamic fee estimation of blockchain provider as confirmation target.
ErrorMessage:
type: object
properties:

12
src/jmclient/wallet_rpc.py

@ -766,7 +766,8 @@ class JMWalletDaemon(Service):
self.check_cookie(request)
assert isinstance(request.content, BytesIO)
payment_info_json = self.get_POST_body(request, ["mixdepth", "amount_sats",
"destination"])
"destination"],
["txfee"])
if not payment_info_json:
raise InvalidRequestFormat()
if not self.services["wallet"]:
@ -780,15 +781,24 @@ class JMWalletDaemon(Service):
# all error conditions).
if not self.coinjoin_state == CJ_NOT_RUNNING:
raise ActionNotAllowed()
old_txfee = jm_single().config.get("POLICY", "tx_fees")
if "txfee" in payment_info_json:
jm_single().config.set("POLICY", "tx_fees",
str(payment_info_json["txfee"]))
try:
tx = direct_send(self.services["wallet"],
int(payment_info_json["amount_sats"]),
int(payment_info_json["mixdepth"]),
destination=payment_info_json["destination"],
return_transaction=True, answeryes=True)
jm_single().config.set("POLICY", "tx_fees", old_txfee)
except AssertionError:
jm_single().config.set("POLICY", "tx_fees", old_txfee)
raise InvalidRequestFormat()
except NotEnoughFundsException as e:
jm_single().config.set("POLICY", "tx_fees", old_txfee)
raise TransactionFailed(repr(e))
if not tx:
# this should not really happen; not a coinjoin

Loading…
Cancel
Save