Skip to content

Commit

Permalink
AlertMessage: Remove alert messages.
Browse files Browse the repository at this point in the history
The alert message facility has been removed from the Bitcoin protocol due to its centralized nature.
  • Loading branch information
Andreas Schildbach authored and ripcurlx committed Aug 17, 2021
1 parent 46cdd7d commit 2d0552b
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 370 deletions.
254 changes: 0 additions & 254 deletions core/src/main/java/org/bitcoinj/core/AlertMessage.java

This file was deleted.

11 changes: 0 additions & 11 deletions core/src/main/java/org/bitcoinj/core/BitcoinSerializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,6 @@ private Message makeMessage(String command, int length, byte[] payloadBytes, byt
return new VersionAck(params, payloadBytes);
} else if (command.equals("headers")) {
return new HeadersMessage(params, payloadBytes);
} else if (command.equals("alert")) {
return makeAlertMessage(payloadBytes);
} else if (command.equals("filterload")) {
return makeBloomFilter(payloadBytes);
} else if (command.equals("notfound")) {
Expand Down Expand Up @@ -254,15 +252,6 @@ public AddressMessage makeAddressMessage(byte[] payloadBytes, int length) throws
return new AddressMessage(params, payloadBytes, this, length);
}

/**
* Make an alert message from the payload. Extension point for alternative
* serialization format support.
*/
@Override
public Message makeAlertMessage(byte[] payloadBytes) throws ProtocolException {
return new AlertMessage(params, payloadBytes);
}

/**
* Make a block from the payload. Extension point for alternative
* serialization format support.
Expand Down
5 changes: 0 additions & 5 deletions core/src/main/java/org/bitcoinj/core/DummySerializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ public AddressMessage makeAddressMessage(byte[] payloadBytes, int length) throws
throw new UnsupportedOperationException(DEFAULT_EXCEPTION_MESSAGE);
}

@Override
public Message makeAlertMessage(byte[] payloadBytes) throws UnsupportedOperationException {
throw new UnsupportedOperationException(DEFAULT_EXCEPTION_MESSAGE);
}

@Override
public Block makeBlock(byte[] payloadBytes, int offset, int length) throws UnsupportedOperationException {
throw new UnsupportedOperationException(DEFAULT_EXCEPTION_MESSAGE);
Expand Down
7 changes: 0 additions & 7 deletions core/src/main/java/org/bitcoinj/core/MessageSerializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@ public abstract class MessageSerializer {
*/
public abstract AddressMessage makeAddressMessage(byte[] payloadBytes, int length) throws ProtocolException, UnsupportedOperationException;

/**
* Make an alert message from the payload. Extension point for alternative
* serialization format support.
*/
public abstract Message makeAlertMessage(byte[] payloadBytes) throws ProtocolException, UnsupportedOperationException;


/**
* Make a block from the payload, using an offset of zero and the payload
* length as block length.
Expand Down
15 changes: 0 additions & 15 deletions core/src/main/java/org/bitcoinj/core/NetworkParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@
* them, you are encouraged to call the static get() methods on each specific params class directly.</p>
*/
public abstract class NetworkParameters {
/**
* The alert signing key originally owned by Satoshi, and now passed on to Gavin along with a few others.
*/
public static final byte[] SATOSHI_KEY = Utils.HEX.decode("04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");

/** The string returned by getId() for the main, production network where people trade things. */
public static final String ID_MAINNET = "org.bitcoin.production";
/** The string returned by getId() for the testnet. */
Expand Down Expand Up @@ -80,7 +75,6 @@ public abstract class NetworkParameters {
protected String segwitAddressHrp;
protected int interval;
protected int targetTimespan;
protected byte[] alertSigningKey;
protected int bip32HeaderP2PKHpub;
protected int bip32HeaderP2PKHpriv;
protected int bip32HeaderP2WPKHpub;
Expand Down Expand Up @@ -110,7 +104,6 @@ public abstract class NetworkParameters {
protected volatile transient MessageSerializer defaultSerializer = null;

protected NetworkParameters() {
alertSigningKey = SATOSHI_KEY;
genesisBlock = createGenesis(this);
}

Expand Down Expand Up @@ -334,14 +327,6 @@ public BigInteger getMaxTarget() {
return maxTarget;
}

/**
* The key used to sign {@link AlertMessage}s. You can use {@link ECKey#verify(byte[], byte[], byte[])} to verify
* signatures using it.
*/
public byte[] getAlertSigningKey() {
return alertSigningKey;
}

/** Returns the 4 byte header for BIP32 wallet P2PKH - public key part. */
public int getBip32HeaderP2PKHpub() {
return bip32HeaderP2PKHpub;
Expand Down
18 changes: 0 additions & 18 deletions core/src/main/java/org/bitcoinj/core/Peer.java
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,6 @@ protected void processMessage(Message m) throws Exception {
processAddressMessage((AddressMessage) m);
} else if (m instanceof HeadersMessage) {
processHeaders((HeadersMessage) m);
} else if (m instanceof AlertMessage) {
processAlert((AlertMessage) m);
} else if (m instanceof VersionMessage) {
processVersionMessage((VersionMessage) m);
} else if (m instanceof VersionAck) {
Expand Down Expand Up @@ -627,22 +625,6 @@ protected void processNotFoundMessage(NotFoundMessage m) {
}
}

protected void processAlert(AlertMessage m) {
try {
if (log.isDebugEnabled()) {
if (m.isSignatureValid())
log.debug("Received alert from peer {}: {}", this, m.getStatusBar());
else
log.debug("Received alert with invalid signature from peer {}: {}", this, m.getStatusBar());
}
} catch (Throwable t) {
// Signature checking can FAIL on Android platforms before Gingerbread apparently due to bugs in their
// BigInteger implementations! See https://github.com/bitcoinj/bitcoinj/issues/526 for discussion. As
// alerts are just optional and not that useful, we just swallow the error here.
log.error("Failed to check signature: bug in platform libraries?", t);
}
}

protected void processHeaders(HeadersMessage m) throws ProtocolException {
// Runs in network loop thread for this peer.
//
Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/org/bitcoinj/params/TestNet3Params.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public TestNet3Params() {
subsidyDecreaseBlockCount = 210000;
String genesisHash = genesisBlock.getHashAsString();
checkState(genesisHash.equals("000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"));
alertSigningKey = Utils.HEX.decode("04302390343f91cc401d56d68b123028bf52e5fca1939df127f63c6467cdf9c8e2c14b61104cf817d0b780da337893ecc4aaff1309e536162dabbdb45200ca2b0a");

dnsSeeds = new String[] {
"testnet-seed.bitcoin.jonasschnelli.ch", // Jonas Schnelli
Expand Down
Loading

0 comments on commit 2d0552b

Please sign in to comment.