| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "bounce_fees": { |
| 5 | "base": 10000 |
| 6 | }, |
| 7 | "init": "{ |
| 8 | $this = { |
| 9 | dust_collector : "B2UMBICLZSBVDHRC7BYM6BBU4AQEXL2F", |
| 10 | htlc_base_aa : "QDUO5LIIERVQM2Q5JSZCNIEGBD5XEVAW" |
| 11 | }; |
| 12 | |
| 13 | |
| 14 | }", |
| 15 | "messages": { |
| 16 | "cases": [ |
| 17 | { |
| 18 | "if": "{ !!trigger.data.destination_address and !!trigger.data.hash_of_secret}", |
| 19 | "init": "{ |
| 20 | $duration = json_parse(trigger.data.duration_in_hours otherwise 12)*60*60; |
| 21 | $aa_definition = ['autonomous agent', { |
| 22 | base_aa: $this.htlc_base_aa , |
| 23 | params: { |
| 24 | destination_address: trigger.data.destination_address, |
| 25 | hash_of_secret: trigger.data.hash_of_secret, |
| 26 | amount: trigger.data.amount otherwise 0, |
| 27 | asset_id: trigger.data.asset_id otherwise "base", |
| 28 | duration: $duration, |
| 29 | } |
| 30 | } |
| 31 | ]; |
| 32 | }", |
| 33 | "messages": [ |
| 34 | { |
| 35 | "app": "definition", |
| 36 | "payload": { |
| 37 | "definition": "{$aa_definition}" |
| 38 | } |
| 39 | }, |
| 40 | { |
| 41 | "app": "payment", |
| 42 | "payload": { |
| 43 | "asset": "base", |
| 44 | "outputs": [ |
| 45 | { |
| 46 | "address": "{trigger.initial_address}", |
| 47 | "amount": "{balance[base]-2000}" |
| 48 | } |
| 49 | ] |
| 50 | } |
| 51 | }, |
| 52 | { |
| 53 | "app": "state", |
| 54 | "state": "{ |
| 55 | response['message'] = "HTLC has been created"; |
| 56 | response['HTLC address'] = chash160($aa_definition); |
| 57 | response['HTLC duration'] = trigger.data.duration_in_hours; |
| 58 | response['HTLC destination'] = trigger.data.destination_address; |
| 59 | }" |
| 60 | } |
| 61 | ] |
| 62 | }, |
| 63 | { |
| 64 | "messages": [ |
| 65 | { |
| 66 | "app": "state", |
| 67 | "state": "{ |
| 68 | bounce("I need:'destination_address' and 'hash_of_secret' and optional 'amount', 'asset_id' and 'duration_in_hours'."); |
| 69 | }" |
| 70 | } |
| 71 | ] |
| 72 | } |
| 73 | ] |
| 74 | } |
| 75 | } |
| 76 | ] |