public void Load(Stream stream, ConsensusFactory consensusFactory, ChainSerializationFormat format) { if (consensusFactory == null) { throw new ArgumentNullException(nameof(consensusFactory)); } Load(new BitcoinStream(stream, false) { ConsensusFactory = consensusFactory }, format); }
public IDisposable ConsensusFactoryScope(ConsensusFactory consensusFactory) { var old = ConsensusFactory; return(new Scope(() => { ConsensusFactory = consensusFactory; }, () => { ConsensusFactory = old; })); }
public static PSBT Load(byte[] rawBytes, ConsensusFactory consensusFactory) { if (rawBytes == null) { throw new ArgumentNullException(nameof(rawBytes)); } var stream = new BitcoinStream(rawBytes); stream.ConsensusFactory = consensusFactory; var ret = new PSBT(stream, null); return(ret); }
public static Block Load(byte[] hex, ConsensusFactory consensusFactory) { if (hex == null) { throw new ArgumentNullException(nameof(hex)); } if (consensusFactory == null) { throw new ArgumentNullException(nameof(consensusFactory)); } var block = consensusFactory.CreateBlock(); block.ReadWrite(hex, consensusFactory); return(block); }
public static Block Parse(string hex, ConsensusFactory consensusFactory) { if (hex == null) { throw new ArgumentNullException(nameof(hex)); } if (consensusFactory == null) { throw new ArgumentNullException(nameof(consensusFactory)); } var block = consensusFactory.CreateBlock(); block.ReadWrite(Encoders.Hex.DecodeData(hex), consensusFactory); return(block); }
public static Block CreateBlock(BlockHeader header, ConsensusFactory consensusFactory) { var ms = new MemoryStream(100); BitcoinStream bs = new BitcoinStream(ms, true); bs.ConsensusFactory = consensusFactory; bs.ReadWrite(header); var block = consensusFactory.CreateBlock(); ms.Position = 0; bs = new BitcoinStream(ms, false); block.Header.ReadWrite(bs); return(block); }
public BlockHeader(string hex, ConsensusFactory consensusFactory) { if (hex == null) { throw new ArgumentNullException(nameof(hex)); } if (consensusFactory == null) { throw new ArgumentNullException(nameof(consensusFactory)); } BitcoinStream bs = new BitcoinStream(Encoders.Hex.DecodeData(hex)) { ConsensusFactory = consensusFactory }; this.ReadWrite(bs); }
public BlockHeader(byte[] data, ConsensusFactory consensusFactory) { if (data == null) { throw new ArgumentNullException(nameof(data)); } if (consensusFactory == null) { throw new ArgumentNullException(nameof(consensusFactory)); } BitcoinStream bs = new BitcoinStream(data) { ConsensusFactory = consensusFactory }; this.ReadWrite(bs); }
public static PSBT Parse(string hexOrBase64, ConsensusFactory consensusFactory) { if (hexOrBase64 == null) { throw new ArgumentNullException(nameof(hexOrBase64)); } if (consensusFactory == null) { throw new ArgumentNullException(nameof(consensusFactory)); } byte[] raw; if (HexEncoder.IsWellFormed(hexOrBase64)) { raw = Encoders.Hex.DecodeData(hexOrBase64); } else { raw = Encoders.Base64.DecodeData(hexOrBase64); } return(Load(raw, consensusFactory)); }
public Block CreateNextBlockWithCoinbase(PubKey pubkey, Money value, ConsensusFactory consensusFactory) { return(CreateNextBlockWithCoinbase(pubkey, value, DateTimeOffset.UtcNow, consensusFactory)); }
public Block CreateNextBlockWithCoinbase(PubKey pubkey, Money value, DateTimeOffset now, ConsensusFactory consensusFactory) { Block block = consensusFactory.CreateBlock(); block.Header.Nonce = RandomUtils.GetUInt32(); block.Header.HashPrevBlock = this.GetHash(); block.Header.BlockTime = now; var tx = block.AddTransaction(consensusFactory.CreateTransaction()); tx.Inputs.Add(scriptSig: new Script(Op.GetPushOp(RandomUtils.GetBytes(30)))); tx.Outputs.Add(new TxOut() { Value = value, ScriptPubKey = PayToPubkeyHashTemplate.Instance.GenerateScriptPubKey(pubkey) }); return(block); }
public static void ReadWrite(this IBitcoinSerializable serializable, byte[] bytes, ConsensusFactory consensusFactory, uint?version = null) { ReadWrite(serializable, new MemoryStream(bytes), false, consensusFactory, version); }
public ConcurrentChain(byte[] bytes, ConsensusFactory consensusFactory, ChainSerializationFormat format) { Load(bytes, consensusFactory, format); }
public ConcurrentChain(byte[] bytes, ConsensusFactory consensusFactory) : this(bytes, consensusFactory, null) { }
public void Load(byte[] chain, ConsensusFactory consensusFactory) { Load(chain, consensusFactory, null); }
public void Load(byte[] chain, ConsensusFactory consensusFactory, ChainSerializationFormat format) { Load(new MemoryStream(chain), consensusFactory, format); }
public static Block CreateBlock(ConsensusFactory consensusFactory) { return(consensusFactory.CreateBlock()); }
public static void ReadWrite(this IBitcoinSerializable serializable, Stream stream, bool serializing, ConsensusFactory consensusFactory, uint?version = null) { BitcoinStream s = new BitcoinStream(stream, serializing) { ProtocolVersion = version }; if (consensusFactory != null) { s.ConsensusFactory = consensusFactory; } serializable.ReadWrite(s); }