<pre>
  PIP: 8
  Title: Hook(s) to start external programs
  Type: Backend
  Impact: None
  Author: Preben Björn Biermann Madsen (nightraven) <i>&lt;natugle@gmail.com&gt;</i>
  Comments-URI: <a href="https://github.com/PascalCoin/PascalCoin/issues/48">https://github.com/PascalCoin/PascalCoin/issues/48</a>
  Status: Draft
  Created: 2017-08-12
</pre>

## Summary

A hook to watch the paylod and invoke external functions when certain events occur.
 
## Motivation

Hook(s) will make it easy for developers and users to implement new functions without modifying the original wallet.

## Specification

The payload opens up for an easy way to implement new functions to the wallet. It is already possible to watch the payload through the JSON RPC API, but a hook would make it more easy for developers and users to interact with the PascalCoin Wallet.

The hook should watch an account for incomming payloads and invoke an external program when a marker is received. Account, external program and marker should be defined by the user at a setup page or in an ini-file. The payload and other necessary data should continuously be transferred via TCP or UPC to the external program.

There is a difficulty for this hook to work namely the encoding facility of the payload. This should be addressed somehow or there should be a secondary uncode payload or at least an uncoded field for the marker.

In the future such a hook could be combined with some scripting and / or call back functions.


**Example of possible use:**

The [Whitepaper][1] describes the possibilities for layer 2 applications. Such applications could be invoked by a hook. And a layer 2 need a protocol like the The Omni Layer Protocol. Something like the following:

- Marker -- 32-bit unsigned integer, 4 bytes
- Protocol version -- 16-bit unsigned integer, 2 bytes
- Transaction type -- 16-bit unsigned integer, 2 bytes
- Currency ID -- 32-bit unsigned integer, 4 bytes
- Amount to pay -- 64-bit signed integer, 8 bytes 
- Currency ID desired -- 32-bit unsigned integer, 4 bytes
- Amount desired -- 64-bit signed integer, 8 bytes 
- Payment window -- 8-bit unsigned integer, 1 byte (blocks)
- Transaction fee -- 32-bit signed integer, 4 bytes
- Action -- 8-bit unsigned integer, 1 byte (offer, accept, reject)

38 bytes in all or 52 bytes Base58 encoded or 76 bytes if Base 16 encoded.

The hook reacts to the marker and transfers the handling to the external program.
 
## Rationale

TO-BE-EDITED
Discussion why was the specification was chosen over alternate designs. Evidence supporting the specification should be provided here, as well as community concerns and consensus.

## Backwards Compatibility

PIP is fully backwards compatible.

## Reference Implementation

None provided.
 
## Links

1. [PascalCoin White Paper V2][1]

[1]: https://github.com/PascalCoin/PascalCoin/blob/master/PascalCoinWhitePaperV2.pdf