Created
December 18, 2022 19:10
-
-
Save cryptoskillz/fed5df52ab11c56d5da13967d63e406a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//import swan. | |
const swan = require('@swan-bitcoin/xpub-lib'); | |
export async function onRequestGet(context) { | |
//build the paramaters | |
const { | |
request, // same as existing Worker API | |
env, // same as existing Worker API | |
params, // if filename includes [id] or [[path]] | |
waitUntil, // same as ctx.waitUntil in existing Worker API | |
next, // used for middleware or to fetch assets | |
data, // arbitrary space for passing data between middlewares | |
} = context; | |
const xpub = "xpub6CatWdiZiodmUeTDp8LT5or8nmbKNcuyvz7WyksVFkKB4RHwCD3XyuvPEbvqAQY3rAPshWcMLoP2fMFMKHPJ4ZeZXYVUhLv1VMrjPC7PW6V" | |
let address = swan.addressFromExtPubKey({ extPubKey: xpub, network: "mainnet" }) | |
return new Response(JSON.stringify({ "address": address }), { status: 200 }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment