コード例 #1
0
 public void AdvanceTo(BuilderState next)
 {
     if(!CanAdvanceTo(next))
         throw new InvalidOperationException("Can't move from state " + _state.ToString() + " to state " + next.ToString() + ".");
     BuilderState before = _state;
     _state = next;
     OnAfterAdvance(before, next, before != BuilderState.Idle, before != BuilderState.Idle && before != BuilderState.System);
 }
コード例 #2
0
 public DLCTransactionBuilder GetBuilder(Network network)
 {
     if (BuilderState is null)
     {
         throw new InvalidOperationException("The builder is not created yet");
     }
     return(new DLCTransactionBuilder(BuilderState.ToString(), network));
 }
コード例 #3
0
        public void AdvanceTo(BuilderState next)
        {
            if (!CanAdvanceTo(next))
            {
                throw new InvalidOperationException("Can't move from state " + _state.ToString() + " to state " + next.ToString() + ".");
            }
            BuilderState before = _state;

            _state = next;
            OnAfterAdvance(before, next, before != BuilderState.Idle, before != BuilderState.Idle && before != BuilderState.System);
        }
コード例 #4
0
 protected override void OnAfterAdvance(BuilderState before, BuilderState after, bool wasInsideSystem, bool wasInsideGroup)
 {
     if(after != before)
     {
         if(wasInsideGroup)
             _writer.WriteEndElement();
         if(after == BuilderState.Idle)
             _writer.WriteEndElement();
         else
             _writer.WriteStartElement(after.ToString(), Context.YttriumNamespace);
     }
 }
コード例 #5
0
            public DLCNextStep GetNextStep(Network network)
            {
                if (BuilderState is null)
                {
                    throw new InvalidOperationException("BuilderState not set");
                }
                var         builder = new DLCTransactionBuilder(BuilderState.ToString(), network);
                DLCNextStep nextStep;

                if (builder.State.IsInitiator)
                {
                    if (FundKeyPath is null)
                    {
                        nextStep = DLCNextStep.Setup;
                    }
                    else if (Accept is null)
                    {
                        nextStep = DLCNextStep.CheckSigs;
                    }
                    else if (Sign is null)
                    {
                        nextStep = DLCNextStep.Fund;
                    }
                    else
                    {
                        nextStep = DLCNextStep.Done;
                    }
                }
                else
                {
                    if (builder.State.Funding is null)
                    {
                        nextStep = DLCNextStep.Setup;
                    }
                    else if (Sign is null)
                    {
                        nextStep = DLCNextStep.CheckSigs;
                    }
                    else if (!builder.State.Funding.PSBT.CanExtractTransaction())
                    {
                        nextStep = DLCNextStep.Fund;
                    }
                    else
                    {
                        nextStep = DLCNextStep.Done;
                    }
                }
                return(nextStep);
            }
コード例 #6
0
 protected override void OnAfterAdvance(BuilderState before, BuilderState after, bool wasInsideSystem, bool wasInsideGroup)
 {
     if (after != before)
     {
         if (wasInsideGroup)
         {
             _writer.WriteEndElement();
         }
         if (after == BuilderState.Idle)
         {
             _writer.WriteEndElement();
         }
         else
         {
             _writer.WriteStartElement(after.ToString(), Config.YttriumNamespace);
         }
     }
 }