Anyone know how to pull the transaction input address from the Core client, kinda like what block explorers do? I need it for sending back a payment to the original sender.
I'm using litecoin-cli gettransaction for this.
Just a heads up, I'm testing with Litecoin since it’s more reliable than Testnet.
If you check out this site, it shows the "inputs" address when you decode hex:
But my Core setup doesn’t display the sender's address at all.
Can I get this info without having txindex=1? I’m running a pruned node.
Returning payments: Bitcoin vs Litecoin Core
13 replies 198 views
gr3g.0rbitHero Member
Posts: 1025 · Reputation: 2646
#2Jul 28, 2020, 12:08 AM
Quite possible, if the block where the transaction is still not pruned or if it's still in your mempool,
You can use getrawtransaction in your Bitcoin Core node even without txindex by providing the hash of the block where the transaction is included.
Then use verbosity "2" to include "prevout" to each of the inputs in the result.
For example, test the first non-coinbase transaction in current latest block height 850758 with the block hash 00000000000000000000a8e2c7fcd3b21caa2da453d956f86ec1e77ff39fd0b8.
That block should still be available in your Bitcoin Core's blocksdir I suppose, command:
Result:
But if the block is already pruned, it wont work. You'll have to use txindex and intact blockchain.
This works in Bitcoin Core but not in Litecoin Core. Github issue: https://github.com/litecoin-project/litecoin/issues/948
The block is not pruned yet when I need this.
Blockchair api gives the same without input address: https://api.blockchair.com/litecoin/raw/transaction/75c83da6ddf052405b5629fd30609783bd002ba80db3a947c52e13b8779022b5
gr3g.0rbitHero Member
Posts: 1025 · Reputation: 2646
#4Jul 28, 2020, 07:56 AM
Then, Litecoin isn't a good alternative to TestNet when testing some Bitcoin Core-compatible commands.
Try "RegTest" instead; however, you wont be able to easily reproduce a pruned blockchain.
The setup: prune=1 arg/config and pruneblockchain <height> RPC command to reproduce a pruned blockchain
seem to require to reach the minimum prune size as well because it wont prune any block in my RegTest setup with more than 1500 blocks (result: -1).
Or just use your Bitcoin Core, unlike some commands, getrawtransaction wont harm your node anyways.
You intended to use that in Bitcoin Core right?
I intended to use Litecoin for live demonstration. Fees are much friendlier.
I now use api https://litecoinspace.org/api/tx/5c4dcff65ed69060f84005fcfc9c9cccd1d2eed38d30d2df95f4524ce1075576 until I find a better solution.
I wonder why you chose Litecoin when testnet3, testnet4 and signet exist. If you worry about uneven block time (because someone use ASIC) or difficulty obtaining the coin, signet doesn't have such problem.
I think more people use Litecoin than testnet.
RogueDegenFull Member
Posts: 74 · Reputation: 309
#9Jul 28, 2020, 05:36 PM
No!
No, no, no.
Just no.
In Bitcoin, there's no such thing as a "sending address". DO NOT try to guess at a return address from the inputs of a transaction. Doing so WILL eventually result in lost bitcoins and angry users. If you want to send bitcoins to someone, ASK THEM TO PROVIDE a receiving address, then use the address they give you.
There are just SO MANY ways that guessing a user's address from inputs will result in you using an incorrect address.
hodler2019Legendary
Posts: 2182 · Reputation: 12913
#10Jul 28, 2020, 06:57 PM
Yep one simple way is someone pays with their coinbase exchange account
The address that pays has nothing to do with the senders coinbase address.
The coins come from coinbases hot wallet address not from my coinbase address
You're probably right, some users will ignore even the simplest of instructions. The return address only works when using your own wallet. This badly complicates my idea.
RogueDegenFull Member
Posts: 74 · Reputation: 309
#12Jul 30, 2020, 09:51 AM
A significant percentage of the population doesn't even understand the difference between a self-custody wallet, and an account with a service provider.
Then companies like Coinbase (and others) make it even more confusing by calling their accounts "Wallets" all over their user interface.
Then on top of that, you've got multi-sig addresses and the possibility of CoinJoin transactions.
And even if users completely understand how to "use their own wallet" AND they understand that they need to avoid input sharing, you still have the problem that a user could compromise their address very shortly after sending the bitcoins to you (either lost the private keys and don't have a backup, or leaked the private keys). In either case, those coins aren't going to make it back to the person you intend them to.
And if the input is spending a non-standard output, then there is no "address" at all. Are you going to perfectly reproduce their customized script? Or is your code going to try to convert the bytes into an address for which they don't have the private key?
hodler2019Legendary
Posts: 2182 · Reputation: 12913
#13Jul 30, 2020, 12:31 PM
@Dannyhamilton
I have a coinbase account.
I have a kracken account.
I have a nicehash account.
All three gave me a deposit address say
1btc coinbase
1btc kraken
1btc nicehash
if coin is sent to those addresses they auto go to the main wallets of those exchanges and all of them are controlling my coins in a hot wallet. If I send anyone coins from my accounts above my wallets do not register in the least.
I won't mention they have LN services.
I will say to the op you are wasting a lot of time as your ideas will only cover a few types of wallets. You may as well close the thread. Before there is more confusion.
Only Bitcoin Core has merged the code for storing undo data for blocks. The other clients haven't caught up I think.
Having said that, I would be surprised if you could not get the undo data for Litecoin Core using a verbosity of 1. I think I may have tried that before, but it was a while ago so I am not sure.