{"transaction_hash":"0801c93078c926050707bc94622ebe5a2cd2e5ef6dc385f3c1856fcde01d456b","output_index":1,"value":10000,"addresses":["mgex8y7ExdTdAfLxDovKyY4aru6QEyCrDd"],"script":"OP_DUP OP_HASH160 0c7b529d3625ebbb237efadbfbae5f75f13f0f4e OP_EQUALVERIFY OP_CHECKSIG","script_hex":"76a9140c7b529d3625ebbb237efadbfbae5f75f13f0f4e88ac","script_type":"pubkeyhash","required_signatures":1,"spent":false,"confirmations":6412}
I want to create a transaction from this utxo, and place it into the wallet, so when I create a send request for the amount lesser than one on the above utxo, the subsequent sendCoinsOffline will find the utxo, connect it as an input to the new transaction, calculate change and fee and sign the transaction. I will broadcast the transaction via other channels than bitcoinj.
If the wallet is online, I would already have this transaction with the above output. But, if I want to "emulate" receiving the transaction from the blockchain, I need to create a transaction:
Transaction unspent = new Transaction(params)
(This transaction must have the hash same as on the utxo. It will serve as source of input for my sendCoinsOffline, and if has it's own hash, the result will not be accepted by the network, because the transaction does not exist for real)
and add the above utxo as an output on this transaction. But, I can't find a way to pass hash, index and script, which are needed to unlock the transaction, to unspent.addOutput. I can add this info to input of a new transaction, but this is not what I want (it won't be picked by bitcoinj for spending).
Maybe I'm trying to follow a wrong path and just need to manually construct/connect transaction? My thinking was that the above approach would let me to reuse wallet logic of connecting things together, picking the change address and calculating the fee.