1
1
via Bitcoinj , i am trying to create hot wallet as front used to get balance , create unsigned transaction (corresponding , i have cold wallet forever be offline used to sign transaction only)
My question is how to create/startup my hot wallet , temporarily i use wallet.fromWatchingKeyB58 to retrieve , but watch-only wallet can not create unsigned transaction with inputs , and it's spendable balance always is zero .
whether my concept or method to do it is wrong ?
belowing is func to create unsigned transaction , retrieved by watching key
public String createUnsignedTx(String userId ,String fromAddress ,String externalAddress ,
String amount ,@Nullable String feePerKB) throws InsufficientMoneyException {
try {
SendRequest request = SendRequest.
to(Address.fromBase58(BtcUtil.getNetwork(), externalAddress), Coin.valueOf(Long.valueOf(amount)) );
request.signInputs = false;
request.tx.getInputs();
request.missingSigsMode = MissingSigsMode.USE_DUMMY_SIG;
wallet.completeTx(request);
logger.info("-----------generated unsign tx start ----------");
logger.info(request.tx.toString());
logger.info("-----------generated unsign tx end -----------");
File file = new File(exportUnsignedPath+"btc."+request.tx.getHashAsString()+".txn.unsign");
FileUtils.writeByteArrayToFile(file, request.tx.bitcoinSerialize());
} catch (Exception e) {
logger.error(e.getMessage(),e);
}
return "created";