From 1a45edf0084a5a2f34102d4bc8cdb03d1568a3ce Mon Sep 17 00:00:00 2001 From: kexkey Date: Tue, 27 Aug 2019 14:31:35 -0400 Subject: [PATCH] Made confTarget optional, so we just default bumpfee when not supplied --- doc/API.v0.md | 2 ++ doc/openapi/v0/cyphernode-api.yaml | 1 - proxy_docker/app/script/requesthandler.sh | 1 + proxy_docker/app/script/walletoperations.sh | 22 ++++++++++++++++----- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/doc/API.v0.md b/doc/API.v0.md index 19a184d..3bdd2f9 100644 --- a/doc/API.v0.md +++ b/doc/API.v0.md @@ -626,6 +626,8 @@ Calls bumpfee RPC on the spending wallet with supplied info. POST http://cyphernode:8888/bumpfee with body... {"txid":"af867c86000da76df7ddb1054b273ca9e034e8c89d049b5b2795f9f590f67648","confTarget":4} +or... +{"txid":"af867c86000da76df7ddb1054b273ca9e034e8c89d049b5b2795f9f590f67648"} ``` Proxy response: diff --git a/doc/openapi/v0/cyphernode-api.yaml b/doc/openapi/v0/cyphernode-api.yaml index 594d6a7..6ff807e 100644 --- a/doc/openapi/v0/cyphernode-api.yaml +++ b/doc/openapi/v0/cyphernode-api.yaml @@ -799,7 +799,6 @@ paths: type: "object" required: - "txid" - - "confTarget" properties: txid: $ref: '#/components/schemas/TypeHashString' diff --git a/proxy_docker/app/script/requesthandler.sh b/proxy_docker/app/script/requesthandler.sh index 1c626a6..0725e16 100644 --- a/proxy_docker/app/script/requesthandler.sh +++ b/proxy_docker/app/script/requesthandler.sh @@ -259,6 +259,7 @@ main() bumpfee) # POST http://192.168.111.152:8080/bumpfee # BODY {"txid":"af867c86000da76df7ddb1054b273ca9e034e8c89d049b5b2795f9f590f67648","confTarget":4} + # BODY {"txid":"af867c86000da76df7ddb1054b273ca9e034e8c89d049b5b2795f9f590f67648"} response=$(bumpfee "${line}") response_to_client "${response}" ${?} diff --git a/proxy_docker/app/script/walletoperations.sh b/proxy_docker/app/script/walletoperations.sh index a049aae..a563401 100644 --- a/proxy_docker/app/script/walletoperations.sh +++ b/proxy_docker/app/script/walletoperations.sh @@ -68,12 +68,24 @@ bumpfee() { local request=${1} local txid=$(echo "${request}" | jq ".txid" | tr -d '"') trace "[bumpfee] txid=${txid}" - local confTarget=$(echo "${request}" | jq ".confTarget") - trace "[bumpfee] confTarget=${confTarget}" - local response - response=$(send_to_spender_node "{\"method\":\"bumpfee\",\"params\":[\"${txid}\",{\"confTarget\":${confTarget}}]}") - local returncode=$? + local confTarget + local response + local returncode + + # jq -e will have a return code of 1 if the supplied tag is null. + confTarget=$(echo "${request}" | jq -e ".confTarget") + if [ "$?" -ne "0" ]; then + # confTarget tag null, so there's no confTarget + trace "[bumpfee] confTarget=" + response=$(send_to_spender_node "{\"method\":\"bumpfee\",\"params\":[\"${txid}\"]}") + returncode=$? + else + trace "[bumpfee] confTarget=${confTarget}" + response=$(send_to_spender_node "{\"method\":\"bumpfee\",\"params\":[\"${txid}\",{\"confTarget\":${confTarget}}]}") + returncode=$? + fi + trace_rc ${returncode} trace "[bumpfee] response=${response}"