Stellar cross currency transaction doesn't work

165 views Asked by At

I'm unable to execute payment transaction in Stellar testnet.

Initially i use find_path:

curl -X POST https://test.stellar.org:9002 -d '
{
  "method": "static_path_find",
  "params": [
    {
      "source_account": "g4e5v2ERpKvdBZrchn6DrWUtvezkXsu5wo",
      "destination_account": "gJ3e65GzqERgeeS5oXsv8NGfdZWzm93ej6",
      "source_currencies" : [ { "currency" : "SGD", "issuer" : "gDfapfG5hDHuYkbVpugtupkGYVTKXwd59r"} ],
      "destination_amount": {
        "currency": "MYR",
        "value": "1",
        "issuer": "gsQuUKcxM68nEX9tKR71UH5hZXwrvT2mpS"
      }
    }
  ]
}'

The result I get:

{
  "result": {
    "alternatives": [
      {
        "paths_computed": [
          [
            {
              "currency": "MYR",
              "issuer": "gsQuUKcxM68nEX9tKR71UH5hZXwrvT2mpS",
              "type": 48
            },
            {
              "account": "gsQuUKcxM68nEX9tKR71UH5hZXwrvT2mpS",
              "type": 1
            }
          ]
        ],
        "source_amount": {
          "currency": "SGD",
          "issuer": "gDfapfG5hDHuYkbVpugtupkGYVTKXwd59r",
          "value": "0.375"
        }
      }
    ],
    "destination_account": "gJ3e65GzqERgeeS5oXsv8NGfdZWzm93ej6",
    "destination_currencies": [
      "MYR",
      "STR"
    ],
    "status": "success"
  }
}

Then I trying to broadcast transaction in the network:

curl -X POST https://test.stellar.org:9002 -d '
{
  "method": "submit",
  "params": [
    {
      "secret": "sfk7dUd4N8cxVFVowsZL4DQgonNP9k8WFBgaV2NmwEQKGzWuqXT",
      "tx_json": {
        "TransactionType": "Payment",
        "Account": "g4e5v2ERpKvdBZrchn6DrWUtvezkXsu5wo",
        "Destination": "gJ3e65GzqERgeeS5oXsv8NGfdZWzm93ej6",
        "Amount": {
          "currency": "MYR",
          "value": "1",
          "issuer": "gsQuUKcxM68nEX9tKR71UH5hZXwrvT2mpS"
        },
        "Paths": [
          [
            {
              "currency": "MYR",
              "issuer": "gsQuUKcxM68nEX9tKR71UH5hZXwrvT2mpS",
              "type": 48
            },
            {
              "account": "gsQuUKcxM68nEX9tKR71UH5hZXwrvT2mpS",
              "type": 1
            }
          ]
        ]
      }
    }
  ]
}' 

And finally I'm getting unsuccessful result when transaction passed through consensus:

{
  "engine_result": "tecPATH_PARTIAL",
  "engine_result_code": 101,
  "engine_result_message": "Path could not send full amount.",
  "ledger_hash": "82BCF42941EF00BEA9E575B696CD88EC7E14FDE8CFD39FDA6A76B5710FDD0755",
  "ledger_index": 704612,
  "meta": {
    "AffectedNodes": [
      {
        "ModifiedNode": {
          "FinalFields": {
            "Account": "g4e5v2ERpKvdBZrchn6DrWUtvezkXsu5wo",
            "Balance": "199999960",
            "Flags": 0,
            "OwnerCount": 1,
            "Sequence": 5
          },
          "LedgerEntryType": "AccountRoot",
          "LedgerIndex": "D3433DEE556200D8AB72DED7156A597A273103D2BC50F526193EB9C4D8C8B735",
          "PreviousFields": {
            "Balance": "199999970",
            "Sequence": 4
          },
          "PreviousTxnID": "6ADF48B45D95B3ABD20FD78F95F7E4F20D91FF5D169ECC5EFD6DB0CA78BEA486",
          "PreviousTxnLgrSeq": 704445
        }
      }
    ],
    "TransactionIndex": 0,
    "TransactionResult": "tecPATH_PARTIAL"
  },
  "status": "closed",
  "transaction": {
    "Account": "g4e5v2ERpKvdBZrchn6DrWUtvezkXsu5wo",
    "Amount": {
      "currency": "MYR",
      "issuer": "gsQuUKcxM68nEX9tKR71UH5hZXwrvT2mpS",
      "value": "1"
    },
    "Destination": "gJ3e65GzqERgeeS5oXsv8NGfdZWzm93ej6",
    "Fee": "10",
    "Flags": 2147483648,
    "Paths": [
      [
        {
          "currency": "MYR",
          "issuer": "gsQuUKcxM68nEX9tKR71UH5hZXwrvT2mpS",
          "type": 48
        },
        {
          "account": "gsQuUKcxM68nEX9tKR71UH5hZXwrvT2mpS",
          "type": 1
        }
      ]
    ],
    "Sequence": 4,
    "SigningPubKey": "4B640AC0C64AEF1C97EAAD0629CADDCA95FBA5F095BD20BD6282BEC450A125B1",
    "TransactionType": "Payment",
    "TxnSignature": "7BF5772EB916F20F56C5F148E99C3C3DD77C2916EAA47AB2D7FA8306F2B4A9D3FA4B789BDB79899A634B0C33F50A6ACB447CA6A9633C1C73BAB754FBFE74C105",
    "date": 485412700,
    "hash": "846AB6502D3B7A3137B2B538E6616B9C4459D2A67C48E58AF6B64F4659FF0016"
  },
  "type": "transaction",
  "validated": true
}

Why? What I did wrong? I really can't understand...

1

There are 1 answers

0
Arsenius On

Anyway I found the problem.

I forgot to add required SendMax parameter when submitting transaction.

curl -X POST https://test.stellar.org:9002 -d '
{
"method": "submit",
"params": [
{
"secret": "sfk7dUd4N8cxVFVowsZL4DQgonNP9k8WFBgaV2NmwEQKGzWuqXT",
"tx_json": {
"TransactionType": "Payment",
"Account": "g4e5v2ERpKvdBZrchn6DrWUtvezkXsu5wo",
"Destination": "gJ3e65GzqERgeeS5oXsv8NGfdZWzm93ej6",
"Amount": {
"currency": "MYR",
"value": "1",
"issuer": "gsQuUKcxM68nEX9tKR71UH5hZXwrvT2mpS"
},
"Paths": [
[
{
"currency": "MYR",
"issuer": "gsQuUKcxM68nEX9tKR71UH5hZXwrvT2mpS",
"type": 48
},
{
"account": "gsQuUKcxM68nEX9tKR71UH5hZXwrvT2mpS",
"type": 1
}
]
],
"SendMax" : { "currency" : "SGD", "value" : "0.375", "issuer": "gDfapfG5hDHuYkbVpugtupkGYVTKXwd59r" }
}
}
]
}'