Bitcoin Forum
April 16, 2024, 06:04:09 AM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to get the number of satoshi using adress?  (Read 109 times)
Sanka555 (OP)
Member
**
Offline Offline

Activity: 96
Merit: 36


View Profile
February 28, 2021, 10:59:57 AM
 #1

Java, Spring,  Eclipce, bitcoinj

I'm trying to get the number of satoshi using the private key.
First I get the address
everything prints it fine.
then I try to find out the amount...


NetworkParameters params = MainNetParams.get();

Wallet wallet = new Wallet(params);
BlockStore blockStore = new MemoryBlockStore(params);
BlockChain chain;
try {
chain = new BlockChain(params, wallet, blockStore);

PeerGroup peerGroup = new PeerGroup(params, chain);
peerGroup.addWallet(wallet);
peerGroup.start();
peerGroup.downloadBlockChain ();

model.addAttribute("balance", wallet.getBalance());


hangs tightly.
How to find out the correct amount on the account? I have a synchronized Core / Can I get it out of it somehow?

thank you very much in any your advices


Quote
2021-02-28 13:00:00.044  INFO 7496 --- [eerGroup Thread] o.bitcoinj.wallet.DeterministicKeyChain  : 133 keys needed for M/0H/0 = 0 issued + 100 lookahead size + 33 lookahead threshold - 0 num children
2021-02-28 13:00:00.145  INFO 7496 --- [eerGroup Thread] o.bitcoinj.wallet.DeterministicKeyChain  : Took 101.2 ms
2021-02-28 13:00:00.146  INFO 7496 --- [eerGroup Thread] o.bitcoinj.wallet.DeterministicKeyChain  : 133 keys needed for M/0H/1 = 0 issued + 100 lookahead size + 33 lookahead threshold - 0 num children
2021-02-28 13:00:00.235  INFO 7496 --- [eerGroup Thread] o.bitcoinj.wallet.DeterministicKeyChain  : Took 88.82 ms
2021-02-28 13:00:00.243  INFO 7496 --- [eerGroup Thread] org.bitcoinj.core.PeerGroup              : Starting ...
2021-02-28 13:00:01.250  INFO 7496 --- [eerGroup Thread] org.bitcoinj.core.PeerGroup              : Localhost peer not detected.
2021-02-28 13:00:01.251  INFO 7496 --- [eerGroup Thread] org.bitcoinj.core.PeerGroup              : Peer discovery took 9.320 μs and returned 0 items
1713247449
Hero Member
*
Offline Offline

Posts: 1713247449

View Profile Personal Message (Offline)

Ignore
1713247449
Reply with quote  #2

1713247449
Report to moderator
1713247449
Hero Member
*
Offline Offline

Posts: 1713247449

View Profile Personal Message (Offline)

Ignore
1713247449
Reply with quote  #2

1713247449
Report to moderator
1713247449
Hero Member
*
Offline Offline

Posts: 1713247449

View Profile Personal Message (Offline)

Ignore
1713247449
Reply with quote  #2

1713247449
Report to moderator
"Your bitcoin is secured in a way that is physically impossible for others to access, no matter for what reason, no matter how good the excuse, no matter a majority of miners, no matter what." -- Greg Maxwell
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713247449
Hero Member
*
Offline Offline

Posts: 1713247449

View Profile Personal Message (Offline)

Ignore
1713247449
Reply with quote  #2

1713247449
Report to moderator
aliashraf
Legendary
*
Offline Offline

Activity: 1456
Merit: 1174

Always remember the cause!


View Profile WWW
February 28, 2021, 08:22:40 PM
Last edit: February 28, 2021, 09:59:08 PM by aliashraf
 #2

You are going the hard way. For bitcoinj, I'd suggest to start with WalletAppKit wrapper, it has already integrated all the components you are trying to synchronize. Just follow the instructions in the document, and you will be fine.

As of your code, I think it fails primarily because of network connectivity or misconfiguration. Actually my first diagnosis is that you have initialized the params object for regtest mode while your machine has not a bitcoind process running on it with -regtest argument.

Note: WalletAppKit, works in SPV mode, and it works fine, bitoinj is not a reliable code base for full mode, however.

Edit:
Also note that the PeerGroup class you are using is a blocking I/O class, what you are experiencing may be a blocked object pulling for I/O rather than a dead program.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!