Comments (2)
Hi Peswani, I'm quite surprised because it's our first time to see people using Electrum as a Python library. Could you give us more information like how you run the code, so that we can easily reproduce and help figure it out?
Btw, though we do support Electrum in long term, we have another library bgoldjs-lib which is much more developer friendly. It's based on javascript, though. I'm also very happy to help if you want to know how it could be done with bgoldjs-lib.
from electrum.
@h4x3rotab Thanks for the information. I am working on trezor support. elecrtumg does not support it as of now .Because trezor library is in python so I've choose electrumg for referencing. I've created my own UI as well for the wallet. my issue is how can I know that the signature belong to a particular public key in case of multisig. for this I have referenced electrumg code.
The setup is simple you need to download the electrumg code and install all the dependencies. Create a new python file in lib folder and paste below code
from ecdsa import ecdsa, util
from lib.transaction import Transaction, bh2u, SECP256k1
from lib.bitcoin import Hash, MyVerifyingKey, i2o_ECPublicKey, point_to_ser
from lib.util import bfh
raw_tx = '0100000001f479528049ee4b235548a7116f5ca31c607728af3d4ac8f102c5be13e93dcca900000000b40047304402201b83bd2209bc101736f60eeec3bcc1f79d45019d1829af97f5bd3210e8d8d786022020954c15372268d299b5463e1335595221e16222aee0291509a2098a0eb7fe80414c69522103556117b3f9a92f2997529af415c2c07185b872ddf1439995eca7f3acb65c58822103917f2527fc394ae2da48ce0148d29e5b756c4d9d180a6762bbe7abe215b29a562103f03364c624889c99059902524bcd8e2b24fb09cceb2e0f895d6475ef4913676553aeffffffff02a08601000000000017a914fd80725877f902f4491a6dc733fe788c376aeff8875033f4050000000017a9149aba36d2c19b08781230a4301f364610a163fc2d8700000000'
sig = '304402201b83bd2209bc101736f60eeec3bcc1f79d45019d1829af97f5bd3210e8d8d786022020954c15372268d299b5463e1335595221e16222aee0291509a2098a0eb7fe80'
tx = Transaction(raw_tx)
sighash = Hash(bfh(tx.serialize_preimage(0)))
pubkeys, x_pubkeys = tx.get_sorted_pubkeys(tx.inputs()[0])
print(sighash.hex())
print(pubkeys)
# print(x_pubkeys)
order = ecdsa.generator_secp256k1.order()
r, s = util.sigdecode_der(bfh(sig), order)
sig_string = util.sigencode_string(r, s, order)
compressed = True
for recid in range(4):
print(recid)
public_key = MyVerifyingKey.from_signature(sig_string, recid, sighash, curve=SECP256k1)
#key = i2o_ECPublicKey(public_key.pubkey, compressed=True)
#print("=========" + key.hex() + "============")
pubkey = bh2u(point_to_ser(public_key.pubkey.point, compressed))
print(pubkey)
# print(public_key.verify_digest(sig_string, sighash, sigdecode=ecdsa.util.sigdecode_string))
print(tx.signature_count())
print(sighash.hex())
The above code take reference from Transaction class in lib\transaction.py
folder exact 649 line number
from electrum.
Related Issues (20)
- File->Delete HOT 1
- File->New/Restore
- View->Show Console HOT 1
- Tools->Preferences->Appearance
- test
- Can't scan qr code on macOS HOT 2
- Slow blockchain header syncing HOT 3
- Unsigned Transaction save/export error HOT 2
- Can't sign offline transactions for multi signature wallet
- ImportError: No module named 'pyblake2' HOT 2
- Add android, ios support
- Recover a 2FA wallet HOT 1
- TREZOR support broken HOT 1
- Issue opening BTG wallet
- "not verified" HOT 3
- start error then blockchain update halt(?) HOT 2
- Synchronizing issue! HOT 1
- Server is lagging HOT 1
- Is this wallet still maintained to keep BTG? HOT 1
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 electrum.