Re: bitcoinj 0.14.4 : Send coin - get callback in receiveCoin too

2017-07-10 Thread Andreas Schildbach
What you probably see is the received change from your transaction. You
could try creating a transaction without change and see if there is an
onCoinsReceived event too.

Also, as always, study the logfile.


On 07/10/2017 04:51 PM, Kunal Ransing wrote:
> Hi
> 
> When I send coins I got callback in broadcastComplete as well
> as onCoinsReceived.
> 
> I added receive listner as below:
> 
>   // We want to know when we receive money.
>   kit.wallet().*addCoinsReceivedEventListener*(new
> *WalletCoinsReceivedEventListener*() {
>   @Override
>   public void *onCoinsReceived*(Wallet w, final Transaction
> tx, Coin prevBalance, Coin newBalance) {
>   Coin value = tx.getValueSentToMe(w);
>  
>   updateTxResult(tx, value, tx.getConfidence());
>   
>  
> Futures.addCallback(tx.getConfidence().getDepthFuture(6), new
> FutureCallback() {
>   @Override
>   public void onSuccess(TransactionConfidence result) 
>   {
> //Updated tx status to confirm when depth become
> 6 block
>   updateTxResult(tx, value,result);
>   }
> 
>   });
>   }
>   });
> 
> 
> I am sending coin using below method :
>   ...
>   Address to = Address.fromBase58("send-address");
>   SendRequest req = SendRequest.to(to, Coin.parseCoin("0.003"));
>   req.aesKey = kit.wallet().getKeyCrypter().deriveKey("--my_key--");
>   req.memo = msg;
>   Wallet.SendResult result = kit.wallet().sendCoins(req);
>   Transaction btcTx = result.tx;
>   Futures.addCallback(result.*broadcastComplete*, new
> FutureCallback() {
>   @Override
>   public void *onSuccess*(org.bitcoinj.core.Transaction resTx) 
>   {
>   //Send message to core that Mark tx as completed
>   }
> 
>   @Override
>   public void onFailure(Throwable t) {
> LOGGER.log(Level.INFO,"PayConfig_sendCoin: Something went
> wrong !!!",t);
>   }
>   });
>   ...
> 
> When I sent coin 0.003 BTC to my mobile wallet from my backend app, I
> receive 0.000812 BTC(i.e got call in *onCoinsReceivedfor all sent of
> different coin i receive this same amount*)...also got call
> in *onSuccess*  where fees for sending coin is 0.000188 BTC.
> 
> Please help me to understand this ?
> 
> Regards,
> Kunal
> 
> 
> 
> -- 
> 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.


-- 
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.


bitcoinj 0.14.4 : Send coin - get callback in receiveCoin too

2017-07-10 Thread Kunal Ransing
Hi

When I send coins I got callback in broadcastComplete as well 
as onCoinsReceived.

I added receive listner as below:

  // We want to know when we receive money.
  kit.wallet().*addCoinsReceivedEventListener*(new 
*WalletCoinsReceivedEventListener*() {
  @Override
  public void *onCoinsReceived*(Wallet w, final Transaction tx, 
Coin prevBalance, Coin newBalance) {
  Coin value = tx.getValueSentToMe(w);
 
  updateTxResult(tx, value, tx.getConfidence());
  
  Futures.addCallback(tx.getConfidence().getDepthFuture(6), 
new FutureCallback() {
  @Override
  public void onSuccess(TransactionConfidence result) 
  {
//Updated tx status to confirm when depth become 6 
block
  updateTxResult(tx, value,result);
  }

  });
  }
  });


I am sending coin using below method :
  ...
  Address to = Address.fromBase58("send-address");
  SendRequest req = SendRequest.to(to, Coin.parseCoin("0.003"));
  req.aesKey = kit.wallet().getKeyCrypter().deriveKey("--my_key--");
  req.memo = msg;
  Wallet.SendResult result = kit.wallet().sendCoins(req);
  Transaction btcTx = result.tx;
  Futures.addCallback(result.*broadcastComplete*, new 
FutureCallback() {
  @Override
  public void *onSuccess*(org.bitcoinj.core.Transaction resTx) 
  {
  //Send message to core that Mark tx as completed
  }

  @Override
  public void onFailure(Throwable t) {
LOGGER.log(Level.INFO,"PayConfig_sendCoin: Something went wrong 
!!!",t);
  }
  });
  ...

When I sent coin 0.003 BTC to my mobile wallet from my backend app, I 
receive 0.000812 BTC(i.e got call in *onCoinsReceivedfor all sent of 
different coin i receive this same amount*)...also got call in *onSuccess*  
where fees for sending coin is 0.000188 BTC.

Please help me to understand this ?

Regards,
Kunal



-- 
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.