After importing a previously unknown key, you need to rescan the whole
blockchain for any UTXOs that might be relevant. Only after that is
finished you can prepare and sign a spending transaction. That's the
decentralized way to do it.

Alternatively, you could query an external service like a block explorer
or a full node.


On 28/07/2018 07.34, vishnu magar wrote:
> one more thing 
> 
> My goal is to import the private key claim the coins and then send them
> to a different address. but not getting the result using Bitcoinj
> 
> https://github.com/bitcoinj/bitcoinj/blob/7e9c45ad55f9d1b64d058e2ff84f4fb025e4ad67/examples/src/main/java/org/bitcoinj/examples/PrivateKeys.java
> 
> 
> 
> On Fri, Jul 27, 2018 at 3:32 PM, vishnu magar <mgr.v...@gmail.com
> <mailto:mgr.v...@gmail.com>> wrote:
> 
>     Great bro it works
> 
>     On Fri, Jul 27, 2018 at 1:47 PM, Bobby_Bouche <syngr...@gmail.com
>     <mailto:syngr...@gmail.com>> wrote:
> 
>         
> appkit.setDownloadListener(bListener).setBlockingStartup(false).startAsync().awaitRunning();
> 
> 
>         On Friday, July 27, 2018 at 2:07:13 AM UTC-4, vishnu magar wrote:
> 
>             |
> 
>             publicstaticvoidmain(Stringas[])throwsException{
>                 Stringcoin ="BTC";
>                 NetworkParametersparams=MainNetParams.get();
>                 Filedir
>             
> =newFile(Environment.getExternalStorageDirectory().getPath(),"BobApp");
> 
>                 Context.propagate(newContext(params));
>                 System.out.println("Creating new "+coin +" wallet ...");
>                 Log.w("CLAPCLAP","Creating new "+coin +" wallet ...");
>                 WalletAppKitappKit =newWalletAppKit(params,dir,"Bobby-BTC");
> 
>                
>              
>                
>                 DownloadProgressTrackerbListener
>             =newDownloadProgressTracker(){
>                     @Override
>                     publicvoiddoneDownload(){
>                         System.out.println("doneDownload");
>                         Log.w("CLAPCLAP","doneDownload =");
>                     }
> 
>                     @Override
>                    
>             protectedvoidprogress(doublepct,intblocksSoFar,Datedate){
>                         super.progress(pct,blocksSoFar,date);
>                         System.out.println("progress");
>                      
>                     }
> 
>                     @Override
>                    
>             publicvoidonChainDownloadStarted(Peerpeer,intblocksLeft){
>                         super.onChainDownloadStarted(peer,blocksLeft);
>                         System.out.println("onChainDownloadStarted");
>                        
>                     }
> 
>                     @Override
>                    
>             
> publicvoidonBlocksDownloaded(Peerpeer,Blockblock,@NullableFilteredBlockfilteredBlock,intblocksLeft){
>                        
>             super.onBlocksDownloaded(peer,block,filteredBlock,blocksLeft);
>                         System.out.println("onBlocksDownloaded");
>                        
>                     }
> 
>                     @Override
>                     protectedvoidstartDownload(intblocks){
>                         super.startDownload(blocks);
>                         System.out.println("startDownload");
>                        
>                     }
> 
> 
>                 };
> 
>                 appKit.setDownloadListener(bListener);
> 
>              
>                 appKit.startAsync();
>                 appKit.awaitRunning();
> 
> 
>                 while(true){
>                     assert(appKit !=null);
>                     assert(appKit.wallet()!=null);
> 
>                     IntegerlastHeight =-1;
>                     if(appKit.wallet()==null){
>                         System.out.print("Waiting");
>                     }else{
>                         lastHeight
>             =appKit.wallet().getLastBlockSeenHeight();
>                     }
> 
>                     Listpeers =newLinkedList();
>                     if(appKit.peerGroup()==null){
>                         System.out.print("Waiting");
>                  
>                     }else{
>                         peers =appKit.peerGroup().getConnectedPeers();
>                     }
> 
>                     Log.w("CLAPCLAP","BTC Last height: "+lastHeight +"
>             Balance: "+appKit.wallet().getBalance()+" Peers:
>             "+peers.size());
>                     System.out.print("BTC Last height: "+lastHeight +"
>             Balance: "+appKit.wallet().getBalance()+" Peers:
>             "+peers.size());
>                 }
>             }
> 
>             |
> 
>         -- 
>         You received this message because you are subscribed to the
>         Google Groups "bitcoinj" group.
>         To unsubscribe from this group and stop receiving emails from
>         it, send an email to bitcoinj+unsubscr...@googlegroups.com
>         <mailto:bitcoinj+unsubscr...@googlegroups.com>.
>         For more options, visit https://groups.google.com/d/optout
>         <https://groups.google.com/d/optout>.
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "bitcoinj" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to bitcoinj+unsubscr...@googlegroups.com
> <mailto:bitcoinj+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
"bitcoinj" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bitcoinj+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to