Created
April 8, 2022 11:36
-
-
Save littleli/197eca90ee602db20082ef539fb83d33 to your computer and use it in GitHub Desktop.
Bitcoinjs-lib example
This file contains 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
(ns example | |
(:require ["bitcoinjs-lib$default" :as btc] | |
["tiny-secp256k1" :as secp] | |
["ecpair$default" :as ecpair] | |
["axios$default" :as axios] | |
[promesa.core :as p] | |
[cljs-bean.core :refer [->clj]])) | |
(def ecpf (ecpair/ECPairFactory. secp)) | |
(def keyPair (.makeRandom ecpf)) | |
(def address (.-address (btc/payments.p2pkh #js {"pubkey" (.-publicKey keyPair)}))) | |
(p/let [resp (axios/get (str "https://blockchain.info/rawaddr/" address)) | |
resp (->clj resp :keywordize-keys true)] | |
(prn resp)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment