Esempio n. 1
0
        public void WalletStore_GetUnspentForAddress()
        {
            DataFolder dataFolder = CreateDataFolder(this);

            WalletStore store = new WalletStore(this.Network, dataFolder, new Types.Wallet {
                Name = "wallet1", EncryptedSeed = "EncryptedSeed1"
            });

            var scripts = new List <string>();

            for (int indexAddress = 0; indexAddress < 3; indexAddress++)
            {
                var script = new Key().PubKey.GetAddress(this.Network).ScriptPubKey.ToString();
                scripts.Add(script);

                for (int indexTrx = 0; indexTrx < 5; indexTrx++)
                {
                    var utxo = new OutPoint(new uint256((ulong)indexTrx), indexAddress);
                    var trx  = Create(utxo, script);

                    if (indexTrx > 2)
                    {
                        trx.SpendingDetails = null;
                    }

                    store.InsertOrUpdate(trx);
                }
            }

            var findforAddress = scripts[1];
            var res            = store.GetUnspentForAddress(findforAddress);

            foreach (var item in res)
            {
                item.Address.Should().Be(findforAddress);
                item.SpendingDetails.Should().BeNull();
            }
        }