Skip to main content

trustline_id

Function trustline_id 

Source
pub fn trustline_id(
    account1: &AccountID,
    account2: &AccountID,
    currency: &Currency,
) -> Result<LedgerEntryIdBytes>
Expand description

Generates a trustline ledger entry ID for a given pair of accounts and currency code.

A trustline ledger entry ID is used to reference trustline entries in the XRP Ledger.

§Arguments

  • account - The first AccountID in the trustline relationship
  • account2 - The second AccountID in the trustline relationship
  • currency - The Currency for the trustline

§Returns

  • Result<LedgerEntryIdBytes> - On success, returns a 32-byte trustline ledger entry ID. On failure, returns an Error with the corresponding error code.

§Safety

This function makes unsafe FFI calls to the host environment through the host::trustline_id function.

§Example

use xrpl_common_stdlib::types::account_id::AccountID;
use xrpl_common_stdlib::types::currency::Currency;
use xrpl_common_stdlib::ledger_entry_ids::trustline_id;
use xrpl_common_stdlib::host::trace::{ trace_hex, trace_num };
fn main() -> Result<(), Box<dyn std::error::Error>> {
 let account1: AccountID =
   AccountID::from(*b"\xd5\xb9\x84VP\x9f \xb5'\x9d\x1eJ.\xe8\xb2\xaa\x82\xaec\xe3");
 let account2: AccountID =
   AccountID::from(*b"\xd5\xb9\x84VP\x9f \xb5'\x9d\x1eJ.\xe8\xb2\xaa\x82\xaec\xe3");
 let currency = b"RLUSD\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; // RLUSD currency code
 let currency: Currency = Currency::from(*currency);
 match trustline_id(&account1, &account2, &currency) {
   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(())
}