Skip to content

Instantly share code, notes, and snippets.

@neelriyer
Last active August 11, 2021 01:24
Show Gist options
  • Save neelriyer/ac87a3c2e98347ccccb3b18c12587fa7 to your computer and use it in GitHub Desktop.
Save neelriyer/ac87a3c2e98347ccccb3b18c12587fa7 to your computer and use it in GitHub Desktop.
btcpy.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "btcpy.ipynb",
"provenance": [],
"collapsed_sections": [],
"authorship_tag": "ABX9TyOB8rzhSSErzo+Apabi7MwQ",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/spiyer99/ac87a3c2e98347ccccb3b18c12587fa7/btcpy.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Qqkc8DXxQZyc",
"outputId": "23663955-9ea4-4d31-9126-232cf2dbf271"
},
"source": [
"!pip install chainside-btcpy"
],
"execution_count": 8,
"outputs": [
{
"output_type": "stream",
"text": [
"Collecting chainside-btcpy\n",
" Downloading chainside_btcpy-0.6.5-py3-none-any.whl (62 kB)\n",
"\u001b[K |████████████████████████████████| 62 kB 586 kB/s \n",
"\u001b[?25hCollecting ecdsa==0.13\n",
" Downloading ecdsa-0.13-py2.py3-none-any.whl (86 kB)\n",
"\u001b[K |████████████████████████████████| 86 kB 4.2 MB/s \n",
"\u001b[?25hInstalling collected packages: ecdsa, chainside-btcpy\n",
"Successfully installed chainside-btcpy-0.6.5 ecdsa-0.13\n",
"Requirement already satisfied: chainside-btcpy in /usr/local/lib/python3.7/dist-packages (0.6.5)\n",
"Requirement already satisfied: ecdsa==0.13 in /usr/local/lib/python3.7/dist-packages (from chainside-btcpy) (0.13)\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "djhbkP_nQbN3"
},
"source": [
"address = \"02ea4e183e8c751a4cc72abb7088cea79351dbfb7981ceb48f286ccfdade4d42c8\""
],
"execution_count": 9,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "jErcB5nAQrZU"
},
"source": [
"from btcpy.structs.script import *"
],
"execution_count": 10,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "RCtxFUGFQ-Wb",
"outputId": "1b82c511-a740-4aa0-c085-b18796fae44d"
},
"source": [
"from btcpy.setup import setup\n",
"setup('mainnet')"
],
"execution_count": 11,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"{'mainnet': None, 'netname': None, 'strict': None}"
]
},
"metadata": {
"tags": []
},
"execution_count": 5
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"{'mainnet': True, 'netname': 'mainnet', 'strict': True}"
]
},
"metadata": {
"tags": []
},
"execution_count": 11
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "LbUjXwzpRBwz"
},
"source": [
"from btcpy.structs.crypto import PublicKey\n",
"from btcpy.structs.address import P2pkhAddress, P2wpkhAddress\n",
"pubk = PublicKey.unhexlify(address)\n",
"address = P2pkhAddress(pubk.hash(), mainnet=True)\n",
"sw_address = P2wpkhAddress(pubk.hash(), version=0, mainnet=True)"
],
"execution_count": 13,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"id": "yl-Vaz8QzLKI",
"outputId": "3e02683b-fb54-442f-bb85-c4afa504b92a"
},
"source": [
"str(address)"
],
"execution_count": 14,
"outputs": [
{
"output_type": "execute_result",
"data": {
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
},
"text/plain": [
"'15kaiM6q5xvx5hpxXJmGDGcDStABoGTzSX'"
]
},
"metadata": {
"tags": []
},
"execution_count": 14
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "1EcZw0h4zNme"
},
"source": [
""
],
"execution_count": 12,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment