Version: 0.13.7

Class: Trustline

"Trustline".Trustline

The Trustline class contains all relevant methods for retrieving, creating and editing trustlines. It is meant to be called via a TLNetwork instance like:

const tlNetwork = new TLNetwork(
//...
)
// Get trustlines
tlNetwork.trustline.getAll(
// ...
).then(
trustlines => console.log("Trustlines of loaded user:", trustlines)
)

Hierarchy#

  • Trustline

Methods#

buildTrustlineRequestInviteLink#

buildTrustlineRequestInviteLink(networkAddress: string, amounts: { creditlineGiven: string | number ; creditlineReceived: string | number ; interestRateGiven?: string | number ; interestRateReceived?: string | number }, options?: { [key:string]: string; customBase?: string }): Promise<string>

Defined in src/Trustline.ts:617

Builds an invite link for a trustline request in the format

<BASE_URL>/trustlinerequest/:networkAddress/:senderAddress/:creditlineGiven/:creditlineReceived/:interestRateGiven/:interestRateReceived[?:optionalParams]

Parameters:#

NameTypeDescription
networkAddressstringAddress of currency network.
amounts{ creditlineGiven: string | number ; creditlineReceived: string | number ; interestRateGiven?: string | number ; interestRateReceived?: string | number }Amounts to use for the trustline request.
options?{ [key:string]: string; customBase?: string }Additional options for link creation.

Returns: Promise<string>


confirm#

confirm(rawTx: RawTxObject): Promise<any>

Defined in src/Trustline.ts:295

Signs a raw transaction object as returned by prepareAccept or prepareUpdate and sends the signed transaction.

Parameters:#

NameTypeDescription
rawTxRawTxObjectRaw transaction object.

Returns: Promise<any>


get#

get(networkAddress: string, counterpartyAddress: string, options?: { decimalsOptions?: DecimalsOptions }): Promise<TrustlineObject>

Defined in src/Trustline.ts:354

Returns a trustline to a counterparty address in a specified currency network.

Parameters:#

NameTypeDefault valueDescription
networkAddressstring-Address of a currency network.
counterpartyAddressstring-Address of counterparty of trustline.
options{ decimalsOptions?: DecimalsOptions }{}-

Returns: Promise<TrustlineObject>


getAll#

getAll(networkAddress: string, options?: { decimalsOptions?: DecimalsOptions }): Promise<TrustlineObject[]>

Defined in src/Trustline.ts:327

Returns all trustlines of a loaded user in a currency network.

Parameters:#

NameTypeDefault valueDescription
networkAddressstring-Address of a currency network.
options{ decimalsOptions?: DecimalsOptions }{}Extra options for user, network or trustline.

Returns: Promise<TrustlineObject[]>


getAllOfUser#

getAllOfUser(): Promise<TrustlineObject[]>

Defined in src/Trustline.ts:302

Returns all trustlines of a loaded user in all currency networks.

Returns: Promise<TrustlineObject[]>


getClosePath#

getClosePath(networkAddress: string, senderAddress: string, counterpartyAddress: string, options?: PaymentOptions): Promise<ClosePathObject>

Defined in src/Trustline.ts:562

Returns a path for closing a trustline between sender and counterparty.

Parameters:#

NameTypeDefault valueDescription
networkAddressstring-Address of a currency network.
senderAddressstring-Address of sender.
counterpartyAddressstring-Address of counterparty of trustline.
optionsPaymentOptions{}Payment options. See PaymentOptions for more information.

Returns: Promise<ClosePathObject>

Relevant information for closing a trustline. See ClosePathObject.


getEvents#

getEvents(networkAddress: string, counterPartyAddress: string, filter?: EventFilterOptions): Promise<AnyNetworkTrustlineEvent[]>

Defined in src/Trustline.ts:450

Returns all events of a specific trustline in a currency network. These are BalanceUpdate, TrustlineUpdate, TrustlineUpdateRequest and TrustlineUpdateCancel

Parameters:#

NameTypeDefault valueDescription
networkAddressstring-Address of a currency network.
counterPartyAddressstring-Address of the counter party of the trustline.
filterEventFilterOptions{}Event filter object. See EventFilterOptions for more information.

Returns: Promise<AnyNetworkTrustlineEvent[]>


getRequests#

getRequests(networkAddress: string, filter?: EventFilterOptions): Promise<NetworkTrustlineUpdateEvent[]>

Defined in src/Trustline.ts:384

Returns trustline update requests of loaded user in a currency network.

Parameters:#

NameTypeDefault valueDescription
networkAddressstring-Address of a currency network.
filterEventFilterOptions{}Event filter object. See EventFilterOptions for more information.

Returns: Promise<NetworkTrustlineUpdateEvent[]>


getTrustlineBalanceUpdates#

