The input of this transaction is likely redeeming a P2PK output. In this case, a 'from address' is not easy to determine, as the input script contains only the signature rather than also the public key. It would require to separately query the output (or entire transaction) you're spending from and examine its scriptPubKey. Such query is not available in the Bitcoin P2P protocol.
Note: in not-yet released version 0.15 we will remove the getFromAddress() methods anyway -- try designing your app to do without, e.g. by using the BIP70 payment protocol and returning any coins to the refund address. On 03/03/2018 01:30 PM, Maksim Solovjov wrote: > Here are the logs. I reset the regtest network, generated 101 blocks and > tried to send 4.00 BTC to my own account using bitcoin-cli -regtest > sendtoaddress minLvqKfJbRFtybAtn85xFMouyierccT1w 4.0 > > Please help me if you can. > > Logs: > 2018-03-03 14:25:08.236 INFO 19535 --- [ioClientManager] > org.bitcoinj.core.Peer : [127.0.0.1]:18444: > Downloading dependencies of > ba61241e4cf1726874b3894761b17bbec846807863085924c389c96a27c6329b > 2018-03-03 14:25:08.237 INFO 19535 --- [ioClientManager] > org.bitcoinj.core.Peer : [127.0.0.1]:18444: Bottomed > out dep tree at > 4071fc4047a4778f2d87c891308869662feca47e4453ad8cf8377e03809c15d3 > 2018-03-03 14:25:08.238 INFO 19535 --- [ioClientManager] > org.bitcoinj.core.Peer : [127.0.0.1]:18444: Dependency > download complete! > 2018-03-03 14:25:08.238 INFO 19535 --- [ioClientManager] > org.bitcoinj.wallet.Wallet : Received a pending > transaction > ba61241e4cf1726874b3894761b17bbec846807863085924c389c96a27c6329b that > spends 0.00 BTC from our own wallet, and sends us 4.00 BTC > 2018-03-03 14:25:08.238 INFO 19535 --- [ioClientManager] > org.bitcoinj.wallet.Wallet : commitTx of > ba61241e4cf1726874b3894761b17bbec846807863085924c389c96a27c6329b > 2018-03-03 14:25:08.239 INFO 19535 --- [ioClientManager] > org.bitcoinj.wallet.Wallet : ->pending: > ba61241e4cf1726874b3894761b17bbec846807863085924c389c96a27c6329b > 2018-03-03 14:25:08.240 INFO 19535 --- [ioClientManager] > org.bitcoinj.wallet.Wallet : Estimated balance is now: > 100.00 BTC > 2018-03-03 14:25:08.240 INFO 19535 --- [inj user thread] Bitcoin > Listener : Received tx > ba61241e4cf1726874b3894761b17bbec846807863085924c389c96a27c6329b > 2018-03-03 14:25:08.240 INFO 19535 --- [inj user thread] Bitcoin > Listener : > ba61241e4cf1726874b3894761b17bbec846807863085924c389c96a27c6329b > updated: 2018-03-03T12:25:08Z > version 2 > time locked until block 101 > in > > PUSHDATA(72)[304502210094d0e05a8e69835b0e9bd35a0492da8d0257d567f6a8e1bcf0d0aa857f3383870220085fadb7b634424205b82ad100a38bce97f87a61dadcc1aa2dc119c5e5c7b54101] > > outpoint:4071fc4047a4778f2d87c891308869662feca47e4453ad8cf8377e03809c15d3:0 > sequence:fffffffe > out DUP HASH160 > PUSHDATA(20)[e7d99fa78e61efcca8703292e6c23654d4af4b50] EQUALVERIFY > CHECKSIG 45.9999616 BTC > out DUP HASH160 > PUSHDATA(20)[23d182c40cfefb3d862b76fc465e244164f5a1b9] EQUALVERIFY > CHECKSIG 4.00 BTC > prps UNKNOWN > > 2018-03-03 14:25:08.241 INFO 19535 --- [ioClientManager] > org.bitcoinj.wallet.WalletFiles : Saving wallet; last seen > block is height 101, date 2018-02-11T10:31:51Z, hash > 7970c66ca11aeab7b3ecc5410d5b0037b9fd1c2b7ce03536c4a1840e9a11a85b > org.bitcoinj.core.ScriptException: Script not of right size, expecting 2 > but got 1 > at org.bitcoinj.script.Script.getPubKey(Script.java:288) > at org.bitcoinj.script.Script.getFromAddress(Script.java:343) > > On Friday, March 2, 2018 at 1:14:32 AM UTC+2, Andreas Schildbach wrote: > > 'From addresses' are not available in many cases, and the number of > these cases are growing. > > If you paste the toString() of the transaction the reason should be > obvious. > > > On 02/27/2018 11:50 AM, Maksim Solovjov wrote: > > Anyone? Please help > > > > On Sunday, February 18, 2018 at 2:47:07 PM UTC+2, Maksim Solovjov > wrote: > > > > Hi guys, > > > > I face an exception "Script not of right size, expecting 2 but > got > > 1" when I try to do: > > | > > tx.getInput(0).getFromAddress().toBase58() > > | > > > > *NB! This happens only with a very first transaction after > generate > > 101. Subsequent transactions work well!* > > > > Any ideas why it happens? > > > > Steps to reproduce: > > - bitcoind -regtest -daemon > > - bitcoin-cli -regtest generate 101 > > - bitcoin-cli -regtest getaddressesbyaccount "" -> remember the > > address returned > > - bitcoin-cli -regtest sendtoaddress > <address-from-previous-step> 4.0 > > That's it! > > Subsequent transaction works well: > > - bitcoin-cli -regtest sendtoaddress > <address-from-previous-step> 2.0 > > > > Code sample I took from: > > > > https://stackoverflow.com/questions/27727439/how-to-watch-for-transactions-for-an-address-in-bitcoinj-java > > <https://stackoverflow.com/questions/27727439/how-to-watch-for-transactions-for-an-address-in-bitcoinj-java> > > > > > <https://stackoverflow.com/questions/27727439/how-to-watch-for-transactions-for-an-address-in-bitcoinj-java > > <https://stackoverflow.com/questions/27727439/how-to-watch-for-transactions-for-an-address-in-bitcoinj-java>> > > > > > > > |Stringfrom=tx.getInput(0).getFromAddress().toBase58();| > > > > > > Hope you can help me. > > Thank you in advance. > > > > Best Regards, > > Maksim > > > > -- > > 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 [email protected] > > <mailto:[email protected]>. > > For more options, visit https://groups.google.com/d/optout > <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 [email protected] > <mailto:[email protected]>. > 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
