TransactionInput i = transaction.getInputs ().get (j);
ScriptFormat.Writer sw = new ScriptFormat.Writer ();
if ( ScriptFormat.isPayToAddress (s.getScript ()) )
{
Address address = s.getOutputAddress ();
Key key = getKeyForAddress (address);
if ( key == null )
{
throw new ValidationException ("Have no key to spend this output");
}
byte[] sig = key.sign (hashTransaction (transaction, j, ScriptFormat.SIGHASH_ALL, s.getScript ()));
byte[] sigPlusType = new byte[sig.length + 1];
System.arraycopy (sig, 0, sigPlusType, 0, sig.length);
sigPlusType[sigPlusType.length - 1] = (byte) (ScriptFormat.SIGHASH_ALL & 0xff);
sw.writeData (sigPlusType);
sw.writeData (key.getPublic ());
}
else
{
spendNonAddressOutput (j, s, sw, transaction);
}