Пример #1
0
		public Coin AsCoin(DerivationStrategy.DerivationStrategyBase derivationStrategy)
		{
			var coin = new Coin(Outpoint, new TxOut(Value, ScriptPubKey));
			if (derivationStrategy != null)
			{
				var derivation = derivationStrategy.Derive(KeyPath);
				if (derivation.ScriptPubKey != coin.ScriptPubKey)
					throw new InvalidOperationException($"This Derivation Strategy does not own this coin");
				if (derivation.Redeem != null)
					coin = coin.ToScriptCoin(derivation.Redeem);
			}
			return coin;
		}
Пример #2
0
 public Coin AsCoin(DerivationStrategy.DerivationStrategyBase derivationStrategy)
 {
     if (Value is Money v)
     {
         var coin = new Coin(Outpoint, new TxOut(v, ScriptPubKey));
         if (derivationStrategy != null)
         {
             var derivation = derivationStrategy.GetDerivation(KeyPath);
             if (derivation.ScriptPubKey != coin.ScriptPubKey)
             {
                 throw new InvalidOperationException($"This Derivation Strategy does not own this coin");
             }
             if (derivation.Redeem != null)
             {
                 coin = coin.ToScriptCoin(derivation.Redeem);
             }
         }
         return(coin);
     }
     return(null);
 }