public Account(Account copied, ObjectStream<AccountEntry> entries) { if(entries == null) entries = new StreamObjectStream<AccountEntry>(); _Entries = entries; copied.Entries.Rewind(); entries.Rewind(); foreach(var entry in copied.Entries.Enumerate()) { if(_NextToProcess < copied._NextToProcess) { PushAccountEntry(entry); } else entries.WriteNext(entry); } }
private void NeutralizeUnconfirmed(Chain chain, Account account) { var unconfirmed = account.GetInChain(chain, false).Where(e => e.Reason != AccountEntryReason.ChainBlockChanged); foreach(var e in unconfirmed) { account.PushAccountEntry(e.Neutralize()); } var confirmedCanceled = account.GetInChain(chain, true).Where(e => e.Reason == AccountEntryReason.ChainBlockChanged); foreach(var e in confirmedCanceled) { account.PushAccountEntry(e.Neutralize()); } }
public Accounts() { _Confirmed = new Account(); _Available = new Account(); _Unconfirmed = new Account(); }
public bool CompleteTx(Transaction tx, Money fees, Account pool = null) { pool = pool ?? Accounts.Available; var entries = pool.GetEntriesToCover(tx.TotalOut + fees, false); if(entries == null) return false; foreach(var entry in entries) { tx.AddInput(new TxIn(entry.OutPoint)); } var surplus = entries.Sum(i => i.TxOut.Value) - fees - tx.TotalOut; if(surplus != Money.Zero) tx.AddOutput(surplus, GetKey().PubKey.ID); for(int i = 0 ; i < entries.Length ; i++) { var entry = entries[i]; var vin = tx.Inputs[i]; var key = GetKey(entry.TxOut.ScriptPubKey.GetDestination()); tx.Inputs[i].ScriptSig = new PayToPubkeyHashTemplate().GenerateScriptPubKey(key.PubKey); var hash = tx.Inputs[i].ScriptSig.SignatureHash(tx, i, SigHash.All); var sig = key.Sign(hash); tx.Inputs[i].ScriptSig = new PayToPubkeyHashTemplate().GenerateScriptSig(new TransactionSignature(sig, SigHash.All), key.PubKey); } return true; }
public bool CompleteTx(Transaction tx, Account pool = null) { return CompleteTx(tx, Money.Zero, pool); }
public Account(Account copied) : this(copied, null) { }