/// <summary> /// Builds the extended filter for a given block. /// /// The extended filter contains extra data that is meant to enable applications with more advanced smart contracts. /// An extended filter MUST contain exactly the following items for each transaction in a block except the coinbase: /// * Each item within the witness stack of each input (if the input has a witness) /// * Each data push in the scriptSig of each input /// </summary> /// <param name="block">The block used for building the filter.</param> /// <returns>The extended filter for the block.</returns> public static GolombRiceFilter BuildExtendedFilter(Block block) { var builder = new GolombRiceFilterBuilder() .SetKey(block.GetHash()); foreach (var tx in block.Transactions) { if (!tx.IsCoinBase) // except the coinbase { foreach (var txin in tx.Inputs) { if (txin.ScriptSig != Script.Empty) { // Each data push in the scriptSig of each input builder.AddScriptSig(txin.ScriptSig); } if (txin.WitScript != WitScript.Empty) { // Each item within the witness stack of each input (if the input has a witness) builder.AddWitness(txin.WitScript); } } } } return(builder.Build()); }