How does a wallet learn of a transaction it has received? I'm curious how a wallet learns of an incoming transaction. Is it constantly searching the blockchain for blocks containing addresses it generated?
A bitcoin wallet application that runs as a full node client contains a copy of every unspent transaction in the blockchain. This allows a wallet to construct transaction inputs as well as quickly verify incoming transactions as having correct inputs. However, most user wallets run lightweight clients that only track a users own unspent outputs. If the wallet does not maintain a copy of unspent transaction outputs it can query the bitcoin network using a variety of APIs. The API's will return all the unspent transaction outputs for an address. Most wallets will not run continuously and so when a user starts up the application it will query the network to synchronize with it.