public static byte[] hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
/**
* @param args
* @throws ScriptException
*/
public static void main(String[] args) throws ScriptException {
TransactionInput tin = new TransactionInput(NetworkParameters.testNet3(), null, hexStringToByteArray(s));
Address a = tin.getScriptSig().getFromAddress();
System.out.println(a.toString());
}
The code outputs correctly "mkMUgWeh3mfpgvKgjK81rUMqKfNoww7tie" (txid: 1d893276bcae417e39aa08b60d02c9b3d4d5e2380aba6bcf359b6d752923ae9f)
hey i have question
if sendAddress is multisig address(ex https://blockchain.info/tx/ad0c703eb06d9dd9556a160a8cfb318e666cc2baf44a95c826ce8bd0b2bcba9a)
this code available?
The same code should work with BitcoinJ. .getFromAddress() will return P2SH if the ScriptSig is P2SH