Exemple #1
0
 @test
 public void testoffercanceltxsign() {
   ikeypair kp = seed.getkeypair(seed_2);
   offercancel txn = new offercancel();
   // set sender
   txn.account(accountid.fromseedbytes(b58.getinstance().decodefamilyseed(seed_2)));
   txn.offersequence(new uint32(14)); // account_offers.seq
   signedtransaction sign = new signedtransaction(txn);
   // param 2 is tx fee;   param 3 is account_info.sequence returned
   sign.prepare(kp, amount.fromstring("15"), new uint32(15), null);
   system.out.println("blob:" + sign.tx_blob);
   system.out.println("hash:" + sign.hash);
   system.out.println("txn_type:" + sign.transactiontype());
 }
Exemple #2
0
  @test
  public void testtransactionjsonparser() throws exception {
    string json =
        "{"
            + "  \"account\": \"rad5qjmashlehzxf9wjumo6vrk4arj9cf3\","
            + "  \"fee\": \"10\","
            + "  \"flags\": 0,"
            + "  \"sequence\": 103929,"
            + "  \"signingpubkey\": \"028472865af4cb32aa285834b57576b7290aa8c31b459047db27e16f418d6a7166\","
            + "  \"takergets\": {"
            + "    \"currency\": \"ils\","
            + "    \"issuer\": \"rnprnzbb92bvpahhzr4ixdtvecgv5pofm9\","
            + "    \"value\": \"1694.768\""
            + "  },"
            + "  \"takerpays\": \"98957503520\","
            + "  \"transactiontype\": \"offercreate\","
            + "  \"txnsignature\": \"304502202abe08d5e78d1e74a4c18f2714f64e87b8bd57444afa5733109eb3c077077520022100db335ee97386e4c0591cac024d50e9230d8f171eeb901b5e5e4bd6d1e0aef98c\","
            + "  \"hash\": \"232e91912789ea1419679a4aa920c22cfc7c6b601751d6cbe89898c26d7f4394\","
            + "  \"metadata\": {"
            + "    \"affectednodes\": ["
            + "      {"
            + "        \"creatednode\": {"
            + "          \"ledgerentrytype\": \"offer\","
            + "          \"ledgerindex\": \"3596ce72c902bafaab56cc486acaf9b4afc67cf7cadbb81a4aa9cbdc8c5cb1aa\","
            + "          \"newfields\": {"
            + "            \"account\": \"rad5qjmashlehzxf9wjumo6vrk4arj9cf3\","
            + "            \"bookdirectory\": \"62a3338caf2e1bee510fc33de1863c56948e962cce173ca55c14be8a20d7f000\","
            + "            \"ownernode\": \"000000000000000e\","
            + "            \"sequence\": 103929,"
            + "            \"takergets\": {"
            + "              \"currency\": \"ils\","
            + "              \"issuer\": \"rnprnzbb92bvpahhzr4ixdtvecgv5pofm9\","
            + "              \"value\": \"1694.768\""
            + "            },"
            + "            \"takerpays\": \"98957503520\""
            + "          }"
            + "        }"
            + "      },"
            + "      {"
            + "        \"creatednode\": {"
            + "          \"ledgerentrytype\": \"directorynode\","
            + "          \"ledgerindex\": \"62a3338caf2e1bee510fc33de1863c56948e962cce173ca55c14be8a20d7f000\","
            + "          \"newfields\": {"
            + "            \"exchangerate\": \"5c14be8a20d7f000\","
            + "            \"rootindex\": \"62a3338caf2e1bee510fc33de1863c56948e962cce173ca55c14be8a20d7f000\","
            + "            \"takergetscurrency\": \"000000000000000000000000494c530000000000\","
            + "            \"takergetsissuer\": \"92d705968936c419ce614bf264b5eeb1cea47ff4\""
            + "          }"
            + "        }"
            + "      },"
            + "      {"
            + "        \"modifiednode\": {"
            + "          \"finalfields\": {"
            + "            \"flags\": 0,"
            + "            \"indexprevious\": \"0000000000000000\","
            + "            \"owner\": \"rad5qjmashlehzxf9wjumo6vrk4arj9cf3\","
            + "            \"rootindex\": \"801c5afb5862d4666d0df8e5be1385dc9b421ed09a4269542a07bc0267584b64\""
            + "          },"
            + "          \"ledgerentrytype\": \"directorynode\","
            + "          \"ledgerindex\": \"ab03f8aa02ffa4635e7ce2850416aec5542910a2b4dbe93c318feb08375e0db5\""
            + "        }"
            + "      },"
            + "      {"
            + "        \"modifiednode\": {"
            + "          \"finalfields\": {"
            + "            \"account\": \"rad5qjmashlehzxf9wjumo6vrk4arj9cf3\","
            + "            \"balance\": \"106861218302\","
            + "            \"flags\": 0,"
            + "            \"ownercount\": 9,"
            + "            \"sequence\": 103930"
            + "          },"
            + "          \"ledgerentrytype\": \"accountroot\","
            + "          \"ledgerindex\": \"cf23a37e39a571a0f22ec3e97eb0169936b520c3088963f16c5ee4ac59130b1b\","
            + "          \"previousfields\": {"
            + "            \"balance\": \"106861218312\","
            + "            \"ownercount\": 8,"
            + "            \"sequence\": 103929"
            + "          },"
            + "          \"previoustxnid\": \"de15f43f4a73c4f6cb1c334d9e47bde84467c0902796bb81d4924885d1c11e6d\","
            + "          \"previoustxnlgrseq\": 3225338"
            + "        }"
            + "      }"
            + "    ],"
            + "    \"transactionindex\": 0,"
            + "    \"transactionresult\": \"tessuccess\""
            + "  }"
            + "}";

    jsonobject txjson = new jsonobject(json);
    stobject meta = stobject.fromjsonobject((jsonobject) txjson.remove("metadata"));
    transactionmeta txnmeta = (transactionmeta) meta;
    system.out.println("affectednodes:" + txnmeta.affectednodes());
    system.out.println("transactionresult:" + txnmeta.engineresult());
    system.out.println("transactionindex:" + txnmeta.transactionindex());
    stobject tx = stobject.fromjsonobject(txjson);
    transaction txn = (transaction) tx;
    system.out.println("account:" + txn.account().address);
    system.out.println("fee:" + txn.fee());
    system.out.println("txtype:" + txn.transactiontype());
    system.out.println("ledger_sequence::" + txn.lastledgersequence());
    system.out.println("accounttxid:" + txn.accounttxnid());
    system.out.println("flags:" + txn.flags());
    system.out.println("previoustxid:" + txn.previoustxnid());
    system.out.println("sequence:" + txn.sequence());
    system.out.println("source tag:" + txn.sourcetag());
    system.out.println("operationlimit:" + txn.operationlimit());
    system.out.println("signature:" + txn.txnsignature().tohex());
    switch (txn.transactiontype()) {
      case offercreate:
        offercreate oc = (offercreate) txn;
        system.out.println("offercreate-takergets:" + oc.takergets());
        system.out.println("offercreate-takerpays:" + oc.takerpays());
        break;
      case payment:
        payment payment = (payment) txn;
        system.out.println("payment-amount:" + payment.amount());
        system.out.println("payment-amount:" + payment.destination());
        system.out.println("payment-amount:" + payment.sendmax());
        break;
      case offercancel:
        offercancel ocl = (offercancel) txn;
        system.out.println("offercancel-offersequence:" + ocl.offersequence());
        break;
      case addreferee:
        addreferee arf = (addreferee) txn;
        system.out.println("addreferee-destaddr:" + arf.destination());
        break;
      case trustset:
        trustset trustset = (trustset) txn;
        system.out.println("trustset-limitamount:" + trustset.limitamount());
        system.out.println("trustset-qualityin:" + trustset.qualityin());
        system.out.println("trustset-qualityout:" + trustset.qualityout());
        break;
    }
  }