mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-18 13:14:56 +01:00
Fixes + docs
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
;;
|
||||
|
||||
@@ -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}
|
||||
}
|
||||
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user