Bitcoin Forum
October 02, 2024, 08:30:54 PM *
News: Latest Bitcoin Core release: 27.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to increase feePerKb using bitcoinj api  (Read 667 times)
emeraldsoft (OP)
Newbie
*
Offline Offline

Activity: 1
Merit: 0


View Profile
April 14, 2017, 05:41:10 AM
 #1

Hi, I am fairly new to android/java bitcoin development.
I have been given a task by my client to increase the bitcoin transaction fees in his wallet program so that transactions are approved quicker.
he is using bitcoinj api. the current miners fee is 50000/kb mBTC (0.0005) BTC / kb while I want to make it as 100000 mBTC per kb.


here is the code for send request:-

public Map sendCoin(String fid,String address,String coin1,String coin2){
    Map rm=new HashMap();
    WalletAppKit appKit=wallets.get(fid);
    if(appKit!=null){
        Coin c1=Coin.parseCoin(coin1);
        Coin c2=Coin.parseCoin(coin2);
        SendRequest req,req1;
        try {
            Transaction tx = new Transaction(createBitcoinNetwork());
            tx.addOutput(c1,Address.fromBase58(createBitcoinNetwork(), address));
            if(!c2.isZero())tx.addOutput(c2,Address.fromBase58(createBitcoinNetwork(), jHipsterProperties.getBitcoin().getWallet().getMaster()));

            SendRequest request=SendRequest.forTx(tx);
            request.feePerKb=Coin.valueOf(100000);


            appKit.wallet().completeTx(request);
            appKit.peerGroup().broadcastTransaction(request.tx);
            rm.put("code",200);
        rm.put("msg","OK");
    } catch (InsufficientMoneyException e) {
        rm.put("code",400);
        rm.put("msg",e.getMessage());

    }
    }else{
        rm.put("code",500);
        rm.put("msg","Can't send coin");
    }
    return rm;
}




I am trying to change fees by adding code highlighted in green, but its not working (fee remains same)...I also tried to increase the DEFAULT_TX_FEE in the Transaction class,
but that didn't worked either..

please help
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!