Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional txfee property for direct-send wallet RPC #1597

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
kristapsk marked this conversation as resolved.
Show resolved Hide resolved
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:
AdamISZ marked this conversation as resolved.
Show resolved Hide resolved
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)
AdamISZ marked this conversation as resolved.
Show resolved Hide resolved
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