petertodd / checklocktimeverify-demos Goto Github PK
View Code? Open in Web Editor NEWCHECKLOCKTIMEVERIFY (BIP65) Demos
License: GNU General Public License v3.0
CHECKLOCKTIMEVERIFY (BIP65) Demos
License: GNU General Public License v3.0
"create" works well but I have problems with spending.
When I hit
hodl.py -v spend :
I get
Traceback (most recent call last):
File "C:...\hodl.py", line 158, in
args.cmd_func(args)
File "C:...\hodl.py", line 101, in spend_command
prevout = proxy.gettxout(outpoint)
File "C:\Python34\lib\site-packages\bitcoin\rpc.py", line 466, in gettxout
r = self._call('gettxout', b2lx(outpoint.hash), outpoint.n, includemempool)
File "C:\Python34\lib\site-packages\bitcoin\rpc.py", line 184, in _call
'Content-type': 'application/json'})
File "C:\Python34\lib\http\client.py", line 1137, in request
self._send_request(method, url, body, headers)
File "C:\Python34\lib\http\client.py", line 1182, in _send_request
self.endheaders(body)
File "C:\Python34\lib\http\client.py", line 1133, in endheaders
self._send_output(message_body)
File "C:\Python34\lib\http\client.py", line 963, in _send_output
self.send(msg)
File "C:\Python34\lib\http\client.py", line 898, in send
self.connect()
File "C:\Python34\lib\http\client.py", line 871, in connect
self.timeout, self.source_address)
File "C:\Python34\lib\socket.py", line 516, in create_connection
raise err
File "C:\Python34\lib\socket.py", line 507, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061]
I have Win7 x64, firewalls terminated, Bitcoin Core (bitcoin.conf with rpcpassword=) running from drive E:... and symlink created from C:...\Roaming\Bitcoin\ to that location (it's hard to have that 55gb blockchain on C:).
Are there any ways to get the raw spending transaction using your script without connections to Core?
We are working on this python file >>micropayment-channel.py(https://github.com/petertodd/checklocktimeverify-demos/blob/master/micropayment-channel.py)
and we got some error
Might be a dumb question, but why is deposit_redeemScript "self.expiry_nlocktime, 1, OP_NOP2, OP_2DROP" instead of "self.expiry_nlocktime, OP_NOP2, OP_DROP"? In other words, what effect does the 1 have?
Broadcasting a raw-tx, which was generated by the script for the testnet produces the following error:
error code: -26
error message:
16: mandatory-script-verify-flag-failed (Non-canonical DER signature)
I´ve created the following address:
python2 hodl.py -t cR62Q2Dp8HriUXyKf1nYW6SYk6F1MZVMJbb2qqafCLBKSidV3SX3 1113520 create
2MsUY2M8gyWs2oJ56wcDo9MLdkjC5LW8HY4
After depositing 0.1 BTC on that address I´ve used the script to create the raw-tx to spend the coins:
python2 hodl.py -t cR62Q2Dp8HriUXyKf1nYW6SYk6F1MZVMJbb2qqafCLBKSidV3SX3 1113520 spend 5acfe3d5e2587f6c1b43a43b2d3f907b969b0bbd7b31c0f652553a5fca8f34ad:0 mmHhhBPx8qC8bQMAwSPcddsrfnaFhAXjyT
0100000001ad348fca5f3a5552f6c0317bbd0b9b967b903f2d3ba4431b6c7f58e2d5e3cf5a00000000754a30450221009bd5471f6d9fa5f733df788cd818c3a0497f68cf085b5f799b1615cb5bb052d202201d1e8e8eda581fedce145f08d580aec04f6f5ef78c07d741d5bcd5f3c451814e5b315d2903b0fd10b175210218a4b3a95f7b29bc9baf0c69835790af7aca065b38302c13d651972aa2bab3dbac0000000001706f9800000000001976a9143f4f289e811ae3001bfd0024e117ec6a2ab2945a88acb0fd1000
The decoded raw-tx looks like this:
"txid": "08a69cfd97d116975c4f82ac9cc2b8cb8286e42c0ceb47fb193472c9a3122915",
"hash": "08a69cfd97d116975c4f82ac9cc2b8cb8286e42c0ceb47fb193472c9a3122915",
"size": 202,
"vsize": 202,
"version": 1,
"locktime": 1113520,
"vin": [
{
"txid": "5acfe3d5e2587f6c1b43a43b2d3f907b969b0bbd7b31c0f652553a5fca8f34ad",
"vout": 0,
"scriptSig": {
"asm": "30450221009bd5471f6d9fa5f733df788cd818c3a0497f68cf085b5f799b1615cb5bb052d202201d1e8e8eda581fedce145f08d580aec04f6f5ef78c07d741d5bcd5f3c451814e5b315d 03b0fd10b175210218a4b3a95f7b29bc9baf0c69835790af7aca065b38302c13d651972aa2bab3dbac",
"hex": "4a30450221009bd5471f6d9fa5f733df788cd818c3a0497f68cf085b5f799b1615cb5bb052d202201d1e8e8eda581fedce145f08d580aec04f6f5ef78c07d741d5bcd5f3c451814e5b315d2903b0fd10b175210218a4b3a95f7b29bc9baf0c69835790af7aca065b38302c13d651972aa2bab3dbac"
},
"sequence": 0
}
],
"vout": [
{
"value": 0.09990000,
"n": 0,
"scriptPubKey": {
"asm": "OP_DUP OP_HASH160 3f4f289e811ae3001bfd0024e117ec6a2ab2945a OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a9143f4f289e811ae3001bfd0024e117ec6a2ab2945a88ac",
"reqSigs": 1,
"type": "pubkeyhash",
"addresses": [
"mmHhhBPx8qC8bQMAwSPcddsrfnaFhAXjyT"
]
}
}
]
}
But sending this raw-tx leads to the error (mentioned above).
I´ve tried to broadcast with bitcoin core v.0.11.2 and v.0.13.1
I´ve also updated the python-bitcoinlib from v.0.5.0 to v.0.7.0 to see if that maybe fixes the issue, but without any changes.
I´ve started the hodl-script with python v.2.7.
After asking in IRC (channel: bitcoin) @harding helped me out a bit:
(15:14:23) harding:
sj_stefan: it's pretty weird. Your signature seems to be 75 bytes not including the sighash code, which I think is larger than signatures are supposed to be. I don't see any problem with the code though.
For some reason, the same script has generated a raw-tx, that I was able to broadcast successfully last year (with bitcoin core v.0.11.0). Last time I´ve started the script without explicitly using a different python-version.
By just calling the hodl-script with the preferred python-version 3 now, I´m running into some python-errors, that doesn´t occur last year:
Traceback (most recent call last):
File "/var/www/vhosts/service/classiccoin/cltv_origin/bitcoin/rpc.py", line 30, in
import http.client as httplib
ImportError: No module named 'http'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./hodl.py", line 10, in
import bitcoin.rpc
File "/var/www/vhosts/service/classiccoin/cltv_origin/bitcoin/rpc.py", line 32, in
import httplib
ImportError: No module named 'httplib'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.