diff --git a/doc/API.v0.md b/doc/API.v0.md index 85b6182..c695e5f 100644 --- a/doc/API.v0.md +++ b/doc/API.v0.md @@ -893,6 +893,59 @@ Proxy response: } ``` +### Fast address derivation using path in config and provided index (called by your application) + +Derives addresses for supplied index. Must be used with derivation.pub32 and derivation.path properties in config.properties. + +```http +GET http://cyphernode:8888/deriveindex_bitcoind/25-30 +GET http://cyphernode:8888/deriveindex_bitcoind/34 +``` + +Proxy response: + +```json +[ + "2N6Q9kBcLtNswgMSLSQ5oduhbctk7hxEJW8", + "2NFLhFghAPKEPuZCKoeXYYxuaBxhKXbmhBV", + "2N7gepbQtRM5Hm4PTjvGadj9wAwEwnAsKiP", + "2Mth8XDZpXkY9d95tort8HYEAuEesow2tF6", + "2MwqEmAXhUw6H7bJwMhD13HGWVEj2HgFiNH", + "2N2Y4BVRdrRFhweub2ehHXveGZC3nryMEJw" +] +``` + +### Fast address derivation using provided path and index (called by your application) + +Derives addresses for supplied pub32 and path. config.properties' derivation.pub32 and derivation.path are not used. + +```http +POST http://cyphernode:8888/derivepubpath_bitcoind +with body... +{"pub32":"tpubD6NzVbkrYhZ4YR3QK2tyfMMvBghAvqtNaNK1LTyDWcRHLcMUm3ZN2cGm5BS3MhCRCeCkXQkTXXjiJgqxpqXK7PeUSp86DTTgkLpcjMtpKWk","path":"0/25-30"} + +or + +{"pub32":"upub5GtUcgGed1aGH4HKQ3vMYrsmLXwmHhS1AeX33ZvDgZiyvkGhNTvGd2TA5Lr4v239Fzjj4ZY48t6wTtXUy2yRgapf37QHgt6KWEZ6bgsCLpb","path":"0/34"} + +or + +{"pub32":"vpub5SLqN2bLY4WeZF3kL4VqiWF1itbf3A6oRrq9aPf16AZMVWYCuN9TxpAZwCzVgW94TNzZPNc9XAHD4As6pdnExBtCDGYRmNJrcJ4eV9hNqcv","path":"0/25-30"} +``` + +Proxy response: + +```json +[ + "mz3bWMW3BWGT9YGDjJwS8TfhJMMtZ91Frm", + "mkjmKEX3KJrVpiqLSSxKB6jjgm3WhPnrv8", + "mk43Tmf6E5nsmETTaNMTZK9TikaeVJRJ4a", + "n1SEcVHHKpHyNr695JpXNdH6b9cWQ26qkt", + "mzWqwZkA31kYVy1kpMoZgvfzSDyGgEi7Yg", + "mp5jtEDNa88xfSQGs5yYQGk7guGWvaG4ci" +] +``` + ### Get info from Lightning Network node (called by your application) Calls getinfo from lightningd. Useful to let your users know where to connect to. diff --git a/doc/openapi/v0/cyphernode-api.yaml b/doc/openapi/v0/cyphernode-api.yaml index e28f065..6a401ef 100644 --- a/doc/openapi/v0/cyphernode-api.yaml +++ b/doc/openapi/v0/cyphernode-api.yaml @@ -1867,6 +1867,81 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiResponseTemporarilyUnavailable' + /deriveindex_bitcoind/{indexSpecifier}: + get: + parameters: + - in: "path" + name: "indexSpecifier" + description: "Index specifier. Either an integer or a range in the form n-m" + required: true + schema: + type: "string" + tags: + - "addresses" + - "core features" + summary: "Fast address derivation using configured xpub key and derivation path" + description: "Fast address derivation for supplied index. Must be used with derivation.pub32 and derivation.path properties in config.properties." + operationId: "deriveIndex" + responses: + '200': + description: "successful operation" + content: + application/json: + schema: + type: "array" + items: + $ref: '#/components/schemas/TypeAddressString' + '403': + $ref: '#/components/schemas/ApiResponseNotAllowed' + '503': + description: "Resource temporarily unavailable" + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponseTemporarilyUnavailable' + /derivepubpath_bitcoind: + post: + tags: + - "addresses" + - "core features" + summary: "Fast address derivation using supplied xpub key and derivation path" + description: "Fast address derivation for supplied pub32 and path. config.properties' derivation.pub32 and derivation.path are not used." + operationId: "derivePubPath" + requestBody: + required: true + content: + application/json: + schema: + type: "object" + required: + - "pub32" + - "path" + properties: + pub32: + description: "xpub/ypub/zpub/tpub/upub/vpub used to derive address(es)" + type: "string" + path: + description: "Derivation path including the index, in the form n or n-m (ex.: 0/44'/86 or 0/44'/62-77)" + type: "string" + responses: + '200': + description: "successful operation" + content: + application/json: + schema: + type: "array" + items: + $ref: '#/components/schemas/TypeAddressString' + '400': + $ref: '#/components/schemas/ApiResponseInvalidInput' + '403': + $ref: '#/components/schemas/ApiResponseNotAllowed' + '503': + description: "Resource temporarily unavailable" + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponseTemporarilyUnavailable' /getmempoolinfo: get: tags: diff --git a/proxy_docker/app/tests/test-derive.sh b/proxy_docker/app/tests/test-derive.sh index 40db98c..00aed3b 100755 --- a/proxy_docker/app/tests/test-derive.sh +++ b/proxy_docker/app/tests/test-derive.sh @@ -85,6 +85,16 @@ test_derive() { echo -e "\nDeriving 500 addresses with derivepubpath_bitcoind (Bitcoin Core)..." time curl -s -H "Content-Type: application/json" -d "{\"pub32\":\"upub5GtUcgGed1aGH4HKQ3vMYrsmLXwmHhS1AeX33ZvDgZiyvkGhNTvGd2TA5Lr4v239Fzjj4ZY48t6wTtXUy2yRgapf37QHgt6KWEZ6bgsCLpb\",\"path\":\"0/0-499\"}" proxy:8888/derivepubpath_bitcoind > /dev/null + # Deriving 500 addresses with derivepubpath (pycoin)... + # real 0m 18.15s + # user 0m 0.00s + # sys 0m 0.00s + # + # Deriving 500 addresses with derivepubpath_bitcoind (Bitcoin Core)... + # real 0m 0.64s + # user 0m 0.00s + # sys 0m 0.00s + } apk add curl jq