pub fn paychan_id(
account: &AccountID,
destination: &AccountID,
seq: u32,
) -> Result<LedgerEntryIdBytes>Expand description
Generates a payment channel ledger entry ID for a given owner and sequence in the XRP Ledger.
Payment channel ledger entry IDs are used to reference payment channel entries in the XRP Ledger’s state data.
This function uses the generic create_id_from_host_call helper to manage the FFI interaction.
§Arguments
account- Reference to anAccountIDrepresenting the payment channel sender’s accountdestination- Reference to anAccountIDrepresenting the payment channel’s destinationseq- The account sequence associated with the payment channel entry
§Returns
Result<LedgerEntryIdBytes>- On success, returns a 32-byte payment channel ledger entry ID. On failure, returns anErrorwith the corresponding error code.
§Safety
This function makes unsafe FFI calls to the host environment through
the host::paychan_id function, though the unsafe code is contained
within the closure passed to create_id_from_host_call.
§Example
use xrpl_common_stdlib::types::account_id::AccountID;
use xrpl_common_stdlib::ledger_entry_ids::paychan_id;
use xrpl_common_stdlib::host::trace::{ trace_hex, trace_num };
fn main() -> Result<(), Box<dyn std::error::Error>> {
let account: AccountID =
AccountID::from(*b"\xd5\xb9\x84VP\x9f \xb5'\x9d\x1eJ.\xe8\xb2\xaa\x82\xaec\xe3");
let destination: AccountID =
AccountID::from(*b"\xd5\xb9\x84VP\x9f \xb5'\x9d\x1eJ.\xe8\xb2\xaa\x82\xaec\xe3");
let sequence = 12345;
match paychan_id(&account, &destination, sequence) {
xrpl_common_stdlib::host::Result::Ok(id) => {
trace_hex("Generated ledger entry ID", &id);
}
xrpl_common_stdlib::host::Result::Err(e) => {
trace_num("Error assembling ledger entry ID", e.code() as i64);
}
}
Ok(())
}