Class LoanSigningHelper
Helper for LoanSet multi-party signing (XLS-66d). LoanSet requires two signatures: the broker (Account) signs as the submitter (TxnSignature), and the borrower (Counterparty) provides a CounterpartySignature (inner STObject with SigningPubKey + TxnSignature).
Three signing patterns (analogous to Batch V1/V2/V3):
V1 — Automatic (both keys available):
var result = LoanSigningHelper.SignLoanSet(loanTx, brokerWallet, borrowerWallet);
await client.SubmitRequest(result.TxBlob);
V2 — Parallel (keys on separate devices, sign independently):
// Device A (borrower):
var counterpartySig = borrowerWallet.SignAsLoanCounterparty(preparedTxJson);
// Device B (broker):
var brokerSig = brokerWallet.Sign(preparedTxJson);
// Combiner:
var combined = LoanSigningHelper.CombineLoanSignatures(brokerSig.TxBlob, counterpartySig.TxBlob);
await client.SubmitRequest(combined);
V3 — Sequential (borrower signs first, passes to broker):
// Borrower signs, adds CounterpartySignature:
var withCounterparty = borrowerWallet.SignAsLoanCounterparty(preparedTxJson);
// Broker receives the partially signed blob, adds TxnSignature:
var final = LoanSigningHelper.BrokerSign(withCounterparty.TxBlob, brokerWallet);
await client.SubmitRequest(final.TxBlob);
Multisig borrower (Counterparty with a SignerList): each signer of the
borrower's list produces a portable Signer entry with the standard multisign
call, and the composer places them under CounterpartySignature.Signers
(rippled verifies them against the counterparty's SignerList over the same
multisign preimage as tx.Signers). Autofill with the signer count so the
fee covers them (rippled LoanSet::calculateBaseFee charges one base fee
per counterparty signer):
var prepared = LoanSigningHelper.PrepareForSigning(await client.Autofill(loanTx.ToDictionary(), signersCount: 2), brokerWallet);
var brokerPart = brokerWallet.Sign(prepared);
var part1 = signer1.Sign(prepared, multisign: true);
var part2 = signer2.Sign(prepared, multisign: true);
// ledger-driven routing (looks up the Counterparty's SignerList):
var composed = await client.ComposeSignatures(new[] { brokerPart.TxBlob, part1.TxBlob, part2.TxBlob });
// or offline, naming the borrower's signers:
var offline = LoanSigningHelper.CombineLoanSignatures(new[] { brokerPart.TxBlob, part1.TxBlob, part2.TxBlob }, new[] { signer1.ClassicAddress, signer2.ClassicAddress });
Inheritance
Namespace: Xrpl.Wallet
Assembly: Xrpl.dll
Syntax
public static class LoanSigningHelper
Methods
| Edit this page View SourceBrokerSign(string, XrplWallet)
V3 — Broker signs a partially signed LoanSet blob (one that already has CounterpartySignature). Decodes the blob, strips CounterpartySignature to compute the correct preimage, adds the broker's TxnSignature, then restores CounterpartySignature for encoding.
Declaration
public static SignatureResult BrokerSign(string partiallySignedBlob, XrplWallet brokerWallet)
Parameters
| Type | Name | Description |
|---|---|---|
| string | partiallySignedBlob | Hex blob from borrower's SignAsLoanCounterparty (has CounterpartySignature, no TxnSignature). |
| XrplWallet | brokerWallet | The broker's wallet (submitting account). |
Returns
| Type | Description |
|---|---|
| SignatureResult | Fully signed transaction blob and hash. |
CombineLoanSignatures(IEnumerable<string>, IReadOnlyCollection<string>)
Combines a broker part with the portable Signer entries of a multisig
borrower: entries from counterpartySignerAccounts land in
CounterpartySignature.Signers, any other entry in tx.Signers
(a multisig broker). Offline; for ledger-driven routing use
IXrplClient.ComposeSignatures.
Declaration
public static SignatureResult CombineLoanSignatures(IEnumerable<string> partBlobs, IReadOnlyCollection<string> counterpartySignerAccounts)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<string> | partBlobs | The broker's blob and the borrower-side multisign parts. |
| IReadOnlyCollection<string> | counterpartySignerAccounts | Accounts of the borrower's SignerList. |
Returns
| Type | Description |
|---|---|
| SignatureResult |
CombineLoanSignatures(string, string)
V2 — Combine independently signed broker and counterparty blobs. The broker blob has TxnSignature but no CounterpartySignature. The counterparty blob has CounterpartySignature but no TxnSignature.
Declaration
public static SignatureResult CombineLoanSignatures(string brokerSignedBlob, string counterpartySignedBlob)
Parameters
| Type | Name | Description |
|---|---|---|
| string | brokerSignedBlob | Hex blob signed by the broker (has TxnSignature). |
| string | counterpartySignedBlob | Hex blob signed by the borrower (has CounterpartySignature). |
Returns
| Type | Description |
|---|---|
| SignatureResult | Combined fully signed blob. |
PrepareForSigning(JsonObject, XrplWallet)
Prepares a LoanSet JSON object for signing.
Declaration
public static JsonObject PrepareForSigning(JsonObject txJson, XrplWallet brokerWallet)
Parameters
| Type | Name | Description |
|---|---|---|
| JsonObject | txJson | |
| XrplWallet | brokerWallet |
Returns
| Type | Description |
|---|---|
| JsonObject |
PrepareForSigning(ITransactionRequest, XrplWallet)
Prepares a LoanSet transaction JSON for signing. Sets SigningPubKey to the broker's public key and removes signature fields. Returns a JsonObject ready for both parties to sign.
Declaration
public static JsonObject PrepareForSigning(ITransactionRequest loanSetTx, XrplWallet brokerWallet)
Parameters
| Type | Name | Description |
|---|---|---|
| ITransactionRequest | loanSetTx | The LoanSet transaction (autofilled with Sequence, Fee, LastLedgerSequence). |
| XrplWallet | brokerWallet | The broker's wallet (submitting account). |
Returns
| Type | Description |
|---|---|
| JsonObject | JsonObject ready for signing by both parties. |
Remarks
Fee for CounterpartySignature overhead is handled by Autofill
(see CalculateBaseFeeForType in Autofill.cs).
SignLoanSet(JsonObject, XrplWallet, XrplWallet)
V1 — Automatic signing: both broker and borrower wallets available locally. Computes the signing preimage, has both parties sign, and returns the fully signed tx blob.
Declaration
public static SignatureResult SignLoanSet(JsonObject preparedTx, XrplWallet brokerWallet, XrplWallet borrowerWallet)
Parameters
| Type | Name | Description |
|---|---|---|
| JsonObject | preparedTx | Prepared LoanSet JSON (from PrepareForSigning or already prepared). |
| XrplWallet | brokerWallet | The broker's wallet (submitting account). |
| XrplWallet | borrowerWallet | The borrower's wallet (counterparty). |
Returns
| Type | Description |
|---|---|
| SignatureResult | Fully signed transaction blob and hash. |