SHARE
TWEET

Untitled

a guest Sep 20th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # rate, timestamp, tx
  2. match tx {
  3.     case d:DataTransaction =>
  4.         let k0 = d.data[0].key
  5.         let event = take(k0, size(k0) - 5)
  6.         let txid = extract(getString(d.data, event + "_tx"))
  7.         let exchangeTx = extract(match transactionById(fromBase58String(txid)) {
  8.             case e:ExchangeTransaction => e
  9.             case _ => unit
  10.         })
  11.  
  12.         let prevTs = getInteger(tx.sender, event + "_timestamp")
  13.         let eventTs = takeRight(event, 10)
  14.  
  15.         let amountAsset = exchangeTx.buyOrder.assetPair.amountAsset
  16.         let priceAsset = exchangeTx.buyOrder.assetPair.priceAsset
  17.  
  18.         let amountAssetCode =
  19.             if amountAsset == unit then "WAVES"
  20.             else if amountAsset == base58'Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck' then "USD"
  21.             else if amountAsset == base58'8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS' then "BTC"
  22.             else if amountAsset == base58'4LHHvYGNKJUg5hj65aGD5vgScvCBmLpdRFtjokvCjSL8' then "VST"
  23.             else "unknown"
  24.  
  25.         let priceAssetCode =
  26.             if priceAsset == unit then "WAVES"
  27.             else if priceAsset == base58'Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck' then "USD"
  28.             else if priceAsset == base58'8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS' then "BTC"
  29.             else if priceAsset == base58'4LHHvYGNKJUg5hj65aGD5vgScvCBmLpdRFtjokvCjSL8' then "VST"
  30.             else "unknown"
  31.  
  32.         let eventStart = "dex:" + amountAssetCode + "/" + priceAssetCode + ":"
  33.  
  34.         size(d.data) == 5
  35.         && take(event, size(eventStart)) == eventStart
  36.         && exchangeTx.buyOrder.matcherPublicKey == base58'7kPFrHDiGw1rCm7LPszuECwWYL3dMf6iMifLRDJQZMzy'
  37.         && d.data[0].key == event + "_rate"
  38.         && d.data[1].key == event + "_timestamp"
  39.         && d.data[2].key == event + "_tx"
  40.         && d.data[3].key == event + "_eventts"
  41.         && d.data[4].key == event + "_height"
  42.  
  43.         && d.data[0].value == exchangeTx.price
  44.         && d.data[1].value == exchangeTx.timestamp
  45.         && d.data[2].value == txid
  46.         && (!isDefined(prevTs) || (exchangeTx.timestamp < extract(prevTs)))
  47.         && toString(extract(getInteger(d.data, event + "_eventts"))) == eventTs
  48.         && extract(getInteger(d.data, event + "_eventts")) * 1000 <= exchangeTx.timestamp
  49.         && d.data[4].value == transactionHeightById(fromBase58String(txid))
  50.  
  51.     case _ => sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
  52. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top