Fixed labels in watches and added tests

This commit is contained in:
kexkey
2021-09-06 15:08:10 -04:00
parent d7cc865cad
commit 8268247c83
5 changed files with 13 additions and 10 deletions

View File

@@ -332,9 +332,9 @@ main() {
#
# or...
# POST http://192.168.111.152:8080/getnewaddress
# BODY {"address_type":"bech32","label":"myLabel"}
# BODY {"addressType":"bech32","label":"myLabel"}
# BODY {"label":"myLabel"}
# BODY {"address_type":"p2sh-segwit"}
# BODY {"addressType":"p2sh-segwit"}
# BODY {}
# Let's make it work even for a GET request (equivalent to a POST with empty json object body)

View File

@@ -275,19 +275,20 @@ getnewaddress() {
local response
local jqop
local addedfields
local addedfieldstoresponse
local data='{"method":"getnewaddress"}'
if [ -n "${address_type}" ] || [ -n "${label}" ]; then
jqop='. += {"params":{}}'
if [ -n "${label}" ]; then
jqop=${jqop}' | .params += {"label":"'${label}'"}'
addedfields=' | . += {"label":"'${label}'"}'
addedfieldstoresponse=' | . += {"label":"'${label}'"}'
fi
if [ -n "${address_type}" ]; then
jqop=${jqop}' | .params += {"address_type":"'${address_type}'"}'
addedfields=' | . += {"address_type":"'${address_type}'"}'
jqop=${jqop}' | .params += {"addressType":"'${address_type}'"}'
addedfieldstoresponse=' | . += {"addressType":"'${address_type}'"}'
fi
trace "[getnewaddress] jqop=${jqop}"
trace "[getnewaddress] addedfieldstoresponse=${addedfieldstoresponse}"
data=$(echo "${data}" | jq -rc "${jqop}")
fi
@@ -304,7 +305,7 @@ getnewaddress() {
data='{"address":'${address}'}'
if [ -n "${jqop}" ]; then
data=$(echo "${data}" | jq -rc "${data}${addedfields}")
data=$(echo "${data}" | jq -rc ".${addedfieldstoresponse}")
trace "[getnewaddress] data=${data}"
fi
else