今までの試行、コメント、MasteringBitcoin読書により断片的な知識は得た。これで何とか総支払額を算出できないか考えてみた。

MasteringBitcoin日本語訳を読む(Script言語)

272ページ中126〜129ページ。

前回まで

目的

取引データが支払か受取か判別する方法を知りたくて読む。

前回

vinscriptSigをどうにかすれば自分が支払う取引か否かを判定できそう。でもそのためには秘密鍵が必要らしくJavaScriptで実行するにはセキュリティ的に危険。

scriptSigを入力にしてscriptPubKeyにあるscriptを実行することで本人確認できると思われる。が、そもそもScript言語のコンパイラがJavaScript上に存在しないはず。

どのみちscriptを使って支払・受取の判別はできないのでは? なら一体どうすれば判別できるの?

これまでの教えから推測する

おそらくscript実行には専用コンパイラが必要で、それはローカル環境でしか作れない。その環境を作ったサーバを用意してローカルで判定するか、REST APIとして公開するようなことはできるかもしれない。あるいはすでにそういうサービスがあるかもしれない。

ブロックチェーン・エクスプローラがそれかもしれない。ブロックチェーン・エクスプローラのことは以前コメントでも教えていただいたし、あとで読んだMasteringBitcoinの中でも見かけた。

Counterparty や Counterblock は、セカンドレイヤ・チェーン (Counterparty やモナパーティ)のために存在します。 ファーストレイヤー (Bitcoin やモナコイン) の情報は一部しか提供しません。仰る「手数料」がモナコインの採掘手数料を指すなら、モナコインを対象とするブロックチェーン・エクスプローラを利用する必要があります。たとえば https://blockbook.electrum-mona.org/ です。API の使い方は GitHub にあります。https://github.com/trezor/blockbook/blob/master/docs/api.md#get-transaction

コメントで教わったURL先のREADMEを読んでみる。ブロックハッシュというのはMasteringBitcoinでいうブロックヘッダと関係あるのだろうか。これと秘密鍵を使い、なんやかんや計算し、vinscriptSigだかvoutscriptPubKeyだかと一致すれば本人が支払う取引データであると判断できるとか?

あるいは指定アドレスの全トランザクションを取得し、そこからuxto(未使用アウトプット)を取得するAPIを使ってその要素を抜けば、残ったものが支払いトランザクションなのでは? その和が総支払額になるのでは?

この路線で調査してみよう。

GET /api/v1/utxo/{address}

GET /api/v1/utxo/{address}

とりあえず私のアドレスを渡してuxtoを取得してみる。

