# input selection scenarii ## Assumptions & Rules - Input selection should prioritise lowest account depth that has been selected - Basic outputs should be considered before others when sending a normal transaction - Outputs without native tokens should be considered before those with native tokens - Outputs should be selected before any outputs are selected to proved ownership (i.e sender feature) - Minimum storage depoit 500_000 - Inputs are ordered from smallest to largest ## Simple ### No inputs T1: :heavy_check_mark: inputs: [] outputs: [basic{ amount: 1_000_000 }] expected error: insufficient inputs ### Single input T2: :wavy_dash: inputs: [basic{ amount: 1_000_000 }] outputs: [basic{ amount: 250_000 }] expected error: output too small T3: :wavy_dash: inputs: [basic{ amount: 1_000_000 }] outputs: [basic{ amount: 500_000 }] expected selected: [basic{ amount: 1_000_000 }] expected remainder: Some(basic{ amount: 500_000 }) T4: :wavy_dash: inputs: [basic{ amount: 1_000_000 }] outputs: [basic{ amount: 750_000 }] expected error: remainder too small T5: :wavy_dash: inputs: [basic{ amount: 1_000_000 }] outputs: [basic{ amount: 1_000_000 }] expected selected: [basic{ amount: 1_000_000 }] expected remainder: None T6: :wavy_dash: inputs: [basic{ amount: 1_000_000 }] outputs: [basic{ amount: 1_250_000 }] expected error: insufficient inputs ### Two basic outputs T7: :wavy_dash: inputs: [basic{ amount: 1_000_000 }, basic{ amount: 2_000_000 }] outputs: [basic{ amount: 500_000 }] exected selected: [basic{ amount: 1_000_000 }] expected remainder: Some(basic{ amount: 500_000 }) T8: :wavy_dash: inputs: [basic{ amount: 1_000_000 }, basic{ amount: 2_000_000 }] outputs: [basic{ amount: 750_000 }] expected selected: [basic{ amount: 2_000_000 }] expected remainder: Some(basic{ amount: 1_250_000 }) T9: :heavy_check_mark: inputs: [basic{ amount: 1_000_000 }, basic{ amount: 2_000_000 }] outputs: [basic{ amount: 1_000_000 }] expected selected: [basic{ amount: 1_000_000 }] expected remainder: None T10: :wavy_dash: inputs: [basic{ amount: 1_000_000 }, basic{ amount: 2_000_000 }] outputs: [basic{ amount: 1_500_000 }] expected selected: [basic{ amount: 2_000_000 }] expected remainder: Some(basic{ amount: 500_000 }) T11: :wavy_dash: inputs: [basic{ amount: 1_000_000 }, basic{ amount: 2_000_000 }] outputs: [basic{ amount: 1_750_000 }] expected selected: [basic{ amount: 1_000_000 }, basic{ amount: 2_000_000 }] expected remainder: Some(basic{ amount: 1_250_000 }) T12: :wavy_dash: inputs: [basic{ amount: 1_000_000 }, basic{ amount: 2_000_000 }] outputs: [basic{ amount: 2_000_000 }] expected selected: [basic{ amount: 2_000_000 }] expected remainder: None T13: :heavy_check_mark: inputs: [basic{ amount: 1_000_000 }, basic{ amount: 2_000_000 }] outputs: [basic{ amount: 2_500_000 }] expected selected: [basic{ amount: 1_000_000 }, basic{ amount: 2_000_000 }] expected remainder: Some(basic{ amount: 500_000 }) T14: :wavy_dash: inputs: [basic{ amount: 1_000_000 }, basic{ amount: 2_000_000 }] outputs: [basic{ amount: 2_750_000 }] expected error: remainder too small T15: :heavy_check_mark: inputs: [basic{ amount: 1_000_000 }, basic{ amount: 2_000_000 }] outputs: [basic{ amount: 3_000_000 }] expected selected: [basic{ amount: 1_000_000 }, basic{ amount: 2_000_000 }] expected remainder: None T16: :heavy_check_mark: inputs: [basic{ amount: 1_000_000 }, basic{ amount: 2_000_000 }] outputs: [basic{ amount: 3_500_000 }] expected error: insufficient inputs ## Native Tokens - Gifting storage deposit ### Single Output T17: :wavy_dash: inputs: [basic{ amount: 1_000_000] }] outputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 150}] }] expected error: insufficient inputs T18: :wavy_dash: inputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }] }] outputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 50}] }] expected error: insufficient inputs for remainder native tokens T19: :wavy_dash: inputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }] }] outputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }] expected selected: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }] expected remainder: None T20: :wavy_dash: inputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }] }] outputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 150}] }] expected error: insufficient inputs T21: :wavy_dash: inputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }] }] outputs: [basic{ amount: 500_000, native_tokens: [{'a': 50}] }] expected selected: [basic{ amount: 500_000, native_tokens: [{'a': 50}] }] expected remainder: Some(basic{ amount: 500_000, native_tokens: [{'a': 50}]}) T22: :wavy_dash: inputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }] }] outputs: [basic{ amount: 500_000, native_tokens: [{'a': 100}] }] expected selected: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }] expected remainder: Some(basic{ amount: 500_000 }) ### Two basic outputs T23: :wavy_dash: inputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 200}] }] }] outputs: [basic{ amount: 500_000] expected selected: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }] expected remainder: Some(basic{ amount: 500_000, native_tokens: [{'a': 100}] }) T24: :wavy_dash: inputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 200}] }] }] outputs: [basic{ amount: 500_000, native_tokens: [{'a': 50}] }] expected selected: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }] expected remainder: Some(basic{ amount: 500_000, native_tokens: [{'a': 50}] }) T25: :wavy_dash: inputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 200}] }] }] outputs: [basic{ amount: 500_000, native_tokens: [{'a': 75}] }] expected selected: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }] expected remainder: Some(basic{ amount: 500_000, native_tokens: [{'a': 25}] }) T26: :wavy_dash: inputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 200}] }] }] outputs: [basic{ amount: 500_000, native_tokens: [{'a': 100}] }] expected selected: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }] expected remainder: Some(basic{ amount: 500_000 }) T27: :wavy_dash: inputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 200}] }] }] outputs: [basic{ amount: 500_000, native_tokens: [{'a': 150}] }] expected selected: [basic{ amount: 1_000_000, native_tokens: [{'a': 200}] }] expected remainder: Some(basic{ amount: 500_000, native_tokens: [{'a': 50}] }) T28: :wavy_dash: inputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 200}] }] }] outputs: [basic{ amount: 500_000, native_tokens: [{'a': 200}] }] expected selected: [basic{ amount: 1_000_000, native_tokens: [{'a': 200}] }] expected remainder: Some(basic{ amount: 500_000 }) T29: :wavy_dash: inputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 200}] }] }] outputs: [basic{ amount: 500_000, native_tokens: [{'a': 250}] }] expected selected: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 200}] }] expected remainder: Some(basic{ amount: 1_500_000, native_tokens: [{'a': 50}] }) T30: :wavy_dash: inputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 200}] }] }] outputs: [basic{ amount: 500_000, native_tokens: [{'a': 300}] }] expected selected: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 200}] }] expected remainder: Some(basic{ amount: 1_500_000 }) T31: :wavy_dash: inputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 200}] }] }] outputs: [basic{ amount: 500_000, native_tokens: [{'a': 350}] }] expected error: insufficient inputs ## Multiple native tokens T32: :wavy_dash: inputs: [ basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 100}, {'b': 100}] }] outputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }] expected selected: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }] expected remainder: None T33: :wavy_dash: inputs: [ basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 100}, {'b': 100}] }] outputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 150}] }] expected selected: [ basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 100}, {'b': 100}] }] expected remainder: Some(basic{ amount: 1_000_000, native_tokens: [{'a': 50}, {'b': 100}] }) T34: :wavy_dash: inputs: [ basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 100}, {'b': 100}] }] outputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 200}] }] expected selected: [ basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 100}, {'b': 100}] }] expected remainder: Some(basic{ amount: 1_000_000, native_tokens: [{'b': 100}] }) ### Lots of Native Tokens T35: :wavy_dash: // Wrong selected inputs will create too many NTs error // Differente similar combinations might be good to be sure that it works not only if provided in the "correct" order inputs: [ basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'b': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 300}, {'c': 100}, {'d': 100}, {'e': 100}, ... {'bf or whatever so it's 64 native tokens': 100}] } ] outputs: [basic{ amount: 500_000, native_tokens: [{'a': 300}, {'b': 100}] }] expected selected: [ basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'b': 100}] } ] expected remainder: Some(basic{ amount: 3_500_000 }) ### Burn Native Tokens T36: :wavy_dash: inputs: [ basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, burn: {native_tokens: [{'a': 50}]} expected selected: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }] expected remainder: expected remainder: Some(basic{ amount: 1_000_000, native_tokens: [{'a': 50}] }) T37: :wavy_dash: inputs: [ basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }, basic{ amount: 1_000_000, native_tokens: [{'a': 100}, {'b': 100}] }] burn: {native_tokens: [{'a': 50}]} expected selected: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}] }] expected remainder: expected remainder: Some(basic{ amount: 1_000_000, native_tokens: [{'a': 50}] }) T38: :wavy_dash: inputs: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}, {'b': 100}]}] burn: {native_tokens: [{'a': 50}]} expected selected: [basic{ amount: 1_000_000, native_tokens: [{'a': 100}, {'b': 100}] }] expected remainder: Some(basic{ amount: 1_000_000, native_tokens: [{'a': 50}, {'b': 100}] })