getTrustlineBalanceUpdates(networkAddress: string, counterPartyAddress: string, filter?: EventFilterOptions): Promise<NetworkTrustlineBalanceUpdate[]>

Defined in src/Trustline.ts:432

Returns trustline balance updates of a specific trustline in a currency network. A balance update happens, because of interests or because of received, sent or mediated transfers.

Parameters:#

NameTypeDefault valueDescription
networkAddressstring-Address of a currency network.
counterPartyAddressstring-Address of the counter party of the trustline.
filterEventFilterOptions{}Event filter object. See EventFilterOptions for more information.

Returns: Promise<NetworkTrustlineBalanceUpdate[]>


getTrustlineUpdateCancels#

getTrustlineUpdateCancels(networkAddress: string, filter?: EventFilterOptions): Promise<NetworkTrustlineCancelEvent[]>

Defined in src/Trustline.ts:399

Returns trustline update cancels of loaded user in a currency network.

Parameters:#

NameTypeDefault valueDescription
networkAddressstring-Address of a currency network.
filterEventFilterOptions{}Event filter object. See EventFilterOptions for more information.

Returns: Promise<NetworkTrustlineCancelEvent[]>


getUpdates#

getUpdates(networkAddress: string, filter?: EventFilterOptions): Promise<NetworkTrustlineUpdateEvent[]>

Defined in src/Trustline.ts:415

Returns trustline updates of loaded user in a currency network. An update happens when a user accepts a trustline update request.

Parameters:#

NameTypeDefault valueDescription
networkAddressstring-Address of a currency network.
filterEventFilterOptions{}Event filter object. See EventFilterOptions for more information.

Returns: Promise<NetworkTrustlineUpdateEvent[]>


prepareAccept#

prepareAccept(networkAddress: string, initiatorAddress: string, creditlineGiven: number | string, creditlineReceived: number | string, options?: TrustlineUpdateOptions): Promise<TxObject>

Defined in src/Trustline.ts:235

Prepares a transaction object for accepting a trustline update request. Called by receiver of initial update request.

Parameters:#

NameTypeDefault valueDescription
networkAddressstring-Address of a currency network.
initiatorAddressstring-Address of user who initiated the trustline update request.
creditlineGivennumber | string-Proposed creditline limit given by receiver to initiator, i.e. 1.23 if network has to 2 decimals.
creditlineReceivednumber | string-Proposed creditline limit received by initiator from receiver, i.e. 1.23 if network has to 2 decimals.
optionsTrustlineUpdateOptions{}Options for creating a ethereum transaction. See type TrustlineUpdateOptions for more information.

Returns: Promise<TxObject>


prepareCancelTrustlineUpdate#

prepareCancelTrustlineUpdate(networkAddress: string, counterpartyAddress: string, options?: TxOptions): Promise<TxObject>

Defined in src/Trustline.ts:261

Prepares a transaction object for canceling / rejecting a trustline update request. Called by initiator of cancel.

Parameters:#

NameTypeDefault valueDescription
networkAddressstring-Address of a currency network.
counterpartyAddressstring-Address of counterparty to cancel / reject the trustline update with.
optionsTxOptions{}Options for creating the ethereum transaction. See TxOptions for more information.

Returns: Promise<TxObject>


prepareClose#

prepareClose(networkAddress: string, counterpartyAddress: string, options?: PaymentOptions): Promise<CloseTxObject>

Defined in src/Trustline.ts:484

Prepares an ethereum transaction object for closing a trustline.

Parameters:#

NameTypeDefault valueDescription
networkAddressstring-Address of a currency network.
counterpartyAddressstring-Address of counterparty to who the trustline should be settled.
optionsPaymentOptions{}Payment options. See PaymentOptions for more information.

Returns: Promise<CloseTxObject>

A transaction object for closing a trustline. See CloseTxObject for more information.


prepareUpdate#

prepareUpdate(networkAddress: string, counterpartyAddress: string, creditlineGiven: number | string, creditlineReceived: number | string, options?: TrustlineUpdateOptions): Promise<TxObject>

Defined in src/Trustline.ts:119

Prepares a transaction object for creating a trustline update request. Called by initiator of update request.

Parameters:#

NameTypeDefault valueDescription
networkAddressstring-Address of a currency network.
counterpartyAddressstring-Address of counterparty who receives trustline update request.
creditlineGivennumber | string-Proposed creditline limit given by initiator to counterparty, i.e. 1.23 if network has to 2 decimals.
creditlineReceivednumber | string-Proposed creditline limit received by initiator from counterparty, i.e. 1.23 if network has to 2 decimals.
optionsTrustlineUpdateOptions{}Options for creating an updateTrustline ethereum transaction. See type TrustlineUpdateOptions for more information.

Returns: Promise<TxObject>