protected override void BuildTransaction(JObject json, Transaction tx)
        {
            tx.Version  = (uint)json.GetValue("ver");
            tx.LockTime = (uint)json.GetValue("lock_time");

            var vin      = (JArray)json.GetValue("in");
            int vinCount = (int)json.GetValue("vin_sz");

            for (int i = 0; i < vinCount; i++)
            {
                var jsonIn = (JObject)vin[i];
                var txin   = new TxIn();
                tx.Inputs.Add(txin);
                var prevout = (JObject)jsonIn.GetValue("prev_out");

                txin.PrevOut.Hash = uint256.Parse((string)prevout.GetValue("hash"));
                txin.PrevOut.N    = (uint)prevout.GetValue("n");


                var script = (string)jsonIn.GetValue("scriptSig");
                if (script != null)
                {
                    txin.ScriptSig = new Script(script);
                }
                else
                {
                    var coinbase = (string)jsonIn.GetValue("coinbase");
                    txin.ScriptSig = new Script(Encoders.Hex.DecodeData(coinbase));
                }

                var seq = jsonIn.GetValue("sequence");
                if (seq != null)
                {
                    txin.Sequence = (uint)seq;
                }
            }

            var vout      = (JArray)json.GetValue("out");
            int voutCount = (int)json.GetValue("vout_sz");

            for (int i = 0; i < voutCount; i++)
            {
                var jsonOut = (JObject)vout[i];
                var txout   = new NBitcoinBTG.TxOut();
                tx.Outputs.Add(txout);

                txout.Value        = Money.Parse((string)jsonOut.GetValue("value"));
                txout.ScriptPubKey = new Script((string)jsonOut.GetValue("scriptPubKey"));
            }
        }
Exemple #2
0
 public TxInUndo(NBitcoinBTG.TxOut txOut)
 {
     this.TxOut = txOut;
 }