Author

Topic: How to increase feePerKb using bitcoinj api (Read 656 times)

newbie
Activity: 1
Merit: 0
April 14, 2017, 01: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
Jump to: