Skip to content

Instantly share code, notes, and snippets.

@muzam1l
Forked from xrplfgists/README.md
Last active December 7, 2022 09:47
Show Gist options
  • Save muzam1l/1f8109c80f504e6326db2735df2f0ad6 to your computer and use it in GitHub Desktop.
Save muzam1l/1f8109c80f504e6326db2735df2f0ad6 to your computer and use it in GitHub Desktop.

Starter

Starter is the simplest possible hook: it just accepts all transactions and logs that it is running.

to test:

  • in the develop pane, compile starter.c
  • in the deploy pane, deploy it to Alice account
  • set up payment transaction from Alice to Bob
  • run it and see in the debug stream 'Accept.c: Called.'

Modifying the tracing message and compiling with different optimizations are left as an exercise for the reader.

/**
* This hook just accepts any transaction coming through it
*/
#include "hookapi.h"
int64_t hook(uint32_t reserved ) {
TRACESTR("Accept.c: Called.");
accept (0,0,0);
_g(1,1); // every hook needs to import guard function and use it at least once
// unreachable
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment