The bitcoinj.cash library has been retired, this repository will be put into archive mode soon.
For the Bitcoin SV version of BitcoinJ, please see https://github.com/bitcoinj-sv/bitcoinj-sv.
This project forked from bitcoinj/bitcoinj
A library for working with Bitcoin
Home Page: http://bitcoinj.cash
License: Apache License 2.0
The bitcoinj.cash library has been retired, this repository will be put into archive mode soon.
For the Bitcoin SV version of BitcoinJ, please see https://github.com/bitcoinj-sv/bitcoinj-sv.
When using checkpoints, the November 13 DAA will fail. This was resolved with #18 on cash-0.14
with https://github.com/bitcoinj-cash/bitcoinj/pull/18/files#diff-ef262b65e6add81fc5f71fd7a4e2d82cR242
on getPrev()
, check for null and if it is null throw BlockStoreException
.
By way of reminder, checkpoints allow the app to start syncing the blockchain at arbitrary block heights instead of starting from block 0.
java.lang.NullPointerException: Attempt to invoke virtual method 'org.bitcoinj.core.StoredBlock org.bitcoinj.core.StoredBlock.getPrev(org.bitcoinj.store.BlockStore)' on a null object reference
at org.bitcoinj.pow.rule.NewDifficultyAdjustmentAlgorithmRulesChecker.GetMostSuitableBlock(NewDifficultyAdjustmentAlgorithmRulesChecker.java:72) ~[na:0.0]
at org.bitcoinj.pow.rule.NewDifficultyAdjustmentAlgorithmRulesChecker.checkNextCashWorkRequired(NewDifficultyAdjustmentAlgorithmRulesChecker.java:49) ~[na:0.0]
at org.bitcoinj.pow.rule.NewDifficultyAdjustmentAlgorithmRulesChecker.checkRules(NewDifficultyAdjustmentAlgorithmRulesChecker.java:32) ~[na:0.0]
at org.bitcoinj.pow.RulesPoolChecker.checkRules(RulesPoolChecker.java:22) ~[na:0.0]
at org.bitcoinj.core.AbstractBlockChain.add(AbstractBlockChain.java:494) ~[na:0.0]
at org.bitcoinj.core.AbstractBlockChain.add(AbstractBlockChain.java:357) ~[na:0.0]
at org.bitcoinj.core.Peer.processHeaders(Peer.java:703) ~[na:0.0]
at org.bitcoinj.core.Peer.processMessage(Peer.java:504) ~[na:0.0]
at org.bitcoinj.core.PeerSocketHandler.receiveBytes(PeerSocketHandler.java:142) ~[na:0.0]
at org.bitcoinj.net.ConnectionHandler.handleKey(ConnectionHandler.java:223) ~[na:0.0]
at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:86) ~[na:0.0]
at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122) ~[na:0.0]
at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66) ~[na:0.0]
at com.google.common.util.concurrent.Callables$4.run(Callables.java:122) ~[na:0.0]
at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:49) ~[na:0.0]
at java.lang.Thread.run(Thread.java:818) ~[na:0.0]
public class MyWalletAppKit extends WalletAppKit {
public MyWalletAppKit(Context context, File directory, String filePrefix) {
super(context, directory, filePrefix);
// TODO Auto-generated constructor stub
}
public MyWalletAppKit(NetworkParameters params, File file, String filePrefix) {
super(params, file, filePrefix);
}
@Override
protected void onSetupCompleted() {
if (wallet().getKeyChainGroupSize() < 1) {
ECKey eckey= new ECKey();
wallet().importKey(eckey);
}
peerGroup().addPeerDiscovery(new DnsDiscovery(this.params));
peerGroup().setMinBroadcastConnections(8);
peerGroup().setMaxConnections(10);
peerGroup().setFastCatchupTimeSecs(wallet().getEarliestKeyCreationTime());
System.out.println("wallet address:"+wallet().currentReceiveAddress()+" wallet "+wallet().toString());
}
@Override
protected PeerGroup createPeerGroup() throws TimeoutException {
// TODO Auto-generated method stub
PeerGroup peerGroup = null;
try {
FullPrunedBlockStore store = new H2FullPrunedBlockStore(this.params, "bch_test9", 1000);
FullPrunedBlockChain vChain = new FullPrunedBlockChain(this.params, store);
peerGroup = new PeerGroup(this.params, vChain);
// super.peerGroup()
// peerGroup.downloadBlockChain();
} catch (BlockStoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("peergroup error" + e);
}
return peerGroup;
}
}
When I Override the createPeerGroup method, I use the new H2FullPrunedBlockStore and then use peerGroup ().SetFastCatchupTimeSecs ().SetFastCatchupTimeSecs (wallet ().GetEarliestKeyCreationTime ()); the system will throw the Fast catchup is incompatible with exception. ImeSecs
I propose to remove the BTC Bitcoinj branches from this repo because they cause confusion. If we need to merge changes from the BTC Bitcoinj into this repo, this can be done using a local git, pulling the necessary commits across.
The affected branches would be: "master", "release-0.14", and "segwit".
Any thoughts?
I have noticed sometimes the MultiplexingDiscovery
is not able to find peers. This issue occurs randomly and is very confusing for the user: Can't see the balance increasing after send some funds.
Some additional details:
Example of log file:
W/MultiplexingDiscovery: Seed seed.bitcoinabc.org: timed out
W/MultiplexingDiscovery: Seed seed-abc.bitcoinforks.org: timed out
W/MultiplexingDiscovery: Seed btccash-seeder.bitcoinunlimited.info: timed out
W/MultiplexingDiscovery: Seed seed.bitprim.org: timed out
W/MultiplexingDiscovery: Seed seed.deadalnix.me: timed out
W/MultiplexingDiscovery: Seed seeder.criptolayer.net: timed out
E/PeerGroup: Peer discovery failure org.bitcoinj.net.discovery.PeerDiscoveryException: No peer discovery returned any results in 5000ms. Check internet connection?
at org.bitcoinj.net.discovery.MultiplexingDiscovery.getPeers(MultiplexingDiscovery.java:116)
at org.bitcoinj.core.PeerGroup.discoverPeers(PeerGroup.java:1051)
at org.bitcoinj.core.PeerGroup$6.go(PeerGroup.java:546)
at org.bitcoinj.core.PeerGroup$6.run(PeerGroup.java:512)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:49)
at java.lang.Thread.run(Thread.java:761)
I/PeerGroup: Peer discovery didn't provide us any more peers, will try again in 6010ms.
Have you experienced anything similar? Any ideas or alternatives?
Regards,
Add support for Bitcoin Cash Address Format.
Links:
Thoughts on Backwards Compatibility - Do we need to preserve backwards compatibility? Do we have any users yet? Should we replace the default method of obtaining string representations of an address with the new format, or add a new method?
`
NetworkParameters params = MainNetParams.get();
Wallet toWatch=new Wallet(params);
System.out.println(toWatch.toString());
DeterministicKey watchingKey = toWatch.getWatchingKey();
System.out.format("key priv: %s\n", watchingKey.getPrivateKeyAsHex());
watchingKey.dropPrivateBytes().dropParent();
System.out.format("after drop.\nkey data: %s\n", watchingKey.toString());
System.out.format("key priv: %s\n", watchingKey.getPrivateKeyAsHex());
Wallet watchingWallet = Wallet.fromWatchingKey(params, watchingKey);
`
Exception in thread "main" java.lang.IllegalArgumentException: Private subtrees not currently supported: if you got this key from DKC.getWatchingKey() then use .dropPrivate().dropParent() on it first. at com.google.common.base.Preconditions.checkArgument(Preconditions.java:122) at org.bitcoinj.wallet.DeterministicKeyChain.<init>(DeterministicKeyChain.java:318) at org.bitcoinj.wallet.DeterministicKeyChain.watch(DeterministicKeyChain.java:351) at org.bitcoinj.wallet.KeyChainGroup.<init>(KeyChainGroup.java:92) at org.bitcoinj.wallet.Wallet.fromWatchingKey(Wallet.java:279) at shen.Test.main(Test.java:32)
String seedCode = "xxxx xxxx xxx xxx";
long creationtime = 1524106204;
DeterministicSeed seed = null;
try {
seed = new DeterministicSeed(seedCode, null, "", creationtime);
} catch (UnreadableWalletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
wallet = Wallet.fromSeed(params, seed);
wallet.getBalance()
I use the above code to import the wallet, get the balance of the wallet, but the balance of the wallet is empty, and the address of this wallet is not 0 in the other purse tools. Why
I'm experiencing problems with the tx.getFee()
method. Some times works fine but others just returns 0.0 when actually the fees are higher than that.
I haven't been able to find a pattern with the transactions causing the issues. Some examples:
Any hypothesis about what could be causing the this random issue?
hi:
how can i sign bch txs offline with this library?
Can you give me a demo?
Now it's impossible to use this module with bitcoinj in one project due the package name conflict, this is very inconvenient.
I have a problem:
org.bitcoinj.core.RejectedTransactionException: Reject: tx for reason 'mandatory-script-verify-flag-failed (Signature must use SIGHASH_FORKID)' (16)
at org.bitcoinj.core.TransactionBroadcast$2.onPreMessageReceived(TransactionBroadcast.java:102) [bitcoincashj-core-0.14.5-SNAPSHOT.jar:?]
at org.bitcoinj.core.Peer.processMessage(Peer.java:461) [bitcoincashj-core-0.14.5-SNAPSHOT.jar:?]
at org.bitcoinj.core.PeerSocketHandler.receiveBytes(PeerSocketHandler.java:182) [bitcoincashj-core-0.14.5-SNAPSHOT.jar:?]
at org.bitcoinj.net.ConnectionHandler.handleKey(ConnectionHandler.java:223) [bitcoincashj-core-0.14.5-SNAPSHOT.jar:?]
at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:86) [bitcoincashj-core-0.14.5-SNAPSHOT.jar:?]
at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122) [bitcoincashj-core-0.14.5-SNAPSHOT.jar:?]
at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:60) [guava-18.0.jar:?]
at com.google.common.util.concurrent.Callables$3.run(Callables.java:95) [guava-18.0.jar:?]
at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:49) [bitcoincashj-core-0.14.5-SNAPSHOT.jar:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_73]
2017-12-13 07:40:24 ERROR Peer [514]-[119.23.160.146]:8333 /Bitcoin ABC:0.16.1(EB8.0)/: Received Reject
merge any relevant updates from BTC BitcoinJ into our cash branch
refer to bitcoinj.org issue: 1477
Compiling using JDK 9 yields the following error:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/user/bitcoinj/core/src/main/java/org/bitcoinj/store/WindowsMMapHack.java:[34,9] cannot find symbol
symbol: class Cleaner
location: class org.bitcoinj.store.WindowsMMapHack
In JDK 9 the Cleaner the sun.mic.Cleaner class was removed.
use JDK 8 or lower.
Taken from javadoc of org.bitcoinj.store.WindowsMMapHack
:
This class knows how to force an mmap'd ByteBuffer to reliquish its file handles before it becomes garbage collected,
by exploiting implementation details of the HotSpot JVM implementation.This is required on Windows because otherwise an attempt to delete a file that is still mmapped will fail. This can happen when a user requests a "restore from seed" function, which involves deleting and recreating the chain file. At some point we should stop using mmap in SPVBlockStore and we can then delete this class.
It is a separate class to avoid hitting unknown imports when running on other JVMs
The specific java bug is marked as a won't fix
Suggest we look at alternatives to MappedByteBuffers or an alternative (API supported) means of explicitly releasing the memory mapping.
As you know, Bitcoin Cash dropped the legacy RBF protocol in order to simplify 0-conf payments. Still not 100% secure since a rival could try different attacks that I personally consider very unlikely, but just my opinion (we can discuss about it if required).
The different Bitcoin Cash wallet, should consider this feature to provide the best user experience. In the future, we should stop using "confirmations" as a common word for payments. To go mainstream we need people and merchants to stop caring about confirmations, they just need to pay done. Does people care about the technical details when they pay using Visa? Not at all.
Since we have a technology that allow us to work this way, I think we should start taking the most from Bitcoin Cash. If we all are integrating 0-conf in our wallets, add this feature to the Bitcoinj-cash library is the way to go: each wallet don't need to reinvent the wheel + we standardise the algorithm to do it.
Just following some comments from Satoshi: https://bitcointalk.org/index.php?topic=423.msg3819#msg3819 and https://bitcointalk.org/index.php?topic=532.msg6306#msg6306.
In the big picture we need to:
As far as I understand, this is could be an algorithm to process 0-conf payments, opened to changes, for sure:
Notice any of this parameters could be tuned, depending of the considerations of each wallet. If this is becoming standard, should be flexible enough.
Pending question: what to do in case we find a double-spend after we broadcast?
As the original bitcoinj project works over Bitcoin Core, and it includes the RBF feature obviously it doesn't consider any of the previous points.
Correct me if I'm wrong but when you include a broadcast transaction listener, it's only invoked if the transaction is accepted by a node, but you can't notice if any node rejects it. This node rejection message remains totally hidden, what makes the previous algorithm a little bit tricky. https://github.com/bitcoinj-cash/bitcoinj/blob/cash-0.14/core/src/main/java/org/bitcoinj/core/TransactionBroadcast.java#L91
Provide a solution to have all the required events over the transactions is a must to implement the a 0-conf algorithm.
TransactionBroadcaster
https://github.com/bitcoinj-cash/bitcoinj/blob/cash-0.14/core/src/main/java/org/bitcoinj/core/TransactionBroadcaster.java that performs this new logic.broadcastTransaction
method to include a kind of listener to notify the response:public TransactionBroadcast broadcastTransaction(Transaction tx, int minConnections)
public TransactionBroadcast broadcastTransaction(Transaction tx, int minConnections, BroadcastTransactionListener listener)
BroadcastTransactionListener
. For instance: public interface BroadcastTransactionListener{
void onBroadcastSuccess(Transaction tx);
void onDoubleSpendReceived(Transaction broadcasted, Transaction received);
void onProgress(int totalBroadcasts, int target);
}
What is your view for this? Many points to discuss, so please just let out any insight or comment you have.
Regards,
bitcoincashorg/bitcoincash.org#94
This pull request list coming proposed changes for Bitcoin Cash.
The file pki_test.bitcoinpaymentrequest
contains a certificate that expired on February 27. It is associated with www.bitcoincore.org
. For now we could simply ignore this test.
java.security.cert.CertificateExpiredException: NotAfter: Tue Feb 27 15:59:59 PST 2018
Full Details:
org.bitcoinj.protocols.payments.PaymentProtocolException$PkiVerificationException: java.security.cert.CertPathValidatorException: timestamp check failed
at org.bitcoinj.protocols.payments.PaymentProtocol.verifyPaymentRequestPki(PaymentProtocol.java:236)
at org.bitcoinj.protocols.payments.PaymentSessionTest.testPkiVerification(PaymentSessionTest.java:128)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.security.cert.CertPathValidatorException: timestamp check failed
at sun.security.provider.certpath.PKIXMasterCertPathValidator.validate(PKIXMasterCertPathValidator.java:135)
at sun.security.provider.certpath.PKIXCertPathValidator.validate(PKIXCertPathValidator.java:219)
at sun.security.provider.certpath.PKIXCertPathValidator.validate(PKIXCertPathValidator.java:140)
at sun.security.provider.certpath.PKIXCertPathValidator.engineValidate(PKIXCertPathValidator.java:79)
at java.security.cert.CertPathValidator.validate(CertPathValidator.java:292)
at org.bitcoinj.protocols.payments.PaymentProtocol.verifyPaymentRequestPki(PaymentProtocol.java:201)
... 32 more
Caused by: java.security.cert.CertificateExpiredException: NotAfter: Tue Feb 27 15:59:59 PST 2018
at sun.security.x509.CertificateValidity.valid(CertificateValidity.java:274)
at sun.security.x509.X509CertImpl.checkValidity(X509CertImpl.java:629)
at sun.security.provider.certpath.BasicChecker.verifyTimestamp(BasicChecker.java:190)
at sun.security.provider.certpath.BasicChecker.check(BasicChecker.java:144)
at sun.security.provider.certpath.PKIXMasterCertPathValidator.validate(PKIXMasterCertPathValidator.java:125)
... 37 more
Hello
I've developing some bitcoin cash wallet app on android with this bitcoinj.cash library.
I've some problems with restoring wallet from seed.
I restored wallet I had created in other wallet app (handcash) and there are some BCH.
but restored wallet shows always has a zero balance.
If I send some bch to this newly restored wallet, It will be displayed as successful and it will be displayed with another wallet app(handcash) that I already have.
The newly restored wallet only shows transactions that occurred after it was restored....
how can I fix this issue?
here is the code that i've tried
NetworkParameters parameters = null;
if(walletAppKit == null || !walletAppKit.isRunning()) {
if(BuildConfig.MAINNET)
parameters = MainNetParams.get();
else
parameters = TestNet3Params.get();
File walletDir = getFilesDir();
walletAppKit = new WalletAppKit(parameters, walletDir, WALLET_NAME) {
@Override
protected void onSetupCompleted() {
wallet().allowSpendingUnconfirmedTransactions();;
wallet().addCoinsReceivedEventListener(BitcoinService.this);
wallet().addCoinsSentEventListener(BitcoinService.this);
walletAppKit.setDownloadListener(new DownloadProgressTracker() {
@Override
protected void progress(double pct, int blocksSoFar, Date date) {
super.progress(pct, blocksSoFar, date);
// progressing....
}
});
}
};
walletAppKit.setBlockingStartup(false);
walletAppKit.setAutoSave(true);
walletAppKit.setUserAgent(getString(R.string.app_name), BuildConfig.VERSION_NAME);
if (mnemonicCode != null) {
try {
DeterministicSeed seed = new DeterministicSeed(mnemonicCode, null, "", MnemonicCode.BIP39_STANDARDISATION_TIME_SECS);
walletAppKit.restoreWalletFromSeed(seed);
} catch (UnreadableWalletException e) {
e.printStackTrace();
}
}
}
walletAppKit.startAsync();
}
[ERROR] Errors:
[ERROR] BIP38PrivateKeyTest.badPassphrase » Unexpected exception, expected<org.bitcoi...
[ERROR] BIP38PrivateKeyTest.bip38testvector_compression_noEcMultiply_test1:75 » Runtime
[ERROR] BIP38PrivateKeyTest.bip38testvector_compression_noEcMultiply_test2:84 » Runtime
[ERROR] BIP38PrivateKeyTest.bip38testvector_ecMultiply_noCompression_lotAndSequence_test1:111 » Runtime
[ERROR] BIP38PrivateKeyTest.bip38testvector_ecMultiply_noCompression_lotAndSequence_test2:120 » Runtime
[ERROR] BIP38PrivateKeyTest.bip38testvector_ecMultiply_noCompression_noLotAndSequence_test1:93 » Runtime
[ERROR] BIP38PrivateKeyTest.bip38testvector_ecMultiply_noCompression_noLotAndSequence_test2:102 » Runtime
[ERROR] BIP38PrivateKeyTest.bip38testvector_noCompression_noEcMultiply_test1:42 » Runtime
[ERROR] BIP38PrivateKeyTest.bip38testvector_noCompression_noEcMultiply_test2:51 » Runtime
[ERROR] BIP38PrivateKeyTest.bip38testvector_noCompression_noEcMultiply_test3:66 » Runtime
[ERROR] BIP38PrivateKeyTest.bitaddress_testnet:140 » Runtime java.security.InvalidKeyE...
[ERROR] BIP38PrivateKeyTest.bitcoinpaperwallet_testnet:130 » Runtime java.security.Inv...
OS
Mac 10.13.4
Command using
mvn clean package
I get this error when I build the JAR - mvn clean package -DskipTests
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.10.2:jar (attach-javadocs) on project bitcoinj-core: MavenReportException: Error while creating archive:
I have to add the <skip>
to the pom.xml
configuration to successfully build the JAR.
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<notimestamp>true</notimestamp>
<skip>true</skip>
</configuration>
</plugin>
Should this plugin be removed?
https://www.blocktrail.com/tBCC/address/mnzWQVW2iwgNccCW9VgfuW94PuK1vL17uV
Account balances are adequate, and transfers always indicate insufficient balance. The balance found through the import wallet is also correct. Why?
org.bitcoinj.core.InsufficientMoneyException: Insufficient money, missing 0.01001546 BCH
The payment channel implementation in bitcoinj-cash is outdated, I dont recommend using it.
I'm willing to update it, but its not a high priority at the moment. If you actually want to use it, let me know here.
Currently on the bitcoin cash network, 1 sat/byte fees are going through no problem. Transactions in bitcoinj, however, have an "ensuredMinRequiredFee" option that makes the minimum TOTAL fee be 1000 satoshis, which is usually about 4-5 satoshis per byte (outrageous!) So it needs to be default for the min fee to be much lower, perhaps even 0, as we move towards reinstating zero fee transactions in the future.
This is the code that I made. Is there anything to correct?
public void send(String toAddress , String amount)
{
try {
SendRequest request = SendRequest.to(Address.fromBase58(getMainNetNetwork(), toAddress), Coin.parseCoin(amount));
kit.wallet().completeTx(request);
kit.wallet().commitTx(request.tx);
kit.peerGroup().broadcastTransaction(request.tx).broadcast();
} catch (InsufficientMoneyException e) {
e.printStackTrace();
}
}
hi:
how can i use this library in android studio?
thank you very much
When wallet_tool syncs the blockchain from scratch, it automatically uses checkpoints to skip ahead in the chain and sync faster.
However, for testing purposes, it would be nice to be able to skip this feature and sync from the beginning of the chain.
I have noticed you can't use multiple outputs in a SendRequest
using the emptyWallet option. I understand this makes sense when this outputs have a value but, what happens if the output is an OP_RETURN? Why should't be correct create an emptyWallet request including an OP_RETURN?
This is line I'm referring to: https://github.com/bitcoinj-cash/bitcoinj/blob/cash-0.14/core/src/main/java/org/bitcoinj/wallet/Wallet.java#L3986
Not sure if this is a bug or I'm missing any consideration.
hi:
how can i export jar with this library ? i want to use this library in my android project.
but cause a problem : Error:Program type already present: org.spongycastle.asn1.ASN1Choice
I'm trying to send coins, getting transaction id but it isn't sending. My code is that:
Address address = Address.fromBase58(params, coldWalletAddress.getAddress());
SendRequest req = SendRequest.to(address, Coin.parseCoin("0.001"));
req.feePerKb = Coin.parseCoin("0.0005");
org.bitcoinj.wallet.Wallet.SendResult result = getBitcoin().wallet().sendCoins(getBitcoin().peerGroup(), req);
result.broadcastComplete.addListener(new Runnable() {
@Override
public void run() {
System.out.println("=========================================================================");
System.out.println("Sent coins onwards! Transaction hash is " + result.tx.getHashAsString());
}
}, Executors.newSingleThreadExecutor());
Transaction createdTx = result.tx;
This is the log output:
14:49:34,995 INFO (Context.java:57) Creating bitcoinj 0.14.5.2 context.
14:49:34,997 DEBUG (BitcoinCash.java:267) USE_TEST_NET: true
14:49:35,184 INFO (PeerGroup.java:584) Waiting 7021 msec before next connect attempt to [37.233.101.121]:18333
14:49:35,923 INFO (PeerGroup.java:584) Waiting 6283 msec before next connect attempt to [207.154.196.149]:18333
14:49:35,956 INFO (Wallet.java:3942) Completing send tx with 1 outputs totalling 0.001 BCH and a fee of 0.0005 BCH/kB
14:49:35,958 INFO (PeerGroup.java:584) Waiting 6247 msec before next connect attempt to [37.233.101.121]:18333
14:49:35,963 INFO (Wallet.java:4004) with 0.9988875 BCH change
14:49:35,969 INFO (PeerGroup.java:584) Waiting 6236 msec before next connect attempt to [207.154.196.149]:18333
14:49:35,982 INFO (Secp256k1Context.java:41) java.lang.UnsatisfiedLinkError: no secp256k1 in java.library.path
14:49:36,001 INFO (Wallet.java:4032) completed: 4c83d41c3165751653a648f052a147852aa47366e7400a4e588d3c1f6146cc08
in PUSHDATA(71)[304402206fa1e6e40a263f2d246bffa5c4a13a8b91e89aa72005b1b4ae61b80d4c93fba802206ec992bb68c8eb1f7085bc8118ec009cf8cb71f50387fa58494d9311e79bd01401] PUSHDATA(33)[0272648a92005246706af0dc6ec056bcb9ec04109d47e6344229e6f7101c8887cd] 1.00 BCH
outpoint:a5ccc778a9e2d37918a7964315f47eecce30f5197f26f474bba3f7a9485db9a1:0 hash160:91635d9041bed11fd7a2b22d02ffa65c65bef3ed
out DUP HASH160 PUSHDATA(20)[c6291ec82cf47ab0c6c42c99f8755685fcb6a956] EQUALVERIFY CHECKSIG 0.9988875 BCH
out HASH160 PUSHDATA(20)[33c8b68d882ac1293cd01812dd9812ccf020db87] EQUAL 0.001 BCH
fee 0.00050448 BCH/kB, 0.0001125 BCH for 223 bytes
prps USER_PAYMENT
14:49:36,001 INFO (Wallet.java:2407) commitTx of 4c83d41c3165751653a648f052a147852aa47366e7400a4e588d3c1f6146cc08
14:49:36,003 INFO (Wallet.java:2276) marked a5ccc778a9e2d37918a7964315f47eecce30f5197f26f474bba3f7a9485db9a1:0 as spent by 4c83d41c3165751653a648f052a147852aa47366e7400a4e588d3c1f6146cc08
14:49:36,003 INFO (Wallet.java:2382) a5ccc778a9e2d37918a7964315f47eecce30f5197f26f474bba3f7a9485db9a1 prevtx <-unspent ->spent
14:49:36,004 INFO (Wallet.java:2450) ->pending: 4c83d41c3165751653a648f052a147852aa47366e7400a4e588d3c1f6146cc08
14:49:36,005 INFO (Wallet.java:2456) Estimated balance is now: 52.48872515 BCH
14:49:36,007 INFO (KeyChainGroup.java:411) Marking key as used: DeterministicKey{pub=02cb2891ed191020ef9f9812a94d23554e9fc5b7482ebc8f73ebaef6651dabb4aa, chainCode=bc1fdbedbce2f0285ef512aa8638f09c1ef46a14cbc2e7bf52f34a1e46c6a805, path=M/0H/1/8, isEncrypted=false, isPubKeyOnly=false}
14:49:36,013 ERROR (Context.java:105) Performing thread fixup: you are accessing bitcoinj via a thread that has not had any context set on it.
14:49:36,014 ERROR (Context.java:106) This error has been corrected for, but doing this makes your app less robust.
14:49:36,014 ERROR (Context.java:107) You should use Context.propagate() or a ContextPropagatingThreadFactory.
14:49:36,015 ERROR (Context.java:108) Please refer to the user guide for more information about this.
14:49:36,015 ERROR (Context.java:109) Thread name is bitcoinj user thread.
14:49:36,015 INFO (WalletFiles.java:117) Saving wallet; last seen block is height 1221001, date 2018-03-23T12:46:15Z, hash 0000000017aab6850d8a1535b162fcfbf9fef45b8d885324ef7d0789dedcc50a
14:49:36,108 INFO (WalletFiles.java:134) Save completed in 92.50 ms
I'm getting transaction id and trying to check from blocktrail but not found:
https://www.blocktrail.com/tBCC/tx/4c83d41c3165751653a648f052a147852aa47366e7400a4e588d3c1f6146cc08
Do you have any idea? Thanks.
Is it possible to make scriptPubkey by using the bitcoincashj if address p(address 3 in bitcoin) is in input, like the picture above?
I coded like a code below, progressed a signdRawtransaction and found the error saying "script evaluated without error but finished with a false/empty top stack element". Is there any solution?
in.setScriptSig(script);
Sha256Hash sigHash = tx.hashForSignatureWitness(i, in.getScriptSig(), Coin.valueOf(preValue), Transaction.SigHash.ALL, false);
ECKey.ECDSASignature ecdsaSignature = key.sign(sigHash);
TransactionSignature txSignature = new TransactionSignature(ecdsaSignature, Transaction.SigHash.ALL, false, true);
tx.getInput(i).setScriptSig(ScriptBuilder.createInputScript(txSignature, key));
WalletAppKit kit = new WalletAppKit(params, new File("/tmp/test_address3"), "PRE_FIX_address3") {
@Override
protected void onSetupCompleted() {
if (wallet().getKeyChainGroupSize() < 1) {
String seedCode = "music luggage more pizza peasant family seminar meat solid trust uncover learn";
DeterministicSeed seed = null;
long creationtime = 1524600058l;
try {
seed = new DeterministicSeed(seedCode, null, "", creationtime);
} catch (UnreadableWalletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
restoreWalletFromSeed(seed);
}
}
@Override
public PeerGroup peerGroup() {
// TODO Auto-generated method stub
PeerGroup peerGroup = null;
try {
FullPrunedBlockStore store = new H2FullPrunedBlockStore(this.params, "bch_test3", 1000);
FullPrunedBlockChain vChain = new FullPrunedBlockChain(this.params, store);
peerGroup = new PeerGroup(this.params, vChain);
peerGroup.setFastCatchupTimeSecs(this.wallet().getEarliestKeyCreationTime());
peerGroup.addPeerDiscovery(new DnsDiscovery(this.params));
// peerGroup.downloadBlockChain();
} catch (BlockStoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("peergroup error"+e);
}
return peerGroup;
}
};
if (params == RegTestParams.get()) {
kit.connectToLocalHost();
}
kit.startAsync();
kit.awaitRunning();
kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
@Override
public void onCoinsReceived(Wallet w, Transaction tx, Coin prevBalance, Coin newBalance) {
Coin value = tx.getValueSentToMe(w);
System.out.println("Received tx for " + value.toFriendlyString() + ": " + tx);
System.out.println("Transaction will be forwarded after it confirms.");
Futures.addCallback(tx.getConfidence().getDepthFuture(1), new FutureCallback<TransactionConfidence>() {
@Override
public void onSuccess(TransactionConfidence result) {
// "result" here is the same as "tx" above, but we use it anyway for clarity.
// forwardCoins(result);
System.out.println(result.toString());
}
@Override
public void onFailure(Throwable t) {
}
});
}
});
Address targetAddress = new Address(params, "mgRoeWs2CeCEuqQmNfhJjnpX8YvtPACmCX");
Script script = new ScriptBuilder().op(ScriptOpCodes.OP_RETURN).data("my message mango ".getBytes()).build();
Wallet wallet = kit.wallet();
Transaction tx = new Transaction(params);
tx.addOutput(Coin.CENT, targetAddress);
tx.addOutput(Coin.CENT, script);
System.out.println(kit.wallet().toString());
SendResult sr = wallet.sendCoins(SendRequest.forTx(tx));
Transaction trans = sr.broadcastComplete.get();// future.get();
System.out.println(trans.toString());
System.out.println("hashAsString:" + trans.getHashAsString());
The above is my code, I use TestNet to transfer to my wallet address mhCHrjrvtjnv1of8EN6ffGUe1iazeQUc7i, and then when the code is executed again, the balance of the wallet is rich, but when I turn out, the account balance is insufficient and the wallet information has several addresses. How should I make it correct Transfer your wallet with your wallet? Is there any problem with my code? Thank you very much. The following is the log:
Wallet containing 6.47998695 BCH (spendable: 0.00 BCH) in:
1 pending transactions
0 unspent transactions
1 spent transactions
0 dead transactions
Last seen best block: 1228736 (2018-04-24T20:27:32Z): 00000000cd7385aa71e6a3fce425cd496bf70d3aac7d6b425945280b8cd92f63
Keys:
Earliest creation time: 2018-04-24T20:00:58Z
Seed birthday: 1524600058 [2018-04-24T20:00:58Z]
Key to watch: tpubD8rSayx3h35cfkWLBBMv7PGNQK2PaQ6LQptDXoQD3mAtgR3WsxbKDQ1nHfNcELKAEB1qyrvZoAn6e45pHDwEDgtTRC8MWjj9i7PXGQiSbus
addr:mhCHrjrvtjnv1of8EN6ffGUe1iazeQUc7i hash160:1268addaddf7b27eb9882b0e8a55ac6047dcbb28 (M/0H/0/0)
addr:mxiqQTd759U8taPsEZQy8YZYz46GNvqqHF hash160:bcb960f611b0e3b92d76606d10df9efc7ea33c6d (M/0H/0/1)
addr:mfiw2BdhH49DRkHYVD1duYrSMGExS2poAN hash160:0243edaa30bf9ddb8ba876c4ba8b5440432cf2d1 (M/0H/1/0)
addr:mzEK14E6ZNLWGdLj5dwbucKWTrT5Nedsgv hash160:cd449a9422484f650a61dcd3dce6d2c3b71c8470 (M/0H/1/1)
PENDING:
-0.02001305 BCH total value (sends 6.50 BCH and receives 6.47998695 BCH)
confidence: Pending/unconfirmed. Source: SELF
be7d834a0192d0ab481b075da112050ec25b5441b0c023dcfb40a3c06f818a64
updated: 2018-04-24T20:12:07Z
in PUSHDATA(72)[30450221008a042127ba3a7476c70a40e4e5b2b9f7937c361d8645a124b43ac8efb8c4667602203274ea4d5ce302bda4a066379959e74904efbcb3bf6fa18f4fcf31f884d3031e01] PUSHDATA(33)[02df634709ebc833aebb71b2b12d7fd58950953f02292e1721ef15e7828f085c31] 6.50 BCH
outpoint:a9d8ad9c9ec346049063c512cff98d3d86c138d2e0b5f8bbde9eb395dff450a4:0 hash160:1268addaddf7b27eb9882b0e8a55ac6047dcbb28
out RETURN PUSHDATA(23)[6d79206d657373616765206d616e676f20e4b8ade69687] 0.01 BCH
out DUP HASH160 PUSHDATA(20)[0243edaa30bf9ddb8ba876c4ba8b5440432cf2d1] EQUALVERIFY CHECKSIG 6.47998695 BCH
out DUP HASH160 PUSHDATA(20)[09fed3e08e624b23dbbacc77f7b2a39998351a68] EQUALVERIFY CHECKSIG 0.01 BCH
fee 0.00005019 BCH/kB, 0.00001305 BCH for 260 bytes
prps USER_PAYMENT
SPENT:
6.50 BCH total value (sends 0.00 BCH and receives 6.50 BCH)
confidence: Appeared in best chain at height 1228735, depth 2. Source: NETWORK
a9d8ad9c9ec346049063c512cff98d3d86c138d2e0b5f8bbde9eb395dff450a4
updated: 2018-04-24T20:07:15Z
in PUSHDATA(72)[3045022100b46976d3427f7cc729b36aef98628ab2e731eff81574504c4b8ce53cf763a987022051870d329fda052f1d722daf4476b9f0a655395cdffd9ad7f4c9b7df66afb14b41] PUSHDATA(33)[022ced4fa5bbdfdb8b4bd3ff84822ebb69178d2622af4eb9c0300e4b164092fd5e]
outpoint:5f42d029c1b6611865f3f0e0c8880c57b9f5c06323e99cdda6e87bea542f53fa:1
out DUP HASH160 PUSHDATA(20)[1268addaddf7b27eb9882b0e8a55ac6047dcbb28] EQUALVERIFY CHECKSIG 6.50 BCH Spent by be7d834a0192d0ab481b075da112050ec25b5441b0c023dcfb40a3c06f818a64
out DUP HASH160 PUSHDATA(20)[04ee9419a1c5d35402b349edeb497192c0b26fb1] EQUALVERIFY CHECKSIG 711.55342792 BCH
prps UNKNOWN
Apr 25, 2018 4:32:39 AM org.bitcoinj.wallet.Wallet completeTx
信息: Completing send tx with 2 outputs totalling 0.02 BCH and a fee of 0.00005 BCH/kB
Apr 25, 2018 4:32:39 AM org.bitcoinj.wallet.Wallet calculateFee
警告: Insufficient value in wallet for send: needed 0.02001 BCH more
Exception in thread "main" org.bitcoinj.core.InsufficientMoneyException: Insufficient money, missing 0.02001 BCH
at org.bitcoinj.wallet.Wallet.calculateFee(Wallet.java:4970)
at org.bitcoinj.wallet.Wallet.completeTx(Wallet.java:3979)
at org.bitcoinj.wallet.Wallet.sendCoinsOffline(Wallet.java:3767)
at org.bitcoinj.wallet.Wallet.sendCoins(Wallet.java:3840)
at org.bitcoinj.wallet.Wallet.sendCoins(Wallet.java:3870)
at com.btc.api.test.demo.WalletAppKitTest.main(WalletAppKitTest.java:125)
This is a transfer record:https://www.blocktrail.com/tBCC/tx/a9d8ad9c9ec346049063c512cff98d3d86c138d2e0b5f8bbde9eb395dff450a4
Hi, it would be useful to know the history of the fork from bitcoinj, like is cash branched out from 0.14 or master?
NetworkParameters networkParameters = TestNet3Params.get();
String toAddress = "mhxZtz7af5DfFhSggJxnzhvzfD67d59XCZ";
String privateKey = "cRDZN9LKkMarsPCS9ZQy7uQobqUyEf6VJt9DKj8UnQa2Zb921FEQ";
DumpedPrivateKey dumpedPrivateKey2 = DumpedPrivateKey.fromBase58(networkParameters, privateKey);
ECKey ecKey2 = dumpedPrivateKey2.getKey();
Address legacyAddress = ecKey2.toAddress(networkParameters);
BigDecimal amountOfSatoshis = new BigDecimal("65300000");
BigDecimal utxoAmount = BigDecimal.ZERO;
BigDecimal fee = new BigDecimal("19191");
//找零钱
BigDecimal changeAmount;
Transaction transaction = new Transaction(networkParameters, 2);
transaction.setVersion(Transaction.FORKID_VERSION);
List<LTCUTXO> needUtxos = new ArrayList<LTCUTXO>();
transaction.addOutput(Coin.valueOf(amountOfSatoshis.longValue()), Address.fromBase58(networkParameters, toAddress));
changeAmount = utxoAmount.subtract(amountOfSatoshis.add(fee));
if (changeAmount.compareTo(BigDecimal.ZERO) > 0) {
transaction.addOutput(Coin.valueOf(changeAmount.longValue()), ecKey2);
}
TransactionOutPoint transactionOutPoint = new TransactionOutPoint(networkParameters, 1L, Sha256Hash.wrap("f706d2307b08020280051451696f19fc12aa2a72a1d20239883926a3785b0131"));
//key point
transaction.addSignedInput(transactionOutPoint, Coin.parseCoin("65319191"), new Script(Hex.decode("76a914a92fb7ea024aa1098cf41710d536345f85c43c9e88ac")), ecKey2, Transaction.SigHash.ALL, true, true);
byte[] bytes = transaction.bitcoinSerialize();
String sigendTransacitonHash = Hex.toHexString(bytes);
System.out.println(sigendTransacitonHash);
output code
020000000131015b78a32639883902d2a1722aaa12fc196f69511405800202087b30d206f7010000006b483045022100a70c271edf6a8a9158759db0662b5b370b28adaa7f754f3ed02e98a9d396f1c202202376abd5598930f82a9ac3e2baf8858d99794a7775d91503de80278a526b527dc1210341eeed3dee65432a52799d97369ee7866e5fa7bf37ec4754366025b815002e46ffffffff012066e403000000001976a9141ac85eb102de6fe31196615d105828648ecb00c688ac00000000
but I broadcast get errors
https://test-bch-insight.bitpay.com/
An error occurred: 16: mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation). Code:-26
Please help me. I've wasted three days on this problem.
It was pointed out to me that my Bitcoin Cash Wallet app (for testnet) gets stuck at the November 13 hard fork.
In my bitcoincashj library, the difficulty adjustment algorithm for testnet does not work correctly. Since this library is based my library, then bitcoinj-cash probably has the same problem. I will work on a solution and submit it in the next week or so.
I don't see a way to make an Address object from a bech32 address.
Ideally there would also be a method to get an address without caring which format it is in.
And a way to convert an address into a bech32 string.
I can add this but probably won't get to it for a while.
Error handling SelectionKey: java.nio.channels.CancelledKeyException
java.nio.channels.CancelledKeyException
at sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:73)
at sun.nio.ch.SelectionKeyImpl.readyOps(SelectionKeyImpl.java:87)
at java.nio.channels.SelectionKey.isWritable(SelectionKey.java:312)
at org.bitcoinj.net.ConnectionHandler.handleKey(ConnectionHandler.java:229)
at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:86)
at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:60)
at com.google.common.util.concurrent.Callables$3.run(Callables.java:95)
at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:49)
at java.lang.Thread.run(Thread.java:745)
https://github.com/Bitcoin-ABC/bitcoin-abc/blob/master/doc/release-notes.md
At the MTP time of 1526400000 (Tue May 15 12:00:00 UTC, 2018) the following behaviors will change:
Sometimes I cannot broadcast pending transactions because active peers size won't be larger than the value returned by PeerGroup#getMinBroadcastTransacions.
So, I want to call PeerGroup#setMinBroadcastTransactions before broadcasting pending transactions on startup...
I've been working on a small project with bitcoinj cash (great work by the way). Recently I tried to build it and got this error:
INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113
I found this post on stackoverflow dealing with a previous version of bitcoinj:
In this issue, excluding the 'scrypt' module from bitcoinj got rid of this error, and it also worked for me. I'm interested if anyone else has this issue building for Android, and how they fixed it. In the post, they recommend switching to org.spongycastle.crypto.generators.SCrypt. If there's an easier way to fix this, that's great, but it might be worth looking into migrating to spongycastle's implementation.
While loading blk files before 2017.8.1, org.bitcoinj.utils.BlockFileLoader#loadNextBlock does not work well.
It looks like that the magic number for block before 2017.8.1 is 0xf9beb4d9L
, instead of 0xe3e1f3e8L
.
I'm receiving coin to my wallet. I can see it as estimated balance. After half hour transaction getting 1 confirmation. It coin is still in estimated. Must it be available but it doesn't. This is my wallet app kit initialization:
context = new Context(this.params);
// If seed is non-null it means we are restoring from backup.
bitcoin = new WalletAppKit(context, new File("./wallets/bitcoincash/"), WALLET_FILE_NAME) {
@Override
protected void onSetupCompleted() {
logger.info("Wallet App Kit setup completed.");
// WARN Don't try to spend unconfirmed transaction. Becouse bitcoinj is bullshit.
// getBitcoin().wallet().allowSpendingUnconfirmedTransactions();
getBitcoin().peerGroup().setMinBroadcastConnections(MIN_PEER_COUNT);
getBitcoin().peerGroup().setMaxConnections(15);
WalletCoinsReceivedEventListener walletCoinsReceivedEventListener = new WalletCoinsReceivedEventListener() {
@Override
public synchronized void onCoinsReceived(org.bitcoinj.wallet.Wallet wallet, Transaction tx, Coin prevBalance,
Coin newBalance) {
try {
if (newBalance.value < prevBalance.value)
return;
Context.propagate(createContext());
logger.debug("txid: " + tx.getHashAsString() );
} catch (Exception e) {
e.printStackTrace();
logger.error(e);
}
}
};
getBitcoin().wallet().addCoinsReceivedEventListener(walletCoinsReceivedEventListener);
TransactionConfidenceEventListener transactionConfidenceEventListener = new TransactionConfidenceEventListener() {
@Override
public synchronized void onTransactionConfidenceChanged(org.bitcoinj.wallet.Wallet wallet, Transaction tx) {
try {
logger.debug("Confirmation: " + tx.getConfidence().getDepthInBlocks());
} catch (Exception e) {
e.printStackTrace();
logger.error(e);
}
}
};
getBitcoin().wallet().addTransactionConfidenceEventListener(transactionConfidenceEventListener);
logger.info("Wallet event listeners added.");
}
};
getBitcoin().setAutoSave(true).setDownloadListener(new BitcoinDownloadProgressTracker()).setBlockingStartup(false)
.setUserAgent(Main.WALLET_FILE_NAME_PREFIX, "1.0");
if (seed != null)
getBitcoin().restoreWalletFromSeed(seed);
if (getBitcoin().isChainFileLocked()) {
logger.error("This application is already running and cannot be started twice.");
System.exit(1);
}
getBitcoin().startAsync();
getBitcoin().awaitRunning();
When I try to get wallet info the result is like that:
{
"currentAddr": "mo4P88sqzNW473XYrQESsjmSDq77Vtx7Lf",
"balance": 0,
"balanceAvailableSpendable": 0,
"balanceEstimated": 2699595500,
"balanceEstimatedSpendable": 2699595500,
"balanceBtc": "0.00 BCH",
"balanceEstimatedBtc": "26.995955 BCH",
"peersCount": 4,
"transactions": [
{
"txid": "7afcc13c6bf48a1130e2f428c434c7ae3effe90ea8d76e520d5d247b66968e64",
"pending": true,
"cached": false,
"coinBase": false
},
{
"txid": "793a1cadec14519891b87b0d728107df2938a246a038a5e62d28de4466fcb169",
"pending": true,
"cached": false,
"coinBase": false
},
{
"txid": "fdc907b8dbc503264daf55c95beff03967e427c95131f5af9b559b12cd9e740b",
"pending": true,
"cached": false,
"coinBase": false
},
{
"txid": "97e36ee4bd7ad7763502099dc449a4230ca3cf1e458db9e258a7c6845a58714e",
"pending": true,
"cached": false,
"coinBase": false
},
{
"txid": "4961b0cf6aca77956199c73ada165b91e4820107e601e422d6a60daf6a510246",
"pending": true,
"cached": false,
"coinBase": false
},
{
"txid": "fee29f42e10e0388b6155e77c9a1c91bf924b4f28631d175d1357edb085f0696",
"pending": true,
"cached": false,
"coinBase": false
},
{
"txid": "6ccbe252c6cce6c95583e8567fb061cbd675e222aa26df47123f3e0f3985a93c",
"pending": true,
"cached": false,
"coinBase": false
},
{
"txid": "2275312fd48c04e55b4817a25dda39b41f0c823185f789ac55e263f88694baef",
"pending": true,
"cached": false,
"coinBase": false
},
{
"txid": "a5b106f7c5efaf494558d57f0ec19d9483c9372784779261ed8402f7eecdeb01",
"pending": true,
"cached": false,
"coinBase": false
},
{
"txid": "e2e4f601a9c5dee3eb0e466b168ddfeb4bca4c86ef546fa6ff14785f426bec56",
"pending": true,
"cached": false,
"coinBase": false
},
{
"txid": "40764acae96919e8ddc31a4a01b2295b3adcb9b2b61669b46fef1b68ea7b46b6",
"pending": true,
"cached": false,
"coinBase": false
}
],
"addresses": [
"mo4P88sqzNW473XYrQESsjmSDq77Vtx7Lf",
"n2mFHsi4fGmsTViJtyd1PPEdWtWBCCy5GC",
"mgCY2PJiu4HqVijPHNUTGZ4Doi78vLpFva"
]
}
This is my incoming transaction: https://www.blocktrail.com/tBCC/tx/97e36ee4bd7ad7763502099dc449a4230ca3cf1e458db9e258a7c6845a58714e
This transaction is increased my estimatedBalance value in first come. When it get one confirmation it must be available but it didn't. Where I'm making mistake? Please help. Thanks.
I'm trying to send a test transaction using Android / Kotlin, and encountered the SIGHASH_FORKID error, but even after using request.setForkId(True) it still doesn't work? Not sure whats going on?
Everything I find out there just says set the flag?
Received Reject: tx for reason 'mandatory-script-verify-flag-failed (Signature must use SIGHASH_FORKID)' (16)
fun send() {
val recipientAddress = "someAddress"
val amount = "0.00001"
val request =
SendRequest.to(Address.fromBase58(MainNetParams.get(), recipientAddress), Coin.parseCoin(amount))
request.setUseForkId(true)
request.feePerKb = Coin.valueOf(1000)
try {
kit.wallet().sendCoins(request)
} catch (e: InsufficientMoneyException) {
e.printStackTrace()
Log.i("TAG", "Error")
}
}
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.