Exemplo n.º 1
0
 /// <summary>
 /// This will not clear utxos since tx extractor might want to check the validity
 /// </summary>
 internal void ClearForFinalize()
 {
     this.redeem_script  = null;
     this.witness_script = null;
     this.partial_sigs.Clear();
     this.hd_keypaths.Clear();
     this.sighash_type = null;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Delete superflous information from a finalized input.
 /// This will not clear utxos since tx extractor might want to check the validity
 /// </summary>
 /// <exception cref="System.InvalidOperationException">The input need to be finalized</exception>
 public void ClearForFinalize()
 {
     if (!IsFinalized())
     {
         throw new InvalidOperationException("The input need to be finalized");
     }
     this.redeem_script  = null;
     this.witness_script = null;
     this.partial_sigs.Clear();
     this.hd_keypaths.Clear();
     this.sighash_type = null;
 }
Exemplo n.º 3
0
        internal void Combine(PSBTInput other)
        {
            if (this.IsFinalized())
            {
                return;
            }

            foreach (var uk in other.unknown)
            {
                unknown.TryAdd(uk.Key, uk.Value);
            }


            if (other.final_script_sig != null)
            {
                final_script_sig = other.final_script_sig;
            }

            if (other.final_script_witness != null)
            {
                final_script_witness = other.final_script_witness;
            }
            if (IsFinalized())
            {
                ClearForFinalize();
                return;
            }

            if (non_witness_utxo == null && other.non_witness_utxo != null)
            {
                non_witness_utxo = other.non_witness_utxo;
            }

            if (witness_utxo == null && other.witness_utxo != null)
            {
                non_witness_utxo = other.non_witness_utxo;
            }

            if (sighash_type == 0 && other.sighash_type > 0)
            {
                sighash_type = other.sighash_type;
            }

            if (redeem_script == null && other.redeem_script != null)
            {
                redeem_script = other.redeem_script;
            }

            if (witness_script == null && other.witness_script != null)
            {
                witness_script = other.witness_script;
            }

            foreach (var sig in other.partial_sigs)
            {
                partial_sigs.TryAdd(sig.Key, sig.Value);
            }

            foreach (var keyPath in other.hd_keypaths)
            {
                hd_keypaths.TryAdd(keyPath.Key, keyPath.Value);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Import informations contained by <paramref name="other"/> into this instance.
        /// </summary>
        /// <param name="other"></param>
        public void UpdateFrom(PSBTInput other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            foreach (var uk in other.unknown)
            {
                unknown.TryAdd(uk.Key, uk.Value);
            }


            if (other.final_script_sig != null)
            {
                final_script_sig = other.final_script_sig;
            }

            if (other.final_script_witness != null)
            {
                final_script_witness = other.final_script_witness;
            }

            if (non_witness_utxo == null && other.non_witness_utxo != null)
            {
                non_witness_utxo = other.non_witness_utxo;
            }

            if (witness_utxo == null && other.witness_utxo != null)
            {
                witness_utxo = other.witness_utxo;
            }

            if (sighash_type == 0 && other.sighash_type > 0)
            {
                sighash_type = other.sighash_type;
            }

            if (redeem_script == null && other.redeem_script != null)
            {
                redeem_script = other.redeem_script;
            }

            if (witness_script == null && other.witness_script != null)
            {
                witness_script = other.witness_script;
            }

            foreach (var sig in other.partial_sigs)
            {
                partial_sigs.TryAdd(sig.Key, sig.Value);
            }

            foreach (var keyPath in other.hd_keypaths)
            {
                hd_keypaths.TryAdd(keyPath.Key, keyPath.Value);
            }

            if (IsFinalized())
            {
                ClearForFinalize();
            }
        }