Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send coins not working #27

Open
kodmanyagha opened this issue Mar 23, 2018 · 4 comments
Open

Send coins not working #27

kodmanyagha opened this issue Mar 23, 2018 · 4 comments

Comments

@kodmanyagha
Copy link

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.

@kodmanyagha
Copy link
Author

kodmanyagha commented Mar 23, 2018

Probably I found the problem. It's about broadcast connection count. Min peer count must be 10. My peer connection is 3. Library is waiting new peers for broadcast the transaction.

Now I have a question too. My app is working about half hour and connected only 5 peers. Why finding peer process is slow?

16:08:30,387 INFO  (PeerGroup.java:1770) [191.235.87.191]:18333: Peer died      (5 connected, 0 pending, 12 max)
16:08:30,389 WARN  (MultiplexingDiscovery.java:109) Seed testnet-seed.bitcoinunlimited.info: failed to look up: org.bitcoinj.net.discovery.PeerDiscoveryException: java.net.UnknownHostException: testnet-seed.bitcoinunlimited.info

@HashEngineering
Copy link
Collaborator

See issue #17. another developer had the same issue.

@HashEngineering
Copy link
Collaborator

#17 was reopened.

testnet-seed.bitcoinunlimited.info is no longer active. Bitcoin ABC has removed this from their code.

@rafa-js
Copy link

rafa-js commented Mar 27, 2018

You can customise the target number of broadcasts to consider the transaction as "broadcasted".

peerGroup.broadcastTransaction( transaction, MIN_BROADCAST_CONNECTIONS )
                .broadcast()
                .addListener( //Transaction broadcasted here )

I think you got it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants