bumpfee first draft

This commit is contained in:
kexkey
2019-08-27 13:36:28 -04:00
committed by kexkey
parent a1195580aa
commit c1d978af9d
7 changed files with 117 additions and 1 deletions

View File

@@ -32,6 +32,7 @@ action_getbalancebyxpub=spender
action_getbalancebyxpublabel=spender
action_getnewaddress=spender
action_spend=spender
action_bumpfee=spender
action_addtobatch=spender
action_batchspend=spender
action_deriveindex=spender

View File

@@ -56,3 +56,6 @@ blocknotify=/usr/bin/curl proxy:8888/newblock/%s
<% if ( bitcoin_uacomment != null && bitcoin_uacomment != '' ) { %>
uacomment=<%= bitcoin_uacomment %>
<% } %>
addresstype=bech32
walletrbf=1

View File

@@ -35,6 +35,7 @@ action_getbalancebyxpub=spender
action_getbalancebyxpublabel=spender
action_getnewaddress=spender
action_spend=spender
action_bumpfee=spender
action_addtobatch=spender
action_batchspend=spender
action_deriveindex=spender

View File

@@ -294,7 +294,7 @@ When cyphernode receives a transaction confirmation (/conf endpoint) on a watche
### Get mempool information
Returns the mempool information of the Bitcoin node.
Returns the mempool information of the Bitcoin node.
```http
GET http://cyphernode:8888/getmempoolinfo
```
@@ -618,6 +618,27 @@ Proxy response:
}
```
### Bump transaction's fees (called by application)
Calls bumpfee RPC on the spending wallet with supplied info.
```http
POST http://cyphernode:8888/bumpfee
with body...
{"txid":"af867c86000da76df7ddb1054b273ca9e034e8c89d049b5b2795f9f590f67648","confTarget":4}
```
Proxy response:
```json
{
"txid": "af867c86000da76df7ddb1054b273ca9e034e8c89d049b5b2795f9f590f67648",
"origfee": 0.00041221,
"fee": 0.00068112,
"errors": [ "Blabla don't do that" ]
}
```
### Add an output to the next batched transaction (called by application)
Inserts output information in the DB. Used when batchspend is called later.

View File

@@ -782,6 +782,62 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ApiResponseTemporarilyUnavailable'
/bumpfee:
post:
tags:
- "spending wallet"
- "core features"
summary: "Bump the fees of an unconfirmed transaction"
description: "Calls bumpfee RPC on the spending wallet with supplied info."
operationId: "bumpfee"
requestBody:
description: "txid and confirmation target"
required: true
content:
application/json:
schema:
type: "object"
required:
- "txid"
- "confTarget"
properties:
txid:
$ref: '#/components/schemas/TypeHashString'
confTarget:
type: "number"
responses:
'200':
description: "operation successful"
content:
application/json:
schema:
type: "object"
required:
- "txid"
- "origfee"
- "fee"
- "errors"
properties:
txid:
$ref: '#/components/schemas/TypeHashString'
origfee:
type: "number"
fee:
type: "number"
errors:
type: "array"
items:
type: "string"
'403':
$ref: '#/components/schemas/ApiResponseNotAllowed'
'405':
$ref: '#/components/schemas/ApiResponseInvalidInput'
'503':
description: "Resource temporarily unavailable"
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponseTemporarilyUnavailable'
/addtobatch:
post:
tags:

View File

@@ -256,6 +256,14 @@ main()
response_to_client "${response}" ${?}
break
;;
bumpfee)
# POST http://192.168.111.152:8080/bumpfee
# BODY {"txid":"af867c86000da76df7ddb1054b273ca9e034e8c89d049b5b2795f9f590f67648","confTarget":4}
response=$(bumpfee "${line}")
response_to_client "${response}" ${?}
break
;;
addtobatch)
# POST http://192.168.111.152:8080/addtobatch
# BODY {"address":"2N8DcqzfkYi8CkYzvNNS5amoq3SbAcQNXKp","amount":0.00233}

View File

@@ -62,6 +62,32 @@ spend() {
return ${returncode}
}
bumpfee() {
trace "Entering 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=$?
trace_rc ${returncode}
trace "[bumpfee] response=${response}"
if [ "${returncode}" -eq 0 ]; then
trace "[bumpfee] error!"
else
trace "[bumpfee] success!"
fi
echo "${response}"
return ${returncode}
}
getbalance() {
trace "Entering getbalance()..."