简体   繁体   English

支付提供商如何确认交易?

[英]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?我了解比特币交易可以有多个输入/输出,但我对支付提供商如何确认在 3rd 方钱包中收到付款很感兴趣?

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.归根结底,一旦您将交易 ID 发送给收件人(作为付款证明),他们就会想查看您的钱包、他们的钱包以及已支付的总金额。 Not 15 inputs and another 29 outputs, confirmations, and all that stuff.不是 15 个输入和另外 29 个输出、确认和所有这些东西。

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.但是我正在尝试将一个资源管理器放在一起,它可以更容易地以简单的方式(没有所有这些输入和输出)显示(向比特币普通用户)交易,但更简单的是 From, To, Value, Fee ,就是这样。

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.交易有数组vIn ,包含输入列表,在此交易中花费。 Each input spent output of another transaction, and value of output is specified in that vOut .每个输入都花费了另一个事务的 output ,并且在该 vOut 中指定了vOut的值。 Thus, for compute the input transaction value, you need iterate of vIn s of your transaction.因此,为了计算输入交易价值,您需要迭代交易的vIn For each In - you need extract pair (TXID,n), where:对于每个 In - 您需要提取对 (TXID,n),其中:

  • TXID - ID of transaction, whose output is spent here. TXID - 事务的 ID,其 output 用在这里。
  • n - index within vOut of that transaction n - 该交易的vOut内的索引

Thereafter, you must fetch transaction, extract appropriate vOut, and extract value from that vOut.此后,您必须获取交易,提取适当的 vOut,并从该 vOut 中提取价值。

For example, let review Emercoin transaction TXID= 5cf7bb31bde158a12abb6d4d9ff7acd91a00fc71a2baca601405114322fa171d例如,让我们查看 Emercoin 交易 TXID= 5cf7bb31bde158a12abb6d4d9ff7acd91a00fc71a2baca601405114322fa171d

When we will run the command:当我们将运行命令时:

$ emc getrawtransaction 5cf7bb31bde158a12abb6d4d9ff7acd91a00fc71a2baca601405114322fa171d 1

we will see long JSON output, contains:我们将看到长 JSON output,包含:

 "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:如您所见,此交易有来自同一 TX 的 2 个输入:

  • ab16f439260f41d4e086428c78a5ef3fdb31002f4ce942e212b7c6071e52135c, 1 ab16f439260f41d4e086428c78a5ef3fdb31002f4ce942e212b7c6071e52135c, 1
  • ab16f439260f41d4e086428c78a5ef3fdb31002f4ce942e212b7c6071e52135c, 0 ab16f439260f41d4e086428c78a5ef3fdb31002f4ce942e212b7c6071e52135c, 0

Extract them with a commands:使用命令提取它们:

$ emc getrawtransaction ab16f439260f41d4e086428c78a5ef3fdb31002f4ce942e212b7c6071e52135c 1

And you will see vOut array, contains values:你会看到 vOut 数组,包含值:

  "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).将所有这些值相加,您将得到一个总的 TX 输入值(输出值可以更少,因为 TX FEE)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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