https://blockbook.electrum-mona.org/api/v1/utxo/MEHCqJbgiNERCH3bRAtNSSD9uxPViEX1nu
[{"txid":"394eabd9532a09793adf03f229effc88c55185dba59b6fce53559013ba377146","vout":0,"amount":"0.0222","satoshis":2220000,"height":2709785,"confirmations":45},{"txid":"f5421dfef52c33822038c6ecaba1cb146943c67aa99bfb269f2be7566952decf","vout":1,"amount":"0.00114","satoshis":114000,"height":2709367,"confirmations":463},{"txid":"bd4e1f0a6373027d38e7a284969df79f4ffa78f3973b282546097c3be8f33f75","vout":1,"amount":"0.001","satoshis":100000,"height":2709267,"confirmations":563},{"txid":"e3f5b65087c770e7a218ff775cd1c33ae5393aa8159465b33cd6bb2e301e91fe","vout":0,"amount":"0.0222","satoshis":2220000,"height":2709178,"confirmations":652},{"txid":"570d83eceb834dda1e601e1a0349602310a07c48d14e6f88375e7c7eacc88438","vout":1,"amount":"0.001","satoshis":100000,"height":2709036,"confirmations":794},{"txid":"cab09e03c9f58be0e89f71a62c9fbc3fe26f16005be66c95e428dbd1d5900548","vout":1,"amount":"0.001","satoshis":100000,"height":2708879,"confirmations":951},{"txid":"83cdacb3932e4fa28909c838c37d95a053e049f2532f4b58cf609ee61363ba0f","vout":0,"amount":"0.114315","satoshis":11431500,"height":2708405,"confirmations":1425},{"txid":"ae30aba3825721ac1ca61678c52b257427ef71557209357a58ce4c5a5c2f0dd9","vout":0,"amount":"0.001","satoshis":100000,"height":2708342,"confirmations":1488},{"txid":"1d91bbcb5f20b457313e738224012b1e1b44eb275839c2867dc997b9b7c04e0f","vout":1,"amount":"0.00114","satoshis":114000,"height":2708143,"confirmations":1687},{"txid":"16cd6acae8f8d831808f0fbc84bbcb5b61b70fe18326424450d7143e592da3c7","vout":1,"amount":"0.00114","satoshis":114000,"height":2708090,"confirmations":1740},{"txid":"85e702bde5f359772a97784628119170d5823a79adf1d7e0f2c51378e35cd081","vout":0,"amount":"0.114315","satoshis":11431500,"height":2708065,"confirmations":1765},{"txid":"a448c5b0cfc49db119519fadba4f99d235d16b46bff6cfb4de1d89ff2180fc3b","vout":1,"amount":"0.003","satoshis":300000,"height":2707979,"confirmations":1851},{"txid":"a932f303af8829932f69fd8708a046a638c0132a885536a0109d4085fe5561eb","vout":0,"amount":"0.00114","satoshis":114000,"height":2707580,"confirmations":2250},{"txid":"465fd6191ebe50495c55fc922ac9e70c61f1dafc18f0852f52f874d7ca8d7273","vout":1,"amount":"0.00114","satoshis":114000,"height":2707545,"confirmations":2285},{"txid":"6541964282c63b17c7cb9a1efa371576d2c3d4ea77ebc447dcce5eb76cfd0d58","vout":1,"amount":"0.00114","satoshis":114000,"height":2707390,"confirmations":2440},{"txid":"fe6513275f3607f809f386a0c4be924e287f456b0251e471ad6d446cbf20a685","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2707286,"confirmations":2544},{"txid":"2313631a3afcafbaead1e1a11d09c09f3081c5697856f1ef4f738b92e574ad09","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2707286,"confirmations":2544},{"txid":"76933f139080ff35a7c2daa0ee7bd9ecf812063290b4475a6f1a3ae7764ce1f0","vout":0,"amount":"0.00114","satoshis":114000,"height":2706669,"confirmations":3161},{"txid":"3e911a24be7101a4a03bd1bbdb17ef160fd77f9ab766c1cb631367829e1a57f4","vout":1,"amount":"0.001","satoshis":100000,"height":2706387,"confirmations":3443},{"txid":"e4a0a483bedefc033ff2f5991520b411e4b01d5ae719d5a6a9bce252dfbfcdc3","vout":0,"amount":"0.114315","satoshis":11431500,"height":2706381,"confirmations":3449},{"txid":"b18a0aef0726eb1e83d4753b37420af5402a1110f3a2c009d656a618fe47e9c8","vout":0,"amount":"0.114315","satoshis":11431500,"height":2705379,"confirmations":4451},{"txid":"dfd1a387ec540d6da946fb544824597a542d7e1c5b4079bd8805d26bde536159","vout":0,"amount":"0.114315","satoshis":11431500,"height":2704685,"confirmations":5145},{"txid":"327c74ee1853668a558036c3ca816a5ab01e7f297fbad95f26635e0867959415","vout":0,"amount":"0.114114","satoshis":11411400,"height":2703622,"confirmations":6208},{"txid":"289fe75242d284af6905a16c23797ddd0b93df974ad5429ea96bc325b7dcd853","vout":0,"amount":"0.114114","satoshis":11411400,"height":2703621,"confirmations":6209},{"txid":"aa8ebd4b2c543d04e744aed238ac532479d75bb24138d6c72c8b0dc375ebcf61","vout":0,"amount":"0.114114","satoshis":11411400,"height":2703619,"confirmations":6211},{"txid":"42da297750dbf5a6dd3181780d7bfcb1dc646e22063f4e7d9b0c9133ff25b98d","vout":0,"amount":"0.114114","satoshis":11411400,"height":2703618,"confirmations":6212},{"txid":"6ec59ba9196a32ba3f340e894eee3a5d97c1ab006947b0a31364101606ed3e5c","vout":0,"amount":"0.114114","satoshis":11411400,"height":2703617,"confirmations":6213},{"txid":"364b1eb98fd98c65ce6957f1cb61c10ef16de0fa7ea197decf8fce83f78ec5bd","vout":0,"amount":"0.114114","satoshis":11411400,"height":2703599,"confirmations":6231},{"txid":"7b423d28e2328d96768f5ecbb7e83ee29c2ef2d418913bc96084f60a8312eeb9","vout":0,"amount":"0.114114","satoshis":11411400,"height":2703596,"confirmations":6234},{"txid":"608d51fcb92f35853aaa94ea69acf4b134ce4d8008ddb20a935e55049eae349c","vout":0,"amount":"1.14114","satoshis":114114000,"height":2703593,"confirmations":6237},{"txid":"268b109cf0269f1d93d880c3b08cc3da074537ebacb12528bbb542c83447e5fc","vout":0,"amount":"0.114114","satoshis":11411400,"height":2703593,"confirmations":6237},{"txid":"1b6ee3272b2c16572da7370ed65d1b2d5e253ab552fa411a24956b8610421897","vout":0,"amount":"0.114114","satoshis":11411400,"height":2703590,"confirmations":6240},{"txid":"883c333dbf94ab25602e82112c5008eb81bb129b3f8cf9ddfe63d840aaaf381d","vout":0,"amount":"0.114114","satoshis":11411400,"height":2703589,"confirmations":6241},{"txid":"5e708bc9c5cec0812d66808ff07a4af664c02a8aaf970cbd0092f23a410e1dc0","vout":0,"amount":"0.114114","satoshis":11411400,"height":2703586,"confirmations":6244},{"txid":"5244c2179e164a96e5e3feb9d165aef6090f0281658105ea6e34f54e59503d41","vout":0,"amount":"0.055","satoshis":5500000,"height":2703519,"confirmations":6311},{"txid":"bbae4abe7b090030fb37f82141669bbc3eada55bd7ea716d5d44d02a07253091","vout":0,"amount":"0.02525","satoshis":2525000,"height":2703488,"confirmations":6342},{"txid":"5894d2facf6e6083141aca34a9ba81ceb5e116174233d328576e1e686678a292","vout":0,"amount":"0.114315","satoshis":11431500,"height":2703361,"confirmations":6469},{"txid":"92ba464b926cda317908d51c8702d8494d838fe80d3a5892c473dddbc029dd0e","vout":0,"amount":"0.1","satoshis":10000000,"height":2702972,"confirmations":6858},{"txid":"7271195349926a04f667f8dd3751f24559cf9da321c74d41d498c4999b749960","vout":0,"amount":"0.0114315","satoshis":1143150,"height":2702946,"confirmations":6884},{"txid":"f8bc7cf3b5776624493251ed0f5a5c286303d68dbc22fccec0f61106a90f82a0","vout":0,"amount":"0.114114","satoshis":11411400,"height":2702848,"confirmations":6982},{"txid":"9722cde73f91bf04874fedde8c1989388dfc83d5618a7f8a5f02728ac1a8e2d6","vout":0,"amount":"0.114315","satoshis":11431500,"height":2702659,"confirmations":7171},{"txid":"0d125e81934cb58c38d00c6c0ecccf1469288242bcf6e4fe16da955ad7364510","vout":0,"amount":"0.0222","satoshis":2220000,"height":2701991,"confirmations":7839},{"txid":"f9a387695fee01cb0c2e0c17629c261ca01160fb88f8ebe9f22453e3131cdab9","vout":0,"amount":"0.114114","satoshis":11411400,"height":2701114,"confirmations":8716},{"txid":"904325eadce09b36d629518580c4270fdbb4f468b6e27c5f8b84798b787ef023","vout":0,"amount":"0.114315","satoshis":11431500,"height":2701053,"confirmations":8777},{"txid":"7a3ec354f66dde32719131a099df46a67024eeea336e163bcd224414684f64ee","vout":0,"amount":"0.07974","satoshis":7974000,"height":2701023,"confirmations":8807},{"txid":"b5d71f29223c92027db483ecf34c1f23bf173e242e12a6fbfc161a78f2fefd5c","vout":0,"amount":"0.07974","satoshis":7974000,"height":2701006,"confirmations":8824},{"txid":"ff9fe93e566312b5451876446cfe22e73e97bb33a4db554d63a6a45eb457586d","vout":1,"amount":"1.0155696","satoshis":101556960,"height":2700658,"confirmations":9172},{"txid":"18612323ca3f8a4cb953c9c2b406ae8cd86a40dbe3a98bfe9c5bc922f01655f0","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2700171,"confirmations":9659},{"txid":"32e5bd7baf9f5f74aef8ab38cc09b6cd5339fbc1a9727b7a77e29f3c7c2c5280","vout":0,"amount":"0.114315","satoshis":11431500,"height":2700143,"confirmations":9687},{"txid":"c00473a5a819b922469a9369fd204f2e94e327fded709e9ea6c3181f7f1b3007","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2699886,"confirmations":9944},{"txid":"fc5f9aef3d5e510784285b029061e60962feb69327e643759d3f895c2ea61b96","vout":0,"amount":"0.114315","satoshis":11431500,"height":2699886,"confirmations":9944},{"txid":"28104be0b1ee0a6dddb61d800366759515f45225e5670b78b8909e3e1e83d067","vout":0,"amount":"0.114315","satoshis":11431500,"height":2699885,"confirmations":9945},{"txid":"e9531cd7cb4b63020459a7f6a51be3d1cfd5972d267c8e9fb405574d19597a73","vout":1,"amount":"1.1297061","satoshis":112970610,"height":2699778,"confirmations":10052},{"txid":"7522827e1caa01f4e9ed2cef80183b3d55f47e2dd338e3fda07fd13c7f6e3867","vout":0,"amount":"0.05","satoshis":5000000,"height":2699401,"confirmations":10429},{"txid":"eca4d29b8eeb07b2838d39b85f595bb3b68876e214927fac351a5e211f5a16c8","vout":0,"amount":"0.055","satoshis":5500000,"height":2698595,"confirmations":11235},{"txid":"95d2a759421f0c68a7729abab36005e756ec815cc4146e2ae1af927cf2846909","vout":0,"amount":"0.114114","satoshis":11411400,"height":2698502,"confirmations":11328},{"txid":"d368d3fe4f54abaacebe0e69473138317950b592bc018a6155978add98ded9b3","vout":0,"amount":"0.114114","satoshis":11411400,"height":2698486,"confirmations":11344},{"txid":"28483ebbd0b142a5fff43e7ce94b4a43b03cda9d7c462dc5be487eae52e634ea","vout":0,"amount":"0.2525","satoshis":25250000,"height":2698456,"confirmations":11374},{"txid":"39f78e1c8da9cabe1461d24c8d75b792f7a2ffbb4dbb5dfc05c7d06a5d913760","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2698420,"confirmations":11410},{"txid":"d62291fd82352364aedc7778df01156b187da637b1c6f18978083293ae45ee55","vout":0,"amount":"0.114315","satoshis":11431500,"height":2697428,"confirmations":12402},{"txid":"9cc11243498f18d4a65f8d58f54d122d481e6ae2f504210ebcb6ce7ce5a37115","vout":0,"amount":"0.114315","satoshis":11431500,"height":2697085,"confirmations":12745},{"txid":"9c302ffe3a397052dcce7627b9796e775254398197c68c6503953e2cf98a2485","vout":0,"amount":"0.114315","satoshis":11431500,"height":2696052,"confirmations":13778},{"txid":"e19f422375439496abd26da6c9c5f251fa604afee4f54cb874d1a0309436cdb1","vout":0,"amount":"0.114315","satoshis":11431500,"height":2694578,"confirmations":15252},{"txid":"9a5bee5638e7892cde8ae9b8e921f74cc09fa01615a978832922db98fd314248","vout":0,"amount":"0.114315","satoshis":11431500,"height":2694577,"confirmations":15253},{"txid":"6d4e016c8c958804779d6ead471c298eef868ad7525838885ca5f2fe0e168bef","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2693722,"confirmations":16108},{"txid":"53aa1e1df28be33beae69e655f4eaebe6dca3ccfc8a7d522ecacc399e422d843","vout":0,"amount":"0.114114","satoshis":11411400,"height":2692689,"confirmations":17141},{"txid":"b999d888560d0e1a17d1f0e30bd438135a8d9e90d6793f94bc8c650a46c6a707","vout":0,"amount":"0.5963","satoshis":59630000,"height":2692689,"confirmations":17141},{"txid":"1c067d029776d0d97b6fa7ffb2bb7cbc375bec428db0b748be2101d33525eedd","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2691789,"confirmations":18041},{"txid":"3c5f60c410d931a38a417fb08e07c554482bf6509ccdca5edc04a39ebbe9bf9f","vout":0,"amount":"0.114114","satoshis":11411400,"height":2691747,"confirmations":18083},{"txid":"b9e124a3f032d5007472ca1f553c093efa00a391243b1aac0d21f2becdada7d8","vout":0,"amount":"0.114114","satoshis":11411400,"height":2691735,"confirmations":18095},{"txid":"0b8688a630eff478459bab9e420045589936631dba21f89576b36d3ebdde7b76","vout":0,"amount":"0.222","satoshis":22200000,"height":2690785,"confirmations":19045},{"txid":"4a53154c08e2916076c6ad495494b7bc155e8f4481fe554f8defea3599f9a0e0","vout":0,"amount":"0.114315","satoshis":11431500,"height":2690661,"confirmations":19169},{"txid":"e2803d73c4e6ca70e4e93b26692bf39c902b144a339f22bcc58003dd2c6102dd","vout":0,"amount":"0.114315","satoshis":11431500,"height":2689837,"confirmations":19993},{"txid":"f1419fa4f51d3e48f564121a80966fa82dd0c5e2ec3e79a866d4fe42d63d0083","vout":0,"amount":"0.114315","satoshis":11431500,"height":2688948,"confirmations":20882},{"txid":"fb0050ac32ef1dcb926cf35eedd7243904a543394be0b66cb6c122f86e89198e","vout":0,"amount":"0.114114","satoshis":11411400,"height":2688858,"confirmations":20972},{"txid":"986fac8358c68bf4e44010bd69e7f37841347061f049f716e675895ec3bafe27","vout":0,"amount":"0.114114","satoshis":11411400,"height":2688857,"confirmations":20973},{"txid":"538a3d92a5fe0467bd78bb85de002f132ff151b63015e9720eb190aec7f3c8d5","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2688279,"confirmations":21551},{"txid":"b0a35bf1be5892e435610eabbfcdaa9f06e8442d935d8f8ca425c9199eb8db0f","vout":0,"amount":"0.114315","satoshis":11431500,"height":2688279,"confirmations":21551},{"txid":"ac80e9582e257dc77bbbc84beb8972bba3201b2f77f2d5e02f883c6da66e7544","vout":0,"amount":"0.114315","satoshis":11431500,"height":2687278,"confirmations":22552},{"txid":"f6f8bcc2af150146b066ff64725fca4df82d6712ac19f9ab12bb12cf21dfb6ad","vout":0,"amount":"0.114315","satoshis":11431500,"height":2687073,"confirmations":22757},{"txid":"cb64e1375e87b3be44e14ef6c5fff92915495fd7064f6b23a71d7214c7b0e95c","vout":0,"amount":"0.114315","satoshis":11431500,"height":2686049,"confirmations":23781},{"txid":"19ee2ef83acc12ce84a2f60325718dc9a4b70b9d83d46d9f5fc71d7cd07c8279","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2685626,"confirmations":24204},{"txid":"a13f34982c4bf9886764c80e08558f95f724d5daa6931185450c16492c0c5085","vout":0,"amount":"0.114315","satoshis":11431500,"height":2684204,"confirmations":25626},{"txid":"b16db781bd3c4ebd17d815bb5117fd5542fa560a4c4c4a3107b2c3a343524e43","vout":0,"amount":"0.114315","satoshis":11431500,"height":2684204,"confirmations":25626},{"txid":"00573fae17c9957730a9e3250b8ab20d19ed88fd1b46c3d092e298192766e5d0","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2683857,"confirmations":25973},{"txid":"46315b8e698c326fc8167b0466d11aa0046d89d9c79360564d504b85c2b4e0ba","vout":0,"amount":"0.114114","satoshis":11411400,"height":2683349,"confirmations":26481},{"txid":"f74731a9e91118d1274a20b85b317cd0bed34686408bdba95656bd4be918d644","vout":0,"amount":"0.3939","satoshis":39390000,"height":2683349,"confirmations":26481},{"txid":"0cd08224a54f448f4c7fb856374c4e98eb2eb48718261854343a02ab6f1e5b21","vout":0,"amount":"0.114114","satoshis":11411400,"height":2683349,"confirmations":26481},{"txid":"75cd31f88453a5277962e7dffb7853e599e9be909a64252e4bcf1c773bfbee49","vout":0,"amount":"0.114114","satoshis":11411400,"height":2683347,"confirmations":26483},{"txid":"99f79eecbbd28ef43175dec6809d0f8abd9e49b56ab45d8b1a76e252f7ecd286","vout":0,"amount":"0.114315","satoshis":11431500,"height":2683275,"confirmations":26555},{"txid":"8e7e64a54402876d7d87916a5666efa3cc2b1bd67b7b348c4a65b046d388e49b","vout":0,"amount":"0.114315","satoshis":11431500,"height":2681813,"confirmations":28017},{"txid":"adec2d9816f01b4890a6614158b0f6fee311cfcc5d64dd9abc91e05c320dba74","vout":0,"amount":"0.114315","satoshis":11431500,"height":2680664,"confirmations":29166},{"txid":"cb49c13ddc650808187d4cb0d1f19ef7dbefe88fb7be124f57c7a1074b71cc6d","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2680664,"confirmations":29166},{"txid":"89e3f644050f90bc4a72ac357c070166d1189faa64be1cd0976dbb16fa87c7f9","vout":0,"amount":"0.114315","satoshis":11431500,"height":2679965,"confirmations":29865},{"txid":"1d2ba7cddbbf51ded3701ebd74425fdc2c832880601f17c76bde3ac7e7390cb2","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2678617,"confirmations":31213},{"txid":"3fc205e53cedeeb828d491ec8a7bbaaeb38cc8c0f0135523953f41c594626dae","vout":0,"amount":"0.114315","satoshis":11431500,"height":2678163,"confirmations":31667},{"txid":"206ad6442b309f37e9d0af8219d36207ce51b03d36b4b624a884f2c503180d9a","vout":0,"amount":"0.114114","satoshis":11411400,"height":2676936,"confirmations":32894},{"txid":"559cc4fe70bea88c4f702ae1e86a70c641353c4ae63a961f982865212454c04b","vout":0,"amount":"0.114114","satoshis":11411400,"height":2676935,"confirmations":32895},{"txid":"44df3397289311479bef3853e0efe14e059ead9ce4488b38f3fd99fb9a78f9c8","vout":0,"amount":"0.114114","satoshis":11411400,"height":2676931,"confirmations":32899},{"txid":"7774cc9cc79ac314231061e8cd3743d35417149a9167e81349356ed953eab86d","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2675075,"confirmations":34755},{"txid":"c044b53c833a6d470268cd9f76d15a35e28e80310b704cf3dbb19fa69cab13d5","vout":0,"amount":"0.114315","satoshis":11431500,"height":2674191,"confirmations":35639},{"txid":"de1da180409b74ed103fe4bb61c57b6bda3aad036751ec88dd9c5a78c813e888","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2674191,"confirmations":35639},{"txid":"b0dddd6202363324474d3f6e2580fceaacd66ce7e123e92cf28a849e315d1664","vout":0,"amount":"0.114114","satoshis":11411400,"height":2674097,"confirmations":35733},{"txid":"efe6b3efd5c22069109ed6b22468713082f8dcef137f16daafe63c9bfd9e78c9","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2673924,"confirmations":35906},{"txid":"0e6f6844385dd07856194b66aca40a94d40a7d109952b07bcff9782971c234c9","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2672740,"confirmations":37090},{"txid":"be13adb03b5b7f1b24e0bf18db01d5092406dcd3617b96e84cb1375e540c1bf5","vout":0,"amount":"0.114315","satoshis":11431500,"height":2672739,"confirmations":37091},{"txid":"e55d76e30e2b59d589cbf056baa0d6be4ce900bb6a7b59426f39eff715689665","vout":0,"amount":"0.114114","satoshis":11411400,"height":2672369,"confirmations":37461},{"txid":"c0ea3a09660da2f270f5ecca695caa0ff4047f9c2a7dec2d5222eb10c56337e9","vout":0,"amount":"0.114","satoshis":11400000,"height":2672368,"confirmations":37462},{"txid":"131f491bebef29fa4a9545ea894552bb302065dfadc405752c6f31142e5cad02","vout":0,"amount":"0.114114","satoshis":11411400,"height":2672368,"confirmations":37462},{"txid":"4e490864c0b975cc9c504adcec03bd1ecb793c3b0559b5ae1fc37e7af014b17a","vout":0,"amount":"0.114315","satoshis":11431500,"height":2672294,"confirmations":37536},{"txid":"91c8765e1b745420d288f9064b659aaadcb08d0ec9f0d05fab195f71e23b41cc","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2672293,"confirmations":37537},{"txid":"c15d93a315941c21a81d50a8fedbbf1fb0aae50217b1659b31039af3d6ae1f31","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2671389,"confirmations":38441},{"txid":"f78a61b91269bd8b16993f6f3d49c5ae23ed11b2376b3b394ae6a525308798bb","vout":0,"amount":"0.114315","satoshis":11431500,"height":2671389,"confirmations":38441},{"txid":"0524ae5c8415e4893c57604e5950c88553da673bcb6d8fd9dea2a5fd0eb7041b","vout":0,"amount":"0.3939","satoshis":39390000,"height":2670703,"confirmations":39127},{"txid":"bcad39c53288d19870b6ecb156cb89786c9576a1786b1d0d7e26338c56f81635","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2669573,"confirmations":40257},{"txid":"87236c5ba27d094ada5b110fdbd8513cf266cb4d442d7bb55bb7845a8e06388c","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2669006,"confirmations":40824},{"txid":"f30f6aa525b5e8e49d1cf06a30b1696c1ed7aa60e35f9ed60840db3e64f78a5f","vout":0,"amount":"0.114315","satoshis":11431500,"height":2668966,"confirmations":40864},{"txid":"4de2f455ec1c40f0962abf3d35cf8902d82f5a0e94170b882127578cda3bd26b","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2668966,"confirmations":40864},{"txid":"43e2a380e0f1a66f7dce9d3c62ca004bbe312b2e05f5b8f832f3c43598dd4d55","vout":0,"amount":"0.0114315","satoshis":1143150,"height":2668482,"confirmations":41348},{"txid":"f8c62ce8de3ec286d988499621f78d0aa4191d50e84eea7bdc7e4f3d4c365923","vout":0,"amount":"0.114114","satoshis":11411400,"height":2666378,"confirmations":43452},{"txid":"8f50c7f4c35fbd77a0ae669baf5f1d4fa69d04e34b3f777630d69156938c7f2c","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2666062,"confirmations":43768},{"txid":"4b0a9eeda48a03c3c09caee4f3608784669f87d9d475aaecc8c0a9d98da48c66","vout":1,"amount":"0.941095","satoshis":94109500,"height":2666003,"confirmations":43827},{"txid":"831c41287d17e58b7d566d875c203751e89c2c272cdfe8ad884ca848811c412c","vout":0,"amount":"0.114315","satoshis":11431500,"height":2665901,"confirmations":43929},{"txid":"9004fe5012c3bc067b48147dc5e03ece0bd1c92032be3b42823597ecb090dc63","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2665901,"confirmations":43929},{"txid":"35c204ccb2709bc0eb15a736991f020d45c8f20222ce5462207deb7b268cf752","vout":1,"amount":"0.8410725","satoshis":84107250,"height":2665230,"confirmations":44600},{"txid":"f48ba7e92f964a0f25bc2cbd0d025be5ecf6c4ed27ead3ffb453c3b0451fa2f3","vout":1,"amount":"0.8410725","satoshis":84107250,"height":2665230,"confirmations":44600},{"txid":"f361755e992a137104045aab29a3c8aa5a5b1728f3da1f0c14d6bc535d67aa5e","vout":0,"amount":"0.0114114","satoshis":1141140,"height":2665158,"confirmations":44672}]

おそらくuxtoがもつamountの和が「残高」になると思われる。

なら、全トランザクションからその要素を抜けば、残ったものが支払った取引データになるはず。

指定アドレスの支払い取引要素
=指定アドレスの全トランザクション要素−指定アドレスの未使用アウトプット要素

指定アドレスの全トランザクション取得は以下の方法。search_raw_transactions APIを使う。

問題は、どうやってuxtoと全トランザクション情報を一致判定させるか。txidが識別子っぽいので、それで一致判定させるのだろう。でも、全トランザクション情報の中でtxidを持っているのはvinのみ。vinは入力であり、もし自分が受け取る側の取引だったらvinには支払う相手側のtxidが入っている。私のではない。voutのおつり側ではないほうが私のuxtoになるはず。でも、voutのほうにtxidは書いてない。なら、一体どうやってuxtoと全トランザクション中にある要素が同じ要素であると判定すればいいの? わからない。

一応、アドレスと金額なら一致するだろうが、それと同じ要素は他にもたくさんある。せめてタイムスタンプがあればよかったのだが、uxto側にはタイムスタンプがない。

GET /api/v2/utxo/{address|xpub|descriptor}

v2utxoをみても戻り値に大差ない。amoutvalueになって、わかりにくくなったくらいか。

https://blockbook.electrum-mona.org/api/v2/utxo/MEHCqJbgiNERCH3bRAtNSSD9uxPViEX1nu
[{"txid":"394eabd9532a09793adf03f229effc88c55185dba59b6fce53559013ba377146","vout":0,"value":"2220000","height":2709785,"confirmations":60},{"txid":"f5421dfef52c33822038c6ecaba1cb146943c67aa99bfb269f2be7566952decf","vout":1,"value":"114000","height":2709367,"confirmations":478},{"txid":"bd4e1f0a6373027d38e7a284969df79f4ffa78f3973b282546097c3be8f33f75","vout":1,"value":"100000","height":2709267,"confirmations":578},{"txid":"e3f5b65087c770e7a218ff775cd1c33ae5393aa8159465b33cd6bb2e301e91fe","vout":0,"value":"2220000","height":2709178,"confirmations":667},{"txid":"570d83eceb834dda1e601e1a0349602310a07c48d14e6f88375e7c7eacc88438","vout":1,"value":"100000","height":2709036,"confirmations":809},{"txid":"cab09e03c9f58be0e89f71a62c9fbc3fe26f16005be66c95e428dbd1d5900548","vout":1,"value":"100000","height":2708879,"confirmations":966},{"txid":"83cdacb3932e4fa28909c838c37d95a053e049f2532f4b58cf609ee61363ba0f","vout":0,"value":"11431500","height":2708405,"confirmations":1440},{"txid":"ae30aba3825721ac1ca61678c52b257427ef71557209357a58ce4c5a5c2f0dd9","vout":0,"value":"100000","height":2708342,"confirmations":1503},{"txid":"1d91bbcb5f20b457313e738224012b1e1b44eb275839c2867dc997b9b7c04e0f","vout":1,"value":"114000","height":2708143,"confirmations":1702},{"txid":"16cd6acae8f8d831808f0fbc84bbcb5b61b70fe18326424450d7143e592da3c7","vout":1,"value":"114000","height":2708090,"confirmations":1755},{"txid":"85e702bde5f359772a97784628119170d5823a79adf1d7e0f2c51378e35cd081","vout":0,"value":"11431500","height":2708065,"confirmations":1780},{"txid":"a448c5b0cfc49db119519fadba4f99d235d16b46bff6cfb4de1d89ff2180fc3b","vout":1,"value":"300000","height":2707979,"confirmations":1866},{"txid":"a932f303af8829932f69fd8708a046a638c0132a885536a0109d4085fe5561eb","vout":0,"value":"114000","height":2707580,"confirmations":2265},{"txid":"465fd6191ebe50495c55fc922ac9e70c61f1dafc18f0852f52f874d7ca8d7273","vout":1,"value":"114000","height":2707545,"confirmations":2300},{"txid":"6541964282c63b17c7cb9a1efa371576d2c3d4ea77ebc447dcce5eb76cfd0d58","vout":1,"value":"114000","height":2707390,"confirmations":2455},{"txid":"fe6513275f3607f809f386a0c4be924e287f456b0251e471ad6d446cbf20a685","vout":0,"value":"1141140","height":2707286,"confirmations":2559},{"txid":"2313631a3afcafbaead1e1a11d09c09f3081c5697856f1ef4f738b92e574ad09","vout":0,"value":"1141140","height":2707286,"confirmations":2559},{"txid":"76933f139080ff35a7c2daa0ee7bd9ecf812063290b4475a6f1a3ae7764ce1f0","vout":0,"value":"114000","height":2706669,"confirmations":3176},{"txid":"3e911a24be7101a4a03bd1bbdb17ef160fd77f9ab766c1cb631367829e1a57f4","vout":1,"value":"100000","height":2706387,"confirmations":3458},{"txid":"e4a0a483bedefc033ff2f5991520b411e4b01d5ae719d5a6a9bce252dfbfcdc3","vout":0,"value":"11431500","height":2706381,"confirmations":3464},{"txid":"b18a0aef0726eb1e83d4753b37420af5402a1110f3a2c009d656a618fe47e9c8","vout":0,"value":"11431500","height":2705379,"confirmations":4466},{"txid":"dfd1a387ec540d6da946fb544824597a542d7e1c5b4079bd8805d26bde536159","vout":0,"value":"11431500","height":2704685,"confirmations":5160},{"txid":"327c74ee1853668a558036c3ca816a5ab01e7f297fbad95f26635e0867959415","vout":0,"value":"11411400","height":2703622,"confirmations":6223},{"txid":"289fe75242d284af6905a16c23797ddd0b93df974ad5429ea96bc325b7dcd853","vout":0,"value":"11411400","height":2703621,"confirmations":6224},{"txid":"aa8ebd4b2c543d04e744aed238ac532479d75bb24138d6c72c8b0dc375ebcf61","vout":0,"value":"11411400","height":2703619,"confirmations":6226},{"txid":"42da297750dbf5a6dd3181780d7bfcb1dc646e22063f4e7d9b0c9133ff25b98d","vout":0,"value":"11411400","height":2703618,"confirmations":6227},{"txid":"6ec59ba9196a32ba3f340e894eee3a5d97c1ab006947b0a31364101606ed3e5c","vout":0,"value":"11411400","height":2703617,"confirmations":6228},{"txid":"364b1eb98fd98c65ce6957f1cb61c10ef16de0fa7ea197decf8fce83f78ec5bd","vout":0,"value":"11411400","height":2703599,"confirmations":6246},{"txid":"7b423d28e2328d96768f5ecbb7e83ee29c2ef2d418913bc96084f60a8312eeb9","vout":0,"value":"11411400","height":2703596,"confirmations":6249},{"txid":"608d51fcb92f35853aaa94ea69acf4b134ce4d8008ddb20a935e55049eae349c","vout":0,"value":"114114000","height":2703593,"confirmations":6252},{"txid":"268b109cf0269f1d93d880c3b08cc3da074537ebacb12528bbb542c83447e5fc","vout":0,"value":"11411400","height":2703593,"confirmations":6252},{"txid":"1b6ee3272b2c16572da7370ed65d1b2d5e253ab552fa411a24956b8610421897","vout":0,"value":"11411400","height":2703590,"confirmations":6255},{"txid":"883c333dbf94ab25602e82112c5008eb81bb129b3f8cf9ddfe63d840aaaf381d","vout":0,"value":"11411400","height":2703589,"confirmations":6256},{"txid":"5e708bc9c5cec0812d66808ff07a4af664c02a8aaf970cbd0092f23a410e1dc0","vout":0,"value":"11411400","height":2703586,"confirmations":6259},{"txid":"5244c2179e164a96e5e3feb9d165aef6090f0281658105ea6e34f54e59503d41","vout":0,"value":"5500000","height":2703519,"confirmations":6326},{"txid":"bbae4abe7b090030fb37f82141669bbc3eada55bd7ea716d5d44d02a07253091","vout":0,"value":"2525000","height":2703488,"confirmations":6357},{"txid":"5894d2facf6e6083141aca34a9ba81ceb5e116174233d328576e1e686678a292","vout":0,"value":"11431500","height":2703361,"confirmations":6484},{"txid":"92ba464b926cda317908d51c8702d8494d838fe80d3a5892c473dddbc029dd0e","vout":0,"value":"10000000","height":2702972,"confirmations":6873},{"txid":"7271195349926a04f667f8dd3751f24559cf9da321c74d41d498c4999b749960","vout":0,"value":"1143150","height":2702946,"confirmations":6899},{"txid":"f8bc7cf3b5776624493251ed0f5a5c286303d68dbc22fccec0f61106a90f82a0","vout":0,"value":"11411400","height":2702848,"confirmations":6997},{"txid":"9722cde73f91bf04874fedde8c1989388dfc83d5618a7f8a5f02728ac1a8e2d6","vout":0,"value":"11431500","height":2702659,"confirmations":7186},{"txid":"0d125e81934cb58c38d00c6c0ecccf1469288242bcf6e4fe16da955ad7364510","vout":0,"value":"2220000","height":2701991,"confirmations":7854},{"txid":"f9a387695fee01cb0c2e0c17629c261ca01160fb88f8ebe9f22453e3131cdab9","vout":0,"value":"11411400","height":2701114,"confirmations":8731},{"txid":"904325eadce09b36d629518580c4270fdbb4f468b6e27c5f8b84798b787ef023","vout":0,"value":"11431500","height":2701053,"confirmations":8792},{"txid":"7a3ec354f66dde32719131a099df46a67024eeea336e163bcd224414684f64ee","vout":0,"value":"7974000","height":2701023,"confirmations":8822},{"txid":"b5d71f29223c92027db483ecf34c1f23bf173e242e12a6fbfc161a78f2fefd5c","vout":0,"value":"7974000","height":2701006,"confirmations":8839},{"txid":"ff9fe93e566312b5451876446cfe22e73e97bb33a4db554d63a6a45eb457586d","vout":1,"value":"101556960","height":2700658,"confirmations":9187},{"txid":"18612323ca3f8a4cb953c9c2b406ae8cd86a40dbe3a98bfe9c5bc922f01655f0","vout":0,"value":"1141140","height":2700171,"confirmations":9674},{"txid":"32e5bd7baf9f5f74aef8ab38cc09b6cd5339fbc1a9727b7a77e29f3c7c2c5280","vout":0,"value":"11431500","height":2700143,"confirmations":9702},{"txid":"c00473a5a819b922469a9369fd204f2e94e327fded709e9ea6c3181f7f1b3007","vout":0,"value":"1141140","height":2699886,"confirmations":9959},{"txid":"fc5f9aef3d5e510784285b029061e60962feb69327e643759d3f895c2ea61b96","vout":0,"value":"11431500","height":2699886,"confirmations":9959},{"txid":"28104be0b1ee0a6dddb61d800366759515f45225e5670b78b8909e3e1e83d067","vout":0,"value":"11431500","height":2699885,"confirmations":9960},{"txid":"e9531cd7cb4b63020459a7f6a51be3d1cfd5972d267c8e9fb405574d19597a73","vout":1,"value":"112970610","height":2699778,"confirmations":10067},{"txid":"7522827e1caa01f4e9ed2cef80183b3d55f47e2dd338e3fda07fd13c7f6e3867","vout":0,"value":"5000000","height":2699401,"confirmations":10444},{"txid":"eca4d29b8eeb07b2838d39b85f595bb3b68876e214927fac351a5e211f5a16c8","vout":0,"value":"5500000","height":2698595,"confirmations":11250},{"txid":"95d2a759421f0c68a7729abab36005e756ec815cc4146e2ae1af927cf2846909","vout":0,"value":"11411400","height":2698502,"confirmations":11343},{"txid":"d368d3fe4f54abaacebe0e69473138317950b592bc018a6155978add98ded9b3","vout":0,"value":"11411400","height":2698486,"confirmations":11359},{"txid":"28483ebbd0b142a5fff43e7ce94b4a43b03cda9d7c462dc5be487eae52e634ea","vout":0,"value":"25250000","height":2698456,"confirmations":11389},{"txid":"39f78e1c8da9cabe1461d24c8d75b792f7a2ffbb4dbb5dfc05c7d06a5d913760","vout":0,"value":"1141140","height":2698420,"confirmations":11425},{"txid":"d62291fd82352364aedc7778df01156b187da637b1c6f18978083293ae45ee55","vout":0,"value":"11431500","height":2697428,"confirmations":12417},{"txid":"9cc11243498f18d4a65f8d58f54d122d481e6ae2f504210ebcb6ce7ce5a37115","vout":0,"value":"11431500","height":2697085,"confirmations":12760},{"txid":"9c302ffe3a397052dcce7627b9796e775254398197c68c6503953e2cf98a2485","vout":0,"value":"11431500","height":2696052,"confirmations":13793},{"txid":"e19f422375439496abd26da6c9c5f251fa604afee4f54cb874d1a0309436cdb1","vout":0,"value":"11431500","height":2694578,"confirmations":15267},{"txid":"9a5bee5638e7892cde8ae9b8e921f74cc09fa01615a978832922db98fd314248","vout":0,"value":"11431500","height":2694577,"confirmations":15268},{"txid":"6d4e016c8c958804779d6ead471c298eef868ad7525838885ca5f2fe0e168bef","vout":0,"value":"1141140","height":2693722,"confirmations":16123},{"txid":"53aa1e1df28be33beae69e655f4eaebe6dca3ccfc8a7d522ecacc399e422d843","vout":0,"value":"11411400","height":2692689,"confirmations":17156},{"txid":"b999d888560d0e1a17d1f0e30bd438135a8d9e90d6793f94bc8c650a46c6a707","vout":0,"value":"59630000","height":2692689,"confirmations":17156},{"txid":"1c067d029776d0d97b6fa7ffb2bb7cbc375bec428db0b748be2101d33525eedd","vout":0,"value":"1141140","height":2691789,"confirmations":18056},{"txid":"3c5f60c410d931a38a417fb08e07c554482bf6509ccdca5edc04a39ebbe9bf9f","vout":0,"value":"11411400","height":2691747,"confirmations":18098},{"txid":"b9e124a3f032d5007472ca1f553c093efa00a391243b1aac0d21f2becdada7d8","vout":0,"value":"11411400","height":2691735,"confirmations":18110},{"txid":"0b8688a630eff478459bab9e420045589936631dba21f89576b36d3ebdde7b76","vout":0,"value":"22200000","height":2690785,"confirmations":19060},{"txid":"4a53154c08e2916076c6ad495494b7bc155e8f4481fe554f8defea3599f9a0e0","vout":0,"value":"11431500","height":2690661,"confirmations":19184},{"txid":"e2803d73c4e6ca70e4e93b26692bf39c902b144a339f22bcc58003dd2c6102dd","vout":0,"value":"11431500","height":2689837,"confirmations":20008},{"txid":"f1419fa4f51d3e48f564121a80966fa82dd0c5e2ec3e79a866d4fe42d63d0083","vout":0,"value":"11431500","height":2688948,"confirmations":20897},{"txid":"fb0050ac32ef1dcb926cf35eedd7243904a543394be0b66cb6c122f86e89198e","vout":0,"value":"11411400","height":2688858,"confirmations":20987},{"txid":"986fac8358c68bf4e44010bd69e7f37841347061f049f716e675895ec3bafe27","vout":0,"value":"11411400","height":2688857,"confirmations":20988},{"txid":"538a3d92a5fe0467bd78bb85de002f132ff151b63015e9720eb190aec7f3c8d5","vout":0,"value":"1141140","height":2688279,"confirmations":21566},{"txid":"b0a35bf1be5892e435610eabbfcdaa9f06e8442d935d8f8ca425c9199eb8db0f","vout":0,"value":"11431500","height":2688279,"confirmations":21566},{"txid":"ac80e9582e257dc77bbbc84beb8972bba3201b2f77f2d5e02f883c6da66e7544","vout":0,"value":"11431500","height":2687278,"confirmations":22567},{"txid":"f6f8bcc2af150146b066ff64725fca4df82d6712ac19f9ab12bb12cf21dfb6ad","vout":0,"value":"11431500","height":2687073,"confirmations":22772},{"txid":"cb64e1375e87b3be44e14ef6c5fff92915495fd7064f6b23a71d7214c7b0e95c","vout":0,"value":"11431500","height":2686049,"confirmations":23796},{"txid":"19ee2ef83acc12ce84a2f60325718dc9a4b70b9d83d46d9f5fc71d7cd07c8279","vout":0,"value":"1141140","height":2685626,"confirmations":24219},{"txid":"a13f34982c4bf9886764c80e08558f95f724d5daa6931185450c16492c0c5085","vout":0,"value":"11431500","height":2684204,"confirmations":25641},{"txid":"b16db781bd3c4ebd17d815bb5117fd5542fa560a4c4c4a3107b2c3a343524e43","vout":0,"value":"11431500","height":2684204,"confirmations":25641},{"txid":"00573fae17c9957730a9e3250b8ab20d19ed88fd1b46c3d092e298192766e5d0","vout":0,"value":"1141140","height":2683857,"confirmations":25988},{"txid":"46315b8e698c326fc8167b0466d11aa0046d89d9c79360564d504b85c2b4e0ba","vout":0,"value":"11411400","height":2683349,"confirmations":26496},{"txid":"f74731a9e91118d1274a20b85b317cd0bed34686408bdba95656bd4be918d644","vout":0,"value":"39390000","height":2683349,"confirmations":26496},{"txid":"0cd08224a54f448f4c7fb856374c4e98eb2eb48718261854343a02ab6f1e5b21","vout":0,"value":"11411400","height":2683349,"confirmations":26496},{"txid":"75cd31f88453a5277962e7dffb7853e599e9be909a64252e4bcf1c773bfbee49","vout":0,"value":"11411400","height":2683347,"confirmations":26498},{"txid":"99f79eecbbd28ef43175dec6809d0f8abd9e49b56ab45d8b1a76e252f7ecd286","vout":0,"value":"11431500","height":2683275,"confirmations":26570},{"txid":"8e7e64a54402876d7d87916a5666efa3cc2b1bd67b7b348c4a65b046d388e49b","vout":0,"value":"11431500","height":2681813,"confirmations":28032},{"txid":"adec2d9816f01b4890a6614158b0f6fee311cfcc5d64dd9abc91e05c320dba74","vout":0,"value":"11431500","height":2680664,"confirmations":29181},{"txid":"cb49c13ddc650808187d4cb0d1f19ef7dbefe88fb7be124f57c7a1074b71cc6d","vout":0,"value":"1141140","height":2680664,"confirmations":29181},{"txid":"89e3f644050f90bc4a72ac357c070166d1189faa64be1cd0976dbb16fa87c7f9","vout":0,"value":"11431500","height":2679965,"confirmations":29880},{"txid":"1d2ba7cddbbf51ded3701ebd74425fdc2c832880601f17c76bde3ac7e7390cb2","vout":0,"value":"1141140","height":2678617,"confirmations":31228},{"txid":"3fc205e53cedeeb828d491ec8a7bbaaeb38cc8c0f0135523953f41c594626dae","vout":0,"value":"11431500","height":2678163,"confirmations":31682},{"txid":"206ad6442b309f37e9d0af8219d36207ce51b03d36b4b624a884f2c503180d9a","vout":0,"value":"11411400","height":2676936,"confirmations":32909},{"txid":"559cc4fe70bea88c4f702ae1e86a70c641353c4ae63a961f982865212454c04b","vout":0,"value":"11411400","height":2676935,"confirmations":32910},{"txid":"44df3397289311479bef3853e0efe14e059ead9ce4488b38f3fd99fb9a78f9c8","vout":0,"value":"11411400","height":2676931,"confirmations":32914},{"txid":"7774cc9cc79ac314231061e8cd3743d35417149a9167e81349356ed953eab86d","vout":0,"value":"1141140","height":2675075,"confirmations":34770},{"txid":"c044b53c833a6d470268cd9f76d15a35e28e80310b704cf3dbb19fa69cab13d5","vout":0,"value":"11431500","height":2674191,"confirmations":35654},{"txid":"de1da180409b74ed103fe4bb61c57b6bda3aad036751ec88dd9c5a78c813e888","vout":0,"value":"1141140","height":2674191,"confirmations":35654},{"txid":"b0dddd6202363324474d3f6e2580fceaacd66ce7e123e92cf28a849e315d1664","vout":0,"value":"11411400","height":2674097,"confirmations":35748},{"txid":"efe6b3efd5c22069109ed6b22468713082f8dcef137f16daafe63c9bfd9e78c9","vout":0,"value":"1141140","height":2673924,"confirmations":35921},{"txid":"0e6f6844385dd07856194b66aca40a94d40a7d109952b07bcff9782971c234c9","vout":0,"value":"1141140","height":2672740,"confirmations":37105},{"txid":"be13adb03b5b7f1b24e0bf18db01d5092406dcd3617b96e84cb1375e540c1bf5","vout":0,"value":"11431500","height":2672739,"confirmations":37106},{"txid":"e55d76e30e2b59d589cbf056baa0d6be4ce900bb6a7b59426f39eff715689665","vout":0,"value":"11411400","height":2672369,"confirmations":37476},{"txid":"c0ea3a09660da2f270f5ecca695caa0ff4047f9c2a7dec2d5222eb10c56337e9","vout":0,"value":"11400000","height":2672368,"confirmations":37477},{"txid":"131f491bebef29fa4a9545ea894552bb302065dfadc405752c6f31142e5cad02","vout":0,"value":"11411400","height":2672368,"confirmations":37477},{"txid":"4e490864c0b975cc9c504adcec03bd1ecb793c3b0559b5ae1fc37e7af014b17a","vout":0,"value":"11431500","height":2672294,"confirmations":37551},{"txid":"91c8765e1b745420d288f9064b659aaadcb08d0ec9f0d05fab195f71e23b41cc","vout":0,"value":"1141140","height":2672293,"confirmations":37552},{"txid":"c15d93a315941c21a81d50a8fedbbf1fb0aae50217b1659b31039af3d6ae1f31","vout":0,"value":"1141140","height":2671389,"confirmations":38456},{"txid":"f78a61b91269bd8b16993f6f3d49c5ae23ed11b2376b3b394ae6a525308798bb","vout":0,"value":"11431500","height":2671389,"confirmations":38456},{"txid":"0524ae5c8415e4893c57604e5950c88553da673bcb6d8fd9dea2a5fd0eb7041b","vout":0,"value":"39390000","height":2670703,"confirmations":39142},{"txid":"bcad39c53288d19870b6ecb156cb89786c9576a1786b1d0d7e26338c56f81635","vout":0,"value":"1141140","height":2669573,"confirmations":40272},{"txid":"87236c5ba27d094ada5b110fdbd8513cf266cb4d442d7bb55bb7845a8e06388c","vout":0,"value":"1141140","height":2669006,"confirmations":40839},{"txid":"f30f6aa525b5e8e49d1cf06a30b1696c1ed7aa60e35f9ed60840db3e64f78a5f","vout":0,"value":"11431500","height":2668966,"confirmations":40879},{"txid":"4de2f455ec1c40f0962abf3d35cf8902d82f5a0e94170b882127578cda3bd26b","vout":0,"value":"1141140","height":2668966,"confirmations":40879},{"txid":"43e2a380e0f1a66f7dce9d3c62ca004bbe312b2e05f5b8f832f3c43598dd4d55","vout":0,"value":"1143150","height":2668482,"confirmations":41363},{"txid":"f8c62ce8de3ec286d988499621f78d0aa4191d50e84eea7bdc7e4f3d4c365923","vout":0,"value":"11411400","height":2666378,"confirmations":43467},{"txid":"8f50c7f4c35fbd77a0ae669baf5f1d4fa69d04e34b3f777630d69156938c7f2c","vout":0,"value":"1141140","height":2666062,"confirmations":43783},{"txid":"4b0a9eeda48a03c3c09caee4f3608784669f87d9d475aaecc8c0a9d98da48c66","vout":1,"value":"94109500","height":2666003,"confirmations":43842},{"txid":"831c41287d17e58b7d566d875c203751e89c2c272cdfe8ad884ca848811c412c","vout":0,"value":"11431500","height":2665901,"confirmations":43944},{"txid":"9004fe5012c3bc067b48147dc5e03ece0bd1c92032be3b42823597ecb090dc63","vout":0,"value":"1141140","height":2665901,"confirmations":43944},{"txid":"35c204ccb2709bc0eb15a736991f020d45c8f20222ce5462207deb7b268cf752","vout":1,"value":"84107250","height":2665230,"confirmations":44615},{"txid":"f48ba7e92f964a0f25bc2cbd0d025be5ecf6c4ed27ead3ffb453c3b0451fa2f3","vout":1,"value":"84107250","height":2665230,"confirmations":44615},{"txid":"f361755e992a137104045aab29a3c8aa5a5b1728f3da1f0c14d6bc535d67aa5e","vout":0,"value":"1141140","height":2665158,"confirmations":44687}]

GET /api/v2/tx/{txid}

上記uxtoで最初の要素のtxidを渡してみる。Ask Mona 3.0で0.0222 MONA受け取ったときのもの。Ask monaには以下のようなリンクがあった。URL末尾の値は、上記uxtoで取得された最初の要素のtxidと一致する。

https://blockbook.electrum-mona.org/tx/394eabd9532a09793adf03f229effc88c55185dba59b6fce53559013ba377146

READMEをみてAPI用URLを作ると以下。

https://blockbook.electrum-mona.org/api/v2/tx/394eabd9532a09793adf03f229effc88c55185dba59b6fce53559013ba377146

その結果が以下。

{"txid":"394eabd9532a09793adf03f229effc88c55185dba59b6fce53559013ba377146","version":1,"vin":[{"txid":"13faaf3729365fc75f6817aecf1967b3bc7c568a0026dbbf4b6818bb8c61b745","vout":1,"sequence":4294967295,"n":0,"addresses":["MVaW396wLPpocjUBiw939wbyvgg5g9D7D5"],"isAddress":true,"value":"473532330","hex":"483045022100a0bab345668fcade4622cb8e739a128081fcf62a8281f6b615786bdf35ca4da0022038d9019add3cd461023bf706c67ee0692aefa22a829b0e29650f7c13664232a8012102d4cb384ff895f4e669a9e228777afb473030682a309bd4e499f85817cf3b73c0"}],"vout":[{"value":"2220000","n":0,"hex":"76a91445fc13c9d3a0df34008291492c39e0efcdd220b888ac","addresses":["MEHCqJbgiNERCH3bRAtNSSD9uxPViEX1nu"],"isAddress":true},{"value":"471289605","n":1,"spent":true,"hex":"76a914edcb658a665e51e7a5ed93f26f3512311625aae088ac","addresses":["MVaW396wLPpocjUBiw939wbyvgg5g9D7D5"],"isAddress":true}],"blockHash":"3bda3a70f404e96014f3e0e364063f11fc77512de0356513bc6f03a0391b9b84","blockHeight":2709785,"confirmations":62,"blockTime":1657064015,"value":"473509605","valueIn":"473532330","fees":"22725","hex":"010000000145b7618cbb18684bbfdb26008a567cbcb36719cfae17685fc75f362937affa13010000006b483045022100a0bab345668fcade4622cb8e739a128081fcf62a8281f6b615786bdf35ca4da0022038d9019add3cd461023bf706c67ee0692aefa22a829b0e29650f7c13664232a8012102d4cb384ff895f4e669a9e228777afb473030682a309bd4e499f85817cf3b73c0ffffffff02e0df2100000000001976a91445fc13c9d3a0df34008291492c39e0efcdd220b888ac054f171c000000001976a914edcb658a665e51e7a5ed93f26f3512311625aae088ac00000000"}

おや? このAPIはsearch_raw_transactions APIと違い、vinにアドレスが入っているぞ? これなら支払いが自分かどうか判断できる! ついでにtxidからトランザクション情報を取得するAPIを探す 追記で教わったとおり手数料feesも判明する!

でも、そもそもこのtxiduxto APIから取得しており、それは自分のアドレスの未使用アウトプット。つまり自分が受け取ったトランザクションであるということ。なので、そのtxidから得たトランザクションのvinは必ず相手のアドレスになっていると分かりきっている。

なら、search_raw_transactions APIのvinにあるtxidすべてに対して今回のGET /api/v2/tx/{txid}をかけ、そのvinが自分のアドレスなら支払い、そうでないなら受け取りと判定できるのでは?

これか! これっぽいぞ。この方法なら取引データが支払か受取かを判別できるに違いない。試してみよう。

search_raw_transactionsGET /api/v2/tx/{txid}

私のアドレスの全取引データをsearch_raw_transactionsAPIで取得する。このうち記念すべき最初の取引である配列要素[0]は、私がモナレッジでその作者らいう様から受け取ったときのデータと思われる。

[0]
{
    "blockhash": "b25e87ea736c39df3a51c032aefc558f0f6851a602cc57d21b3cb38fc3ec465f",
    "blocktime": 1652234061,
    "confirmations": 51093,
    "hash": "483aa8414711bb71246f355240cb4a79a5292d8b7b152caca8c985b0c6e6acd0",
    "height": 2658711,
    "hex": "010000000103804fe9ad11c4485fbdc3b025dd68a6c99ae7ccd19b9d63e641f5b6e24be9e1010000006b483045022100b18c83115da395e12791b717b32aff754865cac478bb4e72ddde0f0e6c28b28d0220716c20fcd5151e4aeb8c2f898b9735713a596ff8daac03d7169e207c2e4e6743012103aedd2422519c7ea14e48116b571903c16d2b4657d4a3ffc0e35646cd7e53be3dffffffff02d03dcd06000000001976a91445fc13c9d3a0df34008291492c39e0efcdd220b888ac6a4d1606000000001976a91413bd7f2032c935652371722ae6d987f2f8135aac88ac00000000",
    "locktime": 0,
    "size": 226,
    "time": 1652234061,
    "txid": "483aa8414711bb71246f355240cb4a79a5292d8b7b152caca8c985b0c6e6acd0",
    "version": 1,
    "vin": [
        {
            "scriptSig": {
                "asm": "3045022100b18c83115da395e12791b717b32aff754865cac478bb4e72ddde0f0e6c28b28d0220716c20fcd5151e4aeb8c2f898b9735713a596ff8daac03d7169e207c2e4e6743[ALL] 03aedd2422519c7ea14e48116b571903c16d2b4657d4a3ffc0e35646cd7e53be3d",
                "hex": "483045022100b18c83115da395e12791b717b32aff754865cac478bb4e72ddde0f0e6c28b28d0220716c20fcd5151e4aeb8c2f898b9735713a596ff8daac03d7169e207c2e4e6743012103aedd2422519c7ea14e48116b571903c16d2b4657d4a3ffc0e35646cd7e53be3d"
            },
            "sequence": 4294967295,
            "txid": "e1e94be2b6f541e6639d9bd1cce79ac9a668dd25b0c3bd5f48c411ade94f8003",
            "vout": 1
        }
    ],
    "vout": [
        {
            "n": 0,
            "scriptPubKey": {
                "addresses": [
                    "MEHCqJbgiNERCH3bRAtNSSD9uxPViEX1nu"
                ],
                "asm": "OP_DUP OP_HASH160 45fc13c9d3a0df34008291492c39e0efcdd220b8 OP_EQUALVERIFY OP_CHECKSIG",
                "hex": "76a91445fc13c9d3a0df34008291492c39e0efcdd220b888ac",
                "reqSigs": 1,
                "type": "pubkeyhash"
            },
            "value": 1.14114
        },
        {
            "n": 1,
            "scriptPubKey": {
                "addresses": [
                    "M9hY5XcC7MSD54DfqcEojiKm9QMgXeQhGK"
                ],
                "asm": "OP_DUP OP_HASH160 13bd7f2032c935652371722ae6d987f2f8135aac OP_EQUALVERIFY OP_CHECKSIG",
                "hex": "76a91413bd7f2032c935652371722ae6d987f2f8135aac88ac",
                "reqSigs": 1,
                "type": "pubkeyhash"
            },
            "value": 1.02124906
        }
    ],
    "vsize": 226,
    "weight": 904
}

このときvinにはtxidがある。これは私に支払った相手が所有するコインを含んだ取引データを指す識別子のはず。

  • e1e94be2b6f541e6639d9bd1cce79ac9a668dd25b0c3bd5f48c411ade94f8003

このtxidGET /api/v2/tx/{txid}に渡してみる。もしその結果のvinの中に、自分ではないアドレスがあれば、相手が支払い、私が受け取ったときの取引だと判断できるはず。

https://blockbook.electrum-mona.org/api/v2/tx/e1e94be2b6f541e6639d9bd1cce79ac9a668dd25b0c3bd5f48c411ade94f8003
{"txid":"e1e94be2b6f541e6639d9bd1cce79ac9a668dd25b0c3bd5f48c411ade94f8003","version":1,"vin":[{"txid":"7b628af7e435d9e0b14116b11c346d6f3bbe2510c0cabd8fb5d01af68359b219","vout":1,"sequence":4294967295,"n":0,"addresses":["M9hY5XcC7MSD54DfqcEojiKm9QMgXeQhGK"],"isAddress":true,"value":"255284356","hex":"483045022100e7b36a5115a86326b91d0bf89407df78733850c63e041a51a913f3f09f6df13e022048896aaa5b71ababf66323b8bc8ed25e1b3a423ed643b5a7acf484dcf4f3afbf012103aedd2422519c7ea14e48116b571903c16d2b4657d4a3ffc0e35646cd7e53be3d"}],"vout":[{"value":"39000000","n":0,"hex":"76a9145bef72db1e9a105cf734ead06ef87a54f1d39a3588ac","addresses":["MGHGa55FH7CcaJdNqJZZb3YCPuZAn2iMUF"],"isAddress":true},{"value":"216261631","n":1,"spent":true,"hex":"76a91413bd7f2032c935652371722ae6d987f2f8135aac88ac","addresses":["M9hY5XcC7MSD54DfqcEojiKm9QMgXeQhGK"],"isAddress":true}],"blockHash":"f413585659148cdfc442975bb9bd9de8dddfafe2ccaad1fa3f394280988ae7b1","blockHeight":2633653,"confirmations":76208,"blockTime":1649863002,"value":"255261631","valueIn":"255284356","fees":"22725","hex":"010000000119b25983f61ad0b58fbdcac01025be3b6f6d341cb11641b1e0d935e4f78a627b010000006b483045022100e7b36a5115a86326b91d0bf89407df78733850c63e041a51a913f3f09f6df13e022048896aaa5b71ababf66323b8bc8ed25e1b3a423ed643b5a7acf484dcf4f3afbf012103aedd2422519c7ea14e48116b571903c16d2b4657d4a3ffc0e35646cd7e53be3dffffffff02c0175302000000001976a9145bef72db1e9a105cf734ead06ef87a54f1d39a3588acffe3e30c000000001976a91413bd7f2032c935652371722ae6d987f2f8135aac88ac00000000"}

vinの中にあるaddressesM9hY5XcC7MSD54DfqcEojiKm9QMgXeQhGK。これはらいう様のアドレスと思われる。つまり、この取引の支払者は私ではないため、私は受け取り側だと判断できる!

キタ━━━━(゚∀゚)━━━━!!

まとめ

  1. search_raw_transactionsで自分のアドレスの全トランザクション情報を取得する
  2. 1のデータ1件ずつにGET /api/v2/tx/{txid}をかける
  3. 2のデータにあるvinaddressesに自分のアドレスがあれば支払い、なければ受け取りと判断できる