NBitcoin throws InvalidOperationException with the message: “Mac HMACSHA256 not recognised.”

0 votes

I got the message when I try to sign a transaction:

Transaction payment = new Transaction();
BitcoinSecret PaymentSecret = new BitcoinSecret("1sXCvdpXz...UqkXW9mvT");
...
payment.Sign(Container.PaymentSecret, false);

I dig into the opensource NBitcoin API and figured out these lines give me the error message. What can I do? (https://github.com/NicolasDorier/NBitcoin/blob/master/NBitcoin/Crypto/DeterministicECDSA.cs)

try
{
    hmac = MacUtilities.GetMac(macName);
}
catch(SecurityUtilityException nsae)
{
    throw new InvalidOperationException(nsae.Message, nsae);
}
Aug 27, 2018 in Blockchain by slayer
• 29,240 points
34 views

1 answer to this question.

0 votes

If someone would like to figure out what is happening exactly, here's a code snippet that'll cause the bug:

    string mechanism = "HMACSHA256";
    if (mechanism.StartsWith("HMAC"))
    {
        Console.WriteLine("good");
    }
    else
    {
        Console.WriteLine("bad");
    }
    Console.ReadLine();

answered Aug 27, 2018 by digger
• 26,600 points

Related Questions In Blockchain

0 votes
1 answer

Is it that new bitcoins gets created with the every block mined??

Bitcoin mining means validation of a block ...READ MORE

answered Apr 20, 2018 in Blockchain by Perry
• 17,090 points
45 views
0 votes
1 answer

Account not listed in the Deploy Contract screen?

You need to get an initial allocated ...READ MORE

answered Jun 4, 2018 in Blockchain by Perry
• 17,090 points
29 views
0 votes
1 answer

Not Able to register a user with Hyperledger-Fabric v1.1 preview

The error: "Certificate not found with AKI 'e729224e8b3f31784c8a93c5b8ef6f4c1c91d9e6e577c45c33163609fe40011' ...READ MORE

answered Jun 16, 2018 in Blockchain by charlie_brown
• 7,720 points
456 views
0 votes
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by ariaholic
• 7,340 points
103 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,810 points
188 views
0 votes
1 answer
0 votes
1 answer

Not receiving any data from the BitStamp API.

I saw a code online that was ...READ MORE

answered Aug 21, 2018 in Blockchain by digger
• 26,600 points
112 views