Android Open Source - bitcoin-wallet Tx In






From Project

Back to project page bitcoin-wallet.

License

The source code is released under:

Copyright (C) 2011 by Caleb Anderson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the ...

If you think the Android project bitcoin-wallet listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package net.dirtyfilthy.bitcoin.core;
//w  w  w . j a  va2 s.co m
import java.io.DataInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

import net.dirtyfilthy.bitcoin.util.MyHex;



public class TxIn  implements ByteArrayable, Cloneable {
  private byte[] outpointHash=new byte[32];
  private long outpointIndex=0;
  private Script script=new Script();
  private long sequence=0;
  
  
  

  public TxIn(DataInputStream in) throws IOException{
    in.read(outpointHash);
    System.out.println("outpoint: "+MyHex.encode(outpointHash));
    this.outpointIndex=((long) Integer.reverseBytes(in.readInt())) & 0xffffffffL;
    System.out.println("index: "+outpointIndex);
    this.script=new Script(in);
    this.sequence=((long) Integer.reverseBytes(in.readInt())) & 0xffffffffL;
  }
  
  
  
  public TxIn() {
    // TODO Auto-generated constructor stub
  }
  
  public String toString() {
    String s="outpointHash: "+MyHex.encode(outpointHash)+"\n";
    s+="outpointIndex: "+this.outpointIndex+"\n";
    s+="Script:\n"+script.toString()+"\n";
    s+="Sequence: "+sequence+"\n";
    return s;
  }

  public TxIn clone(){
    try {
      return (TxIn) super.clone();
    } catch (CloneNotSupportedException e) {
      
      throw new RuntimeException(e);
    }
  }
  

  public void setOutpointHash(byte[] outpointHash) {
    this.outpointHash = outpointHash;
  }


  public byte[] getOutpointHash() {
    return outpointHash;
  }
  
   
  public long getSequence() {
    return sequence;
  }

  public void setSequence(long sequence) {
    this.sequence = sequence;
  }

  public void setOutpointIndex(int outpointIndex) {
    this.outpointIndex = outpointIndex;
  }


  public long getOutpointIndex() {
    return outpointIndex;
  }


  public void setScript(Script script) {
    this.script = script;
  }


  public Script getScript() {
    return script;
  }
  

  public Script script() {
    return getScript();
  }
  
  


  public void setTransactionVersion(int transactionVersion) {
    this.sequence = transactionVersion;
  }


  public long getTransactionVersion() {
    return sequence;
  }
  
  public byte[] toByteArray(){
    byte[] rawScript=this.script.toByteArray();
    ByteBuffer dataBuffer=ByteBuffer.allocate(rawScript.length+40);
    dataBuffer.order(ByteOrder.LITTLE_ENDIAN);
    dataBuffer.put(this.outpointHash);
    dataBuffer.putInt((int) this.outpointIndex);
    dataBuffer.put(rawScript);
    dataBuffer.putInt((int) this.sequence);
    return dataBuffer.array();
  }

  public void setOutpointIndex(long outpointIndex) {
    this.outpointIndex = outpointIndex;
  }
  
  
  
  
}




Java Source Code List

net.dirtyfilthy.bitcoin.core.Address.java
net.dirtyfilthy.bitcoin.core.Base58Hash160.java
net.dirtyfilthy.bitcoin.core.BlockChain.java
net.dirtyfilthy.bitcoin.core.BlockExistsException.java
net.dirtyfilthy.bitcoin.core.BlockStore.java
net.dirtyfilthy.bitcoin.core.Block.java
net.dirtyfilthy.bitcoin.core.BtcValue.java
net.dirtyfilthy.bitcoin.core.ByteArrayable.java
net.dirtyfilthy.bitcoin.core.InvalidBlockException.java
net.dirtyfilthy.bitcoin.core.OpCode.java
net.dirtyfilthy.bitcoin.core.OpData.java
net.dirtyfilthy.bitcoin.core.OrphanBlockException.java
net.dirtyfilthy.bitcoin.core.Script.java
net.dirtyfilthy.bitcoin.core.TxIn.java
net.dirtyfilthy.bitcoin.core.TxOut.java
net.dirtyfilthy.bitcoin.core.Tx.java
net.dirtyfilthy.bitcoin.protocol.AddressBook.java
net.dirtyfilthy.bitcoin.protocol.AddressPacket.java
net.dirtyfilthy.bitcoin.protocol.BlockPacket.java
net.dirtyfilthy.bitcoin.protocol.ConnectionHandler.java
net.dirtyfilthy.bitcoin.protocol.Connection.java
net.dirtyfilthy.bitcoin.protocol.GetAddressPacket.java
net.dirtyfilthy.bitcoin.protocol.GetBlocksPacket.java
net.dirtyfilthy.bitcoin.protocol.GetDataPacket.java
net.dirtyfilthy.bitcoin.protocol.GetHeadersPacket.java
net.dirtyfilthy.bitcoin.protocol.HeadersPacket.java
net.dirtyfilthy.bitcoin.protocol.InventoryPacket.java
net.dirtyfilthy.bitcoin.protocol.InventoryVector.java
net.dirtyfilthy.bitcoin.protocol.IrcBootStrap.java
net.dirtyfilthy.bitcoin.protocol.MalformedPacketException.java
net.dirtyfilthy.bitcoin.protocol.PacketFactory.java
net.dirtyfilthy.bitcoin.protocol.PacketType.java
net.dirtyfilthy.bitcoin.protocol.Packet.java
net.dirtyfilthy.bitcoin.protocol.PingPacket.java
net.dirtyfilthy.bitcoin.protocol.ProtocolVersion.java
net.dirtyfilthy.bitcoin.protocol.ReplyPacket.java
net.dirtyfilthy.bitcoin.protocol.TxPacket.java
net.dirtyfilthy.bitcoin.protocol.VersionAckPacket.java
net.dirtyfilthy.bitcoin.protocol.VersionPacket.java
net.dirtyfilthy.bitcoin.util.Base58.java
net.dirtyfilthy.bitcoin.util.BigIntegerTools.java
net.dirtyfilthy.bitcoin.util.HashTools.java
net.dirtyfilthy.bitcoin.util.KeyTools.java
net.dirtyfilthy.bitcoin.util.MyHex.java
net.dirtyfilthy.bitcoin.wallet.ExposedSQLiteCursor.java
net.dirtyfilthy.bitcoin.wallet.InvalidPasswordException.java
net.dirtyfilthy.bitcoin.wallet.KeyRing.java
net.dirtyfilthy.bitcoin.wallet.SqlBlockStore.java
net.dirtyfilthy.bitcoin.wallet.Wallet.java