Added addresstype when calling getnewaddress.

This commit is contained in:
kexkey
2019-05-23 12:26:21 -04:00
parent 8d36466da8
commit 2c3b28bc84
3 changed files with 158 additions and 140 deletions

View File

@@ -554,10 +554,13 @@ Proxy response:
### Get a new Bitcoin address from spending wallet (called by application)
Calls getnewaddress RPC on the spending wallet. Used to refill the spending wallet from cold wallet (ie Trezor).
Calls getnewaddress RPC on the spending wallet. Used to refill the spending wallet from cold wallet (ie Trezor). Will derive the default address type (set in your bitcoin.conf file, p2sh-segwit if not specified) or you can supply the address type like the following examples.
```http
GET http://cyphernode:8888/getnewaddress
GET http://cyphernode:8888/getnewaddress/bech32
GET http://cyphernode:8888/getnewaddress/legacy
GET http://cyphernode:8888/getnewaddress/p2sh-segwit
```
Proxy response:
@@ -568,6 +571,12 @@ Proxy response:
}
```
```json
{
"address":"tb1ql7yvh3lmajxmaljsnsu3w8lhwczu963tvjfzpj"
}
```
### Spend coins from spending wallet (called by application)
Calls sendtoaddress RPC on the spending wallet with supplied info.

View File

@@ -227,8 +227,9 @@ main()
;;
getnewaddress)
# curl (GET) http://192.168.111.152:8080/getnewaddress
# curl (GET) http://192.168.111.152:8080/getnewaddress/bech32
response=$(getnewaddress)
response=$(getnewaddress $(echo "${line}" | cut -d ' ' -f2 | cut -d '/' -f3))
response_to_client "${response}" ${?}
break
;;

View File

@@ -127,8 +127,16 @@ getbalancebyxpub() {
getnewaddress() {
trace "Entering getnewaddress()..."
local address_type=${1}
trace "[getnewaddress] address_type=${address_type}"
local response
local data='{"method":"getnewaddress"}'
local data
if [ -z "${address_type}" ]; then
data='{"method":"getnewaddress"}'
else
data="{\"method\":\"getnewaddress\",\"params\":[\"\",\"${address_type}\"]}"
fi
response=$(send_to_spender_node "${data}")
local returncode=$?
trace_rc ${returncode}