thanks for your answer. what other cases should I find in a blockchain analisys? how to manage that?
Il giorno sabato 11 maggio 2019 11:55:36 UTC+2, Andreas Schildbach ha scritto: > > Generally it's not a good idea trying to derive a "from address". > > Your code can only work in very specific cases (inputs spending P2PKH > outputs). > > You should assert that chunks.size() == 2. > > Also the example transaction is a BCH transaction. I'm not sure how > similar BCH is to Bitcoin these days -- better check with the BCH folks. > > > On 09/05/2019 19.45, Mebitek The manufactured eXPerience wrote: > > Hi all, > > I'm trying to get the fromAddress of a given trasaction. I can calculate > > one but I have different values in front of the ones reported on > > blockchain.com explorer. Can someone help me? > > > > bitcoinj version: 0.15.1 > > > > Script scriptSig = inputTx.getScriptSig(); > > List<ScriptChunk> chunks = scriptSig.getChunks(); > > > > byte[] pubKey = chunks.get(chunks.size() - 1).data; > > assert pubKey != null; > > byte[] pubKeyHash = Utils.sha256hash160(pubKey); > > > > LegacyAddress fromAddress = LegacyAddress.fromPubKeyHash(np, > > pubKeyHash); > > from blockchain.com explorer: > > > > tx = f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16 > > fromAddress = 12cbQLTFMXRnSzktFkuoG3eHoMeFtpTu3S > > I get: 1N6HfR4j5dnrBPpHET9ZmSwDhLkr5hprCG > > > > for newer transactions, the result is good: tx: > > 1554a02d4eb1c7a73e3736922ed99530e360784e709896c42e5756e65b2da341 > > > > can someone point me how to fix this? > > thanks > > Claudio > > > > -- > > You received this message because you are subscribed to the Google > > Groups "bitcoinj" group. > > To unsubscribe from this group and stop receiving emails from it, send > > an email to bitc...@googlegroups.com <javascript:> > > <mailto:bitc...@googlegroups.com <javascript:>>. > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/bitcoinj/a490fe24-5553-4e0e-8c7e-317f8ddeac4f%40googlegroups.com > > > < > https://groups.google.com/d/msgid/bitcoinj/a490fe24-5553-4e0e-8c7e-317f8ddeac4f%40googlegroups.com?utm_medium=email&utm_source=footer>. > > > > For more options, visit https://groups.google.com/d/optout. > > > -- You received this message because you are subscribed to the Google Groups "bitcoinj" group. To unsubscribe from this group and stop receiving emails from it, send an email to bitcoinj+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/bitcoinj/04a38824-204f-42e5-9821-ec3682a7b04f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.