Skip to content

Commit 43d248f

Browse files
committed
Key: add helper method GetSeedBytes
1 parent 252f052 commit 43d248f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

NBitcoin/Key.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Linq;
55
using System.Text;
66
using NBitcoin.DataEncoders;
7+
using System.IO;
78
#if !HAS_SPAN
89
using NBitcoin.BouncyCastle.Math;
910
#endif
@@ -407,6 +408,18 @@ public BitcoinSecret GetWif(Network network)
407408
return new BitcoinSecret(this, network);
408409
}
409410

411+
public byte[] GetSeedBytes()
412+
{
413+
AssertNotDiposed();
414+
byte[] bytes = Enumerable.Repeat((byte)0x00, KEY_SIZE).ToArray();
415+
using (var bytesStream = new MemoryStream(bytes))
416+
{
417+
var stream = new BitcoinStream(bytesStream, true);
418+
ReadWrite(stream);
419+
}
420+
return bytes;
421+
}
422+
410423
public BitcoinEncryptedSecretNoEC GetEncryptedBitcoinSecret(string password, Network network)
411424
{
412425
AssertNotDiposed();

0 commit comments

Comments
 (0)