Comments (3)
I can get a Tx
object from this, but not an UnsignedTx
.
>>> pycoin.tx.Tx.parse(io.BytesIO(h2b('01000000016a26923302377f548764ba5d28d75ff89405f08dbd626876c5e8359ae84955e1010000001976a914a0e8d5fe498e6ca2c2000de13fc9cc470bd9b87088acffffffff036c2a0000000000001976a914f9200a96db875f8906ad34a1f46de4ad0626d4c488ac6c2a00000000000047512103f62c74a1686c41e2639c2c6e9ab336856a405f7aba0b753af6002ce709daf55d211c434e5452505254590000000000000000000000010000000001312d000000000052aec6572c01000000001976a914a0e8d5fe498e6ca2c2000de13fc9cc470bd9b87088ac00000000'))) Tx [3fc4e9b1d3882f86145993ed314229be3d0693165718201499ee2c2f461dd017] (v:1) [TxIn<e15549e89a35e8c5766862bd8df00594f85fd7285dba6487547f37023392266a[1] "OP_DUP OP_HASH160 a0e8d5fe498e6ca2c2000de13fc9cc470bd9b870 OP_EQUALVERIFY OP_CHECKSIG">] [TxOut<0.0001086 "OP_DUP OP_HASH160 f9200a96db875f8906ad34a1f46de4ad0626d4c4 OP_EQUALVERIFY OP_CHECKSIG">, TxOut<0.0001086 "OP_1 03f62c74a1686c41e2639c2c6e9ab336856a405f7aba0b753af6002ce709daf55d 1c434e5452505254590000000000000000000000010000000001312d0000000000 OP_2 OP_CHECKMULTISIG">, TxOut<0.1968327 "OP_DUP OP_HASH160 a0e8d5fe498e6ca2c2000de13fc9cc470bd9b870 OP_EQUALVERIFY OP_CHECKSIG">]
>>> pycoin.tx.UnsignedTx.parse(io.BytesIO(h2b('01000000016a26923302377f548764ba5d28d75ff89405f08dbd626876c5e8359ae84955e1010000001976a914a0e8d5fe498e6ca2c2000de13fc9cc470bd9b87088acffffffff036c2a0000000000001976a914f9200a96db875f8906ad34a1f46de4ad0626d4c488ac6c2a00000000000047512103f62c74a1686c41e2639c2c6e9ab336856a405f7aba0b753af6002ce709daf55d211c434e5452505254590000000000000000000000010000000001312d000000000052aec6572c01000000001976a914a0e8d5fe498e6ca2c2000de13fc9cc470bd9b87088ac00000000'))) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.4/site-packages/pycoin/tx/UnsignedTx.py", line 65, in parse new_txs_out.append(TxOut.parse(f)) File "/usr/lib/python3.4/site-packages/pycoin/tx/TxOut.py", line 51, in parse return self(*parse_struct("QS", f)) File "/usr/lib/python3.4/site-packages/pycoin/serialize/streamer.py", line 39, in parse_struct l.append(self.parse_lookup[c](f)) File "/usr/lib/python3.4/site-packages/pycoin/serialize/bitcoin_streamer.py", line 39, in <lambda> "Q" : (lambda f: struct.unpack("<Q", f.read(8))[0], lambda f, v: f.write(struct.pack("<Q", v))), struct.error: unpack requires a bytes object of length 8
from pycoin.
UnsignedTx is a custom type that I made up, so it won't be easy to use that type. No matter what you do, you're going to have to get the "Spendable" TxOut outputs that correspond to this transaction's TxIn inputs.
I'm working on a rewrite of how signing works (sponsored by coinsafe.com) that should make things easier. Although not API-stable, take a look at https://github.com/richardkiss/pycoin/tree/offline_tx. As of 19fa9c2 you can do the following:
- Load the input Txs into a dictionary tx_db using tx_cache.tx_for_hash (this will fetch the Txs from blockchain.info, although it can be configured to use blockr.io).
- For your parsed Tx tx, call tx.use unspents_from_db(tx_db) using the tx_db.
- Build hash160_lookup using tx/script/solvers/build_hash160_lookup_db
- Call tx.sign(hash160_lookup)
I believe this will work.
This could be made easier by combining steps 1 and 2 with an adaptor but I haven't done that work yet. (It's more of an organization problem than a programming one.)
from pycoin.
Got it. Thanks!
from pycoin.
Related Issues (20)
- pycoin==0.90a dissapeared from pypi HOT 2
- ku: command not found
- [Bounty] Faster address generation HOT 14
- 10000 btc address convert to hash160 HOT 1
- cant parse - cat 1.txt | xargs -n1 ku | grep hash160 HOT 6
- Remove wrapping / in output HOT 1
- How to create network and sign transaction by parameters of network? HOT 3
- The bip84_as_string method is not added to network HOT 1
- Error "absurdly-high-fee, (code 256)" HOT 1
- Release with P2TR support HOT 2
- P2TR: unknown expression PUSH_81 HOT 6
- error while signing HOT 1
- pycoin\ecdsa\__init__.py file is 0KB HOT 3
- Pycoin does not work with latest Ubuntu (22.04 Jammy) (ripemd160 has been deprecated in OpenSSL-3) HOT 4
- How to generate many addresses from a parent address HOT 3
- How to send coins with privately HOT 1
- check_tx gone HOT 2
- python 3.11 HOT 4
- Documentation for Liquid and elements HOT 1
- Issue with Litecoin (LTC) parsing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pycoin.