Discussions
hooks languages?
"typically hooks are written in c"
I see all the examples and docs are in c. You prefer people to write in c? How do the examples compare/port over to other languages for hooks?
Posted by Hooks Question 3 days ago
Is there a code example to how to blackist ongoing tx address ?
1. I would like to know If I can block the incomming transaction addr is a blacklisted one
2. How can I know if a particular addr already made a sucessful tx with me.
Do I need to create a list , and how do I map and filter to them.
Note : I am not from the C background, mostly javascript and java. please help
Thank you.
Posted by watchDhog69 7 months ago
About "inline functions"
Hi
there is a question that has been in my mind for some time.
https://github.com/XRPL-Labs/xrpld-hooks/discussions/57
I ask the question again here, because I think it is an important one.
about "C inline functions" and the compiler option to force compile "always inline".
There is a possibility to enable this functionality?
Inline functions, I know, can be an alternative to the awful macros.
recursion is not possible with inline functions
and the benefit could be a programming style very similar to javascript and solidity.
thank you
Posted by f1f47a23 7 months ago
How to get all out going payments of a specific address
platform: "nodejs"
lib: "xrpl - ^2.5.0"
I'm trying to print out all transactions made by a specific account but its showing 2 transactions even though I only sent one. I understand some what that there is in essence outgoing and incoming transactions.
- from my source code what changes are needed to filter the sending account to show all outgoing transactions?
- why am I seeing 2 transactions?
- do i just need to filter by account? but then how do I differentiate the direction?
thanks,
sedo:
1) connect
2) create and fund sender and recipient
3) submitAndWait for transaction
4) request "account_tx"
full code:
`
const TESTNET_SERVER = 'wss://s.altnet.rippletest.net:51233'
// Define the network client
const client = new xrpl.Client(TESTNET_SERVER)
await client.connect()
// Derive a wallet from a bip39 Mnemonic - cold address - issuer
const senderWallet = xrpl.Wallet.fromMnemonic(getMnemonic())
await client.fundWallet(senderWallet)
// Derive a wallet from a bip39 Mnemonic - hot address - regular user's address
const recipientWallet = xrpl.Wallet.fromMnemonic(getMnemonic())
await client.fundWallet(recipientWallet)
var result = await transfer(client, senderWallet, recipientWallet)
// Check transaction results -------------------------------------------------
console.log("Transaction result:", result)
const tx_response = await client.request({
"command": "account_tx",
"account": senderWallet.address,
"validated": true
})
console.log(tx_response)
console.log( '*************************' )
console.log(tx_response.result.transactions)
// Disconnect when done (If you omit this, Node.js won't end the process)
client.disconnect()
`
output:
`
Transaction result: tesSUCCESS
{
id: 21,
result: {
account: 'rD9zvrG9G62UtzZtaUteaENTV7SgEdJqof',
ledger_index_max: 32544985,
ledger_index_min: 32476837,
limit: 0,
transactions: [ [Object], [Object] ],
validated: true
},
type: 'response'
}
*************************
[
{
meta: {
AffectedNodes: [Array],
TransactionIndex: 3,
TransactionResult: 'tesSUCCESS',
delivered_amount: '1000000'
},
tx: {
Account: 'rfTxspF3GiroFd3Hfay2Th92kfVthDPenP',
Amount: '1000000',
Destination: 'rD9zvrG9G62UtzZtaUteaENTV7SgEdJqof',
Fee: '12',
Flags: 0,
LastLedgerSequence: 32545003,
Sequence: 32544980,
SigningPubKey: '03315108259B667674B193C51691F16901BE10783BD612A8343FED94EB56FBFC25',
TransactionType: 'Payment',
TxnSignature: '304402207D8263B69C2C08AF06A1AD84C14055655DA0DFF2106B91AE3C33CD70365ABFE3022000E71A788AD60A451CC7D6E438CF029AA474087632627C07F59E0CB735DFD7ED',
date: 720772413,
hash: 'CF091E1871A1972EC9FC8252E4AD9D3C40893F2CA3B3B821B3D56D2E77B1688C',
inLedger: 32544985,
ledger_index: 32544985
},
validated: true
},
{
meta: {
AffectedNodes: [Array],
TransactionIndex: 1,
TransactionResult: 'tesSUCCESS',
delivered_amount: '1000000000'
},
tx: {
Account: 'rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe',
Amount: '1000000000',
Destination: 'rD9zvrG9G62UtzZtaUteaENTV7SgEdJqof',
Fee: '12',
Flags: 2147483648,
LastLedgerSequence: 32544986,
Sequence: 4414467,
SigningPubKey: '02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC',
TransactionType: 'Payment',
TxnSignature: '304402203EC0CEF2BEDDBEFA3093E5F9E951A55C514A780C06AD3A560BCEB1E9535E2F2602207E807454B35CC278D4437285DD457A0743145E5DE0702617BF5AA64CEDA0FED5',
date: 720772411,
hash: 'B36F8491C4235EF137E243DFF8A3273BE3FED544217B346D51DEF4AA7AF791C6',
inLedger: 32544983,
ledger_index: 32544983
},
validated: true
}
]
`
Posted by [email protected] 7 months ago
Prevent deleting a hook
Is there anyway to prevent a hook from being deleted?
my thought process:
I don't want a user to be able to remove the hook...
so if an account is compromised and the seed/keys land up in the hands of a malicious user. that malicious user should not be able to remove the hook...
can a hook be programmed to check some state before being removed/overwritten and act upon that state?
is there any sort of OnRemove(); BeforeRemove();
very broad question so im open round about ways.
thanks,
Posted by muhammad ahmod 7 months ago
EmitGeneration field value looks wrong
Hi
In 3 chained transactions test,
where the 1st ordinary payment txn triggers the 2nd emitted,
and the 2nd triggers the 3rd,
I see that the 2 emitted transactions have
the EmitGeneration field = 2(the 2nd) and 4(the 3rd)
1st txn
https://hooks-testnet-v2-explorer.xrpl-labs.com/tx/D8868FF6761DACA9A704A98D9CD3225BC82E914B507364ECA4D273F919C4712B
2nd emitted txn triggered by the 1st
https://hooks-testnet-v2-explorer.xrpl-labs.com/tx/47CDEC6EBA4AAEA9E640643C4A6ACAFF09E63DBE093138F10847EA407509ACE7
3rd emitted txn triggered by the 2nd
https://hooks-testnet-v2-explorer.xrpl-labs.com/tx/AF372886C4A3297A0137B43D6C3C823180A69779F060228D27C33F5DE015906F
But, according to the documentation, I should see values of 1 and 2
https://xrpl-hooks.readme.io/docs/emitted-transactions#emitdetails-block
fields are filled by etxn_details()
etxn_reserve always = 1
EmitBurden always = "1" seems correct
Posted by f1f47a23 8 months ago
SetHook with field HookHash "xrpl-hooks" issue?
Hi.
below seems to be an issue about "hookDefinition sharing" feature as documented here:
https://xrpl-hooks.readme.io/docs/sethook-transaction#install-operation
https://xrpl-hooks.readme.io/docs/reference-counting
So
To make all easier, I wasm compiled the tiny "starter.c" with no parameters.
1) using HookBuilder (or my environment) I defined a "SetHook" transaction to account (A) as below
txn hash: "9BA7315CDE3D50A0DDC88EB4A3E41A0E2FA886A8B11061AA16D4D531E183E4FF"
...omiss....
Fee: "10000000",
Flags: 0,
Hooks: [
{
Hook: {
CreateCode: "0061736D01000000011C0460057F7F7F7F7F017E60037F7F7E017E60027F7F017F60017F017E02230303656E76057472616365000003656E7606616363657074000103656E76025F670002030201030503010002062B077F0141C088040B7F004180080B7F0041BA080B7F004180080B7F0041C088040B7F0041000B7F0041010B07080104686F6F6B00030AC4800001C0800001017F230041106B220124002001200036020C419C08411D418008411C410010001A410022002000420010011A41012200200010021A200141106A240042000B0B4001004180080B39537461727465722E633A2043616C6C65642C205061706572696E6F0022537461727465722E633A2043616C6C65642C205061706572696E6F22",
Flags: 1,
HookApiVersion: 0,
HookNamespace: "A0800997EB2FED3F3B33D86DE629F548449450ECF40530106224132D616061BE",
HookOn: "3FF5BE"
}
}
]
...omiss....
2) using only my environment I defined a second "SetHook" transaction to account (B) as below,
just by referring the same hook by its hash
txn hash: N.D.
...omiss....
Fee: "10000000",
Flags: 0,
Hooks: [
{
Hook: {
HookHash: "A8DDA006B1DA5008CE6FC7C8E6C9A93F08CEA24DA1F2AD8ED03274E3FFB93D59",
Flags: 1,
HookApiVersion: 0,
HookNamespace: "A0800997EB2FED3F3B33D86DE629F548449450ECF40530106224132D616061BE",
HookOn: "3FF5BE"
}
}
]
...omiss....
I simply am using something like this js call
const txnResponse = await xclient.submitAndWait(txnBlob);
and "npm update" to all the latest packages including:
"dependencies": {
"xrpl-hooks": "^2.2.1"
}
I don't know much more about, but I suspect the problem is in the client-side "xrpl-hooks".
It seems it simply doesn't handle a transaction with field "HookHash" and without "CreateCode"
Posted by f1f47a23 8 months ago
hook namespace bug
Hi
below might be the same bug on namespaces seen yesterday
I set 2 peggy.c hooks with 2 different namespaces.
when I tried to reset both namespaces I had the results below
/////////////////////////////////////////////////////
step 1) RESET namespace 2F8A0C01F668BCA73EC51C0D8DA77D419582347055E99D5D04FCF73B47BEBCED
Result Step 1)
Account info
{
Account: "rnxdRkDeLxVKeRyxsUSpNJBqoDQXUHff7m",
Balance: "15064638417",
Flags: 0,
HookNamespaces: [
"0000000000000000000000000000000000000000000000000000000000000000",
"64254733CF035704661D093F45812F0E22020B7034EBD6565DAA3834420B382A"
]
HookStateCount: 1,
LedgerEntryType: "AccountRoot",
OwnerCount: 2,
PreviousTxnID: "4C78C3A343D0F2DD9FC4D6DF240321863B6AA7619463C1C2F1035E8B004CA81F",
PreviousTxnLgrSeq: 5500013,
Sequence: 4132842,
index: "14AEF56D0C89E1DE65F4B84983800C1DAE70310691037986D0BBE145796D70E1"
}
---------------------
step 2) RESET namespace 64254733CF035704661D093F45812F0E22020B7034EBD6565DAA3834420B382A
Result Step 2)
Account info
{
Account: "rnxdRkDeLxVKeRyxsUSpNJBqoDQXUHff7m",
Balance: "15054638417",
Flags: 0,
HookNamespaces: [
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000000"
]
HookStateCount: 0,
LedgerEntryType: "AccountRoot",
OwnerCount: 2,
PreviousTxnID: "CF4D0DD1A4F1CED0E56918BE9BFED41AD767C8692E764B41D42B13C0EBD6F1A4",
PreviousTxnLgrSeq: 5500189,
Sequence: 4132843,
index: "14AEF56D0C89E1DE65F4B84983800C1DAE70310691037986D0BBE145796D70E1"
}
Posted by f1f47a23 9 months ago
RESET hook namespace data
Hi while testing peggy example I tried to RESET the hook namespace data
https://xrpl-hooks.readme.io/docs/sethook-transaction#namespace-reset
Is there a quick way to do this task inside the online hook ide tool filled with examples I am testing currently
or maybe do I have to create a small project outside here that sends the right "SetHook" txn using Richard's xrpl-hooks lib
below is the code I wrote online but it doesn't work, probably for "xrpl-accountlib" not supporting hooks.
thank you.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// reset-nshook.js
// RESET HOOK NAMESPACE
// from modified trust-user.js
import lib from "https://esm.sh/xrpl-accountlib?bundle";
import { XrplClient } from "https://esm.sh/xrpl-client?bundle";
import keypairs from "https://esm.sh/ripple-keypairs?bundle";
/**
* @input {Account.secret} hook_secret Hook Account
*/
const { hook_secret} = process.env
const hook_keypair = lib.derive.familySeed(hook_secret);
const hook_account = keypairs.deriveAddress(hook_keypair.keypair.publicKey);
const client = new XrplClient('wss://hooks-testnet-v2.xrpl-labs.com');
const main = async () => {
const { account_data } = await client.send({ command: 'account_info', 'account': hook_account });
if (!account_data) {
console.log('Account not found.');
client.close();
return;
}
const tx = {
TransactionType: "SetHook",
Account: hook_account,
Fee: "2000000",
Sequence: account_data.Sequence,
//Flags: 262144,
Hooks:
[
{
Hook: {
// absent CreateCode: fs.readFileSync('accept.wasm').toString('hex').toUpperCase(),
// absent HookOn: '0000000000000000',
HookNamespace: "2F8A0C01F668BCA73EC51C0D8DA77D419582347055E99D5D04FCF73B47BEBCED",
// absent HookApiVersion: 0,
Flags:2 // hsfOVERRIDE: 1, hsfNSDELETE: 2,
}
}
]
};
//!!!! lib.sign() doesn't handle "SetHook"
const { signedTransaction } = lib.sign(tx, hook_keypair);
const submit = await client.send({ command: 'submit', 'tx_blob': signedTransaction });
console.log(submit);
console.log('Shutting down...');
client.close();
};
main();
Posted by f1f47a23 9 months ago
Tx Sucess in Callback?
Hi,
I'm trying to find out whether an emitted tx was successful or not(from within the cbak function).
Since I have neither access to "engine_result" nor "meta" data in the cbak function, the emitted Tx might not be sufficiently financed (tecPATH_PARTIAL) and the cbak function would still be called with "0".
Is there a way to make sure the emitted tx went through properly?
Best greets Chris
Posted by Chris 10 months ago