google开源项目 bitcoinj







My favorites |Sign in





bitcoinj

A Java implementation of a Bitcoin client-only node


Project Home

Downloads

Wiki

Issues

Source


Summary  People


Project Information


Members

Featured


Wiki pages

Links

bitcoinj is a Java implementation of the Bitcoin protocol, which allows it to maintain a wallet and send/receive transactions without needing a local copy of the official implementation. It comes with full documentation and some example apps showing how to use the library.

The project aims to be easier to understand than the C++ implementation, and be suitable for usage on constrained devices such as mobile phones or cheap virtual servers.

bitcoinj implements both the lightweight "simplified payment verification" mode of Satoshis paper which does not store a full copy of the block chain or verify all transactions, and anexperimental full verification mode. Do not use this without reading the documentation below.

If you use bitcoinj in an application please sign up for the announcement list so you know when new versions are available and if there are critical bugs found

Download the library and then read:

There are also some more in depth articles covering various topics. For best understanding, read them in order.

Alternatively you can follow bitcoinj on Google+! Get tips and announcements direct to your stream (note: don't plus this specific page if you want updates).

Got questions? Comments? Patches? Talk to us on the mailing list. You can read the release notes for each release starting from 0.3.

Be warned: This software is at an early development stage. You still need to patch it to achieve many use cases and youmust have a good understanding of the Bitcoin protocol. If you lose money you have only yourself to blame!











  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
bitcoinj项目富含完整demo 此项目使用maven构建,不会使用maven的同学,查看项目pom.xml文件,并在http://mvnrepository.com/下载相应的依赖jar包. demo:bitcoinj签名交易 /** * @param unSpentBTCList 未花费utxo集合 * @param from 发送者地址 * @param to 接收者地址 * @param privateKey 私钥 * @param value 发送金额.单位:聪 * @param fee 旷工费.单位:聪 * @return 签名之后未广播的原生交易字符串 * @throws Exception */ public static String signBTCTransactionData(List unSpentBTCList, String from, String to, String privateKey, long value, long fee) throws Exception { NetworkParameters networkParameters = null; // networkParameters = MainNetParams.get(); //测试网络 networkParameters = TestNet3Params.get(); Transaction transaction = new Transaction(networkParameters); DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(networkParameters, privateKey); ECKey ecKey = dumpedPrivateKey.getKey(); long totalMoney = 0; List utxos = new ArrayList(); //遍历未花费列表,组装合适的item for (UnSpentBTC us : unSpentBTCList) { if (totalMoney >= (value + fee)) break; UTXO utxo = new UTXO(Sha256Hash.wrap(us.getTxid()), us.getVout(), Coin.valueOf(us.getSatoshis()), us.getHeight(), false, new Script(Hex.decode(us.getScriptPubKey()))); utxos.add(utxo); totalMoney += us.getSatoshis(); } transaction.addOutput(Coin.valueOf(value), Address.fromBase58(networkParameters, to)); // transaction. //消费列表总金额 - 已经转账的金额 - 手续费 就等于需要返回给自己的金额了 long balance = totalMoney - value - fee; //输出-转给自己 if (balance > 0) { transaction.addOutput(Coin.valueOf(balance), Address.fromBase58(networkParameters, from)); } //输入未消费列表项 for (UTXO utxo : utxos) { TransactionOutPoint outPoint = new TransactionOutPoint(networkParameters, utxo.getIndex(), utxo.getHash());
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值