Skip to content

GetTransaction bug fix#84

Merged
bridgedragon merged 10 commits intoswapper-org:stagingfrom
0xp3gasus:27-standarize-getTransaction
Feb 22, 2022
Merged

GetTransaction bug fix#84
bridgedragon merged 10 commits intoswapper-org:stagingfrom
0xp3gasus:27-standarize-getTransaction

Conversation

@0xp3gasus
Copy link
Collaborator

@0xp3gasus 0xp3gasus commented Feb 5, 2022

Description

Fixes #27

Dependencies (if any)

None

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Test BTC Transaction unconfirmed

    • Request
     curl --location --request POST 'http://localhost:80/rpc' \
     --header 'Content-Type: application/json' \
     --data-raw '{
         "id": 1609070896412,
         "method": "getTransaction",
         "params": {
             "txHash": "cab212db9adc5df27fb3887fc76da92fc55edd8368f7f0530d115239d58f2fd5"
         },
         "jsonrpc": "2.0"
     }'
    
    • Response
     {
           "id": 1609070896412,
           "jsonrpc": "2.0",
           "result": {
               "transaction": {
                   "txHash": "cab212db9adc5df27fb3887fc76da92fc55edd8368f7f0530d115239d58f2fd5",
                   "blockHash": null,
                   "blockNumber": null,
                   "fee": "705",
                   "transfers": [
                       {
                           "from": "bcrt1qf85nxa066r5zue0lcpt5gc5numwwphx9rmu5dt",
                           "to": "bcrt1qv7jglsly4r0ymz36phtzltnxcwask02c8msfwp",
                           "amount": "999295",
                           "fee": "1"
                       },
                       {
                           "from": "bcrt1qf85nxa066r5zue0lcpt5gc5numwwphx9rmu5dt",
                           "to": "bcrt1qfpjzgkk7k2wh3y4w8u7dxjufpurlz5x3l9gm5y",
                           "amount": "1249000000",
                           "fee": "704"
                       }
                   ],
                   "data": {
                       "txid": "cab212db9adc5df27fb3887fc76da92fc55edd8368f7f0530d115239d58f2fd5",
                       "hash": "d384b75a263396f3650dbd0468e47632a4ae2e81dd473858d66d250c199c5bf2",
                       "version": 2,
                       "size": 222,
                       "vsize": 141,
                       "weight": 561,
                       "locktime": 0,
                       "vin": [
                           {
                               "txid": "d159e8b460079843104adc4c8ff3337c3fbf4fbe95acb222daa5842a7a9a0a04",
                               "vout": 0,
                               "scriptSig": {
                                   "asm": "",
                                   "hex": ""
                               },
                               "txinwitness": [
                                   "304402203a8ae1dcedf9292a5c27899f277c4765899ebf71415fffe5164c2484f8ae835e02205db7c23e29e45a4382e8bb1cb49abb5adcf0d95b83f22e3058b139bcbfaefada01",
                                   "0302d8077915b3ff465f7b0b5a2c614f369e440ad7ee25530cad3991ba740ba23e"
                               ],
                               "sequence": 4294967293
                           }
                       ],
                       "vout": [
                           {
                               "value": 0.00999295,
                               "n": 0,
                               "scriptPubKey": {
                                   "asm": "0 67a48fc3e4a8de4d8a3a0dd62fae66c3bb0b3d58",
                                   "hex": "001467a48fc3e4a8de4d8a3a0dd62fae66c3bb0b3d58",
                                   "reqSigs": 1,
                                   "type": "witness_v0_keyhash",
                                   "addresses": [
                                       "bcrt1qv7jglsly4r0ymz36phtzltnxcwask02c8msfwp"
                                   ]
                               }
                           },
                           {
                               "value": 12.49,
                               "n": 1,
                               "scriptPubKey": {
                                   "asm": "0 4864245adeb29d7892ae3f3cd34b890f07f150d1",
                                   "hex": "00144864245adeb29d7892ae3f3cd34b890f07f150d1",
                                   "reqSigs": 1,
                                   "type": "witness_v0_keyhash",
                                   "addresses": [
                                       "bcrt1qfpjzgkk7k2wh3y4w8u7dxjufpurlz5x3l9gm5y"
                                   ]
                               }
                           }
                       ]
                   }
               }
           }
       }
    
  • Test BTC Transaction confirmed

    • Request
     curl --location --request POST 'http://localhost:80/rpc' \
     --header 'Content-Type: application/json' \
     --data-raw '{
         "id": 1609070896412,
         "method": "getTransaction",
         "params": {
             "txHash": "f10c32e621ea20130ffdb8fb0af9cbcc638a3dda7fb4ec57cb294a66d24e0491"
         },
         "jsonrpc": "2.0"
     }'
    
    • Response
     {
               "id": 1609070896412,
               "jsonrpc": "2.0",
               "result": {
                   "transaction": {
                       "txHash": "f10c32e621ea20130ffdb8fb0af9cbcc638a3dda7fb4ec57cb294a66d24e0491",
                       "blockHash": "26c7db583b3ceda63602f1f2bb92457bd1158031b5bbcff739c3e519c976fadc",
                       "blockNumber": "316",
                       "fee": "705",
                       "transfers": [
                           {
                               "from": "bcrt1quzkq5fe3yu3kq8fyfewys90w72lsp8nd3rsk2t",
                               "to": "bcrt1qg7fj3wtqhcmdwdnn04jdrhxxne9mvd2mzgj6tt",
                               "amount": "999295",
                               "fee": "0"
                           },
                           {
                               "from": "bcrt1quzkq5fe3yu3kq8fyfewys90w72lsp8nd3rsk2t",
                               "to": "bcrt1qempcea00gsxznc7llv93463xzwxpzyalw3eeaq",
                               "amount": "4999000000",
                               "fee": "705"
                           }
                       ],
                       "data": {
                           "txid": "f10c32e621ea20130ffdb8fb0af9cbcc638a3dda7fb4ec57cb294a66d24e0491",
                           "hash": "9427c49f0b32ae9101ba7774d9b5f487b136ee46ad0ae40a17dc3edcd2c2dc53",
                           "version": 2,
                           "size": 222,
                           "vsize": 141,
                           "weight": 561,
                           "locktime": 0,
                           "vin": [
                               {
                                   "txid": "652cce90f401216940272109da90abdbb68d7b47f1f1dcfaf7dc76493c125750",
                                   "vout": 0,
                                   "scriptSig": {
                                       "asm": "",
                                       "hex": ""
                                   },
                                   "txinwitness": [
                                       "3044022059bbb9fa964bf9f068f24d1c41f818f466a832a58d5f0562265ade92406746e302200300b2e5514d966a717979369c37d6d3be9fbc5c33d93f9d7aa1b0843e2377e101",
                                       "03badeec3d2c95484971487446ce860613c7cafd269c91f6b3e9ac91d19a47fba5"
                                   ],
                                   "sequence": 4294967293
                               }
                           ],
                           "vout": [
                               {
                                   "value": 0.00999295,
                                   "n": 0,
                                   "scriptPubKey": {
                                       "asm": "0 479328b960be36d736737d64d1dcc69e4bb6355b",
                                       "hex": "0014479328b960be36d736737d64d1dcc69e4bb6355b",
                                       "reqSigs": 1,
                                       "type": "witness_v0_keyhash",
                                       "addresses": [
                                           "bcrt1qg7fj3wtqhcmdwdnn04jdrhxxne9mvd2mzgj6tt"
                                       ]
                                   }
                               },
                               {
                                   "value": 49.99,
                                   "n": 1,
                                   "scriptPubKey": {
                                       "asm": "0 cec38cf5ef440c29e3dffb0b1aea26138c1113bf",
                                       "hex": "0014cec38cf5ef440c29e3dffb0b1aea26138c1113bf",
                                       "reqSigs": 1,
                                       "type": "witness_v0_keyhash",
                                       "addresses": [
                                           "bcrt1qempcea00gsxznc7llv93463xzwxpzyalw3eeaq"
                                       ]
                                   }
                               }
                           ]
                       }
                   }
               }
           }
    
  • Test ETH Transaction confirmed

    • Request
     	curl --location --request POST 'http://localhost:80/rpc' \
     --header 'Content-Type: application/json' \
     --data-raw '{
         "id": 1609070896412,
         "method": "getTransaction",
         "params": {
             "txHash" : "0xd65d918da5667e6fd0698d0c2ccb138cc0d3b4f3157120bae30110dd3aa664d5"
         },
         "jsonrpc": "2.0"
     }'
    
    • Response
         {
             "id": 1609070896412,
             "jsonrpc": "2.0",
             "result": {
                 "transaction": {
                     "txHash": "0xd65d918da5667e6fd0698d0c2ccb138cc0d3b4f3157120bae30110dd3aa664d5",
                     "fee": "420000000000000",
                     "blockHash": "0x24e95577728eb5270e4db410f0f518532e52c020ea811e5414a27d29c9405767",
                     "blockNumber": "16",
                     "data": {
                         "hash": "0xd65d918da5667e6fd0698d0c2ccb138cc0d3b4f3157120bae30110dd3aa664d5",
                         "nonce": "0xf",
                         "blockHash": "0x24e95577728eb5270e4db410f0f518532e52c020ea811e5414a27d29c9405767",
                         "blockNumber": "0x10",
                         "transactionIndex": "0x0",
                         "from": "0xcf90ec25652b97f5c93cb7d04f1e735148c4f6d6",
                         "to": "0xcf90ec25652b97f5c93cb7d04f1e735148c4f6d6",
                         "value": "0xde0b6b3a7640000",
                         "gas": "0x5208",
                         "gasPrice": "0x4a817c800",
                         "input": "0x",
                         "v": "0xa95",
                         "r": "0x449e99367f1a461f6ed09932d77340e537908c5d78a4c3fb0f56bc22de1d2860",
                         "s": "0x2e8b8f80d0f6247d185611fb2188f2e679aca4ccf2773353efbe4933daa1e7b"
                     },
                     "transfers": [
                         {
                             "from": "0xcf90ec25652b97f5c93cb7d04f1e735148c4f6d6",
                             "to": "0xcf90ec25652b97f5c93cb7d04f1e735148c4f6d6",
                             "amount": "1000000000000000000",
                             "fee": "420000000000000"
                         }
                     ]
                 }
             }
         }
    

