User avatar
ArunaDonawade
Posts: 2
Joined: Thu Feb 15, 2018 7:49 am

Bitcoin Transfer Issue

Thu Feb 15, 2018 8:16 am

Hi,

I am writting an application to transfer bitcoins from one bitcoin address to another but when I ran the below code, it generates new bitcoin address and try to send bitcoin amount from newly generated address(having zero balance) to passed receiver bitcoin address. How can I pass sender bitcoin address who is having balance, means what I am missing in below code.


final NetworkParameters netParams = NetworkParameters.testNet3();
BlockStore blockStore = new MemoryBlockStore(netParams);
BlockChain chain;

Wallet wallet = new Wallet(netParams);
final File walletFile = new File("prod.wallet");
wallet = new Wallet(netParams);
wallet.saveToFile(walletFile);
wallet = Wallet.loadFromFile(walletFile);

BigInteger btcToSend = new BigInteger("0.040");
chain = new BlockChain(netParams, wallet, blockStore);
final PeerGroup peergroup = new PeerGroup(netParams, chain);
peergroup.addWallet(wallet);
peergroup.start();

Address recipientAddress = new Address(netParams,"XXXXXXX");
SendResult sendTxn = wallet.sendCoins(peergroup, recipientAddress, btcToSend);


Any help would be appreciated. Thanks in advance.

Regards,
Aruna

Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 19 guests