Java Code Examples for com.btchip.utils.VarintUtils#read()

The following examples show how to use com.btchip.utils.VarintUtils#read() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BitcoinTransaction.java    From green_android with GNU General Public License v3.0 6 votes vote down vote up
public BitcoinTransaction(ByteArrayInputStream data) throws BTChipException  {		
	inputs = new Vector<BitcoinInput>();
	outputs = new Vector<BitcoinOutput>();
	try {
		version = new byte[4];
		data.read(version);
		long numberItems = VarintUtils.read(data);
		for (long i=0; i<numberItems; i++) {
			inputs.add(new BitcoinInput(data));
		}
		numberItems = VarintUtils.read(data);
		for (long i=0; i<numberItems; i++) {
			outputs.add(new BitcoinOutput(data));
		}
		lockTime = new byte[4];
		data.read(lockTime);			
	}
	catch(Exception e) {
		throw new BTChipException("Invalid encoding", e);
	}					
}
 
Example 2
Source File: BitcoinTransaction.java    From GreenBits with GNU General Public License v3.0 6 votes vote down vote up
public BitcoinTransaction(ByteArrayInputStream data) throws BTChipException  {		
	inputs = new Vector<BitcoinInput>();
	outputs = new Vector<BitcoinOutput>();
	try {
		version = new byte[4];
		data.read(version);
		long numberItems = VarintUtils.read(data);
		for (long i=0; i<numberItems; i++) {
			inputs.add(new BitcoinInput(data));
		}
		numberItems = VarintUtils.read(data);
		for (long i=0; i<numberItems; i++) {
			outputs.add(new BitcoinOutput(data));
		}
		lockTime = new byte[4];
		data.read(lockTime);			
	}
	catch(Exception e) {
		throw new BTChipException("Invalid encoding", e);
	}					
}
 
Example 3
Source File: BitcoinTransaction.java    From WalletCordova with GNU Lesser General Public License v2.1 6 votes vote down vote up
public BitcoinTransaction(ByteArrayInputStream data) throws BTChipException  {		
	inputs = new Vector<BitcoinInput>();
	outputs = new Vector<BitcoinOutput>();
	try {
		version = new byte[4];
		data.read(version);
		long numberItems = VarintUtils.read(data);
		for (long i=0; i<numberItems; i++) {
			inputs.add(new BitcoinInput(data));
		}
		numberItems = VarintUtils.read(data);
		for (long i=0; i<numberItems; i++) {
			outputs.add(new BitcoinOutput(data));
		}
		lockTime = new byte[4];
		data.read(lockTime);			
	}
	catch(Exception e) {
		throw new BTChipException("Invalid encoding", e);
	}					
}
 
Example 4
Source File: BitcoinTransaction.java    From green_android with GNU General Public License v3.0 5 votes vote down vote up
public BitcoinInput(ByteArrayInputStream data) throws BTChipException {	
	try {
		prevOut = new byte[36];
		data.read(prevOut);
		long scriptSize = VarintUtils.read(data);
		script = new byte[(int)scriptSize];
		data.read(script);
		sequence = new byte[4];
		data.read(sequence);
	}
	catch(Exception e) {
		throw new BTChipException("Invalid encoding", e);
	}			
}
 
Example 5
Source File: BitcoinTransaction.java    From green_android with GNU General Public License v3.0 5 votes vote down vote up
public BitcoinOutput(ByteArrayInputStream data) throws BTChipException {
	try {
		amount = new byte[8];
		data.read(amount);
		long scriptSize = VarintUtils.read(data);
		script = new byte[(int)scriptSize];
		data.read(script);				
	}
	catch(Exception e) {
		throw new BTChipException("Invalid encoding", e);
	}			
}
 
Example 6
Source File: BitcoinTransaction.java    From GreenBits with GNU General Public License v3.0 5 votes vote down vote up
public BitcoinInput(ByteArrayInputStream data) throws BTChipException {	
	try {
		prevOut = new byte[36];
		data.read(prevOut);
		long scriptSize = VarintUtils.read(data);
		script = new byte[(int)scriptSize];
		data.read(script);
		sequence = new byte[4];
		data.read(sequence);
	}
	catch(Exception e) {
		throw new BTChipException("Invalid encoding", e);
	}			
}
 
Example 7
Source File: BitcoinTransaction.java    From GreenBits with GNU General Public License v3.0 5 votes vote down vote up
public BitcoinOutput(ByteArrayInputStream data) throws BTChipException {
	try {
		amount = new byte[8];
		data.read(amount);
		long scriptSize = VarintUtils.read(data);
		script = new byte[(int)scriptSize];
		data.read(script);				
	}
	catch(Exception e) {
		throw new BTChipException("Invalid encoding", e);
	}			
}
 
Example 8
Source File: BitcoinTransaction.java    From WalletCordova with GNU Lesser General Public License v2.1 5 votes vote down vote up
public BitcoinInput(ByteArrayInputStream data) throws BTChipException {	
	try {
		prevOut = new byte[36];
		data.read(prevOut);
		long scriptSize = VarintUtils.read(data);
		script = new byte[(int)scriptSize];
		data.read(script);
		sequence = new byte[4];
		data.read(sequence);
	}
	catch(Exception e) {
		throw new BTChipException("Invalid encoding", e);
	}			
}
 
Example 9
Source File: BitcoinTransaction.java    From WalletCordova with GNU Lesser General Public License v2.1 5 votes vote down vote up
public BitcoinOutput(ByteArrayInputStream data) throws BTChipException {
	try {
		amount = new byte[8];
		data.read(amount);
		long scriptSize = VarintUtils.read(data);
		script = new byte[(int)scriptSize];
		data.read(script);				
	}
	catch(Exception e) {
		throw new BTChipException("Invalid encoding", e);
	}			
}