bitcoinjs / bip32-wallet

A BIP32 Wallet backed by bitcoinjs-lib, lite on features but heavily tested.
MIT License
19 stars 14 forks source link

Unspents Tracking #1

Closed sidazhang closed 9 years ago

sidazhang commented 9 years ago
  1. Dupe Unspents https://github.com/dcousens/bip32-wallet/blob/master/src/wallet.js#L126-L141

I think this might be better to be an object rather than an array to prevent a client error to adding in duplicate unspents or alternatively someway to aid the client to prevent dupes

  1. Add unspents

Currently, the API only supports setUnspents. So if there is one new unspent, it has to reset it

dcousens commented 9 years ago

Dupe Unspents https://github.com/dcousens/bip32-wallet/blob/master/src/wallet.js#L126-L141

I think this is a user input failure, but I'm happy to track the transaction ids and verify they are unique when using setUnspentOutputs, so I'll add this.

Add unspents

Unspents should be considered a snap shot of the current wallet state only; and should not be mutative (IMHO).

If you're looking for a more scalable way to track unspents, I am too, and I think a separate module that tracks relevant transactions and can provide the unspents atomically would be a better, easier to manage abstraction than lumping it all together in this.

dcousens commented 9 years ago

See https://github.com/dcousens/bip32-wallet/commit/d4cc93dac0ac9b0e4205fc5a03981c4a8c66e1ed.