public TransactionOutputChanges(InputStream in) throws IOException { int numOutsCreated = (in.read() & 0xFF) | ((in.read() & 0xFF) << 8) | ((in.read() & 0xFF) << 16) | ((in.read() & 0xFF) << 24); txOutsCreated = new LinkedList<>(); for (int i = 0; i < numOutsCreated; i++) txOutsCreated.add(new UTXO(in)); int numOutsSpent = (in.read() & 0xFF) | ((in.read() & 0xFF) << 8) | ((in.read() & 0xFF) << 16) | ((in.read() & 0xFF) << 24); txOutsSpent = new LinkedList<>(); for (int i = 0; i < numOutsSpent; i++) txOutsSpent.add(new UTXO(in)); }
public TransactionOutputChanges(InputStream in) throws IOException { int numOutsCreated = (in.read() & 0xFF) | ((in.read() & 0xFF) << 8) | ((in.read() & 0xFF) << 16) | ((in.read() & 0xFF) << 24); txOutsCreated = new LinkedList<>(); for (int i = 0; i < numOutsCreated; i++) txOutsCreated.add(new UTXO(in)); int numOutsSpent = (in.read() & 0xFF) | ((in.read() & 0xFF) << 8) | ((in.read() & 0xFF) << 16) | ((in.read() & 0xFF) << 24); txOutsSpent = new LinkedList<>(); for (int i = 0; i < numOutsSpent; i++) txOutsSpent.add(new UTXO(in)); }
public TransactionOutputChanges(InputStream in) throws IOException { int numOutsCreated = (in.read() & 0xFF) | ((in.read() & 0xFF) << 8) | ((in.read() & 0xFF) << 16) | ((in.read() & 0xFF) << 24); txOutsCreated = new LinkedList<UTXO>(); for (int i = 0; i < numOutsCreated; i++) txOutsCreated.add(new UTXO(in)); int numOutsSpent = (in.read() & 0xFF) | ((in.read() & 0xFF) << 8) | ((in.read() & 0xFF) << 16) | ((in.read() & 0xFF) << 24); txOutsSpent = new LinkedList<UTXO>(); for (int i = 0; i < numOutsSpent; i++) txOutsSpent.add(new UTXO(in)); }
public TransactionOutputChanges(InputStream in) throws IOException { int numOutsCreated = (in.read() & 0xFF) | ((in.read() & 0xFF) << 8) | ((in.read() & 0xFF) << 16) | ((in.read() & 0xFF) << 24); txOutsCreated = new LinkedList<UTXO>(); for (int i = 0; i < numOutsCreated; i++) txOutsCreated.add(new UTXO(in)); int numOutsSpent = (in.read() & 0xFF) | ((in.read() & 0xFF) << 8) | ((in.read() & 0xFF) << 16) | ((in.read() & 0xFF) << 24); txOutsSpent = new LinkedList<UTXO>(); for (int i = 0; i < numOutsSpent; i++) txOutsSpent.add(new UTXO(in)); }
/** * Add a UTXO to account * @param transactionHash String containing txHash of the UTXO * @param outpoint long containng vout/index of the UTXO * @param valueInSatoshi long containing amount of the UTXO * @param blockHeight int containing block height of the transaction * @param address String containing the address */ public void addUtxo(String transactionHash, long outpoint, long valueInSatoshi, int blockHeight, String address) { if (null == this.utxoList) { this.utxoList = new ArrayList<>(); } byte pubKey[] = Base58.decodeChecked(address); String pubKeyHex = String.format( SCRIPT_OP_DUP_OP_HASH160_PUBKEY_OP_EQUALVERIFY_OP_CHECKSIG, DatatypeConverter .printHexBinary(ByteBuffer .allocate(pubKey.length - 1) .put(pubKey, 1, pubKey.length - 1) .array() ) .toLowerCase() ); Script script = new Script(Utils.HEX.decode(pubKeyHex)); this.utxoList.add(new UTXO(Sha256Hash.wrap(transactionHash), outpoint, Coin.valueOf(valueInSatoshi), blockHeight, false, script, address)); }
boolean coinbase = results.getBoolean(4); String address = results.getString(5); UTXO txout = new UTXO(hash, index, value,
boolean coinbase = rs.getBoolean(6); String toAddress = rs.getString(7); UTXO output = new UTXO(hash, index, amount,
boolean coinbase = results.getBoolean(4); String address = results.getString(5); UTXO txout = new UTXO(hash, index, value,
boolean coinbase = results.getBoolean(4); String address = results.getString(5); UTXO txout = new UTXO(hash, index, value,
boolean coinbase = rs.getBoolean(6); String toAddress = rs.getString(7); UTXO output = new UTXO(hash, index, amount,
boolean coinbase = results.getBoolean(4); String address = results.getString(5); UTXO txout = new UTXO(hash, index, value,
boolean coinbase = rs.getBoolean(6); String toAddress = rs.getString(7); UTXO output = new UTXO(hash, index, amount,
boolean coinbase = rs.getBoolean(6); String toAddress = rs.getString(7); UTXO output = new UTXO(hash, index, amount,
UTXO txout = new UTXO(bis);
UTXO txout = new UTXO(bis);
UTXO txout = new UTXO(bis);
Script sc = txout.getScript(); Address address = sc.getToAddress(params, true); UTXO output = new UTXO(txout.getHash(), txout.getIndex(), txout.getValue(), txout.getHeight(), txout.isCoinbase(), txout.getScript(), address.toString()); results.add(output);
Script sc = txout.getScript(); Address address = sc.getToAddress(params, true); UTXO output = new UTXO(txout.getHash(), txout.getIndex(), txout.getValue(), txout.getHeight(), txout.isCoinbase(), txout.getScript(), address.toString()); results.add(output);
@Test public void testJavaSerialization() throws Exception { ECKey key = new ECKey(); UTXO utxo = new UTXO(Sha256Hash.of(new byte[]{1,2,3}), 1, Coin.COIN, 10, true, ScriptBuilder.createOutputScript(key)); ByteArrayOutputStream os = new ByteArrayOutputStream(); new ObjectOutputStream(os).writeObject(utxo); UTXO utxoCopy = (UTXO) new ObjectInputStream( new ByteArrayInputStream(os.toByteArray())).readObject(); assertEquals(utxo, utxoCopy); assertEquals(utxo.getValue(), utxoCopy.getValue()); assertEquals(utxo.getHeight(), utxoCopy.getHeight()); assertEquals(utxo.isCoinbase(), utxoCopy.isCoinbase()); assertEquals(utxo.getScript(), utxoCopy.getScript()); } }
Wallet w = new Wallet(new Context(params)); Address a = w.currentReceiveAddress(); final UTXO utxo = new UTXO(Sha256Hash.of(new byte[] { 1, 2, 3 }), 1, Coin.COIN, 0, false, ScriptBuilder.createOutputScript(a)); w.setUTXOProvider(new UTXOProvider() {