Post
Topic
Board Development & Technical Discussion
Re: Replicate listunspent for multi-sig outputs
by
dudeami
on 12/11/2013, 13:57:01 UTC
If you go through the whole blockchain and record every transaction as you plan, you'll probably run into some sort of memory issue. You do have the right approach, though something like this would save you some memory (using JS in a psuedocode kinda way :p):

Code:
var utxos = {}; // Make an object/list

getblock {
    foreach block.tx {
        getrawtransaction {
            foreach tx.vin {
                if (utxos[vin.txid+':'+vin.vout])
                    unset utxos[vin.txid+':'+vin.vout];
            }
            foreach tx.vout {
                utxos[tx.txid+':'+vout.n] = vout; // Note that the vout object does NOT contain the TX ID
            }
        }
    }
}

So basically, you are only storing the transactions that are unspent. Note this approach may be inaccurate due to doublespends and the like.