fix(economy): llNexBankPayout bank-only and fail closed (#170)

* fix(economy): dedicated llNexBankPayout prevents accidental personal-wallet debits

* docs(economy): clarify bank-only LSL function and fail-closed fallback
This commit is contained in:
OpenGenesis (MPL 2.0) authored and GitHub committed 2026-10-11 21:24:23 +02:00
1 parent f9ee61580a
commit 16d219f142
6 files changed
+107 -62

No files matched your search

@@ -3412,32 +3412,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return 0;
}
// The Master Bank requires an exact server-side object+script
// delegation AND explicit PERMISSION_DEBIT from its operator.
// A copied script or a bare bank UUID cannot access bank funds.
INexMasterBankPayoutModule bank =
World.RequestModuleInterface<INexMasterBankPayoutModule>();
UUID rootObject = m_host.ParentGroup.RootPart.UUID;
UUID rootOwner = m_host.ParentGroup.RootPart.OwnerID;
bool master = bank != null &&
bank.IsAuthorizedBankScript(rootObject, m_item.ItemID, rootOwner);
if (master && m_item.PermsGranter != rootOwner)
return 0;
void act(string _)
{
if (master)
bank.TryBankPayout(rootObject, m_item.ItemID, rootOwner,
toID, amount, UUID.Random(), out _);
else
money.ObjectGiveMoney(rootObject, rootOwner,
toID, amount, UUID.Zero, out _);
money.ObjectGiveMoney(m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID,
toID, amount, UUID.Zero, out _);
}
m_AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, act);
return 0;
}
// Dedicated OGL payment primitive: never falls back to the owner
// wallet, unlike standard llGiveMoney / llTransferLindenDollars.
public LSL_Key llNexBankPayout(LSL_Key target, LSL_Integer amount)
{
UUID txn = UUID.Random();
UUID objectId = m_host.ParentGroup.RootPart.UUID;
UUID ownerId = m_host.ParentGroup.RootPart.OwnerID;
UUID scriptId = m_item.ItemID;
INexMasterBankPayoutModule bank =
World.RequestModuleInterface<INexMasterBankPayoutModule>();
string error = null;
UUID receiver = UUID.Zero;
if (amount <= 0)
error = "INVALID_AMOUNT";
else if (!UUID.TryParse(target, out receiver) || receiver.IsZero())
error = "INVALID_AGENT";
else if (bank == null ||
!bank.IsAuthorizedBankScript(objectId, scriptId, ownerId))
error = "MASTER_BANK_SCRIPT_NOT_AUTHORIZED";
else if (m_item.PermsGranter != ownerId ||
(m_item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0)
error = "MISSING_MASTER_BANK_OPERATOR_PERMISSION";
if (error != null)
{
m_ScriptEngine.PostScriptEvent(scriptId, new EventParams(
"transaction_result", new object[] {
new LSL_String(txn.ToString()),
new LSL_Integer(0),
new LSL_String(error)
}, Array.Empty<DetectParams>()));
return txn.ToString();
}
void act(string unused)
{
bool success = false;
string reason = "BANK_PAYOUT_FAILED";
try
{
success = bank.TryBankPayout(objectId, scriptId, ownerId,
receiver, amount, txn, out reason);
}
catch (Exception)
{
reason = "BANK_PAYOUT_UNAVAILABLE";
}
m_ScriptEngine.PostScriptEvent(scriptId, new EventParams(
"transaction_result", new object[] {
new LSL_String(txn.ToString()),
new LSL_Integer(success ? 1 : 0),
new LSL_String(success
? target + "," + amount.ToString() : reason)
}, Array.Empty<DetectParams>()));
}
m_AsyncCommands.DataserverPlugin.RegisterRequest(
m_host.LocalId, scriptId, act);
return txn.ToString();
}
public void llMakeExplosion(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset)
{
Deprecated("llMakeExplosion", "Use llParticleSystem instead");
@@ -17301,51 +17345,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return txn.ToString();
}
INexMasterBankPayoutModule bank =
World.RequestModuleInterface<INexMasterBankPayoutModule>();
UUID rootObject = m_host.ParentGroup.RootPart.UUID;
UUID rootOwner = m_host.ParentGroup.RootPart.OwnerID;
bool master = bank != null &&
bank.IsAuthorizedBankScript(rootObject, m_item.ItemID, rootOwner);
// The approved bank operator must be the debit granter.
if (master && m_item.PermsGranter != rootOwner)
{
m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
"transaction_result", new object[] {
new LSL_String(txn.ToString()),
new LSL_Integer(0),
new LSL_String("MISSING_MASTER_BANK_OPERATOR_PERMISSION")
}, Array.Empty<DetectParams>()));
return txn.ToString();
}
// Fire and forget, with a correlated transaction_result event.
//fire and forget...
void act(string eventID)
{
int replycode = 0;
try
{
// Generic LSL transfers still require local UserAccount.
// Authorized bank scripts may also pay verified *present*
// HG visitors, resolved by the economy region module.
if (!master)
UserAccount account = m_userAccountService.GetUserAccount(RegionScopeID, toID);
if (account is null)
{
UserAccount account =
m_userAccountService.GetUserAccount(RegionScopeID, toID);
if (account is null)
{
replydata = "LINDENDOLLAR_ENTITYDOESNOTEXIST";
return;
}
replydata = "LINDENDOLLAR_ENTITYDOESNOTEXIST";
return;
}
string reason;
bool result = master
? bank.TryBankPayout(rootObject, m_item.ItemID, rootOwner,
toID, amount, txn, out reason)
: money.ObjectGiveMoney(rootObject, rootOwner,
toID, amount, txn, out reason);
bool result = money.ObjectGiveMoney(m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID,
toID, amount, txn, out string reason);
if (result)
{
replycode = 1;
@@ -234,6 +234,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
void llGiveInventory(LSL_Key destination, LSL_String inventory);
void llGiveInventoryList(LSL_Key destination, LSL_String folderName, LSL_List inventory);
LSL_Integer llGiveMoney(LSL_Key destination, LSL_Integer amount);
LSL_Key llNexBankPayout(LSL_Key target, LSL_Integer amount);
LSL_Key llTransferLindenDollars(LSL_Key destination, LSL_Integer amount);
void llGodLikeRezObject(string inventory, LSL_Vector pos);
LSL_Float llGround(LSL_Vector offset);
@@ -1113,6 +1113,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return m_LSL_Functions.llTransferLindenDollars(destination, amount);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LSL_Key llNexBankPayout(LSL_Key target, LSL_Integer amount)
{
return m_LSL_Functions.llNexBankPayout(target, amount);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void llGodLikeRezObject(LSL_String inventory, LSL_Vector pos)
{
+14 -3
View File
@@ -204,9 +204,10 @@ freigeben. Der Simulator prueft vor *jedem* Vorgang:
Double-Entry-Journal. Der Auszahlungscode nutzt ausschliesslich
die getrennte Bankkonto-UUID als Quelle.
- Keine Schluessel, HTTP-API-Tokens oder privilegierten UUID-Claims
werden an das LSL-Skript ausgegeben. Das Skript ruft die vorhandenen
`llGiveMoney` oder besser `llTransferLindenDollars`-Funktionen auf.
`transaction_result` liefert bei letzterem Erfolg oder Fehler.
werden an das LSL-Skript ausgegeben. Das Skript ruft ausschliesslich
`llNexBankPayout` auf und erhaelt das Ergebnis im
`transaction_result`-Event. Standardfunktionen wie `llGiveMoney`
bleiben **avatarfinanziert** und koennen das Bankkonto nicht belasten.
**Konfiguration:** In der geladenen Simulator-`OpenSim.ini`:
@@ -250,3 +251,13 @@ wird aber nicht in Heimatgrid-Waehrung exportiert.
Zinsen/ATM-Buchungen werden spaeter als gedeckte Ledger-Transaktionen
mit eigenem Reservekonto, Freigaben und Limits implementiert.
Noch **keine** automatische Zinszahlung oder ATM-Live-Freigabe.
**Sicherheitsnachtrag:** Bank-Payouts aus LSL verwenden ausschliesslich die
OGL-Funktion `llNexBankPayout(avatar, betrag)` mit
`transaction_result`. Normales `llGiveMoney` und
`llTransferLindenDollars` bleiben **avatarfinanzierte** Funktionen.
Wenn die Masterbank deaktiviert oder das Script nicht berechtigt ist,
meldet `llNexBankPayout` einen Fehler und belastet **niemals** das
private Konto des Bankoperators. Das Demo-Script verwendet nur diesen
eindeutig abgegrenzten Aufruf.
+15 -3
View File
@@ -208,9 +208,21 @@ for marker in ("MasterBankEnabled", "MasterBankAccountId", "MasterBankOperatorId
'"/api/v1/banking/transfers"', "EnsureMasterBankAccount(",
"GetAgentCircuitData(avatarId)", "IsAuthorizedBankScript(objectId"):
assert marker in viewer, "Incomplete bank payout implementation: " + marker
for marker in ("INexMasterBankPayoutModule", "bank.TryBankPayout(",
"m_item.PermsGranter != rootOwner"):
assert marker in lsl, "Master bank not bound to LSL debit permission: " + marker
for marker in ("INexMasterBankPayoutModule", "llNexBankPayout(",
"bank.TryBankPayout(", "m_item.PermsGranter != ownerId",
"MASTER_BANK_SCRIPT_NOT_AUTHORIZED"):
assert marker in lsl, "Master bank lacks dedicated LSL payout: " + marker
assert "llNexBankPayout(" in Path(
"OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs").read_text()
assert "llNexBankPayout(" in Path(
"OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs").read_text()
assert "llNexBankPayout(TARGET_AVATAR, AMOUNT_NV)" in Path(
"tools/diagnostics/ogl_master_bank_payout_test.lsl").read_text()
assert "TryBankPayout(" not in lsl.split(
"public LSL_Integer llGiveMoney(", 1)[1].split(
"public LSL_Key llNexBankPayout(", 1)[0]
assert "TryBankPayout(" not in lsl.split(
"public LSL_Key llTransferLindenDollars(", 1)[1].split("#endregion", 1)[0]
for marker in ("unauthorized Master Bank payout delegation accepted",
"master bank could not payout to HG resident wallet",
"master bank created unbacked money"):
@@ -5,6 +5,7 @@
// 3. Bankoperator erteilt PERMISSION_DEBIT nach bewusstem Dialog.
// 4. TARGET_AVATAR mit echter lokalen oder anwesenden HG-Avatar-UUID ersetzen.
// Kein API-Key, kein freier Touch-Faucet, kein unlimitierter Timer.
// llNexBankPayout kann NIE aus dem privaten Avatar-Wallet bezahlen.
key TARGET_AVATAR = NULL_KEY;
integer AMOUNT_NV = 1;
@@ -32,7 +33,7 @@ default
llOwnerSay("TEST NICHT GESTARTET: TARGET_AVATAR und Betrag konfigurieren.");
return;
}
key txn = llTransferLindenDollars(TARGET_AVATAR, AMOUNT_NV);
key txn = llNexBankPayout(TARGET_AVATAR, AMOUNT_NV);
llOwnerSay("Masterbank-Transaktion angefragt: " + (string)txn);
}