digraph blockchain {

size=6.25;
splines = "false";
//rankdir=LR;
//ranksep=0.1;
//splines=ortho;

node [ fontname="Sans", shape = box ];
edge [ fontname="Sans", style = invis, minlen = 1 ];
graph [ fontname="Sans" ];
//fixedsize
nodesep = 0.05;
//concentrate = true;

subgraph cluster_alice {
    bgcolor = grey;
    alice_opchecksig [ label = "CHECKSIG" ];
    alice_opequalverify [ label = "OP_EQUALVERIFY" ];
    alice_pubkeyhash [ label = "Pk Hash", shape = "" ];
    alice_ophash [ label = "OP_HASH160" ];
    alice_opdup [ label = "OP_DUP" ];
    alice_pubkey [style = invis, label="PubKey", shape = "" ];
    alice_sig  [style = invis, label="Sig", shape = "" ];

    label = "Instructions And Data Provided By Alice In Transaction #1's Pubkey Script"
    /* label = "Data Provided By Spender 1 To Spend Output" */
}

subgraph cluster_bob {
    bgcolor = grey;
    bob_opchecksig [ label = "CHECKSIG", style = invis ];
    bob_opequalverify [ label = "OP_EQUALVERIFY", style = invis ];
    bob_pubkeyhash [ label = "Pk Hash", style = invis, shape = "" ];
    bob_ophash [ label = "OP_HASH160", style = invis ];
    bob_opdup [ label = "OP_DUP", style = invis ];
    bob_pubkey [style = unfilled, label="PubKey", shape = "" ];
    bob_sig  [style = unfilled, label="Sig", shape = "" ];

    label = "Data Provided By Bob In Transaction #2's Input Signature Script"
}

alice_sig -> bob_sig;
alice_pubkey -> bob_pubkey;
alice_opdup -> bob_opdup;
alice_ophash -> bob_ophash;
alice_pubkeyhash -> bob_pubkeyhash;
alice_opequalverify -> bob_opequalverify;
alice_opchecksig -> bob_opchecksig;

subgraph invis {
    node [ style = invis, label="", width=0, height=0 ];
    invis0_0;
    invis0_1;
    invis0_2;
    invis0_3;

    invis1_0;
    invis1_1;
    invis1_2;

    invis2_0;
    invis2_1;

    invis3_0;

    invis4_0;

    invis5_0;
    invis5_1;

    invis6_0;
    invis6_1;
    invis6_2;
    invis6_3;
    invis6_4;
    invis6_5;
    invis6_6;
}
    stack7_opchecksig  [style = filled, label="OP_CHECKSIG" ];
    stack7_pubkey  [style = filled, label="PubKey", shape = "" ];
    stack7_sig  [style = filled, label="Sig", shape = "" ];

    stack6_opequalverify  [style = filled, label="OP_EQUALVERIFY" ];
    stack6_pubkeyhash  [style = filled, label="Pk Hash", shape = "" ];
    stack6_ophash  [style = filled, label="Pk Hash" ];
    stack6_pubkey  [style = unfilled, label="PubKey", shape = "" ];
    stack6_sig  [style = unfilled, label="Sig", shape = "" ];

    stack5_pubkeyhash  [style = unfilled, label="Pk Hash", shape = "" ];
    stack5_ophash  [style = unfilled, label="Pk Hash" ];
    stack5_pubkey  [style = unfilled, label="PubKey", shape = "" ];
    stack5_sig  [style = unfilled, label="Sig", shape = "" ];

    stack4_ophash  [style = filled, label="OP_HASH160" ];
    stack4_opdup  [style = filled, label="PubKey" ];
    stack4_pubkey  [style = unfilled, label="PubKey", shape = "" ];
    stack4_sig  [style = unfilled, label="Sig", shape = "" ];

    stack3_opdup  [style = filled, label="OP_DUP" ];
    stack3_pubkey  [style = filled, label="PubKey", shape = "" ];
    stack3_sig  [style = unfilled, label="Sig", shape = "" ];

    stack2_pubkey  [style = unfilled, label="PubKey", shape = "" ];
    stack2_sig  [style = unfilled, label="Sig", shape = "" ];
    stack1_sig  [style = unfilled, label="Sig", shape = "" ];

bob_sig -> invis0_0 -> invis0_1 -> invis0_2 -> invis0_3 -> stack1_sig;
bob_sig -> invis0_1 [ style = "dotted" ];

bob_pubkey -> invis1_0 -> invis1_1 -> invis1_2 -> stack2_pubkey;
bob_pubkey -> stack2_pubkey; stack2_pubkey -> stack2_sig;


bob_opdup -> invis2_0 -> invis2_1 -> stack3_opdup;
alice_opdup -> invis2_1 [ constraint = false, style = "dotted" ]; stack3_opdup -> stack3_pubkey -> stack3_sig;

bob_ophash -> invis3_0 -> stack4_ophash;
bob_ophash -> stack4_ophash; stack4_ophash -> stack4_opdup -> stack4_pubkey -> stack4_sig;

bob_pubkeyhash -> invis4_0 -> stack5_pubkeyhash;
bob_pubkeyhash -> stack5_pubkeyhash; stack5_pubkeyhash -> stack5_ophash -> stack5_pubkey -> stack5_sig;

bob_opequalverify -> stack6_opequalverify; stack6_opequalverify -> stack6_pubkeyhash -> stack6_ophash -> stack6_pubkey -> stack6_sig

bob_opchecksig -> invis5_0 -> invis5_1 -> stack7_opchecksig;
bob_opchecksig -> stack7_opchecksig; stack7_opchecksig -> stack7_pubkey -> stack7_sig

invis6_0 -> invis6_1 -> invis6_2 -> invis6_3 -> invis6_4 -> invis6_5 -> TRUE;
stack7_opchecksig -> TRUE [ style = "", minlen = 2 ];


stack3_opdup -> stack4_opdup [ constraint = false, style = "" ]; 
stack3_pubkey -> stack3_opdup [ style = "" ]; 

stack4_ophash -> stack5_ophash [ constraint = false, style = "" ];
stack4_opdup -> stack4_ophash [ style = "" ]; 

stack6_pubkeyhash -> stack6_opequalverify [ style = "" ]; 
stack6_ophash -> stack6_pubkeyhash [ style = "" ]; 

stack7_pubkey -> stack7_opchecksig [ style = "" ]; 
stack7_sig -> stack7_pubkey [ style = "" ]; 

label = "Evaluation Stack Over Time During Succesful P2PKH Script Validation"
}
