With the faucet one significant expense is the transportation cost. To collect all those multi-sig outputs that are spendable I did this:
1. List and store all transactions for address X
2. Iterate over all outputs and store those which are from type "mutlisig" and require one signature and include address X
3. Create a raw transaction that spents such output from (2) for each potential output
4. If signrawtransaction for (3) returns "complete", this output is indeed spendable
5. Store all those and create a transaction that uses all spendable outputs as inputs and send the coins back to address X
This is how the result looks like:
https://blockchain.info/tx/21db95ecd700438bf46e0a435410c27ab0f235218a80afacd81db4fec5bf8260 (ignore the "script translation" from blockchain.info.. of course no OP_FALSE was used)
If you like to test this yourself, feel free to use this as basis:
https://gist.github.com/dexX7/9146763For some odd reason my local bitcoind client started to return a success for outputs that are already spent and thus the whole approach fails now, because the success or failure of signing the tx determined, if an output shall to be considered as spendable. edit: there was one case where an output was added to the list two times.
I haven't looked at alternative implementations like sx or libbitcoin. I like to know, if one of those is worth to look at and if anyone of you guys here already worked on a solution for spending multisig outputs.