Author

Topic: Bitcoin or Litecoin Core: return payment to sender (Read 234 times)

legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
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.

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.
legendary
Activity: 4326
Merit: 8950
'The right to privacy matters'
@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.
legendary
Activity: 3472
Merit: 4801
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.

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?
member
Activity: 239
Merit: 59
a young loner on a crusade
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.
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.
legendary
Activity: 4326
Merit: 8950
'The right to privacy matters'
I need it to return a payment to one of the sending addresses.

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.

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 coinbase’s hot wallet address not from my coinbase address
legendary
Activity: 3472
Merit: 4801
I need it to return a payment to one of the sending addresses.

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.
member
Activity: 239
Merit: 59
a young loner on a crusade
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.
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange

You intended to use that in Bitcoin Core right?
I intended to use Litecoin for live demonstration. Fees are much friendlier.

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.
member
Activity: 239
Merit: 59
a young loner on a crusade
member
Activity: 239
Merit: 59
a young loner on a crusade

You intended to use that in Bitcoin Core right?
I intended to use Litecoin for live demonstration. Fees are much friendlier.
legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
-snip-
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.
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 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?
member
Activity: 239
Merit: 59
a young loner on a crusade
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.

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.

Code:
getrawtransaction 75c83da6ddf052405b5629fd30609783bd002ba80db3a947c52e13b8779022b5 2 9a03b9c095c170b270073b54da293be64dec9a90ed065cce562cf065ff6a9906


{
  "in_active_chain": true,
  "txid": "75c83da6ddf052405b5629fd30609783bd002ba80db3a947c52e13b8779022b5",
  "hash": "8baeff24369ead1589d1c90b3c6dd9162b0798e1102697163384179e1b211477",
  "version": 2,
  "size": 222,
  "vsize": 141,
  "weight": 561,
  "locktime": 2715166,
  "vin": [
    {
      "ismweb": false,
      "txid": "2d7d107e05b9db7c9b226c94ea9d0101330d3d76a7d799cb6f045cb72994bbf2",
      "vout": 1,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "txinwitness": [
        "304402206eaaa210752ca3418606bca1883b563e7b40c8488c50ade9c542d80f131c20a302202ba50d08ffcba7b5e65251969861621064ce3c4b6d61b3e1236b56c15ef124b101",
        "02ae77a4757d225d777d3d4320c2678864ff3608bee5a326149358d6a6edb07418"
      ],
      "sequence": 4294967294
    }
  ],
  "vout": [
    {
      "ismweb": false,
      "value": 0.00010147,
      "n": 0,
      "scriptPubKey": {
        "asm": "0 4f154d4e85d1cae0a8ee766b6a0b37c2905e6b94",
        "hex": "00144f154d4e85d1cae0a8ee766b6a0b37c2905e6b94",
        "reqSigs": 1,
        "type": "witness_v0_keyhash",
        "addresses": [
          "ltc1qfu256n59689wp28wwe4k5zehc2g9u6u5p35vg7"
        ]
      }
    },
    {
      "ismweb": false,
      "value": 0.00043344,
      "n": 1,
      "scriptPubKey": {
        "asm": "0 56e9c0c2cf6de4fbe76bf10bdeabedbf3de33539",
        "hex": "001456e9c0c2cf6de4fbe76bf10bdeabedbf3de33539",
        "reqSigs": 1,
        "type": "witness_v0_keyhash",
        "addresses": [
          "ltc1q2m5upsk0dhj0hemt7y9aa2ldhu77xdfe9ztmru"
        ]
      }
    }
  ],
  "hex": "02000000000101f2bb9429b75c046fcb99d7a7763d0d3301019dea946c229b7cdbb9057e107d2d0100000000feffffff02a3270000000000001600144f154d4e85d1cae0a8ee766b6a0b37c2905e6b9450a900000000000016001456e9c0c2cf6de4fbe76bf10bdeabedbf3de335390247304402206eaaa210752ca3418606bca1883b563e7b40c8488c50ade9c542d80f131c20a302202ba50d08ffcba7b5e65251969861621064ce3c4b6d61b3e1236b56c15ef124b1012102ae77a4757d225d777d3d4320c2678864ff3608bee5a326149358d6a6edb074181e6e2900",
  "blockhash": "9a03b9c095c170b270073b54da293be64dec9a90ed065cce562cf065ff6a9906",
  "confirmations": 7,
  "time": 1720211910,
  "blocktime": 1720211910
}

