Coder Social home page Coder Social logo

quincysx / blockchainwallet-crypto Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 1.0 448 KB

比特币、以太坊公私钥生成以及签名,长时间不维护可移步 https://github.com/QuincySx/ChainWallet

License: GNU General Public License v3.0

Java 100.00%
wallet blockchain bip39 bip32 bip44 bip ethereum bitcoin bip38 keystore

blockchainwallet-crypto's Introduction

blockchainwallet-crypto's People

Contributors

quincysx avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

totulik

blockchainwallet-crypto's Issues

兼容bchABC/BSV

你好:
这个库可以兼容bchabc/bsv吗?
网上资料很少,可以给我一些建议吗?

java.lang.StackOverflowError: stack size 8MB

我运行Sample的时候爆出这个异常,logcat定位在:

java.lang.StackOverflowError: stack size 8MB
at com.quincysx.crypto.bitcoin.BTCTransaction.getSignBytes(BTCTransaction.java:111)

然后发现BTCTransaction这个方法是不是写错了??

@Override
public byte[] getSignBytes() {
    return getSignBytes();
}

自己调用自己,造成死循环?

TODO List

  • 修复 BTC 多签地址转账
  • 实现灵活拓展币种
  • 添加 EOS 签名功能
  • (Done)添加 EOS 生成签名功能
  • (Done)以太坊 KeyStore 导入导出
  • (Done)在本地生成 BTC 交易
  • (Done)考虑删除 CoinPairDerive 缓存机制 (为安全性删除)

在生成keystore的时候我有点疑问

我看到您的keystore生成的时候和web3j调用的时候基本都是一样的 但是我在使用过程中遇到了一个问题
byte[] derivedKey = generateDerivedScryptKey( password.getBytes(Charset.forName("UTF-8")), salt, n, R, p, DKLEN);生成keystore的时候调用这个方法如果用测试类测试会很快就生成,但是编译运行在手机上久久不能通过,不知道您是否也遇到了这个问题。

求讲原理的参考文章资料

你好,能发一篇总结吗?虽然能使用,但是对于BIP原理我一点也不明白,所以希望你能给下参考文章资料参考下

有MnemonicCode这个类吗?

我看Readme中提到了MnemonicCode这个类,并且非常方便调用。但是在添加了库之后,库中并没有这个类。怎么弄?

求助

很多平台都可以通过导入的方式来恢复,
那么也就说可以通过私钥去推算地址,我在你这里面试了很多方法不行,求助

助记词可以生成私钥和地址,已有
没有助记词,也可以用私钥推算出地址,暂无,求助

BTC创建地址连续2次相同?

HI:
请教个问题:我用如下代码,发现不退出程序,连续2次生成的BTC地址是相同的。第三次就不相同了。请问是什么原因?
try {
Log.d(LOGTAG,"==============btc=========================");
MnemonicCode mnemonicCode = new MnemonicCode();
//参数是助记词的个数

                //通过助记词产生
                byte[] random = RandomSeed.random(Words.TWELVE);
                //(可以通过此代码使用助记词恢复随机数 byte[] bytes = mnemonicCode.toEntropy(mnemonicWordsInAList );)
                Log.d(LOGTAG,"random = " +  DigitalTrans.byte2hex(random));


                //生成
                List<String> mnemonicWordsInAList = mnemonicCode.toMnemonic(random);

                String s1 = mnemonicWordsInAList.toString();

                Log.d(LOGTAG,"list = " + mnemonicWordsInAList.toString());

                //随机创建助记词
                byte[] seed = MnemonicCode.toSeed(mnemonicWordsInAList, "");

                Log.d(LOGTAG,"seed = " +  DigitalTrans.byte2hex(seed));
                ExtendedKey extendedKey = ExtendedKey.create(seed);

                AddressIndex address = BIP44.m().purpose44()
                        .coinType(CoinTypes.Bitcoin)
                        .account(0)
                        .external()
                        .address(0);

                Log.e(LOGTAG, "==" + address.toString());
                CoinPairDerive coinKeyPair = new CoinPairDerive(extendedKey);

                ECKeyPair master = coinKeyPair.derive(address);

                try {
                    BTCTransaction btcTransaction = new BTCTransaction(HexUtils.fromHex("02000000018aad5febb0f5165097727eb402d15e96c615560b6d4e0fcbee0882ff589af3220000000000ffffffff0240420f00000000001976a91438ae48c4ff53e9ba952d3c63f200f2dfe04f330188aca0cd8700000000001976a91481f9f80df4efb08e373fa8f2b8896f33e3a270f388ac00000000"));
                    byte[] sign = btcTransaction.sign(master);
                    Log.e("===", HexUtils.toHex(sign));
                } catch (BitcoinException e) {
                    e.printStackTrace();
                }


                Log.e(LOGTAG, "privateKey = " + master.getPrivateKey());
                Log.e(LOGTAG,  "publickey = " + master.getPublicKey());
                Log.e(LOGTAG, "addresss = " + master.getAddress());
                Log.e(LOGTAG, "raworuvatekey = " + DigitalTrans.byte2hex(master.getRawPrivateKey()));
                Log.e(LOGTAG, "=========address end=============");

            } catch (MnemonicException.MnemonicLengthException e) {
                e.printStackTrace();
            } catch (ValidationException e) {
                e.printStackTrace();
            }

找不到库

在readme中说引用库的方式是implementation 'com.github.SmallRaw:BlockchainWallet-Crypto:last-version'.看了最新的标签是v0.1.15-beta,所以的我的工程中配置如下,implementation 'com.github.SmallRaw:BlockchainWallet-Crypto:v0.1.15-beta',编译出错,提示

