prusnak / addrgen Goto Github PK
View Code? Open in Web Editor NEWDeterministic Bitcoin Address Generator
License: MIT License
Deterministic Bitcoin Address Generator
License: MIT License
Hello,
I've taken the master public key from an electrum wallet and attempted to extract addresses from it:
irb(main):001:0> require 'bitcoin-addrgen'
=> true
irb(main):002:0> master_public_key = "xpub661MyMwAqRbcFTm4eJJRB4SvWGWGj8UC2Vajs7arYz4cJfDJS8nYi1pY51FDu65Z2JNFtqj4ZqxdceNueEobSkkNqGjn7aKXTv9yD6Yfycm"
=> "xpub661MyMwAqRbcFTm4eJJRB4SvWGWGj8UC2Vajs7arYz4cJfDJS8nYi1pY51FDu65Z2JNFtqj4ZqxdceNueEobSkkNqGjn7aKXTv9yD6Yfycm"
irb(main):003:0> first_ten_addresses = 10.times.collect do |address_index|
irb(main):004:1* BitcoinAddrgen.generate_public_address(master_public_key, address_index)
irb(main):005:1> end
Exception: Curve does not contain point
from /var/lib/gems/2.3.0/gems/bitcoin-addrgen-0.1.0/lib/bitcoin_addrgen/addrgen.rb:191:in `initialize'
from /var/lib/gems/2.3.0/gems/bitcoin-addrgen-0.1.0/lib/bitcoin_addrgen/addrgen.rb:311:in `new'
from /var/lib/gems/2.3.0/gems/bitcoin-addrgen-0.1.0/lib/bitcoin_addrgen/addrgen.rb:311:in `addr_from_mpk'
from /var/lib/gems/2.3.0/gems/bitcoin-addrgen-0.1.0/lib/bitcoin-addrgen.rb:7:in `generate_public_address'
from (irb):4:in `block in irb_binding'
from (irb):3:in `times'
from (irb):3:in `each'
from (irb):3:in `collect'
from (irb):3
from /usr/bin/irb:11:in `<main>'
irb(main):006:0>
if valid_bitcoin_address?(bitcoin_address)
GC.start
while (i <= limit and search_on)
search_on = ( bitcoin_address != BitcoinAddrgen.generate_public_address(mpk,i))
i += 1
end
if search_on
array = ['This address could not be verified.', 'Keep searching ? launch a new search to extend the search range.']
else
bitcoin_address = BitcoinAddrgen.generate_public_address(mpk,i-1)
array=['Address match : this bitcoin address is safe.', bitcoin_address]
end
else
array = ['This address is not a valid bitcoin address.', 'Please enter a valid bitcoin address.']
end
The script works fine locally but seems to exhaust memory when deployed to heroku:
Error R14 (Memory quota exceeded)
2013-08-14T14:02:02.535801+00:00 heroku[web.1]: Process running mem=1024M(100.0%)
2013-08-14T14:02:02.536011+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2013-08-14T14:02:23.385206+00:00 heroku[web.1]: Process running mem=1024M(100.0%)
2013-08-14T14:02:23.385905+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
Most probably native gmp structures need to be explicitly freed.
Hello is this for hierarchical or sequential deterministic wallet type?
*sorry I don't know where to ask.
Electrum generates Master Public Key not in hex format, but this code requires a hex. It would be great to have few words about how to transform electrum's mpk format to hex.
.
.
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.