Skip to content

Commit

Permalink
Merge #1597: Add optional txfee property for direct-send wallet RPC
Browse files Browse the repository at this point in the history
d8f1fc4 Add optional txfee property for direct-send wallet RPC (Kristaps Kaupe)

Pull request description:

  Resolves #1360. Jam wants it for joinmarket-webui/jam#678.

ACKs for top commit:
  AdamISZ:
    tACK d8f1fc4

Tree-SHA512: aa5afc17c0a39d65094c69d847841295c101ed74518be25610378aa7eda95ee3e609f7ae49be75c3e9d148dd8f7787ac1ccc17aa8ee624d1cef3508fa70af114
  • Loading branch information
kristapsk committed Nov 22, 2023
2 parents 536ddad + d8f1fc4 commit 8e27120
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/api/wallet-rpc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 11 additions & 1 deletion src/jmclient/wallet_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,8 @@ def directsend(self, request, walletname):
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"]:
Expand All @@ -780,15 +781,24 @@ def directsend(self, request, walletname):
# 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
Expand Down

0 comments on commit 8e27120

Please sign in to comment.