Package com.bitsofproof.supernode.common

Examples of com.bitsofproof.supernode.common.ValidationException


  public static String getMnemonic (byte[] data) throws ValidationException
  {
    if ( data.length % 4 != 0 )
    {
      throw new ValidationException ("Invalid data length for mnemonic");
    }
    byte[] check = Hash.sha256 (data);

    boolean[] bits = new boolean[data.length * 8 + data.length / 4];

View Full Code Here


  {
    this.network = network;
    this.type = type;
    if ( address.length != 20 )
    {
      throw new ValidationException ("invalid digest length for an address");
    }
    this.bytes = Arrays.clone (address);
  }
View Full Code Here

  public Address (Type type, byte[] address) throws ValidationException
  {
    this.type = type;
    if ( address.length != 20 )
    {
      throw new ValidationException ("invalid digest length for an address");
    }
    this.bytes = Arrays.clone (address);
  }
View Full Code Here

      writer.writeData (bytes);
      writer.writeToken (new ScriptFormat.Token (Opcode.OP_EQUAL));
    }
    else
    {
      throw new ValidationException ("unknown sink address type");
    }
    return writer.toByteArray ();
  }
View Full Code Here

      byte[] check = Hash.hash (raw, 0, raw.length - 4);
      for ( int i = 0; i < 4; ++i )
      {
        if ( check[i] != raw[raw.length - 4 + i] )
        {
          throw new ValidationException ("Address checksum mismatch");
        }
      }
      byte[] keyDigest = new byte[raw.length - 5];
      System.arraycopy (raw, 1, keyDigest, 0, raw.length - 5);
      return new Address (network, type, keyDigest);
    }
    catch ( Exception e )
    {
      throw new ValidationException (e);
    }
  }
View Full Code Here

    try
    {
      byte[] raw = ByteUtils.fromBase58 (s);
      if ( raw[0] != (byte) (addressFlag & 0xff) )
      {
        throw new ValidationException ("invalid address for this chain");
      }
      byte[] check = Hash.hash (raw, 0, raw.length - 4);
      for ( int i = 0; i < 4; ++i )
      {
        if ( check[i] != raw[raw.length - 4 + i] )
        {
          throw new ValidationException ("Address checksum mismatch");
        }
      }
      byte[] keyDigest = new byte[raw.length - 5];
      System.arraycopy (raw, 1, keyDigest, 0, raw.length - 5);
      return keyDigest;
    }
    catch ( Exception e )
    {
      throw new ValidationException (e);
    }
  }
View Full Code Here

      {
        addressFlag = 0x5;
      }
      else
      {
        throw new ValidationException ("unknown address type");
      }
    }
    else if ( address.getNetwork () == Network.TEST )
    {
      if ( address.getType () == Address.Type.COMMON )
      {
        addressFlag = 0x6f;
      }
      else if ( address.getType () == Address.Type.P2SH )
      {
        addressFlag = 196;
      }
      else
      {
        throw new ValidationException ("unknown address type");
      }
    }
    else
    {
      throw new ValidationException ("unknown network");
    }
    byte[] addressBytes = new byte[1 + keyDigest.length + 4];
    addressBytes[0] = (byte) (addressFlag & 0xff);
    System.arraycopy (keyDigest, 0, addressBytes, 1, keyDigest.length);
    byte[] check = Hash.hash (addressBytes, 0, keyDigest.length + 1);
View Full Code Here

TOP

Related Classes of com.bitsofproof.supernode.common.ValidationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.