简体   繁体   中英

How does payment providers confirm transactions?

I understand bitcoin transactions can have multiple inputs/outputs but I'm intrigued on how payment providers confirm the receipt of payment in a 3rd party wallet?

I understand that once you are inside a wallet, you have a different perspective of the transaction and therefore you can provide a clear view to the user about that specific transaction - as you know which addresses belong to that wallet.

But, is there a way to guess, or get closer to an aggregation of the value of the transaction that doesnt belong to a wallet you own? So we could show it clearly to the user: How much was sent, from where to and how much. Ok there may be multiple outputs, which we have to show, but we can aggregate them and show the sum of the transaction. In the end of the day, once you send a transaction id to a recipient (as proof of payment), they want to see your wallet, their wallet and the total amount which was paid. Not 15 inputs and another 29 outputs, confirmations, and all that stuff.

I get it, its all very important and yadayadayada.

But I'm trying to put together an explorer where it would be easier to show (to a Bitcoin normal user) a transaction in a simple way (without all those inputs and outputs), but something simpler as From, To, Value, Fee, and that's it.

I understand that, by design, the blockchain doesn't work that way. In any case, I would like to ask the community here if you have any clue or idea on how to achieve this or closer to this:)

I'm open to suggestions and ideas on this, cheers!

Thanks in advance,

But, is there a way to guess, or get closer to an aggregation of the value of the transaction that doesnt belong to a wallet you own?

Yes, of course. In the wallet, you can just run the command:

getrawtransaction <TXID> 1

for any translation - belong to your wallet, or not belong.

A transaction has array vIn , contains list of inputs, spent in this transaction. Each input spent output of another transaction, and value of output is specified in that vOut . Thus, for compute the input transaction value, you need iterate of vIn s of your transaction. For each In - you need extract pair (TXID,n), where:

  • TXID - ID of transaction, whose output is spent here.
  • n - index within vOut of that transaction

Thereafter, you must fetch transaction, extract appropriate vOut, and extract value from that vOut.

For example, let review Emercoin transaction TXID= 5cf7bb31bde158a12abb6d4d9ff7acd91a00fc71a2baca601405114322fa171d

When we will run the command:

$ emc getrawtransaction 5cf7bb31bde158a12abb6d4d9ff7acd91a00fc71a2baca601405114322fa171d 1

we will see long JSON output, contains:

 "vin": [
    {
      "txid": "ab16f439260f41d4e086428c78a5ef3fdb31002f4ce942e212b7c6071e52135c",
      "vout": 1,
      "scriptSig": {
        "asm": "3045022100e055effb7427af1a8504387fcdc8ed10859d029695e6a3d10d8e24794c9d55a802205ec2ceb8a937573b306f859bf34654edfc8b9c1716c008c0ae0e4b258b936b0b[ALL] 024d68c6511929667f80caae1f46a5cee3a307503a429f6ccc2ef52e306f966f87",
        "hex": "483045022100e055effb7427af1a8504387fcdc8ed10859d029695e6a3d10d8e24794c9d55a802205ec2ceb8a937573b306f859bf34654edfc8b9c1716c008c0ae0e4b258b936b0b0121024d68c6511929667f80caae1f46a5cee3a307503a429f6ccc2ef52e306f966f87"
      },
      "sequence": 4294967294
    }, 
    {
      "txid": "ab16f439260f41d4e086428c78a5ef3fdb31002f4ce942e212b7c6071e52135c",
      "vout": 0,
      "scriptSig": {
        "asm": "304402206c177d2be96bf666c147e0c13561d7d2cf915f8f8f1f16aeaa805383acc5572e02206104a70e6781d151476bd0345f27adaf896adb505f0fd285adcaddf4474f7de0[ALL] 03370ebd7dae0e80420ebf7d6326759517d8e58821337b476b2656f739bf0082de",
        "hex": "47304402206c177d2be96bf666c147e0c13561d7d2cf915f8f8f1f16aeaa805383acc5572e02206104a70e6781d151476bd0345f27adaf896adb505f0fd285adcaddf4474f7de0012103370ebd7dae0e80420ebf7d6326759517d8e58821337b476b2656f739bf0082de"
      },

As you see, this transaction has 2 inputs from the same TX:

  • ab16f439260f41d4e086428c78a5ef3fdb31002f4ce942e212b7c6071e52135c, 1
  • ab16f439260f41d4e086428c78a5ef3fdb31002f4ce942e212b7c6071e52135c, 0

Extract them with a commands:

$ emc getrawtransaction ab16f439260f41d4e086428c78a5ef3fdb31002f4ce942e212b7c6071e52135c 1

And you will see vOut array, contains values:

  "vout": [
    {
      "value": 0.000100,
      "n": 0,
      "scriptPubKey": {
        "asm": "2 OP_DROP 30354830384b35354449 9999 OP_2DROP 747970653d74657374696e670a2c706f736974696f6e5f69643d313031340a2c706f736974696f6e5f6e616d653dd09cd0bed0b4d0b5d0bbd0b820d0a1d092d09a2e20d09fd180d0b5d0b8d0bcd183d189d0b5d181d182d0b2d0b020d0b820d0bdd0b5d0b4d0bed181d182d0b0d182d0bad0b82028d0a4d0b8d0bd2e20d090d0bad0b0d0b4d0b5d0bcd0b8d18f290a2c76616c75653d36340a2c656e645f74696d653d313539363033323330313532300a2c636f6d70616e793d46696e61636164656d79 OP_DROP OP_DUP OP_HASH160 038411f3dfac30f42e999b87b165046bc205919f OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "52750a30354830384b35354449020f276d4cc4747970653d74657374696e670a2c706f736974696f6e5f69643d313031340a2c706f736974696f6e5f6e616d653dd09cd0bed0b4d0b5d0bbd0b820d0a1d092d09a2e20d09fd180d0b5d0b8d0bcd183d189d0b5d181d182d0b2d0b020d0b820d0bdd0b5d0b4d0bed181d182d0b0d182d0bad0b82028d0a4d0b8d0bd2e20d090d0bad0b0d0b4d0b5d0bcd0b8d18f290a2c76616c75653d36340a2c656e645f74696d653d313539363033323330313532300a2c636f6d70616e793d46696e61636164656d797576a914038411f3dfac30f42e999b87b165046bc205919f88ac",
        "reqSigs": 1,
        "type": "name_pubkeyhash",
        "addresses": [
          "EHUVjZ2cyTqjvqxkg7h587XeEMAGpsi4sX"
        ]
      }
    }, 
    {
      "value": 1.509200,
      "n": 1,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 085caddacb878333658194f96ec45b035be541d8 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914085caddacb878333658194f96ec45b035be541d888ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "EHv7vaRDN1q7b7XsmRYEugj6MuZpADbvYy"
        ]
      }
    }
  ],

Add all of these values, and you will get a total TX input value (output value can be less, since TX FEE).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM