diff --git a/XChainBridge_8cpp_source.html b/XChainBridge_8cpp_source.html index e45b1d175b..16d15ed602 100644 --- a/XChainBridge_8cpp_source.html +++ b/XChainBridge_8cpp_source.html @@ -1425,847 +1425,853 @@ $(function() {
1452 {
1453  auto const account = ctx.tx[sfAccount];
1454  auto const bridgeSpec = ctx.tx[sfXChainBridge];
-
1455 
-
1456  STXChainBridge::ChainType const chainType =
-
1457  STXChainBridge::srcChain(account == bridgeSpec.lockingChainDoor());
-
1458 
-
1459  if (ctx.view.read(keylet::bridge(bridgeSpec, chainType)))
-
1460  {
-
1461  return tecDUPLICATE;
-
1462  }
-
1463 
-
1464  if (!isXRP(bridgeSpec.issue(chainType)))
-
1465  {
-
1466  auto const sleIssuer =
-
1467  ctx.view.read(keylet::account(bridgeSpec.issue(chainType).account));
-
1468 
-
1469  if (!sleIssuer)
-
1470  return tecNO_ISSUER;
-
1471 
-
1472  // Allowing clawing back funds would break the bridge's invariant that
-
1473  // wrapped funds are always backed by locked funds
-
1474  if (sleIssuer->getFlags() & lsfAllowTrustLineClawback)
-
1475  return tecNO_PERMISSION;
-
1476  }
+
1455  STXChainBridge::ChainType const chainType =
+
1456  STXChainBridge::srcChain(account == bridgeSpec.lockingChainDoor());
+
1457 
+
1458  {
+
1459  auto hasBridge = [&](STXChainBridge::ChainType ct) -> bool {
+
1460  return ctx.view.exists(keylet::bridge(bridgeSpec, ct));
+
1461  };
+
1462 
+
1463  if (hasBridge(STXChainBridge::ChainType::issuing) ||
+
1464  hasBridge(STXChainBridge::ChainType::locking))
+
1465  {
+
1466  return tecDUPLICATE;
+
1467  }
+
1468  }
+
1469 
+
1470  if (!isXRP(bridgeSpec.issue(chainType)))
+
1471  {
+
1472  auto const sleIssuer =
+
1473  ctx.view.read(keylet::account(bridgeSpec.issue(chainType).account));
+
1474 
+
1475  if (!sleIssuer)
+
1476  return tecNO_ISSUER;
1477 
-
1478  {
-
1479  // Check reserve
-
1480  auto const sleAcc = ctx.view.read(keylet::account(account));
-
1481  if (!sleAcc)
-
1482  return terNO_ACCOUNT;
+
1478  // Allowing clawing back funds would break the bridge's invariant that
+
1479  // wrapped funds are always backed by locked funds
+
1480  if (sleIssuer->getFlags() & lsfAllowTrustLineClawback)
+
1481  return tecNO_PERMISSION;
+
1482  }
1483 
-
1484  auto const balance = (*sleAcc)[sfBalance];
-
1485  auto const reserve =
-
1486  ctx.view.fees().accountReserve((*sleAcc)[sfOwnerCount] + 1);
-
1487 
-
1488  if (balance < reserve)
-
1489  return tecINSUFFICIENT_RESERVE;
-
1490  }
-
1491 
-
1492  return tesSUCCESS;
-
1493 }
-
1494 
-
1495 TER
-
1496 XChainCreateBridge::doApply()
-
1497 {
-
1498  auto const account = ctx_.tx[sfAccount];
-
1499  auto const bridgeSpec = ctx_.tx[sfXChainBridge];
-
1500  auto const reward = ctx_.tx[sfSignatureReward];
-
1501  auto const minAccountCreate = ctx_.tx[~sfMinAccountCreateAmount];
-
1502 
-
1503  auto const sleAcct = ctx_.view().peek(keylet::account(account));
-
1504  if (!sleAcct)
-
1505  return tecINTERNAL;
-
1506 
-
1507  STXChainBridge::ChainType const chainType =
-
1508  STXChainBridge::srcChain(account == bridgeSpec.lockingChainDoor());
-
1509 
-
1510  Keylet const bridgeKeylet = keylet::bridge(bridgeSpec, chainType);
-
1511  auto const sleBridge = std::make_shared<SLE>(bridgeKeylet);
+
1484  {
+
1485  // Check reserve
+
1486  auto const sleAcc = ctx.view.read(keylet::account(account));
+
1487  if (!sleAcc)
+
1488  return terNO_ACCOUNT;
+
1489 
+
1490  auto const balance = (*sleAcc)[sfBalance];
+
1491  auto const reserve =
+
1492  ctx.view.fees().accountReserve((*sleAcc)[sfOwnerCount] + 1);
+
1493 
+
1494  if (balance < reserve)
+
1495  return tecINSUFFICIENT_RESERVE;
+
1496  }
+
1497 
+
1498  return tesSUCCESS;
+
1499 }
+
1500 
+
1501 TER
+
1502 XChainCreateBridge::doApply()
+
1503 {
+
1504  auto const account = ctx_.tx[sfAccount];
+
1505  auto const bridgeSpec = ctx_.tx[sfXChainBridge];
+
1506  auto const reward = ctx_.tx[sfSignatureReward];
+
1507  auto const minAccountCreate = ctx_.tx[~sfMinAccountCreateAmount];
+
1508 
+
1509  auto const sleAcct = ctx_.view().peek(keylet::account(account));
+
1510  if (!sleAcct)
+
1511  return tecINTERNAL;
1512 
-
1513  (*sleBridge)[sfAccount] = account;
-
1514  (*sleBridge)[sfSignatureReward] = reward;
-
1515  if (minAccountCreate)
-
1516  (*sleBridge)[sfMinAccountCreateAmount] = *minAccountCreate;
-
1517  (*sleBridge)[sfXChainBridge] = bridgeSpec;
-
1518  (*sleBridge)[sfXChainClaimID] = 0;
-
1519  (*sleBridge)[sfXChainAccountCreateCount] = 0;
-
1520  (*sleBridge)[sfXChainAccountClaimCount] = 0;
-
1521 
-
1522  // Add to owner directory
-
1523  {
-
1524  auto const page = ctx_.view().dirInsert(
-
1525  keylet::ownerDir(account), bridgeKeylet, describeOwnerDir(account));
-
1526  if (!page)
-
1527  return tecDIR_FULL;
-
1528  (*sleBridge)[sfOwnerNode] = *page;
-
1529  }
-
1530 
-
1531  adjustOwnerCount(ctx_.view(), sleAcct, 1, ctx_.journal);
-
1532 
-
1533  ctx_.view().insert(sleBridge);
-
1534  ctx_.view().update(sleAcct);
-
1535 
-
1536  return tesSUCCESS;
-
1537 }
+
1513  STXChainBridge::ChainType const chainType =
+
1514  STXChainBridge::srcChain(account == bridgeSpec.lockingChainDoor());
+
1515 
+
1516  Keylet const bridgeKeylet = keylet::bridge(bridgeSpec, chainType);
+
1517  auto const sleBridge = std::make_shared<SLE>(bridgeKeylet);
+
1518 
+
1519  (*sleBridge)[sfAccount] = account;
+
1520  (*sleBridge)[sfSignatureReward] = reward;
+
1521  if (minAccountCreate)
+
1522  (*sleBridge)[sfMinAccountCreateAmount] = *minAccountCreate;
+
1523  (*sleBridge)[sfXChainBridge] = bridgeSpec;
+
1524  (*sleBridge)[sfXChainClaimID] = 0;
+
1525  (*sleBridge)[sfXChainAccountCreateCount] = 0;
+
1526  (*sleBridge)[sfXChainAccountClaimCount] = 0;
+
1527 
+
1528  // Add to owner directory
+
1529  {
+
1530  auto const page = ctx_.view().dirInsert(
+
1531  keylet::ownerDir(account), bridgeKeylet, describeOwnerDir(account));
+
1532  if (!page)
+
1533  return tecDIR_FULL;
+
1534  (*sleBridge)[sfOwnerNode] = *page;
+
1535  }
+
1536 
+
1537  adjustOwnerCount(ctx_.view(), sleAcct, 1, ctx_.journal);
1538 
-
1539 //------------------------------------------------------------------------------
-
1540 
-
1541 NotTEC
-
1542 BridgeModify::preflight(PreflightContext const& ctx)
-
1543 {
-
1544  if (!ctx.rules.enabled(featureXChainBridge))
-
1545  return temDISABLED;
+
1539  ctx_.view().insert(sleBridge);
+
1540  ctx_.view().update(sleAcct);
+
1541 
+
1542  return tesSUCCESS;
+
1543 }
+
1544 
+
1545 //------------------------------------------------------------------------------
1546 
-
1547  if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
-
1548  return ret;
-
1549 
-
1550  if (ctx.tx.getFlags() & tfBridgeModifyMask)
-
1551  return temINVALID_FLAG;
+
1547 NotTEC
+
1548 BridgeModify::preflight(PreflightContext const& ctx)
+
1549 {
+
1550  if (!ctx.rules.enabled(featureXChainBridge))
+
1551  return temDISABLED;
1552 
-
1553  auto const account = ctx.tx[sfAccount];
-
1554  auto const reward = ctx.tx[~sfSignatureReward];
-
1555  auto const minAccountCreate = ctx.tx[~sfMinAccountCreateAmount];
-
1556  auto const bridgeSpec = ctx.tx[sfXChainBridge];
-
1557  bool const clearAccountCreate =
-
1558  ctx.tx.getFlags() & tfClearAccountCreateAmount;
-
1559 
-
1560  if (!reward && !minAccountCreate && !clearAccountCreate)
-
1561  {
-
1562  // Must change something
-
1563  return temMALFORMED;
-
1564  }
+
1553  if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
+
1554  return ret;
+
1555 
+
1556  if (ctx.tx.getFlags() & tfBridgeModifyMask)
+
1557  return temINVALID_FLAG;
+
1558 
+
1559  auto const account = ctx.tx[sfAccount];
+
1560  auto const reward = ctx.tx[~sfSignatureReward];
+
1561  auto const minAccountCreate = ctx.tx[~sfMinAccountCreateAmount];
+
1562  auto const bridgeSpec = ctx.tx[sfXChainBridge];
+
1563  bool const clearAccountCreate =
+
1564  ctx.tx.getFlags() & tfClearAccountCreateAmount;
1565 
-
1566  if (minAccountCreate && clearAccountCreate)
+
1566  if (!reward && !minAccountCreate && !clearAccountCreate)
1567  {
-
1568  // Can't both clear and set account create in the same txn
+
1568  // Must change something
1569  return temMALFORMED;
1570  }
1571 
-
1572  if (bridgeSpec.lockingChainDoor() != account &&
-
1573  bridgeSpec.issuingChainDoor() != account)
-
1574  {
-
1575  return temXCHAIN_BRIDGE_NONDOOR_OWNER;
+
1572  if (minAccountCreate && clearAccountCreate)
+
1573  {
+
1574  // Can't both clear and set account create in the same txn
+
1575  return temMALFORMED;
1576  }
1577 
-
1578  if (reward && (!isXRP(*reward) || reward->signum() < 0))
-
1579  {
-
1580  return temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT;
-
1581  }
-
1582 
-
1583  if (minAccountCreate &&
-
1584  ((!isXRP(*minAccountCreate) || minAccountCreate->signum() <= 0) ||
-
1585  !isXRP(bridgeSpec.lockingChainIssue()) ||
-
1586  !isXRP(bridgeSpec.issuingChainIssue())))
-
1587  {
-
1588  return temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT;
-
1589  }
-
1590 
-
1591  return preflight2(ctx);
-
1592 }
-
1593 
-
1594 TER
-
1595 BridgeModify::preclaim(PreclaimContext const& ctx)
-
1596 {
-
1597  auto const account = ctx.tx[sfAccount];
-
1598  auto const bridgeSpec = ctx.tx[sfXChainBridge];
+
1578  if (bridgeSpec.lockingChainDoor() != account &&
+
1579  bridgeSpec.issuingChainDoor() != account)
+
1580  {
+
1581  return temXCHAIN_BRIDGE_NONDOOR_OWNER;
+
1582  }
+
1583 
+
1584  if (reward && (!isXRP(*reward) || reward->signum() < 0))
+
1585  {
+
1586  return temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT;
+
1587  }
+
1588 
+
1589  if (minAccountCreate &&
+
1590  ((!isXRP(*minAccountCreate) || minAccountCreate->signum() <= 0) ||
+
1591  !isXRP(bridgeSpec.lockingChainIssue()) ||
+
1592  !isXRP(bridgeSpec.issuingChainIssue())))
+
1593  {
+
1594  return temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT;
+
1595  }
+
1596 
+
1597  return preflight2(ctx);
+
1598 }
1599 
-
1600  STXChainBridge::ChainType const chainType =
-
1601  STXChainBridge::srcChain(account == bridgeSpec.lockingChainDoor());
-
1602 
-
1603  if (!ctx.view.read(keylet::bridge(bridgeSpec, chainType)))
-
1604  {
-
1605  return tecNO_ENTRY;
-
1606  }
-
1607 
-
1608  return tesSUCCESS;
-
1609 }
-
1610 
-
1611 TER
-
1612 BridgeModify::doApply()
-
1613 {
-
1614  auto const account = ctx_.tx[sfAccount];
-
1615  auto const bridgeSpec = ctx_.tx[sfXChainBridge];
-
1616  auto const reward = ctx_.tx[~sfSignatureReward];
-
1617  auto const minAccountCreate = ctx_.tx[~sfMinAccountCreateAmount];
-
1618  bool const clearAccountCreate =
-
1619  ctx_.tx.getFlags() & tfClearAccountCreateAmount;
-
1620 
-
1621  auto const sleAcct = ctx_.view().peek(keylet::account(account));
-
1622  if (!sleAcct)
-
1623  return tecINTERNAL;
-
1624 
-
1625  STXChainBridge::ChainType const chainType =
-
1626  STXChainBridge::srcChain(account == bridgeSpec.lockingChainDoor());
-
1627 
-
1628  auto const sleBridge =
-
1629  ctx_.view().peek(keylet::bridge(bridgeSpec, chainType));
-
1630  if (!sleBridge)
-
1631  return tecINTERNAL;
-
1632 
-
1633  if (reward)
-
1634  (*sleBridge)[sfSignatureReward] = *reward;
-
1635  if (minAccountCreate)
-
1636  {
-
1637  (*sleBridge)[sfMinAccountCreateAmount] = *minAccountCreate;
-
1638  }
-
1639  if (clearAccountCreate &&
-
1640  sleBridge->isFieldPresent(sfMinAccountCreateAmount))
-
1641  {
-
1642  sleBridge->makeFieldAbsent(sfMinAccountCreateAmount);
-
1643  }
-
1644  ctx_.view().update(sleBridge);
-
1645 
-
1646  return tesSUCCESS;
-
1647 }
-
1648 
-
1649 //------------------------------------------------------------------------------
-
1650 
-
1651 NotTEC
-
1652 XChainClaim::preflight(PreflightContext const& ctx)
-
1653 {
-
1654  if (!ctx.rules.enabled(featureXChainBridge))
-
1655  return temDISABLED;
+
1600 TER
+
1601 BridgeModify::preclaim(PreclaimContext const& ctx)
+
1602 {
+
1603  auto const account = ctx.tx[sfAccount];
+
1604  auto const bridgeSpec = ctx.tx[sfXChainBridge];
+
1605 
+
1606  STXChainBridge::ChainType const chainType =
+
1607  STXChainBridge::srcChain(account == bridgeSpec.lockingChainDoor());
+
1608 
+
1609  if (!ctx.view.read(keylet::bridge(bridgeSpec, chainType)))
+
1610  {
+
1611  return tecNO_ENTRY;
+
1612  }
+
1613 
+
1614  return tesSUCCESS;
+
1615 }
+
1616 
+
1617 TER
+
1618 BridgeModify::doApply()
+
1619 {
+
1620  auto const account = ctx_.tx[sfAccount];
+
1621  auto const bridgeSpec = ctx_.tx[sfXChainBridge];
+
1622  auto const reward = ctx_.tx[~sfSignatureReward];
+
1623  auto const minAccountCreate = ctx_.tx[~sfMinAccountCreateAmount];
+
1624  bool const clearAccountCreate =
+
1625  ctx_.tx.getFlags() & tfClearAccountCreateAmount;
+
1626 
+
1627  auto const sleAcct = ctx_.view().peek(keylet::account(account));
+
1628  if (!sleAcct)
+
1629  return tecINTERNAL;
+
1630 
+
1631  STXChainBridge::ChainType const chainType =
+
1632  STXChainBridge::srcChain(account == bridgeSpec.lockingChainDoor());
+
1633 
+
1634  auto const sleBridge =
+
1635  ctx_.view().peek(keylet::bridge(bridgeSpec, chainType));
+
1636  if (!sleBridge)
+
1637  return tecINTERNAL;
+
1638 
+
1639  if (reward)
+
1640  (*sleBridge)[sfSignatureReward] = *reward;
+
1641  if (minAccountCreate)
+
1642  {
+
1643  (*sleBridge)[sfMinAccountCreateAmount] = *minAccountCreate;
+
1644  }
+
1645  if (clearAccountCreate &&
+
1646  sleBridge->isFieldPresent(sfMinAccountCreateAmount))
+
1647  {
+
1648  sleBridge->makeFieldAbsent(sfMinAccountCreateAmount);
+
1649  }
+
1650  ctx_.view().update(sleBridge);
+
1651 
+
1652  return tesSUCCESS;
+
1653 }
+
1654 
+
1655 //------------------------------------------------------------------------------
1656 
-
1657  if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
-
1658  return ret;
-
1659 
-
1660  if (ctx.tx.getFlags() & tfUniversalMask)
-
1661  return temINVALID_FLAG;
+
1657 NotTEC
+
1658 XChainClaim::preflight(PreflightContext const& ctx)
+
1659 {
+
1660  if (!ctx.rules.enabled(featureXChainBridge))
+
1661  return temDISABLED;
1662 
-
1663  STXChainBridge const bridgeSpec = ctx.tx[sfXChainBridge];
-
1664  auto const amount = ctx.tx[sfAmount];
+
1663  if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
+
1664  return ret;
1665 
-
1666  if (amount.signum() <= 0 ||
-
1667  (amount.issue() != bridgeSpec.lockingChainIssue() &&
-
1668  amount.issue() != bridgeSpec.issuingChainIssue()))
-
1669  {
-
1670  return temBAD_AMOUNT;
-
1671  }
-
1672 
-
1673  return preflight2(ctx);
-
1674 }
-
1675 
-
1676 TER
-
1677 XChainClaim::preclaim(PreclaimContext const& ctx)
-
1678 {
-
1679  AccountID const account = ctx.tx[sfAccount];
-
1680  STXChainBridge const bridgeSpec = ctx.tx[sfXChainBridge];
-
1681  STAmount const& thisChainAmount = ctx.tx[sfAmount];
-
1682  auto const claimID = ctx.tx[sfXChainClaimID];
-
1683 
-
1684  auto const sleBridge = readBridge(ctx.view, bridgeSpec);
-
1685  if (!sleBridge)
-
1686  {
-
1687  return tecNO_ENTRY;
-
1688  }
+
1666  if (ctx.tx.getFlags() & tfUniversalMask)
+
1667  return temINVALID_FLAG;
+
1668 
+
1669  STXChainBridge const bridgeSpec = ctx.tx[sfXChainBridge];
+
1670  auto const amount = ctx.tx[sfAmount];
+
1671 
+
1672  if (amount.signum() <= 0 ||
+
1673  (amount.issue() != bridgeSpec.lockingChainIssue() &&
+
1674  amount.issue() != bridgeSpec.issuingChainIssue()))
+
1675  {
+
1676  return temBAD_AMOUNT;
+
1677  }
+
1678 
+
1679  return preflight2(ctx);
+
1680 }
+
1681 
+
1682 TER
+
1683 XChainClaim::preclaim(PreclaimContext const& ctx)
+
1684 {
+
1685  AccountID const account = ctx.tx[sfAccount];
+
1686  STXChainBridge const bridgeSpec = ctx.tx[sfXChainBridge];
+
1687  STAmount const& thisChainAmount = ctx.tx[sfAmount];
+
1688  auto const claimID = ctx.tx[sfXChainClaimID];
1689 
-
1690  if (!ctx.view.read(keylet::account(ctx.tx[sfDestination])))
-
1691  {
-
1692  return tecNO_DST;
-
1693  }
-
1694 
-
1695  auto const thisDoor = (*sleBridge)[sfAccount];
-
1696  bool isLockingChain = false;
+
1690  auto const sleBridge = readBridge(ctx.view, bridgeSpec);
+
1691  if (!sleBridge)
+
1692  {
+
1693  return tecNO_ENTRY;
+
1694  }
+
1695 
+
1696  if (!ctx.view.read(keylet::account(ctx.tx[sfDestination])))
1697  {
-
1698  if (thisDoor == bridgeSpec.lockingChainDoor())
-
1699  isLockingChain = true;
-
1700  else if (thisDoor == bridgeSpec.issuingChainDoor())
-
1701  isLockingChain = false;
-
1702  else
-
1703  return tecINTERNAL;
-
1704  }
-
1705 
-
1706  {
-
1707  // Check that the amount specified matches the expected issue
-
1708 
-
1709  if (isLockingChain)
-
1710  {
-
1711  if (bridgeSpec.lockingChainIssue() != thisChainAmount.issue())
-
1712  return tecXCHAIN_BAD_TRANSFER_ISSUE;
-
1713  }
-
1714  else
-
1715  {
-
1716  if (bridgeSpec.issuingChainIssue() != thisChainAmount.issue())
-
1717  return tecXCHAIN_BAD_TRANSFER_ISSUE;
-
1718  }
-
1719  }
-
1720 
-
1721  if (isXRP(bridgeSpec.lockingChainIssue()) !=
-
1722  isXRP(bridgeSpec.issuingChainIssue()))
-
1723  {
-
1724  // Should have been caught when creating the bridge
-
1725  // Detect here so `otherChainAmount` doesn't switch from IOU -> XRP
-
1726  // and the numeric issues that need to be addressed with that.
-
1727  return tecINTERNAL;
-
1728  }
-
1729 
-
1730  auto const otherChainAmount = [&]() -> STAmount {
-
1731  STAmount r(thisChainAmount);
-
1732  if (isLockingChain)
-
1733  r.setIssue(bridgeSpec.issuingChainIssue());
-
1734  else
-
1735  r.setIssue(bridgeSpec.lockingChainIssue());
-
1736  return r;
-
1737  }();
-
1738 
-
1739  auto const sleClaimID =
-
1740  ctx.view.read(keylet::xChainClaimID(bridgeSpec, claimID));
-
1741  {
-
1742  // Check that the sequence number is owned by the sender of this
-
1743  // transaction
-
1744  if (!sleClaimID)
-
1745  {
-
1746  return tecXCHAIN_NO_CLAIM_ID;
-
1747  }
-
1748 
-
1749  if ((*sleClaimID)[sfAccount] != account)
-
1750  {
-
1751  // Sequence number isn't owned by the sender of this transaction
-
1752  return tecXCHAIN_BAD_CLAIM_ID;
+
1698  return tecNO_DST;
+
1699  }
+
1700 
+
1701  auto const thisDoor = (*sleBridge)[sfAccount];
+
1702  bool isLockingChain = false;
+
1703  {
+
1704  if (thisDoor == bridgeSpec.lockingChainDoor())
+
1705  isLockingChain = true;
+
1706  else if (thisDoor == bridgeSpec.issuingChainDoor())
+
1707  isLockingChain = false;
+
1708  else
+
1709  return tecINTERNAL;
+
1710  }
+
1711 
+
1712  {
+
1713  // Check that the amount specified matches the expected issue
+
1714 
+
1715  if (isLockingChain)
+
1716  {
+
1717  if (bridgeSpec.lockingChainIssue() != thisChainAmount.issue())
+
1718  return tecXCHAIN_BAD_TRANSFER_ISSUE;
+
1719  }
+
1720  else
+
1721  {
+
1722  if (bridgeSpec.issuingChainIssue() != thisChainAmount.issue())
+
1723  return tecXCHAIN_BAD_TRANSFER_ISSUE;
+
1724  }
+
1725  }
+
1726 
+
1727  if (isXRP(bridgeSpec.lockingChainIssue()) !=
+
1728  isXRP(bridgeSpec.issuingChainIssue()))
+
1729  {
+
1730  // Should have been caught when creating the bridge
+
1731  // Detect here so `otherChainAmount` doesn't switch from IOU -> XRP
+
1732  // and the numeric issues that need to be addressed with that.
+
1733  return tecINTERNAL;
+
1734  }
+
1735 
+
1736  auto const otherChainAmount = [&]() -> STAmount {
+
1737  STAmount r(thisChainAmount);
+
1738  if (isLockingChain)
+
1739  r.setIssue(bridgeSpec.issuingChainIssue());
+
1740  else
+
1741  r.setIssue(bridgeSpec.lockingChainIssue());
+
1742  return r;
+
1743  }();
+
1744 
+
1745  auto const sleClaimID =
+
1746  ctx.view.read(keylet::xChainClaimID(bridgeSpec, claimID));
+
1747  {
+
1748  // Check that the sequence number is owned by the sender of this
+
1749  // transaction
+
1750  if (!sleClaimID)
+
1751  {
+
1752  return tecXCHAIN_NO_CLAIM_ID;
1753  }
-
1754  }
-
1755 
-
1756  // quorum is checked in `doApply`
-
1757  return tesSUCCESS;
-
1758 }
-
1759 
-
1760 TER
-
1761 XChainClaim::doApply()
-
1762 {
-
1763  PaymentSandbox psb(&ctx_.view());
-
1764 
-
1765  AccountID const account = ctx_.tx[sfAccount];
-
1766  auto const dst = ctx_.tx[sfDestination];
-
1767  STXChainBridge const bridgeSpec = ctx_.tx[sfXChainBridge];
-
1768  STAmount const& thisChainAmount = ctx_.tx[sfAmount];
-
1769  auto const claimID = ctx_.tx[sfXChainClaimID];
-
1770  auto const claimIDKeylet = keylet::xChainClaimID(bridgeSpec, claimID);
-
1771 
-
1772  struct ScopeResult
-
1773  {
-
1774  std::vector<AccountID> rewardAccounts;
-
1775  AccountID rewardPoolSrc;
-
1776  STAmount sendingAmount;
-
1777  STXChainBridge::ChainType srcChain;
-
1778  STAmount signatureReward;
-
1779  };
-
1780 
-
1781  auto const scopeResult = [&]() -> Expected<ScopeResult, TER> {
-
1782  // This lambda is ugly - admittedly. The purpose of this lambda is to
-
1783  // limit the scope of sles so they don't overlap with
-
1784  // `finalizeClaimHelper`. Since `finalizeClaimHelper` can create child
-
1785  // views, it's important that the sle's lifetime doesn't overlap.
+
1754 
+
1755  if ((*sleClaimID)[sfAccount] != account)
+
1756  {
+
1757  // Sequence number isn't owned by the sender of this transaction
+
1758  return tecXCHAIN_BAD_CLAIM_ID;
+
1759  }
+
1760  }
+
1761 
+
1762  // quorum is checked in `doApply`
+
1763  return tesSUCCESS;
+
1764 }
+
1765 
+
1766 TER
+
1767 XChainClaim::doApply()
+
1768 {
+
1769  PaymentSandbox psb(&ctx_.view());
+
1770 
+
1771  AccountID const account = ctx_.tx[sfAccount];
+
1772  auto const dst = ctx_.tx[sfDestination];
+
1773  STXChainBridge const bridgeSpec = ctx_.tx[sfXChainBridge];
+
1774  STAmount const& thisChainAmount = ctx_.tx[sfAmount];
+
1775  auto const claimID = ctx_.tx[sfXChainClaimID];
+
1776  auto const claimIDKeylet = keylet::xChainClaimID(bridgeSpec, claimID);
+
1777 
+
1778  struct ScopeResult
+
1779  {
+
1780  std::vector<AccountID> rewardAccounts;
+
1781  AccountID rewardPoolSrc;
+
1782  STAmount sendingAmount;
+
1783  STXChainBridge::ChainType srcChain;
+
1784  STAmount signatureReward;
+
1785  };
1786 
-
1787  auto const sleAcct = psb.peek(keylet::account(account));
-
1788  auto const sleBridge = peekBridge(psb, bridgeSpec);
-
1789  auto const sleClaimID = psb.peek(claimIDKeylet);
-
1790 
-
1791  if (!(sleBridge && sleClaimID && sleAcct))
-
1792  return Unexpected(tecINTERNAL);
-
1793 
-
1794  AccountID const thisDoor = (*sleBridge)[sfAccount];
-
1795 
-
1796  STXChainBridge::ChainType dstChain = STXChainBridge::ChainType::locking;
-
1797  {
-
1798  if (thisDoor == bridgeSpec.lockingChainDoor())
-
1799  dstChain = STXChainBridge::ChainType::locking;
-
1800  else if (thisDoor == bridgeSpec.issuingChainDoor())
-
1801  dstChain = STXChainBridge::ChainType::issuing;
-
1802  else
-
1803  return Unexpected(tecINTERNAL);
-
1804  }
-
1805  STXChainBridge::ChainType const srcChain =
-
1806  STXChainBridge::otherChain(dstChain);
-
1807 
-
1808  auto const sendingAmount = [&]() -> STAmount {
-
1809  STAmount r(thisChainAmount);
-
1810  r.setIssue(bridgeSpec.issue(srcChain));
-
1811  return r;
-
1812  }();
+
1787  auto const scopeResult = [&]() -> Expected<ScopeResult, TER> {
+
1788  // This lambda is ugly - admittedly. The purpose of this lambda is to
+
1789  // limit the scope of sles so they don't overlap with
+
1790  // `finalizeClaimHelper`. Since `finalizeClaimHelper` can create child
+
1791  // views, it's important that the sle's lifetime doesn't overlap.
+
1792 
+
1793  auto const sleAcct = psb.peek(keylet::account(account));
+
1794  auto const sleBridge = peekBridge(psb, bridgeSpec);
+
1795  auto const sleClaimID = psb.peek(claimIDKeylet);
+
1796 
+
1797  if (!(sleBridge && sleClaimID && sleAcct))
+
1798  return Unexpected(tecINTERNAL);
+
1799 
+
1800  AccountID const thisDoor = (*sleBridge)[sfAccount];
+
1801 
+
1802  STXChainBridge::ChainType dstChain = STXChainBridge::ChainType::locking;
+
1803  {
+
1804  if (thisDoor == bridgeSpec.lockingChainDoor())
+
1805  dstChain = STXChainBridge::ChainType::locking;
+
1806  else if (thisDoor == bridgeSpec.issuingChainDoor())
+
1807  dstChain = STXChainBridge::ChainType::issuing;
+
1808  else
+
1809  return Unexpected(tecINTERNAL);
+
1810  }
+
1811  STXChainBridge::ChainType const srcChain =
+
1812  STXChainBridge::otherChain(dstChain);
1813 
-
1814  auto const [signersList, quorum, slTer] =
-
1815  getSignersListAndQuorum(ctx_.view(), *sleBridge, ctx_.journal);
-
1816 
-
1817  if (!isTesSuccess(slTer))
-
1818  return Unexpected(slTer);
+
1814  auto const sendingAmount = [&]() -> STAmount {
+
1815  STAmount r(thisChainAmount);
+
1816  r.setIssue(bridgeSpec.issue(srcChain));
+
1817  return r;
+
1818  }();
1819 
-
1820  XChainClaimAttestations curAtts{
-
1821  sleClaimID->getFieldArray(sfXChainClaimAttestations)};
+
1820  auto const [signersList, quorum, slTer] =
+
1821  getSignersListAndQuorum(ctx_.view(), *sleBridge, ctx_.journal);
1822 
-
1823  auto const claimR = onClaim(
-
1824  curAtts,
-
1825  psb,
-
1826  sendingAmount,
-
1827  /*wasLockingChainSend*/ srcChain ==
-
1828  STXChainBridge::ChainType::locking,
-
1829  quorum,
-
1830  signersList,
-
1831  ctx_.journal);
-
1832  if (!claimR.has_value())
-
1833  return Unexpected(claimR.error());
-
1834 
-
1835  return ScopeResult{
-
1836  claimR.value(),
-
1837  (*sleClaimID)[sfAccount],
-
1838  sendingAmount,
-
1839  srcChain,
-
1840  (*sleClaimID)[sfSignatureReward],
-
1841  };
-
1842  }();
-
1843 
-
1844  if (!scopeResult.has_value())
-
1845  return scopeResult.error();
-
1846 
-
1847  auto const& [rewardAccounts, rewardPoolSrc, sendingAmount, srcChain, signatureReward] =
-
1848  scopeResult.value();
-
1849  std::optional<std::uint32_t> const dstTag = ctx_.tx[~sfDestinationTag];
-
1850 
-
1851  auto const r = finalizeClaimHelper(
-
1852  psb,
-
1853  bridgeSpec,
-
1854  dst,
-
1855  dstTag,
-
1856  /*claimOwner*/ account,
-
1857  sendingAmount,
-
1858  rewardPoolSrc,
-
1859  signatureReward,
-
1860  rewardAccounts,
-
1861  srcChain,
-
1862  claimIDKeylet,
-
1863  OnTransferFail::keepClaim,
-
1864  DepositAuthPolicy::dstCanBypass,
-
1865  ctx_.journal);
-
1866  if (!r.isTesSuccess())
-
1867  return r.ter();
-
1868 
-
1869  psb.apply(ctx_.rawView());
-
1870 
-
1871  return tesSUCCESS;
-
1872 }
-
1873 
-
1874 //------------------------------------------------------------------------------
-
1875 
-
1876 TxConsequences
-
1877 XChainCommit::makeTxConsequences(PreflightContext const& ctx)
-
1878 {
-
1879  auto const maxSpend = [&] {
-
1880  auto const amount = ctx.tx[sfAmount];
-
1881  if (amount.native() && amount.signum() > 0)
-
1882  return amount.xrp();
-
1883  return XRPAmount{beast::zero};
-
1884  }();
-
1885 
-
1886  return TxConsequences{ctx.tx, maxSpend};
-
1887 }
-
1888 
-
1889 NotTEC
-
1890 XChainCommit::preflight(PreflightContext const& ctx)
-
1891 {
-
1892  if (!ctx.rules.enabled(featureXChainBridge))
-
1893  return temDISABLED;
+
1823  if (!isTesSuccess(slTer))
+
1824  return Unexpected(slTer);
+
1825 
+
1826  XChainClaimAttestations curAtts{
+
1827  sleClaimID->getFieldArray(sfXChainClaimAttestations)};
+
1828 
+
1829  auto const claimR = onClaim(
+
1830  curAtts,
+
1831  psb,
+
1832  sendingAmount,
+
1833  /*wasLockingChainSend*/ srcChain ==
+
1834  STXChainBridge::ChainType::locking,
+
1835  quorum,
+
1836  signersList,
+
1837  ctx_.journal);
+
1838  if (!claimR.has_value())
+
1839  return Unexpected(claimR.error());
+
1840 
+
1841  return ScopeResult{
+
1842  claimR.value(),
+
1843  (*sleClaimID)[sfAccount],
+
1844  sendingAmount,
+
1845  srcChain,
+
1846  (*sleClaimID)[sfSignatureReward],
+
1847  };
+
1848  }();
+
1849 
+
1850  if (!scopeResult.has_value())
+
1851  return scopeResult.error();
+
1852 
+
1853  auto const& [rewardAccounts, rewardPoolSrc, sendingAmount, srcChain, signatureReward] =
+
1854  scopeResult.value();
+
1855  std::optional<std::uint32_t> const dstTag = ctx_.tx[~sfDestinationTag];
+
1856 
+
1857  auto const r = finalizeClaimHelper(
+
1858  psb,
+
1859  bridgeSpec,
+
1860  dst,
+
1861  dstTag,
+
1862  /*claimOwner*/ account,
+
1863  sendingAmount,
+
1864  rewardPoolSrc,
+
1865  signatureReward,
+
1866  rewardAccounts,
+
1867  srcChain,
+
1868  claimIDKeylet,
+
1869  OnTransferFail::keepClaim,
+
1870  DepositAuthPolicy::dstCanBypass,
+
1871  ctx_.journal);
+
1872  if (!r.isTesSuccess())
+
1873  return r.ter();
+
1874 
+
1875  psb.apply(ctx_.rawView());
+
1876 
+
1877  return tesSUCCESS;
+
1878 }
+
1879 
+
1880 //------------------------------------------------------------------------------
+
1881 
+
1882 TxConsequences
+
1883 XChainCommit::makeTxConsequences(PreflightContext const& ctx)
+
1884 {
+
1885  auto const maxSpend = [&] {
+
1886  auto const amount = ctx.tx[sfAmount];
+
1887  if (amount.native() && amount.signum() > 0)
+
1888  return amount.xrp();
+
1889  return XRPAmount{beast::zero};
+
1890  }();
+
1891 
+
1892  return TxConsequences{ctx.tx, maxSpend};
+
1893 }
1894 
-
1895  if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
-
1896  return ret;
-
1897 
-
1898  if (ctx.tx.getFlags() & tfUniversalMask)
-
1899  return temINVALID_FLAG;
+
1895 NotTEC
+
1896 XChainCommit::preflight(PreflightContext const& ctx)
+
1897 {
+
1898  if (!ctx.rules.enabled(featureXChainBridge))
+
1899  return temDISABLED;
1900 
-
1901  auto const amount = ctx.tx[sfAmount];
-
1902  auto const bridgeSpec = ctx.tx[sfXChainBridge];
+
1901  if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
+
1902  return ret;
1903 
-
1904  if (amount.signum() <= 0 || !isLegalNet(amount))
-
1905  return temBAD_AMOUNT;
+
1904  if (ctx.tx.getFlags() & tfUniversalMask)
+
1905  return temINVALID_FLAG;
1906 
-
1907  if (amount.issue() != bridgeSpec.lockingChainIssue() &&
-
1908  amount.issue() != bridgeSpec.issuingChainIssue())
-
1909  return temBAD_ISSUER;
-
1910 
-
1911  return preflight2(ctx);
-
1912 }
-
1913 
-
1914 TER
-
1915 XChainCommit::preclaim(PreclaimContext const& ctx)
-
1916 {
-
1917  auto const bridgeSpec = ctx.tx[sfXChainBridge];
-
1918  auto const amount = ctx.tx[sfAmount];
+
1907  auto const amount = ctx.tx[sfAmount];
+
1908  auto const bridgeSpec = ctx.tx[sfXChainBridge];
+
1909 
+
1910  if (amount.signum() <= 0 || !isLegalNet(amount))
+
1911  return temBAD_AMOUNT;
+
1912 
+
1913  if (amount.issue() != bridgeSpec.lockingChainIssue() &&
+
1914  amount.issue() != bridgeSpec.issuingChainIssue())
+
1915  return temBAD_ISSUER;
+
1916 
+
1917  return preflight2(ctx);
+
1918 }
1919 
-
1920  auto const sleBridge = readBridge(ctx.view, bridgeSpec);
-
1921  if (!sleBridge)
-
1922  {
-
1923  return tecNO_ENTRY;
-
1924  }
+
1920 TER
+
1921 XChainCommit::preclaim(PreclaimContext const& ctx)
+
1922 {
+
1923  auto const bridgeSpec = ctx.tx[sfXChainBridge];
+
1924  auto const amount = ctx.tx[sfAmount];
1925 
-
1926  AccountID const thisDoor = (*sleBridge)[sfAccount];
-
1927  AccountID const account = ctx.tx[sfAccount];
-
1928 
-
1929  if (thisDoor == account)
-
1930  {
-
1931  // Door account can't lock funds onto itself
-
1932  return tecXCHAIN_SELF_COMMIT;
-
1933  }
+
1926  auto const sleBridge = readBridge(ctx.view, bridgeSpec);
+
1927  if (!sleBridge)
+
1928  {
+
1929  return tecNO_ENTRY;
+
1930  }
+
1931 
+
1932  AccountID const thisDoor = (*sleBridge)[sfAccount];
+
1933  AccountID const account = ctx.tx[sfAccount];
1934 
-
1935  bool isLockingChain = false;
+
1935  if (thisDoor == account)
1936  {
-
1937  if (thisDoor == bridgeSpec.lockingChainDoor())
-
1938  isLockingChain = true;
-
1939  else if (thisDoor == bridgeSpec.issuingChainDoor())
-
1940  isLockingChain = false;
-
1941  else
-
1942  return tecINTERNAL;
-
1943  }
-
1944 
-
1945  if (isLockingChain)
-
1946  {
-
1947  if (bridgeSpec.lockingChainIssue() != ctx.tx[sfAmount].issue())
-
1948  return tecXCHAIN_BAD_TRANSFER_ISSUE;
+
1937  // Door account can't lock funds onto itself
+
1938  return tecXCHAIN_SELF_COMMIT;
+
1939  }
+
1940 
+
1941  bool isLockingChain = false;
+
1942  {
+
1943  if (thisDoor == bridgeSpec.lockingChainDoor())
+
1944  isLockingChain = true;
+
1945  else if (thisDoor == bridgeSpec.issuingChainDoor())
+
1946  isLockingChain = false;
+
1947  else
+
1948  return tecINTERNAL;
1949  }
-
1950  else
-
1951  {
-
1952  if (bridgeSpec.issuingChainIssue() != ctx.tx[sfAmount].issue())
-
1953  return tecXCHAIN_BAD_TRANSFER_ISSUE;
-
1954  }
-
1955 
-
1956  return tesSUCCESS;
-
1957 }
-
1958 
-
1959 TER
-
1960 XChainCommit::doApply()
-
1961 {
-
1962  PaymentSandbox psb(&ctx_.view());
-
1963 
-
1964  auto const account = ctx_.tx[sfAccount];
-
1965  auto const amount = ctx_.tx[sfAmount];
-
1966  auto const bridgeSpec = ctx_.tx[sfXChainBridge];
-
1967 
-
1968  if (!psb.read(keylet::account(account)))
-
1969  return tecINTERNAL;
-
1970 
-
1971  auto const sleBridge = readBridge(psb, bridgeSpec);
-
1972  if (!sleBridge)
-
1973  return tecINTERNAL;
-
1974 
-
1975  auto const dst = (*sleBridge)[sfAccount];
+
1950 
+
1951  if (isLockingChain)
+
1952  {
+
1953  if (bridgeSpec.lockingChainIssue() != ctx.tx[sfAmount].issue())
+
1954  return tecXCHAIN_BAD_TRANSFER_ISSUE;
+
1955  }
+
1956  else
+
1957  {
+
1958  if (bridgeSpec.issuingChainIssue() != ctx.tx[sfAmount].issue())
+
1959  return tecXCHAIN_BAD_TRANSFER_ISSUE;
+
1960  }
+
1961 
+
1962  return tesSUCCESS;
+
1963 }
+
1964 
+
1965 TER
+
1966 XChainCommit::doApply()
+
1967 {
+
1968  PaymentSandbox psb(&ctx_.view());
+
1969 
+
1970  auto const account = ctx_.tx[sfAccount];
+
1971  auto const amount = ctx_.tx[sfAmount];
+
1972  auto const bridgeSpec = ctx_.tx[sfXChainBridge];
+
1973 
+
1974  if (!psb.read(keylet::account(account)))
+
1975  return tecINTERNAL;
1976 
-
1977  // Support dipping into reserves to pay the fee
-
1978  TransferHelperSubmittingAccountInfo submittingAccountInfo{
-
1979  account_, mPriorBalance, mSourceBalance};
+
1977  auto const sleBridge = readBridge(psb, bridgeSpec);
+
1978  if (!sleBridge)
+
1979  return tecINTERNAL;
1980 
-
1981  auto const thTer = transferHelper(
-
1982  psb,
-
1983  account,
-
1984  dst,
-
1985  /*dstTag*/ std::nullopt,
-
1986  /*claimOwner*/ std::nullopt,
-
1987  amount,
-
1988  CanCreateDstPolicy::no,
-
1989  DepositAuthPolicy::normal,
-
1990  submittingAccountInfo,
-
1991  ctx_.journal);
-
1992 
-
1993  if (!isTesSuccess(thTer))
-
1994  return thTer;
-
1995 
-
1996  psb.apply(ctx_.rawView());
-
1997 
-
1998  return tesSUCCESS;
-
1999 }
-
2000 
-
2001 //------------------------------------------------------------------------------
-
2002 
-
2003 NotTEC
-
2004 XChainCreateClaimID::preflight(PreflightContext const& ctx)
-
2005 {
-
2006  if (!ctx.rules.enabled(featureXChainBridge))
-
2007  return temDISABLED;
+
1981  auto const dst = (*sleBridge)[sfAccount];
+
1982 
+
1983  // Support dipping into reserves to pay the fee
+
1984  TransferHelperSubmittingAccountInfo submittingAccountInfo{
+
1985  account_, mPriorBalance, mSourceBalance};
+
1986 
+
1987  auto const thTer = transferHelper(
+
1988  psb,
+
1989  account,
+
1990  dst,
+
1991  /*dstTag*/ std::nullopt,
+
1992  /*claimOwner*/ std::nullopt,
+
1993  amount,
+
1994  CanCreateDstPolicy::no,
+
1995  DepositAuthPolicy::normal,
+
1996  submittingAccountInfo,
+
1997  ctx_.journal);
+
1998 
+
1999  if (!isTesSuccess(thTer))
+
2000  return thTer;
+
2001 
+
2002  psb.apply(ctx_.rawView());
+
2003 
+
2004  return tesSUCCESS;
+
2005 }
+
2006 
+
2007 //------------------------------------------------------------------------------
2008 
-
2009  if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
-
2010  return ret;
-
2011 
-
2012  if (ctx.tx.getFlags() & tfUniversalMask)
-
2013  return temINVALID_FLAG;
+
2009 NotTEC
+
2010 XChainCreateClaimID::preflight(PreflightContext const& ctx)
+
2011 {
+
2012  if (!ctx.rules.enabled(featureXChainBridge))
+
2013  return temDISABLED;
2014 
-
2015  auto const reward = ctx.tx[sfSignatureReward];
-
2016 
-
2017  if (!isXRP(reward) || reward.signum() < 0 || !isLegalNet(reward))
-
2018  return temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT;
-
2019 
-
2020  return preflight2(ctx);
-
2021 }
+
2015  if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
+
2016  return ret;
+
2017 
+
2018  if (ctx.tx.getFlags() & tfUniversalMask)
+
2019  return temINVALID_FLAG;
+
2020 
+
2021  auto const reward = ctx.tx[sfSignatureReward];
2022 
-
2023 TER
-
2024 XChainCreateClaimID::preclaim(PreclaimContext const& ctx)
-
2025 {
-
2026  auto const account = ctx.tx[sfAccount];
-
2027  auto const bridgeSpec = ctx.tx[sfXChainBridge];
-
2028  auto const sleBridge = readBridge(ctx.view, bridgeSpec);
-
2029 
-
2030  if (!sleBridge)
-
2031  {
-
2032  return tecNO_ENTRY;
-
2033  }
-
2034 
-
2035  // Check that the reward matches
-
2036  auto const reward = ctx.tx[sfSignatureReward];
-
2037 
-
2038  if (reward != (*sleBridge)[sfSignatureReward])
-
2039  {
-
2040  return tecXCHAIN_REWARD_MISMATCH;
-
2041  }
-
2042 
-
2043  {
-
2044  // Check reserve
-
2045  auto const sleAcc = ctx.view.read(keylet::account(account));
-
2046  if (!sleAcc)
-
2047  return terNO_ACCOUNT;
+
2023  if (!isXRP(reward) || reward.signum() < 0 || !isLegalNet(reward))
+
2024  return temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT;
+
2025 
+
2026  return preflight2(ctx);
+
2027 }
+
2028 
+
2029 TER
+
2030 XChainCreateClaimID::preclaim(PreclaimContext const& ctx)
+
2031 {
+
2032  auto const account = ctx.tx[sfAccount];
+
2033  auto const bridgeSpec = ctx.tx[sfXChainBridge];
+
2034  auto const sleBridge = readBridge(ctx.view, bridgeSpec);
+
2035 
+
2036  if (!sleBridge)
+
2037  {
+
2038  return tecNO_ENTRY;
+
2039  }
+
2040 
+
2041  // Check that the reward matches
+
2042  auto const reward = ctx.tx[sfSignatureReward];
+
2043 
+
2044  if (reward != (*sleBridge)[sfSignatureReward])
+
2045  {
+
2046  return tecXCHAIN_REWARD_MISMATCH;
+
2047  }
2048 
-
2049  auto const balance = (*sleAcc)[sfBalance];
-
2050  auto const reserve =
-
2051  ctx.view.fees().accountReserve((*sleAcc)[sfOwnerCount] + 1);
-
2052 
-
2053  if (balance < reserve)
-
2054  return tecINSUFFICIENT_RESERVE;
-
2055  }
-
2056 
-
2057  return tesSUCCESS;
-
2058 }
-
2059 
-
2060 TER
-
2061 XChainCreateClaimID::doApply()
-
2062 {
-
2063  auto const account = ctx_.tx[sfAccount];
-
2064  auto const bridgeSpec = ctx_.tx[sfXChainBridge];
-
2065  auto const reward = ctx_.tx[sfSignatureReward];
-
2066  auto const otherChainSrc = ctx_.tx[sfOtherChainSource];
-
2067 
-
2068  auto const sleAcct = ctx_.view().peek(keylet::account(account));
-
2069  if (!sleAcct)
-
2070  return tecINTERNAL;
-
2071 
-
2072  auto const sleBridge = peekBridge(ctx_.view(), bridgeSpec);
-
2073  if (!sleBridge)
-
2074  return tecINTERNAL;
-
2075 
-
2076  std::uint32_t const claimID = (*sleBridge)[sfXChainClaimID] + 1;
-
2077  if (claimID == 0)
-
2078  return tecINTERNAL; // overflow
-
2079 
-
2080  (*sleBridge)[sfXChainClaimID] = claimID;
+
2049  {
+
2050  // Check reserve
+
2051  auto const sleAcc = ctx.view.read(keylet::account(account));
+
2052  if (!sleAcc)
+
2053  return terNO_ACCOUNT;
+
2054 
+
2055  auto const balance = (*sleAcc)[sfBalance];
+
2056  auto const reserve =
+
2057  ctx.view.fees().accountReserve((*sleAcc)[sfOwnerCount] + 1);
+
2058 
+
2059  if (balance < reserve)
+
2060  return tecINSUFFICIENT_RESERVE;
+
2061  }
+
2062 
+
2063  return tesSUCCESS;
+
2064 }
+
2065 
+
2066 TER
+
2067 XChainCreateClaimID::doApply()
+
2068 {
+
2069  auto const account = ctx_.tx[sfAccount];
+
2070  auto const bridgeSpec = ctx_.tx[sfXChainBridge];
+
2071  auto const reward = ctx_.tx[sfSignatureReward];
+
2072  auto const otherChainSrc = ctx_.tx[sfOtherChainSource];
+
2073 
+
2074  auto const sleAcct = ctx_.view().peek(keylet::account(account));
+
2075  if (!sleAcct)
+
2076  return tecINTERNAL;
+
2077 
+
2078  auto const sleBridge = peekBridge(ctx_.view(), bridgeSpec);
+
2079  if (!sleBridge)
+
2080  return tecINTERNAL;
2081 
-
2082  Keylet const claimIDKeylet = keylet::xChainClaimID(bridgeSpec, claimID);
-
2083  if (ctx_.view().exists(claimIDKeylet))
-
2084  return tecINTERNAL; // already checked out!?!
+
2082  std::uint32_t const claimID = (*sleBridge)[sfXChainClaimID] + 1;
+
2083  if (claimID == 0)
+
2084  return tecINTERNAL; // overflow
2085 
-
2086  auto const sleClaimID = std::make_shared<SLE>(claimIDKeylet);
+
2086  (*sleBridge)[sfXChainClaimID] = claimID;
2087 
-
2088  (*sleClaimID)[sfAccount] = account;
-
2089  (*sleClaimID)[sfXChainBridge] = bridgeSpec;
-
2090  (*sleClaimID)[sfXChainClaimID] = claimID;
-
2091  (*sleClaimID)[sfOtherChainSource] = otherChainSrc;
-
2092  (*sleClaimID)[sfSignatureReward] = reward;
-
2093  sleClaimID->setFieldArray(
-
2094  sfXChainClaimAttestations, STArray{sfXChainClaimAttestations});
-
2095 
-
2096  // Add to owner directory
-
2097  {
-
2098  auto const page = ctx_.view().dirInsert(
-
2099  keylet::ownerDir(account),
-
2100  claimIDKeylet,
-
2101  describeOwnerDir(account));
-
2102  if (!page)
-
2103  return tecDIR_FULL;
-
2104  (*sleClaimID)[sfOwnerNode] = *page;
-
2105  }
-
2106 
-
2107  adjustOwnerCount(ctx_.view(), sleAcct, 1, ctx_.journal);
-
2108 
-
2109  ctx_.view().insert(sleClaimID);
-
2110  ctx_.view().update(sleBridge);
-
2111  ctx_.view().update(sleAcct);
+
2088  Keylet const claimIDKeylet = keylet::xChainClaimID(bridgeSpec, claimID);
+
2089  if (ctx_.view().exists(claimIDKeylet))
+
2090  return tecINTERNAL; // already checked out!?!
+
2091 
+
2092  auto const sleClaimID = std::make_shared<SLE>(claimIDKeylet);
+
2093 
+
2094  (*sleClaimID)[sfAccount] = account;
+
2095  (*sleClaimID)[sfXChainBridge] = bridgeSpec;
+
2096  (*sleClaimID)[sfXChainClaimID] = claimID;
+
2097  (*sleClaimID)[sfOtherChainSource] = otherChainSrc;
+
2098  (*sleClaimID)[sfSignatureReward] = reward;
+
2099  sleClaimID->setFieldArray(
+
2100  sfXChainClaimAttestations, STArray{sfXChainClaimAttestations});
+
2101 
+
2102  // Add to owner directory
+
2103  {
+
2104  auto const page = ctx_.view().dirInsert(
+
2105  keylet::ownerDir(account),
+
2106  claimIDKeylet,
+
2107  describeOwnerDir(account));
+
2108  if (!page)
+
2109  return tecDIR_FULL;
+
2110  (*sleClaimID)[sfOwnerNode] = *page;
+
2111  }
2112 
-
2113  return tesSUCCESS;
-
2114 }
-
2115 
-
2116 //------------------------------------------------------------------------------
-
2117 
-
2118 NotTEC
-
2119 XChainAddClaimAttestation::preflight(PreflightContext const& ctx)
-
2120 {
-
2121  return attestationPreflight<Attestations::AttestationClaim>(ctx);
-
2122 }
+
2113  adjustOwnerCount(ctx_.view(), sleAcct, 1, ctx_.journal);
+
2114 
+
2115  ctx_.view().insert(sleClaimID);
+
2116  ctx_.view().update(sleBridge);
+
2117  ctx_.view().update(sleAcct);
+
2118 
+
2119  return tesSUCCESS;
+
2120 }
+
2121 
+
2122 //------------------------------------------------------------------------------
2123 
-
2124 TER
-
2125 XChainAddClaimAttestation::preclaim(PreclaimContext const& ctx)
+
2124 NotTEC
+
2125 XChainAddClaimAttestation::preflight(PreflightContext const& ctx)
2126 {
-
2127  return attestationPreclaim<Attestations::AttestationClaim>(ctx);
+
2127  return attestationPreflight<Attestations::AttestationClaim>(ctx);
2128 }
2129 
2130 TER
-
2131 XChainAddClaimAttestation::doApply()
+
2131 XChainAddClaimAttestation::preclaim(PreclaimContext const& ctx)
2132 {
-
2133  return attestationDoApply<Attestations::AttestationClaim>(ctx_);
+
2133  return attestationPreclaim<Attestations::AttestationClaim>(ctx);
2134 }
2135 
-
2136 //------------------------------------------------------------------------------
-
2137 
-
2138 NotTEC
-
2139 XChainAddAccountCreateAttestation::preflight(PreflightContext const& ctx)
-
2140 {
-
2141  return attestationPreflight<Attestations::AttestationCreateAccount>(ctx);
-
2142 }
+
2136 TER
+
2137 XChainAddClaimAttestation::doApply()
+
2138 {
+
2139  return attestationDoApply<Attestations::AttestationClaim>(ctx_);
+
2140 }
+
2141 
+
2142 //------------------------------------------------------------------------------
2143 
-
2144 TER
-
2145 XChainAddAccountCreateAttestation::preclaim(PreclaimContext const& ctx)
+
2144 NotTEC
+
2145 XChainAddAccountCreateAttestation::preflight(PreflightContext const& ctx)
2146 {
-
2147  return attestationPreclaim<Attestations::AttestationCreateAccount>(ctx);
+
2147  return attestationPreflight<Attestations::AttestationCreateAccount>(ctx);
2148 }
2149 
2150 TER
-
2151 XChainAddAccountCreateAttestation::doApply()
+
2151 XChainAddAccountCreateAttestation::preclaim(PreclaimContext const& ctx)
2152 {
-
2153  return attestationDoApply<Attestations::AttestationCreateAccount>(ctx_);
+
2153  return attestationPreclaim<Attestations::AttestationCreateAccount>(ctx);
2154 }
2155 
-
2156 //------------------------------------------------------------------------------
-
2157 
-
2158 NotTEC
-
2159 XChainCreateAccountCommit::preflight(PreflightContext const& ctx)
-
2160 {
-
2161  if (!ctx.rules.enabled(featureXChainBridge))
-
2162  return temDISABLED;
+
2156 TER
+
2157 XChainAddAccountCreateAttestation::doApply()
+
2158 {
+
2159  return attestationDoApply<Attestations::AttestationCreateAccount>(ctx_);
+
2160 }
+
2161 
+
2162 //------------------------------------------------------------------------------
2163 
-
2164  if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
-
2165  return ret;
-
2166 
-
2167  if (ctx.tx.getFlags() & tfUniversalMask)
-
2168  return temINVALID_FLAG;
+
2164 NotTEC
+
2165 XChainCreateAccountCommit::preflight(PreflightContext const& ctx)
+
2166 {
+
2167  if (!ctx.rules.enabled(featureXChainBridge))
+
2168  return temDISABLED;
2169 
-
2170  auto const amount = ctx.tx[sfAmount];
-
2171 
-
2172  if (amount.signum() <= 0 || !amount.native())
-
2173  return temBAD_AMOUNT;
-
2174 
-
2175  auto const reward = ctx.tx[sfSignatureReward];
-
2176  if (reward.signum() < 0 || !reward.native())
-
2177  return temBAD_AMOUNT;
-
2178 
-
2179  if (reward.issue() != amount.issue())
-
2180  return temBAD_AMOUNT;
-
2181 
-
2182  return preflight2(ctx);
-
2183 }
+
2170  if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
+
2171  return ret;
+
2172 
+
2173  if (ctx.tx.getFlags() & tfUniversalMask)
+
2174  return temINVALID_FLAG;
+
2175 
+
2176  auto const amount = ctx.tx[sfAmount];
+
2177 
+
2178  if (amount.signum() <= 0 || !amount.native())
+
2179  return temBAD_AMOUNT;
+
2180 
+
2181  auto const reward = ctx.tx[sfSignatureReward];
+
2182  if (reward.signum() < 0 || !reward.native())
+
2183  return temBAD_AMOUNT;
2184 
-
2185 TER
-
2186 XChainCreateAccountCommit::preclaim(PreclaimContext const& ctx)
-
2187 {
-
2188  STXChainBridge const bridgeSpec = ctx.tx[sfXChainBridge];
-
2189  STAmount const amount = ctx.tx[sfAmount];
-
2190  STAmount const reward = ctx.tx[sfSignatureReward];
-
2191 
-
2192  auto const sleBridge = readBridge(ctx.view, bridgeSpec);
-
2193  if (!sleBridge)
-
2194  {
-
2195  return tecNO_ENTRY;
-
2196  }
+
2185  if (reward.issue() != amount.issue())
+
2186  return temBAD_AMOUNT;
+
2187 
+
2188  return preflight2(ctx);
+
2189 }
+
2190 
+
2191 TER
+
2192 XChainCreateAccountCommit::preclaim(PreclaimContext const& ctx)
+
2193 {
+
2194  STXChainBridge const bridgeSpec = ctx.tx[sfXChainBridge];
+
2195  STAmount const amount = ctx.tx[sfAmount];
+
2196  STAmount const reward = ctx.tx[sfSignatureReward];
2197 
-
2198  if (reward != (*sleBridge)[sfSignatureReward])
-
2199  {
-
2200  return tecXCHAIN_REWARD_MISMATCH;
-
2201  }
-
2202 
-
2203  std::optional<STAmount> const minCreateAmount =
-
2204  (*sleBridge)[~sfMinAccountCreateAmount];
-
2205 
-
2206  if (!minCreateAmount)
-
2207  return tecXCHAIN_CREATE_ACCOUNT_DISABLED;
+
2198  auto const sleBridge = readBridge(ctx.view, bridgeSpec);
+
2199  if (!sleBridge)
+
2200  {
+
2201  return tecNO_ENTRY;
+
2202  }
+
2203 
+
2204  if (reward != (*sleBridge)[sfSignatureReward])
+
2205  {
+
2206  return tecXCHAIN_REWARD_MISMATCH;
+
2207  }
2208 
-
2209  if (amount < *minCreateAmount)
-
2210  return tecXCHAIN_INSUFF_CREATE_AMOUNT;
+
2209  std::optional<STAmount> const minCreateAmount =
+
2210  (*sleBridge)[~sfMinAccountCreateAmount];
2211 
-
2212  if (minCreateAmount->issue() != amount.issue())
-
2213  return tecXCHAIN_BAD_TRANSFER_ISSUE;
+
2212  if (!minCreateAmount)
+
2213  return tecXCHAIN_CREATE_ACCOUNT_DISABLED;
2214 
-
2215  AccountID const thisDoor = (*sleBridge)[sfAccount];
-
2216  AccountID const account = ctx.tx[sfAccount];
-
2217  if (thisDoor == account)
-
2218  {
-
2219  // Door account can't lock funds onto itself
-
2220  return tecXCHAIN_SELF_COMMIT;
-
2221  }
-
2222 
-
2223  STXChainBridge::ChainType srcChain = STXChainBridge::ChainType::locking;
+
2215  if (amount < *minCreateAmount)
+
2216  return tecXCHAIN_INSUFF_CREATE_AMOUNT;
+
2217 
+
2218  if (minCreateAmount->issue() != amount.issue())
+
2219  return tecXCHAIN_BAD_TRANSFER_ISSUE;
+
2220 
+
2221  AccountID const thisDoor = (*sleBridge)[sfAccount];
+
2222  AccountID const account = ctx.tx[sfAccount];
+
2223  if (thisDoor == account)
2224  {
-
2225  if (thisDoor == bridgeSpec.lockingChainDoor())
-
2226  srcChain = STXChainBridge::ChainType::locking;
-
2227  else if (thisDoor == bridgeSpec.issuingChainDoor())
-
2228  srcChain = STXChainBridge::ChainType::issuing;
-
2229  else
-
2230  return tecINTERNAL;
-
2231  }
-
2232  STXChainBridge::ChainType const dstChain =
-
2233  STXChainBridge::otherChain(srcChain);
-
2234 
-
2235  if (bridgeSpec.issue(srcChain) != ctx.tx[sfAmount].issue())
-
2236  return tecXCHAIN_BAD_TRANSFER_ISSUE;
-
2237 
-
2238  if (!isXRP(bridgeSpec.issue(dstChain)))
-
2239  return tecXCHAIN_CREATE_ACCOUNT_NONXRP_ISSUE;
+
2225  // Door account can't lock funds onto itself
+
2226  return tecXCHAIN_SELF_COMMIT;
+
2227  }
+
2228 
+
2229  STXChainBridge::ChainType srcChain = STXChainBridge::ChainType::locking;
+
2230  {
+
2231  if (thisDoor == bridgeSpec.lockingChainDoor())
+
2232  srcChain = STXChainBridge::ChainType::locking;
+
2233  else if (thisDoor == bridgeSpec.issuingChainDoor())
+
2234  srcChain = STXChainBridge::ChainType::issuing;
+
2235  else
+
2236  return tecINTERNAL;
+
2237  }
+
2238  STXChainBridge::ChainType const dstChain =
+
2239  STXChainBridge::otherChain(srcChain);
2240 
-
2241  return tesSUCCESS;
-
2242 }
+
2241  if (bridgeSpec.issue(srcChain) != ctx.tx[sfAmount].issue())
+
2242  return tecXCHAIN_BAD_TRANSFER_ISSUE;
2243 
-
2244 TER
-
2245 XChainCreateAccountCommit::doApply()
-
2246 {
-
2247  PaymentSandbox psb(&ctx_.view());
-
2248 
-
2249  AccountID const account = ctx_.tx[sfAccount];
-
2250  STAmount const amount = ctx_.tx[sfAmount];
-
2251  STAmount const reward = ctx_.tx[sfSignatureReward];
-
2252  STXChainBridge const bridge = ctx_.tx[sfXChainBridge];
-
2253 
-
2254  auto const sle = psb.peek(keylet::account(account));
-
2255  if (!sle)
-
2256  return tecINTERNAL;
-
2257 
-
2258  auto const sleBridge = peekBridge(psb, bridge);
-
2259  if (!sleBridge)
-
2260  return tecINTERNAL;
-
2261 
-
2262  auto const dst = (*sleBridge)[sfAccount];
+
2244  if (!isXRP(bridgeSpec.issue(dstChain)))
+
2245  return tecXCHAIN_CREATE_ACCOUNT_NONXRP_ISSUE;
+
2246 
+
2247  return tesSUCCESS;
+
2248 }
+
2249 
+
2250 TER
+
2251 XChainCreateAccountCommit::doApply()
+
2252 {
+
2253  PaymentSandbox psb(&ctx_.view());
+
2254 
+
2255  AccountID const account = ctx_.tx[sfAccount];
+
2256  STAmount const amount = ctx_.tx[sfAmount];
+
2257  STAmount const reward = ctx_.tx[sfSignatureReward];
+
2258  STXChainBridge const bridge = ctx_.tx[sfXChainBridge];
+
2259 
+
2260  auto const sle = psb.peek(keylet::account(account));
+
2261  if (!sle)
+
2262  return tecINTERNAL;
2263 
-
2264  // Support dipping into reserves to pay the fee
-
2265  TransferHelperSubmittingAccountInfo submittingAccountInfo{
-
2266  account_, mPriorBalance, mSourceBalance};
-
2267  STAmount const toTransfer = amount + reward;
-
2268  auto const thTer = transferHelper(
-
2269  psb,
-
2270  account,
-
2271  dst,
-
2272  /*dstTag*/ std::nullopt,
-
2273  /*claimOwner*/ std::nullopt,
-
2274  toTransfer,
-
2275  CanCreateDstPolicy::yes,
-
2276  DepositAuthPolicy::normal,
-
2277  submittingAccountInfo,
-
2278  ctx_.journal);
-
2279 
-
2280  if (!isTesSuccess(thTer))
-
2281  return thTer;
-
2282 
-
2283  (*sleBridge)[sfXChainAccountCreateCount] =
-
2284  (*sleBridge)[sfXChainAccountCreateCount] + 1;
-
2285  psb.update(sleBridge);
-
2286 
-
2287  psb.apply(ctx_.rawView());
+
2264  auto const sleBridge = peekBridge(psb, bridge);
+
2265  if (!sleBridge)
+
2266  return tecINTERNAL;
+
2267 
+
2268  auto const dst = (*sleBridge)[sfAccount];
+
2269 
+
2270  // Support dipping into reserves to pay the fee
+
2271  TransferHelperSubmittingAccountInfo submittingAccountInfo{
+
2272  account_, mPriorBalance, mSourceBalance};
+
2273  STAmount const toTransfer = amount + reward;
+
2274  auto const thTer = transferHelper(
+
2275  psb,
+
2276  account,
+
2277  dst,
+
2278  /*dstTag*/ std::nullopt,
+
2279  /*claimOwner*/ std::nullopt,
+
2280  toTransfer,
+
2281  CanCreateDstPolicy::yes,
+
2282  DepositAuthPolicy::normal,
+
2283  submittingAccountInfo,
+
2284  ctx_.journal);
+
2285 
+
2286  if (!isTesSuccess(thTer))
+
2287  return thTer;
2288 
-
2289  return tesSUCCESS;
-
2290 }
-
2291 
-
2292 } // namespace ripple
+
2289  (*sleBridge)[sfXChainAccountCreateCount] =
+
2290  (*sleBridge)[sfXChainAccountCreateCount] + 1;
+
2291  psb.update(sleBridge);
+
2292 
+
2293  psb.apply(ctx_.rawView());
+
2294 
+
2295  return tesSUCCESS;
+
2296 }
+
2297 
+
2298 } // namespace ripple
beast::Journal::fatal
Stream fatal() const
Definition: Journal.h:338
-
ripple::XChainClaim::doApply
TER doApply() override
Definition: XChainBridge.cpp:1761
+
ripple::XChainClaim::doApply
TER doApply() override
Definition: XChainBridge.cpp:1767
ripple::temXCHAIN_BAD_PROOF
@ temXCHAIN_BAD_PROOF
Definition: TER.h:130
ripple::keylet::ownerDir
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition: Indexes.cpp:311
ripple::tecXCHAIN_ACCOUNT_CREATE_TOO_MANY
@ tecXCHAIN_ACCOUNT_CREATE_TOO_MANY
Definition: TER.h:326
@@ -2310,10 +2316,10 @@ $(function() {
ripple::tecXCHAIN_SENDING_ACCOUNT_MISMATCH
@ tecXCHAIN_SENDING_ACCOUNT_MISMATCH
Definition: TER.h:323
ripple::temXCHAIN_EQUAL_DOOR_ACCOUNTS
@ temXCHAIN_EQUAL_DOOR_ACCOUNTS
Definition: TER.h:129
ripple::Unexpected
Unexpected(E(&)[N]) -> Unexpected< E const * >
-
ripple::XChainCreateClaimID::doApply
TER doApply() override
Definition: XChainBridge.cpp:2061
+
ripple::XChainCreateClaimID::doApply
TER doApply() override
Definition: XChainBridge.cpp:2067
ripple::tecDST_TAG_NEEDED
@ tecDST_TAG_NEEDED
Definition: TER.h:287
ripple::detail::ApplyViewBase::update
void update(std::shared_ptr< SLE > const &sle) override
Indicate changes to a peeked SLE.
Definition: ApplyViewBase.cpp:146
-
ripple::XChainCommit::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:1915
+
ripple::XChainCommit::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:1921
ripple::STXChainBridge::ChainType::locking
@ locking
ripple::sfOtherChainSource
const SF_ACCOUNT sfOtherChainSource
ripple::tecXCHAIN_NO_CLAIM_ID
@ tecXCHAIN_NO_CLAIM_ID
Definition: TER.h:315
@@ -2328,7 +2334,7 @@ $(function() {
ripple::sfXChainAccountClaimCount
const SF_UINT64 sfXChainAccountClaimCount
ripple::temBAD_ISSUER
@ temBAD_ISSUER
Definition: TER.h:91
ripple::lsfAllowTrustLineClawback
@ lsfAllowTrustLineClawback
Definition: LedgerFormats.h:272
-
ripple::XChainAddClaimAttestation::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:2125
+
ripple::XChainAddClaimAttestation::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:2131
ripple::isTecClaim
bool isTecClaim(TER x)
Definition: TER.h:639
ripple::temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT
@ temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT
Definition: TER.h:134
ripple::generateKeyPair
std::pair< PublicKey, SecretKey > generateKeyPair(KeyType type, Seed const &seed)
Generate a key pair deterministically.
Definition: SecretKey.cpp:351
@@ -2350,12 +2356,12 @@ $(function() {
ripple::XChainCreateBridge::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:1367
ripple::tefBAD_LEDGER
@ tefBAD_LEDGER
Definition: TER.h:161
ripple::adjustOwnerCount
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
Definition: View.cpp:730
-
ripple::XChainCreateAccountCommit::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:2186
+
ripple::XChainCreateAccountCommit::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:2192
ripple::STXChainBridge::issuingChainIssue
Issue const & issuingChainIssue() const
Definition: STXChainBridge.h:182
ripple::Expected
Definition: Expected.h:132
ripple::sfSignatureReward
const SF_AMOUNT sfSignatureReward
ripple::keylet::account
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition: Indexes.cpp:141
-
ripple::XChainCreateAccountCommit::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:2159
+
ripple::XChainCreateAccountCommit::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:2165
ripple::sfXChainClaimAttestations
const SField sfXChainClaimAttestations
ripple::tecDUPLICATE
@ tecDUPLICATE
Definition: TER.h:293
ripple::keylet::bridge
Keylet bridge(STXChainBridge const &bridge, STXChainBridge::ChainType chainType)
Definition: Indexes.cpp:400
@@ -2364,7 +2370,7 @@ $(function() {
ripple::isTefFailure
bool isTefFailure(TER x)
Definition: TER.h:621
ripple::XChainCreateBridge::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:1451
ripple::calcAccountID
AccountID calcAccountID(PublicKey const &pk)
Definition: AccountID.cpp:158
-
ripple::XChainCreateClaimID::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:2004
+
ripple::XChainCreateClaimID::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:2010
ripple::STArray
Definition: STArray.h:28
ripple::flow
path::RippleCalc::Output flow(PaymentSandbox &sb, STAmount const &deliver, AccountID const &src, AccountID const &dst, STPathSet const &paths, bool defaultPaths, bool partialPayment, bool ownerPaysTransferFee, bool offerCrossing, std::optional< Quality > const &limitQuality, std::optional< STAmount > const &sendMax, beast::Journal j, path::detail::FlowDebugInfo *flowDebugInfo)
Make a payment from the src account to the dst account.
Definition: Flow.cpp:59
ripple::TER
TERSubset< CanCvtToTER > TER
Definition: TER.h:604
@@ -2374,7 +2380,7 @@ $(function() {
ripple::ReadView::exists
virtual bool exists(Keylet const &k) const =0
Determine if a state item exists.
ripple::tecINTERNAL
@ tecINTERNAL
Definition: TER.h:288
ripple::STObject::getFlags
std::uint32_t getFlags() const
Definition: STObject.cpp:481
-
ripple::XChainClaim::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:1677
+
ripple::XChainClaim::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:1683
ripple::isXRP
bool isXRP(AccountID const &c)
Definition: AccountID.h:91
ripple::tecXCHAIN_PAYMENT_FAILED
@ tecXCHAIN_PAYMENT_FAILED
Definition: TER.h:327
ripple::temBAD_AMOUNT
@ temBAD_AMOUNT
Definition: TER.h:87
@@ -2387,7 +2393,7 @@ $(function() {
ripple::XChainClaimAttestations
Definition: XChainAttestations.h:488
ripple::featureXChainBridge
const uint256 featureXChainBridge
ripple::ReadView::read
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
-
ripple::BridgeModify::doApply
TER doApply() override
Definition: XChainBridge.cpp:1612
+
ripple::BridgeModify::doApply
TER doApply() override
Definition: XChainBridge.cpp:1618
ripple::ApplyContext::view
ApplyView & view()
Definition: ApplyContext.h:54
ripple::STXChainBridge::lockingChainDoor
AccountID const & lockingChainDoor() const
Definition: STXChainBridge.h:164
ripple::PreclaimContext::tx
STTx const & tx
Definition: Transactor.h:58
@@ -2403,31 +2409,31 @@ $(function() {
ripple::sfMinAccountCreateAmount
const SF_AMOUNT sfMinAccountCreateAmount
ripple::ApplyView::insert
virtual void insert(std::shared_ptr< SLE > const &sle)=0
Insert a new state SLE.
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
-
ripple::XChainCreateClaimID::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:2024
+
ripple::XChainCreateClaimID::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:2030
ripple::tfClearAccountCreateAmount
constexpr std::uint32_t tfClearAccountCreateAmount
Definition: TxFlags.h:185
-
ripple::XChainCreateAccountCommit::doApply
TER doApply() override
Definition: XChainBridge.cpp:2245
+
ripple::XChainCreateAccountCommit::doApply
TER doApply() override
Definition: XChainBridge.cpp:2251
ripple::tecXCHAIN_CREATE_ACCOUNT_DISABLED
@ tecXCHAIN_CREATE_ACCOUNT_DISABLED
Definition: TER.h:330
ripple::ltBRIDGE
@ ltBRIDGE
The ledger object which lists details about sidechains.
Definition: LedgerFormats.h:99
ripple::tecXCHAIN_SELF_COMMIT
@ tecXCHAIN_SELF_COMMIT
Definition: TER.h:328
ripple::temDISABLED
@ temDISABLED
Definition: TER.h:112
ripple::PaymentSandbox::apply
void apply(RawView &to)
Apply changes to base view.
Definition: PaymentSandbox.cpp:254
ripple::Fees::accountReserve
XRPAmount accountReserve(std::size_t ownerCount) const
Returns the account reserve given the owner count, in drops.
Definition: protocol/Fees.h:49
-
ripple::XChainAddAccountCreateAttestation::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:2145
+
ripple::XChainAddAccountCreateAttestation::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:2151
ripple::tecXCHAIN_REWARD_MISMATCH
@ tecXCHAIN_REWARD_MISMATCH
Definition: TER.h:321
ripple::sfFlags
const SF_UINT32 sfFlags
-
ripple::XChainCommit::makeTxConsequences
static TxConsequences makeTxConsequences(PreflightContext const &ctx)
Definition: XChainBridge.cpp:1877
+
ripple::XChainCommit::makeTxConsequences
static TxConsequences makeTxConsequences(PreflightContext const &ctx)
Definition: XChainBridge.cpp:1883
ripple::tecNO_ISSUER
@ tecNO_ISSUER
Definition: TER.h:277
ripple::sfDestinationTag
const SF_UINT32 sfDestinationTag
-
ripple::XChainCommit::doApply
TER doApply() override
Definition: XChainBridge.cpp:1960
+
ripple::XChainCommit::doApply
TER doApply() override
Definition: XChainBridge.cpp:1966
ripple::Transactor::mPriorBalance
XRPAmount mPriorBalance
Definition: Transactor.h:92
ripple::tecNO_PERMISSION
@ tecNO_PERMISSION
Definition: TER.h:283
ripple::Transactor::mSourceBalance
XRPAmount mSourceBalance
Definition: Transactor.h:93
-
ripple::XChainAddClaimAttestation::doApply
TER doApply() override
Definition: XChainBridge.cpp:2131
+
ripple::XChainAddClaimAttestation::doApply
TER doApply() override
Definition: XChainBridge.cpp:2137
ripple::sfXChainAccountCreateCount
const SF_UINT64 sfXChainAccountCreateCount
ripple::sfBalance
const SF_AMOUNT sfBalance
-
ripple::XChainCommit::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:1890
-
ripple::XChainCreateBridge::doApply
TER doApply() override
Definition: XChainBridge.cpp:1496
-
ripple::XChainAddAccountCreateAttestation::doApply
TER doApply() override
Definition: XChainBridge.cpp:2151
+
ripple::XChainCommit::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:1896
+
ripple::XChainCreateBridge::doApply
TER doApply() override
Definition: XChainBridge.cpp:1502
+
ripple::XChainAddAccountCreateAttestation::doApply
TER doApply() override
Definition: XChainBridge.cpp:2157
ripple::keylet::xChainCreateAccountClaimID
Keylet xChainCreateAccountClaimID(STXChainBridge const &bridge, std::uint64_t seq)
Definition: Indexes.cpp:427
ripple::tecINSUFFICIENT_RESERVE
@ tecINSUFFICIENT_RESERVE
Definition: TER.h:285
std::vector::empty
T empty(T... args)
@@ -2435,8 +2441,8 @@ $(function() {
ripple::Transactor::ctx_
ApplyContext & ctx_
Definition: Transactor.h:88
ripple::AttestationMatch
AttestationMatch
Definition: XChainAttestations.h:258
std::optional
-
ripple::XChainAddClaimAttestation::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:2119
-
ripple::BridgeModify::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:1595
+
ripple::XChainAddClaimAttestation::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:2125
+
ripple::BridgeModify::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:1601
ripple::temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT
@ temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT
Definition: TER.h:133
ripple::detail::ApplyViewBase::read
std::shared_ptr< SLE const > read(Keylet const &k) const override
Return the state item associated with a key.
Definition: ApplyViewBase.cpp:71
ripple::sfAccount
const SF_ACCOUNT sfAccount
@@ -2449,10 +2455,10 @@ $(function() {
std::numeric_limits::max
T max(T... args)
ripple::PreflightContext
State information when preflighting a tx.
Definition: Transactor.h:31
ripple::keylet::signers
static Keylet signers(AccountID const &account, std::uint32_t page) noexcept
Definition: Indexes.cpp:276
-
ripple::XChainClaim::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:1652
+
ripple::XChainClaim::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:1658
ripple::ApplyView::dirInsert
std::optional< std::uint64_t > dirInsert(Keylet const &directory, uint256 const &key, std::function< void(std::shared_ptr< SLE > const &)> const &describe)
Insert an entry to a directory.
Definition: ApplyView.h:306
ripple::PreflightContext::rules
const Rules rules
Definition: Transactor.h:36
-
ripple::BridgeModify::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:1542
+
ripple::BridgeModify::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:1548
ripple::tfUniversalMask
constexpr std::uint32_t tfUniversalMask
Definition: TxFlags.h:60
unordered_map
ripple::keylet::depositPreauth
Keylet depositPreauth(AccountID const &owner, AccountID const &preauthorized) noexcept
A DepositPreauth.
Definition: Indexes.cpp:295
@@ -2466,7 +2472,7 @@ $(function() {
ripple::ApplyContext::tx
STTx const & tx
Definition: ApplyContext.h:48
ripple::AccountID
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition: AccountID.h:49
ripple::tecNO_DST
@ tecNO_DST
Definition: TER.h:268
-
ripple::XChainAddAccountCreateAttestation::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:2139
+
ripple::XChainAddAccountCreateAttestation::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:2145
ripple::XRPAmount
Definition: XRPAmount.h:46
ripple::NotTEC
TERSubset< CanCvtToNotTEC > NotTEC
Definition: TER.h:564
ripple::tecXCHAIN_INSUFF_CREATE_AMOUNT
@ tecXCHAIN_INSUFF_CREATE_AMOUNT
Definition: TER.h:324
diff --git a/XChainBridge_8h_source.html b/XChainBridge_8h_source.html index 888caf3001..5ee1bd751a 100644 --- a/XChainBridge_8h_source.html +++ b/XChainBridge_8h_source.html @@ -325,7 +325,7 @@ $(function() {
254 
255 #endif
-
ripple::XChainClaim::doApply
TER doApply() override
Definition: XChainBridge.cpp:1761
+
ripple::XChainClaim::doApply
TER doApply() override
Definition: XChainBridge.cpp:1767
ripple::Transactor::Blocker
@ Blocker
Definition: Transactor.h:101
ripple::XChainClaim
Definition: XChainBridge.h:81
ripple::XChainCommit::ConsequencesFactory
static constexpr ConsequencesFactoryType ConsequencesFactory
Definition: XChainBridge.h:109
@@ -334,26 +334,26 @@ $(function() {
ripple::XChainCreateBridge::ConsequencesFactory
static constexpr ConsequencesFactoryType ConsequencesFactory
Definition: XChainBridge.h:36
ripple::XChainCreateAccountCommit::ConsequencesFactory
static constexpr ConsequencesFactoryType ConsequencesFactory
Definition: XChainBridge.h:235
ripple::XChainCreateClaimID::ConsequencesFactory
static constexpr ConsequencesFactoryType ConsequencesFactory
Definition: XChainBridge.h:141
-
ripple::XChainCreateClaimID::doApply
TER doApply() override
Definition: XChainBridge.cpp:2061
-
ripple::XChainCommit::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:1915
+
ripple::XChainCreateClaimID::doApply
TER doApply() override
Definition: XChainBridge.cpp:2067
+
ripple::XChainCommit::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:1921
ripple::BridgeModify
Definition: XChainBridge.h:52
ripple::XChainCreateAccountCommit::XChainCreateAccountCommit
XChainCreateAccountCommit(ApplyContext &ctx)
Definition: XChainBridge.h:237
ripple::XChainCommit::XChainCommit
XChainCommit(ApplyContext &ctx)
Definition: XChainBridge.h:114
ripple::XChainCommit
Definition: XChainBridge.h:106
-
ripple::XChainAddClaimAttestation::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:2125
+
ripple::XChainAddClaimAttestation::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:2131
ripple::XChainCreateBridge::XChainCreateBridge
XChainCreateBridge(ApplyContext &ctx)
Definition: XChainBridge.h:38
ripple::XChainCreateBridge::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:1367
-
ripple::XChainCreateAccountCommit::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:2186
+
ripple::XChainCreateAccountCommit::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:2192
ripple::Transactor::ConsequencesFactoryType
ConsequencesFactoryType
Definition: Transactor.h:101
ripple::XChainClaim::XChainClaim
XChainClaim(ApplyContext &ctx)
Definition: XChainBridge.h:87
-
ripple::XChainCreateAccountCommit::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:2159
+
ripple::XChainCreateAccountCommit::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:2165
ripple::TERSubset
Definition: TER.h:376
ripple::XChainCreateBridge::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:1451
-
ripple::XChainCreateClaimID::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:2004
-
ripple::XChainClaim::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:1677
+
ripple::XChainCreateClaimID::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:2010
+
ripple::XChainClaim::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:1683
ripple::ApplyContext
State information when applying a tx.
Definition: ApplyContext.h:35
ripple::XChainAddAccountCreateAttestation::XChainAddAccountCreateAttestation
XChainAddAccountCreateAttestation(ApplyContext &ctx)
Definition: XChainBridge.h:192
-
ripple::BridgeModify::doApply
TER doApply() override
Definition: XChainBridge.cpp:1612
+
ripple::BridgeModify::doApply
TER doApply() override
Definition: XChainBridge.cpp:1618
ripple::XChainClaim::ConsequencesFactory
static constexpr ConsequencesFactoryType ConsequencesFactory
Definition: XChainBridge.h:85
ripple::XChainAddClaimAttestation::XChainAddClaimAttestation
XChainAddClaimAttestation(ApplyContext &ctx)
Definition: XChainBridge.h:172
ripple::BridgeModify::ConsequencesFactory
static constexpr ConsequencesFactoryType ConsequencesFactory
Definition: XChainBridge.h:55
@@ -364,28 +364,28 @@ $(function() {
ripple::Transactor::Custom
@ Custom
Definition: Transactor.h:101
ripple::xbridgeMaxAccountCreateClaims
constexpr size_t xbridgeMaxAccountCreateClaims
Definition: XChainBridge.h:29
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
-
ripple::XChainCreateClaimID::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:2024
-
ripple::XChainCreateAccountCommit::doApply
TER doApply() override
Definition: XChainBridge.cpp:2245
+
ripple::XChainCreateClaimID::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:2030
+
ripple::XChainCreateAccountCommit::doApply
TER doApply() override
Definition: XChainBridge.cpp:2251
ripple::XChainAddAccountCreateAttestation::ConsequencesFactory
static constexpr ConsequencesFactoryType ConsequencesFactory
Definition: XChainBridge.h:190
-
ripple::XChainAddAccountCreateAttestation::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:2145
+
ripple::XChainAddAccountCreateAttestation::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:2151
ripple::XChainCreateClaimID
Definition: XChainBridge.h:138
ripple::Transactor::Normal
@ Normal
Definition: Transactor.h:101
-
ripple::XChainCommit::makeTxConsequences
static TxConsequences makeTxConsequences(PreflightContext const &ctx)
Definition: XChainBridge.cpp:1877
-
ripple::XChainCommit::doApply
TER doApply() override
Definition: XChainBridge.cpp:1960
+
ripple::XChainCommit::makeTxConsequences
static TxConsequences makeTxConsequences(PreflightContext const &ctx)
Definition: XChainBridge.cpp:1883
+
ripple::XChainCommit::doApply
TER doApply() override
Definition: XChainBridge.cpp:1966
ripple::XChainCreateClaimID::XChainCreateClaimID
XChainCreateClaimID(ApplyContext &ctx)
Definition: XChainBridge.h:143
-
ripple::XChainAddClaimAttestation::doApply
TER doApply() override
Definition: XChainBridge.cpp:2131
-
ripple::XChainCommit::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:1890
-
ripple::XChainCreateBridge::doApply
TER doApply() override
Definition: XChainBridge.cpp:1496
-
ripple::XChainAddAccountCreateAttestation::doApply
TER doApply() override
Definition: XChainBridge.cpp:2151
-
ripple::XChainAddClaimAttestation::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:2119
-
ripple::BridgeModify::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:1595
+
ripple::XChainAddClaimAttestation::doApply
TER doApply() override
Definition: XChainBridge.cpp:2137
+
ripple::XChainCommit::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:1896
+
ripple::XChainCreateBridge::doApply
TER doApply() override
Definition: XChainBridge.cpp:1502
+
ripple::XChainAddAccountCreateAttestation::doApply
TER doApply() override
Definition: XChainBridge.cpp:2157
+
ripple::XChainAddClaimAttestation::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:2125
+
ripple::BridgeModify::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition: XChainBridge.cpp:1601
ripple::XChainCreateAccountCommit
Definition: XChainBridge.h:232
ripple::PreflightContext
State information when preflighting a tx.
Definition: Transactor.h:31
ripple::XChainAddClaimAttestation
Definition: XChainBridge.h:166
-
ripple::XChainClaim::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:1652
-
ripple::BridgeModify::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:1542
+
ripple::XChainClaim::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:1658
+
ripple::BridgeModify::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:1548
ripple::TxConsequences
Class describing the consequences to the account of applying a transaction if the transaction consume...
Definition: applySteps.h:45
-
ripple::XChainAddAccountCreateAttestation::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:2139
+
ripple::XChainAddAccountCreateAttestation::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: XChainBridge.cpp:2145