Blockchair api gives the same without input address: https://api.blockchair.com/litecoin/raw/transaction/75c83da6ddf052405b5629fd30609783bd002ba80db3a947c52e13b8779022b5
legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
Is this possible without txindex=1?I use a pruned node.
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:
Code:
getrawtransaction "cfb247517f143c0bf5b1ffeca8789f29000c64881e3ed992976a954b58b024d0" (2, "00000000000000000000a8e2c7fcd3b21caa2da453d956f86ec1e77ff39fd0b8")
Result:
Code:
{
  "in_active_chain": true,
  "txid": "cfb247517f143c0bf5b1ffeca8789f29000c64881e3ed992976a954b58b024d0",
  "hash": "9fbe051c4ecc33a306156b489f71eb160fc4179eb0a991c6930b7a294cea74e9",
  "version": 2,
  "size": 394,
  "vsize": 232,
  "weight": 928,
  "locktime": 0,
  "vin": [
    {
      "txid": "1e00b133c90fe8d43039d2cc62df138ed1ac60a39f4dac356a0f9b57f7274db3",
      "vout": 1,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "txinwitness": [
        "304402203339a2d122b03d7afd1f19f2afcda93e3d2d4e996e032b6d7cf2c1dcca97052e02205012f1f8ad6b6cb89b7a2f13a1e8c4fa6c78760da9f0931b08b994ab0533446e01",
        "0363dca8904864aa8aef426b6253b3665909ca4fc3b24cd43e5f05150511825b0c"
      ],
      "prevout": {
        "generated": false,
        "height": 850753,
        "value": 0.00000546,
        "scriptPubKey": {
          "asm": "0 527500fb3b5b7cdd522524287c9a0cd09ed0508d",
          "desc": "addr(bc1q2f6sp7emtd7d6539ys58exsv6z0dq5ydu2xnhq)#4w8k5ahs",
          "hex": "0014527500fb3b5b7cdd522524287c9a0cd09ed0508d",
          "address": "bc1q2f6sp7emtd7d6539ys58exsv6z0dq5ydu2xnhq",
          "type": "witness_v0_keyhash"
        }
      },
      "sequence": 4294967295
    },
    {
      "txid": "e3cf7ba33137218105be5eb8740ca41887c3ce830cf9a2017c7fa1e4738546d1",
      "vout": 2,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "txinwitness": [
        "304402205131daeef0baa06660c5be9984ba0255b9fa46d960fadbe06908e3e20a6e927d0220660b06b940af97346220a11266d7a1631619c1717315b1d9eadfabc1275bf85f01",
        "03497a874c3412319689cc435756a820c3cf4cbb22d88ccafa29a8dc5e74eaa538"
      ],
      "prevout": {
        "generated": false,
        "height": 850738,
        "value": 0.00705938,
        "scriptPubKey": {
          "asm": "0 d58d2895ae676864b28af1d980c797d83f4d781f",
          "desc": "addr(bc1q6kxj39dwva5xfv5278vcp3uhmql567qlpldtcr)#afxt7ysj",
          "hex": "0014d58d2895ae676864b28af1d980c797d83f4d781f",
          "address": "bc1q6kxj39dwva5xfv5278vcp3uhmql567qlpldtcr",
          "type": "witness_v0_keyhash"
        }
      },
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 0.00000000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_RETURN 13 00c0a233038097b7e0ae0101",
        "desc": "raw(6a5d0c00c0a233038097b7e0ae0101)#m6f8ms85",
        "hex": "6a5d0c00c0a233038097b7e0ae0101",
        "type": "nulldata"
      }
    },
    {
      "value": 0.00000546,
      "n": 1,
      "scriptPubKey": {
        "asm": "0 979bdd94f2d5972c062a7839ef114c193eca970a",
        "desc": "addr(bc1qj7dam98j6ktjcp320qu77y2vrylv49c2k2hkmu)#0ms2gq9q",
        "hex": "0014979bdd94f2d5972c062a7839ef114c193eca970a",
        "address": "bc1qj7dam98j6ktjcp320qu77y2vrylv49c2k2hkmu",
        "type": "witness_v0_keyhash"
      }
    },
    {
      "value": 0.00697938,
      "n": 2,
      "scriptPubKey": {
        "asm": "0 d58d2895ae676864b28af1d980c797d83f4d781f",
        "desc": "addr(bc1q6kxj39dwva5xfv5278vcp3uhmql567qlpldtcr)#afxt7ysj",
        "hex": "0014d58d2895ae676864b28af1d980c797d83f4d781f",
        "address": "bc1q6kxj39dwva5xfv5278vcp3uhmql567qlpldtcr",
        "type": "witness_v0_keyhash"
      }
    }
  ],
  "fee": 0.00008000,
  "hex": "02000000000102b34d27f7579b0f6a35ac4d9fa360acd18e13df62ccd23930d4e80fc933b1001e0100000000ffffffffd1468573e4a17f7c01a2f90c83cec38718a40c74b85ebe0581213731a37bcfe30200000000ffffffff0300000000000000000f6a5d0c00c0a233038097b7e0ae01012202000000000000160014979bdd94f2d5972c062a7839ef114c193eca970a52a60a0000000000160014d58d2895ae676864b28af1d980c797d83f4d781f0247304402203339a2d122b03d7afd1f19f2afcda93e3d2d4e996e032b6d7cf2c1dcca97052e02205012f1f8ad6b6cb89b7a2f13a1e8c4fa6c78760da9f0931b08b994ab0533446e01210363dca8904864aa8aef426b6253b3665909ca4fc3b24cd43e5f05150511825b0c0247304402205131daeef0baa06660c5be9984ba0255b9fa46d960fadbe06908e3e20a6e927d0220660b06b940af97346220a11266d7a1631619c1717315b1d9eadfabc1275bf85f012103497a874c3412319689cc435756a820c3cf4cbb22d88ccafa29a8dc5e74eaa53800000000",
  "blockhash": "00000000000000000000a8e2c7fcd3b21caa2da453d956f86ec1e77ff39fd0b8",
  "confirmations": 1,
  "time": 1720151784,
  "blocktime": 1720151784
}

But if the block is already pruned, it wont work. You'll have to use txindex and intact blockchain.
member
Activity: 239
Merit: 59
a young loner on a crusade
How to get a transaction input address, like block explorers do, directly from Core client? I need it to return a payment to one of the sending addresses.

litecoin-cli gettransaction:
Code:
{
  "amount": 0.00005851,
  "confirmations": 2,
  "blockhash": "1ee0005f20625b4dda47cff35a0214940d5c0e8f33cc42054a9ffa3e1370583d",
  "blockheight": 2714382,
  "blockindex": 318,
  "blocktime": 1720098028,
  "txid": "5c4dcff65ed69060f84005fcfc9c9cccd1d2eed38d30d2df95f4524ce1075576",
  "walletconflicts": [
  ],
  "time": 1720097921,
  "timereceived": 1720097921,
  "bip125-replaceable": "no",
  "details": [
    {
      "address": "ltc1qevgc8uymrxd3vq3vztmqhz0tq2y3jpx8twn2qt",
      "category": "receive",
      "amount": 0.00005851,
      "label": "",
      "vout": 1
    }
  ],
  "hex": "020000000001015ed7d1b7f75e3e3c0901b97fa96095d8e3a2d8fdaad07ff5b2e0d0bbd7e12ecf0100000000feffffff02327d030000000000160014ce295448dda30f95852504b78071b3dd23b68232db16000000000000160014cb1183f09b199b16022c12f60b89eb02891904c70247304402201b4a01969140b75d66b797718819d0fcc6538962d666298b9d020db3a9e47b8e022020dea3ec9ecbdb244c3c745555e7e0a553f81785292fa3233209b5bce8009b2801210276771913879beb7efe864f26486987637d06649c01d362dbc3a8d94a35556f7d0d6b2900"
}

I use Litecoin for testing because it works better than Testnet

https://live.blockcypher.com/ltc/decodetx/ shows "inputs" address when decoding "hex":
Code:
{
    "addresses": [
        "ltc1qevgc8uymrxd3vq3vztmqhz0tq2y3jpx8twn2qt",
        "ltc1q70uam3y0hrg3uypsupteldu4dw2385kmks8yqs",
        "ltc1qec54gjxa5v8etpf9qjmcqudnm53mdq3jze7y5s"
    ],
    "block_height": -1,
    "block_index": -1,
    "confirmations": 0,
    "double_spend": false,
    "fees": 155,
    "hash": "5c4dcff65ed69060f84005fcfc9c9cccd1d2eed38d30d2df95f4524ce1075576",
    "inputs": [
        {
            "addresses": [
                "ltc1q70uam3y0hrg3uypsupteldu4dw2385kmks8yqs"
            ],
            "age": 2714381,
            "output_index": 1,
            "output_value": 234664,
            "prev_hash": "cf2ee1d7bbd0e0b2f57fd0aafdd8a2e3d89560a97fb901093c3e5ef7b7d1d75e",
            "script_type": "pay-to-witness-pubkey-hash",
            "sequence": 4294967294,
            "witness": [
                "304402201b4a01969140b75d66b797718819d0fcc6538962d666298b9d020db3a9e47b8e022020dea3ec9ecbdb244c3c745555e7e0a553f81785292fa3233209b5bce8009b2801",
                "0276771913879beb7efe864f26486987637d06649c01d362dbc3a8d94a35556f7d"
            ]
        }
    ],
    "lock_time": 2714381,
    "outputs": [
        {
            "addresses": [
                "ltc1qec54gjxa5v8etpf9qjmcqudnm53mdq3jze7y5s"
            ],
            "script": "0014ce295448dda30f95852504b78071b3dd23b68232",
            "script_type": "pay-to-witness-pubkey-hash",
            "value": 228658
        },
        {
            "addresses": [
                "ltc1qevgc8uymrxd3vq3vztmqhz0tq2y3jpx8twn2qt"
            ],
            "script": "0014cb1183f09b199b16022c12f60b89eb02891904c7",
            "script_type": "pay-to-witness-pubkey-hash",
            "value": 5851
        }
    ],
    "preference": "low",
    "received": "2024-07-04T13:13:34.80374529Z",
    "relayed_by": "50.17.116.247",
    "size": 222,
    "total": 234509,
    "ver": 2,
    "vin_sz": 1,
    "vout_sz": 2,
    "vsize": 141
}

My own Core installation does not show the sending address:
Code:
{
  "txid": "5c4dcff65ed69060f84005fcfc9c9cccd1d2eed38d30d2df95f4524ce1075576",
  "hash": "94af7b95225412fe812b24dc64c9a027b204b7ccef14cde38212c860fa129e9f",
  "version": 2,
  "size": 222,
  "vsize": 141,
  "weight": 561,
  "locktime": 2714381,
  "vin": [
    {
      "ismweb": false,
      "txid": "cf2ee1d7bbd0e0b2f57fd0aafdd8a2e3d89560a97fb901093c3e5ef7b7d1d75e",
      "vout": 1,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "txinwitness": [
        "304402201b4a01969140b75d66b797718819d0fcc6538962d666298b9d020db3a9e47b8e022020dea3ec9ecbdb244c3c745555e7e0a553f81785292fa3233209b5bce8009b2801",
        "0276771913879beb7efe864f26486987637d06649c01d362dbc3a8d94a35556f7d"
      ],
      "sequence": 4294967294
    }
  ],
  "vout": [
    {
      "ismweb": false,
      "value": 0.00228658,
      "n": 0,
      "scriptPubKey": {
        "asm": "0 ce295448dda30f95852504b78071b3dd23b68232",
        "hex": "0014ce295448dda30f95852504b78071b3dd23b68232",
        "reqSigs": 1,
        "type": "witness_v0_keyhash",
        "addresses": [
          "ltc1qec54gjxa5v8etpf9qjmcqudnm53mdq3jze7y5s"
        ]
      }
    },
    {
      "ismweb": false,
      "value": 0.00005851,
      "n": 1,
      "scriptPubKey": {
        "asm": "0 cb1183f09b199b16022c12f60b89eb02891904c7",
        "hex": "0014cb1183f09b199b16022c12f60b89eb02891904c7",
        "reqSigs": 1,
        "type": "witness_v0_keyhash",
        "addresses": [
          "ltc1qevgc8uymrxd3vq3vztmqhz0tq2y3jpx8twn2qt"
        ]
      }
    }
  ]
}

Is this possible without txindex=1?I use a pruned node.
Jump to: