Skip to content

Instantly share code, notes, and snippets.

@Jbekker
Last active July 5, 2022 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jbekker/ab8d8c6d02243a44a1e8c5f2dd607eae to your computer and use it in GitHub Desktop.
Save Jbekker/ab8d8c6d02243a44a1e8c5f2dd607eae to your computer and use it in GitHub Desktop.
#include "hookapi.h"
// TODO: Parameterize this so that you can specify the minimum allowed payment when deploying the hook.
const int64_t MINIMUM_AMOUNT_IN_DROPS = 100000; // 0.1 XRP
int64_t hook(uint32_t reserved ) {
GUARD(1); // every hook needs to import guard function and use it at least once
unsigned char amount_buffer[48];
int64_t amount_len = otxn_field(SBUF(amount_buffer), sfAmount);
// Any IOU payments will be accepted.
if (amount_len != 8)
accept(SBUF("Minimum_payment: IOUs are always allowed. Passing"), 0);
if (AMOUNT_TO_DROPS(amount_buffer) < MINIMUM_AMOUNT_IN_DROPS)
rollback(SBUF("Minimum_payment: Rejecting incoming XRP transaction, amount is below the specified minimal amount."), 5);
// If we're here, it's an valid transaction.
accept(SBUF("Minimum_payment: Valid payment. Passing"), 0);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment