diff --git a/NBitcoin/Key.cs b/NBitcoin/Key.cs index d1e6553e3f..945ff22da3 100644 --- a/NBitcoin/Key.cs +++ b/NBitcoin/Key.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using NBitcoin.DataEncoders; +using System.IO; #if !HAS_SPAN using NBitcoin.BouncyCastle.Math; #endif @@ -154,7 +155,7 @@ public SchnorrSignature SignSchnorr(uint256 hash) { AssertNotDiposed(); #if HAS_SPAN - Span h = stackalloc byte[32]; + Span h = stackalloc byte[KEY_SIZE]; hash.ToBytes(h); return new SchnorrSignature(_ECKey.SignSchnorr(h)); #else @@ -407,6 +408,18 @@ public BitcoinSecret GetWif(Network network) return new BitcoinSecret(this, network); } + public byte[] GetSeedBytes() + { + AssertNotDiposed(); + byte[] bytes = Enumerable.Repeat((byte)0x00, KEY_SIZE).ToArray(); + using (var bytesStream = new MemoryStream(bytes)) + { + var stream = new BitcoinStream(bytesStream, true); + ReadWrite(stream); + } + return bytes; + } + public BitcoinEncryptedSecretNoEC GetEncryptedBitcoinSecret(string password, Network network) { AssertNotDiposed();