Bitcoin extension for vs-code
Often times when writing code I need the same things over and over. Sometimes its a txid, or an address, or a private key. In the above screencast you can see me generating a private key, and then getting an address for that private key.
Typically I find myself opening Chrome just to open dev tools and use the console on a page I know has the bsv library exposed on the window object. I would manually generate some key or address, or maybe just wanting to validate some data I already have.
Other times its sample data in a specific format like bmap, bob, or a raw transaction in hex or json. I'll typically visit whatsonchain.com or a planaria like b.map.sv to browse the blockchain and find a data sample for whatever I'm working on at the moment. In this example, you can see me simply pasting in a txid and getting the bmap formatted transaction data, and pasting it into my VSCode. The options are:
- raw - raw hex string
- bob - bob formatting
- json - json-rpc representation
- bmap - parses a number of known OP_RETURN protocols using bmap.js
This feature uses a secret parser endpoint I've had sitting at bmapjs.com that I use for development and testing sometimes. It's nice to make better use of it :)
To use the plugin, bring up the command palette (ctrl/cmd + shift + p) and type the name of any of the commands below.
- Address from Private Key
- Address from Public Key
- Address from WIF
- Public Key from Private Key
- Generate Public Key
- Generate Private Key
- Generate WIF
- Fetch Transaction by ID (bob, raw, json and bmap formats available)
Download & Source
It turns out, writing vscode extensions is pretty easy compared to other plugin systems, and I managed to get something scrappy out in one day (so far!).
There are many things that could be added to make this even more useful but would really love to hear requests (or better yet pull requests!). A few things I want to implement when I have time:
- Verify a tx is in a block by id (via miner thanks to merchant API)
- Validate Scripts
- Expose hash functions like sha256
- Encode / decode hex strings