getInputs, which is what the wallet uses to find the inputs to use for a new transaction.
getInputs works, it scans your wallet for addresses with a non-zero balance until it has enough IOTAs to fund the transfer.
As an example, let's say that your wallet looks like this:
ADDYZERO: 18 IOTAs
ADDYONE: 260 IOTAs
ADDYTWO: 42 IOTAs
Let's say you wanted to send 42 IOTAs to somebody.
getInputs will iterate over your addresses in order until it has enough IOTAs to fund the transaction:
ADDYZERO => 18 IOTAs (18 < 42; keep going)
ADDYONE => 260 IOTAs (18 + 260 = 278; 278 > 42; done!)
ADDYONE are both used as inputs for your transaction, and all 278 IOTAs are spent:
- 42 of those IOTAs will go to the recipient you specified.
- The remaining 236 IOTAs will go to the next unused address in your wallet (
ADDYTHREE, naturally ).
getInputs does not try to optimise at all — it does not try to minimise the number of input addresses, nor does it try to minimise the amount of change that has to be sent back to your wallet. It simply iterates over your addresses until it has found enough IOTAs to fund the transfer.