cc289089cf
* not-custodial zap scaffolding * invoice forward state machine * small refinements to state machine * make wrap invoice work * get state machine working end to end * untested logic layout for paidAction invoice wraps * perform pessimisitic actions before outgoing payment * working end to end * remove unneeded params from wallets/server/createInvoice * fix cltv relative/absolute confusion + cancelling forwards * small refinements * add p2p wrap info to paidAction docs * fallback to SN invoice when wrap fails * fix paidAction retry description * consistent naming scheme for state machine * refinements * have sn pay bounded outbound fee * remove debug logging * reenable lnc permissions checks * don't p2p zap on item forward splits * make createInvoice params json encodeable * direct -> p2p badge on notifications * allow no tls in dev for core lightning * fix autowithdraw to create invoice with msats * fix autowithdraw msats/sats inconsitency * label p2p zaps properly in satistics * add fees to autowithdrawal notifications * add RETRYING as terminal paid action state * Update api/paidAction/README.md Co-authored-by: ekzyis <ek@stacker.news> * Update api/paidAction/README.md Co-authored-by: ekzyis <ek@stacker.news> * Update api/lnd/index.js Co-authored-by: ekzyis <ek@stacker.news> * ek suggestions * add bugetable to nwc card * get paranoid with numbers * better finalize retries and better max timeout height * refine forward failure transitions * more accurate satistics p2p status * make sure paidaction cancel in state machine only * dont drop bolt11s unless status is not null * only allow PENDING_HELD to transition to FORWARDING * add mermaid state machine diagrams to paid action doc * fix cancel transition name * cleanup readme * move forwarding outside of transition * refine testServerConnect and make sure ensureB64 transforms * remove unused params from testServerConnect --------- Co-authored-by: ekzyis <ek@stacker.news> Co-authored-by: k00b <k00b@stacker.news>
77 lines
2.6 KiB
SQL
77 lines
2.6 KiB
SQL
-- AlterEnum
|
|
-- This migration adds more than one value to an enum.
|
|
-- With PostgreSQL versions 11 and earlier, this is not possible
|
|
-- in a single migration. This can be worked around by creating
|
|
-- multiple migrations, each migration adding only one value to
|
|
-- the enum.
|
|
|
|
|
|
ALTER TYPE "InvoiceActionState" ADD VALUE 'FORWARDING';
|
|
ALTER TYPE "InvoiceActionState" ADD VALUE 'FORWARDED';
|
|
ALTER TYPE "InvoiceActionState" ADD VALUE 'FAILED_FORWARD';
|
|
ALTER TYPE "InvoiceActionState" ADD VALUE 'CANCELING';
|
|
|
|
-- AlterTable
|
|
ALTER TABLE "Invoice" ADD COLUMN "actionOptimistic" BOOLEAN;
|
|
|
|
-- AlterTable
|
|
ALTER TABLE "Withdrawl" ADD COLUMN "preimage" TEXT;
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "InvoiceForward" (
|
|
"id" SERIAL NOT NULL,
|
|
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"bolt11" TEXT NOT NULL,
|
|
"maxFeeMsats" INTEGER NOT NULL,
|
|
"walletId" INTEGER NOT NULL,
|
|
"expiryHeight" INTEGER,
|
|
"acceptHeight" INTEGER,
|
|
"invoiceId" INTEGER NOT NULL,
|
|
"withdrawlId" INTEGER,
|
|
|
|
CONSTRAINT "InvoiceForward_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- historically, optimistic actions were exclusively non-hold invoices
|
|
-- with invoice forwards, we can now have optimistic hold invoices
|
|
UPDATE "Invoice"
|
|
SET "actionOptimistic" = preimage IS NULL
|
|
WHERE "actionType" IS NOT NULL;
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "InvoiceForward_invoiceId_key" ON "InvoiceForward"("invoiceId");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "InvoiceForward_invoiceId_idx" ON "InvoiceForward"("invoiceId");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "InvoiceForward_walletId_idx" ON "InvoiceForward"("walletId");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "InvoiceForward_withdrawlId_idx" ON "InvoiceForward"("withdrawlId");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "Invoice_isHeld_idx" ON "Invoice"("isHeld");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "Invoice_confirmedAt_idx" ON "Invoice"("confirmedAt");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "Withdrawl_walletId_idx" ON "Withdrawl"("walletId");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "Withdrawl_autoWithdraw_idx" ON "Withdrawl"("autoWithdraw");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "Withdrawl_status_idx" ON "Withdrawl"("status");
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "InvoiceForward" ADD CONSTRAINT "InvoiceForward_invoiceId_fkey" FOREIGN KEY ("invoiceId") REFERENCES "Invoice"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "InvoiceForward" ADD CONSTRAINT "InvoiceForward_walletId_fkey" FOREIGN KEY ("walletId") REFERENCES "Wallet"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "InvoiceForward" ADD CONSTRAINT "InvoiceForward_withdrawlId_fkey" FOREIGN KEY ("withdrawlId") REFERENCES "Withdrawl"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|