Test Configuration:

  • Operating system (output of sw_vers): macOs 12.0.1
  • Kernel version (output of uname -sr): Darwin 21.1.0
  • Architecture (output of uname -m): x86_64

Related PR or Docs PR

Other PR related #65

Good practices to consider

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • x ] My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@0xp3gasus 0xp3gasus linked an issue Feb 5, 2022 that may be closed by this pull request
3 tasks
@0xp3gasus 0xp3gasus marked this pull request as ready for review February 5, 2022 17:20
@phoenix-web3
Copy link
Collaborator

This PR should be reviewed by @bridgedragon

@bridgedragon
Copy link
Collaborator

bridgedragon commented Feb 5, 2022

Amount and fees should be in the minimum unit (satoshi, wei) as it is in the rest of the application, txid should be included inside of "transaction" and not only inside of "data".

@0xp3gasus
Copy link
Collaborator Author

@bridgedragon Changes have been applied.

@bridgedragon
Copy link
Collaborator

Great! Have you got the outputs?

@0xp3gasus
Copy link
Collaborator Author

Great! Have you got the outputs?

New outputs are in this pull request description

@phoenix-web3
Copy link
Collaborator

Once @bridgedragon has reviewed the new outputs we should merge this PR

@bridgedragon bridgedragon merged commit cee2477 into swapper-org:staging Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Abstract and standarize getTransaction() method

3 participants