From ae3e6ce9c5c5589a0ae24c50762cdec3568300f8 Mon Sep 17 00:00:00 2001 From: g-homebase Date: Tue, 17 Dec 2019 16:59:18 -0500 Subject: [PATCH] Fixes + docs --- .../templates/gatekeeper/api.properties | 2 +- doc/openapi/v0/cyphernode-api.yaml | 264 ++++++++++++++++++ proxy_docker/app/script/confirmation.sh | 6 +- proxy_docker/app/script/requesthandler.sh | 6 +- proxy_docker/app/script/sendtobitcoinnode.sh | 8 +- proxy_docker/app/script/walletoperations.sh | 12 +- 6 files changed, 279 insertions(+), 19 deletions(-) diff --git a/cyphernodeconf_docker/templates/gatekeeper/api.properties b/cyphernodeconf_docker/templates/gatekeeper/api.properties index 335bae9..0a85497 100644 --- a/cyphernodeconf_docker/templates/gatekeeper/api.properties +++ b/cyphernodeconf_docker/templates/gatekeeper/api.properties @@ -35,7 +35,7 @@ action_ln_getconnectionstring=watcher action_ln_decodebolt11=watcher # Spender can do what the watcher can do, plus: -action_gettxnslist=spender +action_get_txns_spending=spender action_getbalance=spender action_getbalancebyxpub=spender action_getbalancebyxpublabel=spender diff --git a/doc/openapi/v0/cyphernode-api.yaml b/doc/openapi/v0/cyphernode-api.yaml index b7d7997..b552e91 100644 --- a/doc/openapi/v0/cyphernode-api.yaml +++ b/doc/openapi/v0/cyphernode-api.yaml @@ -351,6 +351,135 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiResponseTemporarilyUnavailable' + /get_txns_by_watchlabel/{label}/{count}: + get: + parameters: + - in: "path" + name: "label" + description: "Xpub label" + required: true + schema: + type: "string" + - in: "path" + name: "count" + description: "Number of transactions to return" + required: false + schema: + type: "number" + tags: + - "watching transactions" + - "core features" + summary: "Get list of transactions observed for addreses belonging to this label" + description: "Get list of transactions observed for addreses belonging to this label" + operationId: "get_txns_by_watchlabel" + responses: + '200': + description: "successful operation" + content: + application/json: + schema: + type: "object" + required: + - "label_txns" + properties: + watches: + type: "array" + items: + $ref: '#/components/schemas/WatchXPubTxn' + '403': + $ref: '#/components/schemas/ApiResponseNotAllowed' + '503': + description: "Resource temporarily unavailable" + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponseTemporarilyUnavailable' + /get_txns_spending/{count}/{skip}: + get: + parameters: + - in: "path" + name: "count" + description: "Number of txns to return" + required: false + schema: + type: "number" + - in: "path" + name: "skip" + description: "Skip/offset to start from" + required: false + schema: + type: "number" + tags: + - "spending transactions" + - "core features" + summary: "Get list of spending wallets transactions" + description: "Get list of spending wallets transactions" + operationId: "get_txns_spending" + responses: + '200': + description: "successful operation" + content: + application/json: + schema: + type: "object" + required: + - "txns" + properties: + watches: + type: "array" + items: + $ref: '#/components/schemas/TransactionsSpending' + '403': + $ref: '#/components/schemas/ApiResponseNotAllowed' + '503': + description: "Resource temporarily unavailable" + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponseTemporarilyUnavailable' + /get_unused_addresses_by_watchlabel/{label}/{count}: + get: + parameters: + - in: "path" + name: "label" + description: "Xpub label" + required: true + schema: + type: "string" + - in: "path" + name: "count" + description: "Number of addresses to return" + required: false + schema: + type: "number" + tags: + - "watching addresses" + - "core features" + summary: "Get list of unused derived addreses belonging to this label" + description: "Gets an unused subset of addreses from the set of derived addresses belonging to this label" + operationId: "get_unused_addresses_by_watchlabel" + responses: + '200': + description: "successful operation" + content: + application/json: + schema: + type: "object" + required: + - "label_unused_addresses" + properties: + watches: + type: "array" + items: + $ref: '#/components/schemas/UnusedWatchXPubAddress' + '403': + $ref: '#/components/schemas/ApiResponseNotAllowed' + '503': + description: "Resource temporarily unavailable" + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponseTemporarilyUnavailable' /getactivexpubwatches: get: tags: @@ -1614,6 +1743,141 @@ components: type: "string" pub32_index: type: "string" + UnusedWatchXPubAddress: + type: "object" + required: + - "pub32_watch_id" + - "pub32_label" + - "pub32" + - "address_pub32_index" + - "address" + properties: + pub32_watch_id: + type: "string" + address: + $ref: '#/components/schemas/TypeAddressString' + pub32: + $ref: '#/components/schemas/TypeXpubString' + pub32_label: + type: "string" + address_pub32_index: + type: "string" + TransactionsSpending: + type: "object" + required: + - "address" + - "category" + - "amount" + - "label" + - "vout" + - "fee" + - "confirmations" + - "blockhash" + - "blockindex" + - "blocktime" + - "txid" + - "time" + - "timereceived" + - "comment" + - "bip125-replaceable" + - "abandoned" + properties: + address: + $ref: '#/components/schemas/TypeAddressString' + category: + $ref: 'string' + amount: + type: "number" + label: + type: "string" + vout: + type: "integer" + fee: + type: "fee" + confirmations: + type: "integer" + blockhash: + $ref: '#/components/schemas/TypeHashString' + blockindex: + $ref: 'number' + blocktime: + type: "number" + txid: + $ref: '#/components/schemas/TypeHashString' + time: + type: "number" + timereceived: + type: "number" + comment: + type: "string" + bip125-replaceable: + type: "string" + abandoned: + type: "boolean" + WatchXPubTxn: + type: "object" + required: + - "label" + - "address" + - "txid" + - "confirmations" + - "blockheight" + - "v_out" + - "amount" + - "blockhash" + - "blocktime" + - "timereceived" + properties: + label: + type: "string" + address: + $ref: '#/components/schemas/TypeAddressString' + txid: + $ref: '#/components/schemas/TypeHashString' + confirmations: + type: "integer" + v_out: + type: "integer" + amount: + type: "number" + blockhash: + $ref: '#/components/schemas/TypeHashString' + blocktime: + type: "number" + timereceived: + type: "number" + WatchXPubTxn: + type: "object" + required: + - "label" + - "address" + - "txid" + - "confirmations" + - "blockheight" + - "v_out" + - "amount" + - "blockhash" + - "blocktime" + - "timereceived" + properties: + label: + type: "string" + address: + $ref: '#/components/schemas/TypeAddressString' + txid: + $ref: '#/components/schemas/TypeHashString' + confirmations: + type: "integer" + v_out: + type: "integer" + amount: + type: "number" + blockhash: + $ref: '#/components/schemas/TypeHashString' + blocktime: + type: "number" + timereceived: + type: "number" WatchedXpub: type: "object" required: diff --git a/proxy_docker/app/script/confirmation.sh b/proxy_docker/app/script/confirmation.sh index 32f519e..9664d62 100644 --- a/proxy_docker/app/script/confirmation.sh +++ b/proxy_docker/app/script/confirmation.sh @@ -29,9 +29,8 @@ confirmation() { local returncode local txid=${1} - local txn_payload local tx_details - txn_payload="$(get_transaction ${txid})" + tx_details="$(get_transaction ${txid})" returncode=$? trace_rc ${returncode} trace "[confirmation] tx_details=${tx_details}" @@ -39,9 +38,6 @@ confirmation() { trace "[confirmation] Transaction not in watcher, exiting." return 0 fi - # We need make sure to discard error results generated by get_transction tryin to find a watching wallet's `txn in - # spender wallet first,return code will tell if there's an actaul error. See #153 - tx_details="$(echo $txn_payload | jq '. | select(.result != null)')" ######################################################################################################## # First of all, let's make sure we're working on watched addresses... local address diff --git a/proxy_docker/app/script/requesthandler.sh b/proxy_docker/app/script/requesthandler.sh index e537434..4478a87 100644 --- a/proxy_docker/app/script/requesthandler.sh +++ b/proxy_docker/app/script/requesthandler.sh @@ -238,10 +238,10 @@ main() { response_to_client "${response}" ${?} break ;; - gettxnslist) - # curl (GET) http://192.168.111.152:8080/gettxnslist/20/10 + get_txns_spending) + # curl (GET) http://192.168.111.152:8080/get_txns_spending/20/10 - response=$(gettxnslist $(echo "${line}" | cut -d ' ' -f2 | cut -d '/' -f3) $(echo "${line}" | cut -d ' ' -f2 | cut -d '/' -f4)) + response=$(get_txns_spending $(echo "${line}" | cut -d ' ' -f2 | cut -d '/' -f3) $(echo "${line}" | cut -d ' ' -f2 | cut -d '/' -f4)) response_to_client "${response}" ${?} break ;; diff --git a/proxy_docker/app/script/sendtobitcoinnode.sh b/proxy_docker/app/script/sendtobitcoinnode.sh index b82a641..77c4c6f 100644 --- a/proxy_docker/app/script/sendtobitcoinnode.sh +++ b/proxy_docker/app/script/sendtobitcoinnode.sh @@ -4,18 +4,18 @@ send_to_watcher_node() { trace "Entering send_to_watcher_node()..." - send_to_bitcoin_node ${WATCHER_NODE_RPC_URL}/${WATCHER_BTC_NODE_DEFAULT_WALLET} ${WATCHER_NODE_RPC_CFG} $@ + local node_payload + node_payload="$(send_to_bitcoin_node ${WATCHER_NODE_RPC_URL}/${WATCHER_BTC_NODE_DEFAULT_WALLET} ${WATCHER_NODE_RPC_CFG} $@)" local returncode=$? trace_rc ${returncode} - if [ "${returncode}" -ne 0 ]; then # Ok, since we now have multiple watching wallets, we need to try them all if it fails # We have 2 right now: watching and watching-for-xpubs - send_to_watcher_node_wallet ${WATCHER_BTC_NODE_XPUB_WALLET} $@ + node_payload="$(send_to_watcher_node_wallet ${WATCHER_BTC_NODE_XPUB_WALLET} $@)" returncode=$? trace_rc ${returncode} fi - + echo "$node_payload" return ${returncode} } diff --git a/proxy_docker/app/script/walletoperations.sh b/proxy_docker/app/script/walletoperations.sh index 27a7711..6ea65f8 100644 --- a/proxy_docker/app/script/walletoperations.sh +++ b/proxy_docker/app/script/walletoperations.sh @@ -123,8 +123,8 @@ bumpfee() { return ${returncode} } -gettxnslist() { - trace "Entering gettxnslist()... with count: $1 , skip: $2" +get_txns_spending() { + trace "Entering get_txns_spending()... with count: $1 , skip: $2" local count="$1" local skip="$2" local response @@ -132,19 +132,19 @@ gettxnslist() { response=$(send_to_spender_node "${data}") local returncode=$? trace_rc ${returncode} - trace "[gettxnlist] response=${response}" + trace "[get_txns_spending] response=${response}" if [ "${returncode}" -eq 0 ]; then local txns=$(echo ${response} | jq -rc ".result") - trace "[gettxnlist] txns=${txns}" + trace "[get_txns_spending] txns=${txns}" data="{\"txns\":${txns}}" else - trace "[gettxnlist] Coudn't get txns!" + trace "[get_txns_spending] Coudn't get txns!" data="" fi - trace "[gettransactions] responding=${data}" + trace "[get_txns_spending] responding=${data}" echo "${data}" return ${returncode}