c# - NBitcoin throws InvalidOperationException with the message: "Mac HMACSHA256 not recognised." -
i got message when try sign transaction:
transaction payment = new transaction(); bitcoinsecret paymentsecret = new bitcoinsecret("1sxcvdpxz...uqkxw9mvt"); ... payment.sign(container.paymentsecret, false);
i dig opensource nbitcoin api , figured out these lines give me error message. can 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); }
if figure out happening exactly, here's code snippet that'll cause bug:
string mechanism = "hmacsha256"; if (mechanism.startswith("hmac")) { console.writeline("good"); } else { console.writeline("bad"); } console.readline();
if set mechanism = "hmac-sha256", bug won't happen. if use mechanism.startswith("hmac",stringcomparison.invariantculture), bug won't happen.
i've fixed bug in github , created pull request nbitcoin api, won't happen others in future.
Comments
Post a Comment