Skip to content

Instantly share code, notes, and snippets.

@cdecker
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdecker/f0de1565758a47f2c1f4 to your computer and use it in GitHub Desktop.
Save cdecker/f0de1565758a47f2c1f4 to your computer and use it in GitHub Desktop.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"56e04966d8d95bfc88b2e70d66ef15316d07a1ee ?= 56e04966d8d95bfc88b2e70d66ef15316d07a1ee True\n",
"b640a567c9499ef74f63648e9ba515dc13d412fc ?= 657b0866e79b1621a4193d5c94079533223862fb False\n"
]
}
],
"source": [
"import hashlib\n",
"\n",
"def op_hash160(data):\n",
" d = hashlib.sha256(data).digest()\n",
" return hashlib.new('ripemd160', d).digest()\n",
"\n",
"# TX https://blockchain.info/tx/00bb072a7a81477d69ce22a61f408c53e37f9470488f8407e1026d3771644fdf\n",
"pubkey = '032936ecc6967a1c169f50c3e8df317271cf8190526843f0992aec155ee3fb2f44'.decode('hex')\n",
"hash160 = '56e04966d8d95bfc88b2e70d66ef15316d07a1ee'\n",
" \n",
"print hash160, '?=', op_hash160(pubkey).encode('hex'), op_hash160(pubkey).encode('hex') == hash160\n",
"\n",
"# Your TX\n",
"hash160 = 'b640a567c9499ef74f63648e9ba515dc13d412fc'\n",
"pubkey = ('02d7aebadf772f8987f92d3ebe175ac8a78ace8a89609629e03afd3ac12679b4b8').decode('hex')\n",
"\n",
"print hash160, '?=', op_hash160(pubkey).encode('hex'), op_hash160(pubkey).encode('hex') == hash160\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment