Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: fbueller on October 28, 2013, 05:00:48 PM



Title: Sending alerts in the testnet-in-a-box
Post by: fbueller on October 28, 2013, 05:00:48 PM
I know the testnet gets periodic alerts but I wanted to do it myself to check how my software will react. Is there any scripts which will do this?

I'm sure others have a similar interest.. I'm also just curious about how to do this, I know for the main bitcoin network Satoshi, theymos and Gavin have they key, but how do we do this using our own testnet?


Title: Re: Sending alerts in the testnet-in-a-box
Post by: gatra on October 28, 2013, 06:25:21 PM
I found no code for generating alerts. In alert_tests.cpp, I found this:

// (SignAndSave code not shown, alert signing key is secret)

but I think that code for SignAndSave should be shown: they could share the code without sharing the private key, otherwise it feels like security by obscurity.
Currently we have to make our own code to generate alerts and test them. If we change the keys then the tests no longer work and can't be made to work without extra coding.


Title: Re: Sending alerts in the testnet-in-a-box
Post by: fbueller on October 29, 2013, 08:49:47 AM
Have you been successful? I'd be wary about altering the pubkey (after generating a private one) and recompiling. Obviously a testing environment should be as close to the real thing as possible. It working because of a fluky choice in key, would be a mess. We shouldn't have to modify code to get this working. Substituting a key I could live with, but right now excluding it feels wrong.

It should be included and adequately documented. Developers are given access to more features on a testnet, signing and sending alerts should be one of those things. Not just being told "you're not one of these 3 people, so youlll never have to look at this code" by omission.

If not the main testnet, it may as well be available for our own testnet in a box.


Title: Re: Sending alerts in the testnet-in-a-box
Post by: deepceleron on October 29, 2013, 12:53:41 PM
I don't know that it's ever been done, but you could ask for a testnet alert to be set by a core dev if you are a client developer that wants to implement user presentation properly.


Title: Re: Sending alerts in the testnet-in-a-box
Post by: gatra on October 29, 2013, 05:28:42 PM
I believe it's ok that the keys are kept secret, it would be a mess otherwise.
If you need to test, I can think of two options: comment out the validation (make CAlert::CheckSignature return always true) or use your own keys.
If you create new keys using CKey::MakeNewKey and then IsValid() there should be no such thing as "fluky keys"
But I guess that either way you'll have to code you own alert sending functions.
Asking a dev to generate an alert for you is a good idea but you can do it only once or twice, you can't rely on that for testing/debugging.
I'm working on an alt-coin so I generated new keys but I haven't written the code to actually test them yet... it shouldn't be hard: just create a CAlert manually and then make the client relay it to the other nodes (adding it to mapAlerts).


Title: Re: Sending alerts in the testnet-in-a-box
Post by: gatra on October 31, 2014, 07:01:56 PM
These may help:

https://gist.github.com/laanwj/0e689cfa37b52bcbbb44 (https://gist.github.com/laanwj/0e689cfa37b52bcbbb44)

https://gist.github.com/gavinandresen/1481736 (https://gist.github.com/gavinandresen/1481736)

The first one worked for me.