Skip to main content

paychan_keylet

Function paychan_keylet 

Source
pub fn paychan_keylet(
    account: &AccountID,
    destination: &AccountID,
    seq: u32,
) -> Result<KeyletBytes>
Expand description

Generates a payment channel keylet for a given owner and sequence in the XRP Ledger.

Payment channel keylets are used to reference payment channel entries in the XRP Ledger’s state data. This function uses the generic create_keylet_from_host_call helper to manage the FFI interaction.

§Arguments

  • account - Reference to an AccountID representing the payment channel sender’s account
  • destination - Reference to an AccountID representing the payment channel’s destination
  • seq - The account sequence associated with the payment channel entry

§Returns

  • Result<KeyletBytes> - On success, returns a 32-byte payment channel keylet. On failure, returns an Error with the corresponding error code.

§Safety

This function makes unsafe FFI calls to the host environment through the host::paychan_keylet function, though the unsafe code is contained within the closure passed to create_keylet_from_host_call.

§Example

use xrpl_wasm_stdlib::core::types::account_id::AccountID;
use xrpl_wasm_stdlib::core::keylets::paychan_keylet;
use xrpl_wasm_stdlib::host::trace::{DataRepr, trace_data, 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_keylet(&account, &destination, sequence) {
    xrpl_wasm_stdlib::host::Result::Ok(keylet) => {
      let _ = trace_data("Generated keylet", &keylet, DataRepr::AsHex);
    }
    xrpl_wasm_stdlib::host::Result::Err(e) => {
      let _ = trace_num("Error assembling keylet", e.code() as i64);
    }
  }
  Ok(())
}