Could not resolve com.github.SmallRaw:BlockchainWallet-Crypto:v0.1.15-beta

这里的版本号要配置多少?

bch wallet

hello ,
how can i create a bch testnet wallet use this library?

LTC DASH

大哥,什么时候把LTC DASH币种的地址生成加上作为范例呀。。。

转账

目前类库中支持转账功能API嘛

公钥跟网上的对不上的问题。

String m = "message trophy income arch glimpse ordinary fitness pear depend honey give mansion";//助记词
byte[] seed = new SeedCalculator().calculateSeed(m,"");
ExtendedKey extendedKey = null;
try {
extendedKey = ExtendedKey.create(seed);
} catch (ValidationException e) {
e.printStackTrace();
}
AddressIndex address = BIP44.m().purpose44()
.coinType(CoinTypes.Ethereum)
.account(0)
.external()
.address(0);
CoinPairDerive coinKeyPair = new CoinPairDerive(extendedKey);
ECKeyPair master = null;
try {
master = coinKeyPair.derive(address);
String add = master.getAddress();
Log.e("=1221=", "==" + address.toString());
Log.e("=1221private", master.getPrivateKey());
Log.e("=1221public=", master.getPublicKey());
Log.e("=1221address=", master.getAddress());
Log.e("=1221=", "======================");
} catch (ValidationException e) {
e.printStackTrace();

    }

这个是本地执行的结果:

2018-11-05 14:41:10.155 13784-13784/com.xxE/=1221=: ==m/44'/60'/0'/0/0
2018-11-05 14:41:10.633 13784-13784/com.xxE/=1221private: d7e2b2931ceb99e387f12cc22cea991624e1bbf3181607dabfc307e2c7ee7efa
2018-11-05 14:41:28.370 13784-13784/com.xxE/=1221public=: 7bfac8c947faa89f9c74ce980797b6177ede0be6855bc0e8c00b9042c0d47e98a418c4689eacec3e4a88106254744d43bee8bf14967ba297987ed2c4cd404838
2018-11-05 14:42:18.359 13784-13784/com.xxE/=1221address=: C7F998350a6B13Bd9a6712e176f64a7fd19bBD70

这个是在网上执行的结果
https://iancoleman.io/bip39/#chinese_simplified

m/44'/60'/0'/0/0 0xC7F998350a6B13Bd9a6712e176f64a7fd19bBD70 0x027bfac8c947faa89f9c74ce980797b6177ede0be6855bc0e8c00b9042c0d47e98 0xd7e2b2931ceb99e387f12cc22cea991624e1bbf3181607dabfc307e2c7ee7efa

现在公钥这个对不上。私钥跟地址是没问题的,麻烦帮忙看看。谢谢。

请问接下来有做支持EOS相关操作的打算吗?

首先,感谢您的付出,关于助记词一块,给了我很大的帮助。注意到你的代码中有预留了EOS的位置,但目前还没相关代码,不知之后是否会继续编写相关代码呢?目前我在从事EOS的相关开发工作,很期待你的回信,并且希望有机会进行下一步的合作。
再次感谢。

Hi~请问有没有兴趣来W3c.Group区块链技术社区创建您的专属小组?

您可以做什么:在W3c.Group社区创建和您的项目相关的小组,输出和区块链技术相关的内容,和加入小组的成员关注者进行互动。

这样做的价值:帮助更多的开发者学习区块链技术,同时提升您的社区知名度,对您感兴趣的开发者或潜在合作者、投资人能主动找到您。

官网以及介绍:https://w3c.group/about

W3c.Group正在冷启动,欢迎通过社区内私信或微信联系瓦工,了解并成为W3c.Group核心共建者

请教一下这个里面 new BTCTransaction(?)里面的这个是什么

Transaction transaction= new BTCTransaction(十六进制 TX Byte[]);// HexUtils.fromHex(str) 可以转换
byte[] signByte = transaction.sign(master);
String signTx = HexUtils.toHex(signByte);

请教一下这个里面 new BTCTransaction(?)里面的这个是什么,我现在要做btc的转账签名,手续费,地址都怎么传,这个十六进制又是怎么生成的

transaction error

i create a transaction, i got a signed tx. but i an error when broadcast :

1、create a tx:
try {
BTCTransaction.Input[] inputs = new BTCTransaction.Input[1];
BTCTransaction.Output[] outputs = new BTCTransaction.Output[2];
BTCTransaction.OutPoint outPoint = new BTCTransaction.OutPoint(HexUtils.fromHex("0068a570118ff3cdde0a13f2a7aa3a4b3c2f8f094bc8980f7310daa1bcea3ed9"), 0);

                inputs[0] = new BTCTransaction.Input(outPoint, null, 0xffffffff);

                BTCTransaction.Output output1 = new BTCTransaction.Output(100, BTCTransaction.Script.buildOutput("mztEzH7tSzauW1vQmZ9NQog8VfJAsgtjLB"));
                outputs[0] = output1;

                BTCTransaction.Output output2 = new BTCTransaction.Output(1000, BTCTransaction.Script.buildOutput("mqQtNiy8YJgJUpT3DFtcXkKy1UVjLY4rPH"));
                outputs[1] = output2;

                BTCTransaction transaction = new BTCTransaction(inputs, outputs, 0);

//
byte[] sign = transaction.sign(master);
Log.e(TAG, HexUtils.toHex(sign));
} catch (Exception e) {
e.printStackTrace();
}

2、interface to return:
Missing parents for 84ea32e77c6365b4463ab0de95223ff10cdcf34e53138598e487765aed657e81 while inserting: [0068a570118ff3cdde0a13f2a7aa3a4b3c2f8f094bc8980f7310daa1bcea3ed9]

help me!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.