Best Regards
Yup we can do through the concept bitcoinj, and you can acheive in wallet connect as well as you can trace the wallet's transactions too.
Please find it...
import java.math.BigInteger;
import com.google.bitcoin.core.*;
import com.google.bitcoin.core.Wallet.SendRequest;
import com.google.bitcoin.params.UnitTestParams;
import com.google.bitcoin.store.*;
import com.google.bitcoin.utils.TestUtils;
public class MyProgram {
public static void main(String[] args) throws Exception {
Wallet wallet = new FakeWallet();
System.out.println("Your wallet:\n"+wallet);
ECKey toDestination = new ECKey();
Address destination = toDestination.toAddress(wallet.getNetworkParameters());
//You could also create an address like this in prod (but not here in test):
//Address destination = new Address(wallet.getNetworkParameters(), "1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T");
SendRequest request = SendRequest.to(destination, BigInteger.valueOf(2000L));
//Here are some examples that could change the transaction fee
Wallet.SendRequest.DEFAULT_FEE_PER_KB = BigInteger.ZERO;
request.ensureMinRequiredFee = false;
request.fee = BigInteger.ZERO;
request.feePerKb = BigInteger.ZERO;
//Create the transaction
Transaction transaction = wallet.sendCoinsOffline(request);
System.out.println("The transaction:\n"+transaction);
}
static class FakeWallet extends Wallet {
//A fake wallet that does not run on the real bitcoin network
static NetworkParameters params = UnitTestParams.get();
private static final long serialVersionUID = 1L;
private ECKey myKey;
private Address myAddress;
private BlockStore blockStore;
public FakeWallet() throws Exception {
super(params);
myKey = new ECKey();
myAddress = myKey.toAddress(params);
addKey(myKey);
blockStore = new MemoryBlockStore(params);
receiveFakeCoins(blockStore, BigInteger.valueOf(100000000), this, myAddress);
//You could also create a blockchain = new BlockChain(params, wallet, blockStore);
}
public static void receiveFakeCoins(BlockStore blockStore, BigInteger amount, Wallet wallet, Address toAddress) throws Exception {
Transaction tx = TestUtils.createFakeTx(wallet.getNetworkParameters(), amount, toAddress);
TestUtils.BlockPair bp = TestUtils.createFakeBlock(blockStore, tx);
wallet.receiveFromBlock(tx, bp.storedBlock, AbstractBlockChain.NewBlockType.BEST_CHAIN, 0);
wallet.notifyNewBestBlock(bp.storedBlock);
}
}
}
This I created with fake Btc address and with fake details. But this is the coding format and functions for Wallet transaction and wallet connection In Java platform medium.