diff --git a/proto/autogenerated/client.md b/proto/autogenerated/client.md index 6c574090..99023c69 100644 --- a/proto/autogenerated/client.md +++ b/proto/autogenerated/client.md @@ -1524,7 +1524,7 @@ The nostr server will send back a message response, and inside the body there wi ### PayAddressRequest - __address__: _string_ - - __amoutSats__: _number_ + - __amountSats__: _number_ - __satsPerVByte__: _number_ - __swap_operation_id__: _string_ *this field is optional diff --git a/proto/autogenerated/go/types.go b/proto/autogenerated/go/types.go index b8794a80..841ced1d 100644 --- a/proto/autogenerated/go/types.go +++ b/proto/autogenerated/go/types.go @@ -549,7 +549,7 @@ type OperationsCursor struct { } type PayAddressRequest struct { Address string `json:"address"` - Amoutsats int64 `json:"amoutSats"` + Amountsats int64 `json:"amountSats"` Satspervbyte int64 `json:"satsPerVByte"` Swap_operation_id string `json:"swap_operation_id"` } diff --git a/proto/autogenerated/ts/types.ts b/proto/autogenerated/ts/types.ts index 8f8c97ef..e397cd94 100644 --- a/proto/autogenerated/ts/types.ts +++ b/proto/autogenerated/ts/types.ts @@ -3243,7 +3243,7 @@ export const OperationsCursorValidate = (o?: OperationsCursor, opts: OperationsC export type PayAddressRequest = { address: string - amoutSats: number + amountSats: number satsPerVByte: number swap_operation_id?: string } @@ -3252,7 +3252,7 @@ export const PayAddressRequestOptionalFields: PayAddressRequestOptionalField[] = export type PayAddressRequestOptions = OptionsBaseMessage & { checkOptionalsAreSet?: PayAddressRequestOptionalField[] address_CustomCheck?: (v: string) => boolean - amoutSats_CustomCheck?: (v: number) => boolean + amountSats_CustomCheck?: (v: number) => boolean satsPerVByte_CustomCheck?: (v: number) => boolean swap_operation_id_CustomCheck?: (v?: string) => boolean } @@ -3263,8 +3263,8 @@ export const PayAddressRequestValidate = (o?: PayAddressRequest, opts: PayAddres if (typeof o.address !== 'string') return new Error(`${path}.address: is not a string`) if (opts.address_CustomCheck && !opts.address_CustomCheck(o.address)) return new Error(`${path}.address: custom check failed`) - if (typeof o.amoutSats !== 'number') return new Error(`${path}.amoutSats: is not a number`) - if (opts.amoutSats_CustomCheck && !opts.amoutSats_CustomCheck(o.amoutSats)) return new Error(`${path}.amoutSats: custom check failed`) + if (typeof o.amountSats !== 'number') return new Error(`${path}.amountSats: is not a number`) + if (opts.amountSats_CustomCheck && !opts.amountSats_CustomCheck(o.amountSats)) return new Error(`${path}.amountSats: custom check failed`) if (typeof o.satsPerVByte !== 'number') return new Error(`${path}.satsPerVByte: is not a number`) if (opts.satsPerVByte_CustomCheck && !opts.satsPerVByte_CustomCheck(o.satsPerVByte)) return new Error(`${path}.satsPerVByte: custom check failed`) diff --git a/proto/service/structs.proto b/proto/service/structs.proto index d94dffb5..00552fdd 100644 --- a/proto/service/structs.proto +++ b/proto/service/structs.proto @@ -431,7 +431,7 @@ message NewAddressResponse{ } message PayAddressRequest{ string address = 1; - int64 amoutSats = 2; + int64 amountSats = 2; int64 satsPerVByte = 3; optional string swap_operation_id = 4; } diff --git a/src/services/lnd/swaps.ts b/src/services/lnd/swaps.ts index af8ef6c7..727f0e88 100644 --- a/src/services/lnd/swaps.ts +++ b/src/services/lnd/swaps.ts @@ -114,7 +114,7 @@ export class Swaps { if (swappers.length === 0) { throw new Error("No swap services available") } - const res = await Promise.allSettled(Object.values(this.revSwappers).map(sw => this.getTxSwapQuote(sw, appUserId, amt, getServiceFee))) + const res = await Promise.allSettled(swappers.map(sw => this.getTxSwapQuote(sw, appUserId, amt, getServiceFee))) const failures: string[] = [] const success: Types.TransactionSwapQuote[] = [] for (const r of res) { diff --git a/src/services/main/paymentManager.ts b/src/services/main/paymentManager.ts index 55e22413..4d498023 100644 --- a/src/services/main/paymentManager.ts +++ b/src/services/main/paymentManager.ts @@ -552,7 +552,7 @@ export default class { async PayAddress(ctx: Types.UserContext, req: Types.PayAddressRequest): Promise { await this.watchDog.PaymentRequested() - this.log("paying address", req.address, "for user", ctx.user_id, "with amount", req.amoutSats) + this.log("paying address", req.address, "for user", ctx.user_id, "with amount", req.amountSats) const maybeBanned = await this.storage.userStorage.GetUser(ctx.user_id) if (maybeBanned.locked) { throw new Error("user is banned, cannot send chain tx") @@ -593,21 +593,21 @@ export default class { const { blockHeight } = await this.lnd.GetInfo() const app = await this.storage.applicationStorage.GetApplication(ctx.app_id) const isManagedUser = ctx.user_id !== app.owner.user_id - const serviceFee = this.getSendServiceFee(Types.UserOperationType.OUTGOING_USER_TO_USER, req.amoutSats, isManagedUser) + const serviceFee = this.getSendServiceFee(Types.UserOperationType.OUTGOING_USER_TO_USER, req.amountSats, isManagedUser) const txId = crypto.randomBytes(32).toString("hex") const addressData = `${req.address}:${txId}` - await this.storage.userStorage.DecrementUserBalance(ctx.user_id, req.amoutSats + serviceFee, addressData) - this.addressPaidCb({ hash: txId, index: 0 }, req.address, req.amoutSats, 'internal') + await this.storage.userStorage.DecrementUserBalance(ctx.user_id, req.amountSats + serviceFee, addressData) + this.addressPaidCb({ hash: txId, index: 0 }, req.address, req.amountSats, 'internal') if (isManagedUser && serviceFee > 0) { await this.storage.userStorage.IncrementUserBalance(app.owner.user_id, serviceFee, 'fees') } const chainFees = 0 const internalAddress = true - const newTx = await this.storage.paymentStorage.AddUserTransactionPayment(ctx.user_id, req.address, txId, 0, req.amoutSats, chainFees, serviceFee, internalAddress, blockHeight, app) + const newTx = await this.storage.paymentStorage.AddUserTransactionPayment(ctx.user_id, req.address, txId, 0, req.amountSats, chainFees, serviceFee, internalAddress, blockHeight, app) const user = await this.storage.userStorage.GetUser(ctx.user_id) const txData = `${newTx.address}:${newTx.tx_hash}` - this.storage.eventsLog.LogEvent({ type: 'address_payment', userId: ctx.user_id, appId: app.app_id, appUserId: "", balance: user.balance_sats, data: txData, amount: req.amoutSats }) + this.storage.eventsLog.LogEvent({ type: 'address_payment', userId: ctx.user_id, appId: app.app_id, appUserId: "", balance: user.balance_sats, data: txData, amount: req.amountSats }) return { txId: txId, operation_id: `${Types.UserOperationType.OUTGOING_TX}-${newTx.serial_id}`, diff --git a/src/services/nostr/sender.ts b/src/services/nostr/sender.ts index d81d81b2..1fd336a5 100644 --- a/src/services/nostr/sender.ts +++ b/src/services/nostr/sender.ts @@ -26,6 +26,7 @@ export class NostrSender { if (!this.isReady) { this.log("tried to send before nostr was ready, caching request") this.pendingSends.push({ initiator, data, relays }) + return } this._nostrSend(initiator, data, relays) } diff --git a/src/services/serverMethods/index.ts b/src/services/serverMethods/index.ts index b5d2ad0c..8b9b80a3 100644 --- a/src/services/serverMethods/index.ts +++ b/src/services/serverMethods/index.ts @@ -159,7 +159,7 @@ export default (mainHandler: Main): Types.ServerMethods => { PayAddress: async ({ ctx, req }) => { const err = Types.PayAddressRequestValidate(req, { address_CustomCheck: addr => addr !== '', - amoutSats_CustomCheck: amt => amt > 0, + amountSats_CustomCheck: amt => amt > 0, // satsPerVByte_CustomCheck: spb => spb > 0 }) if (err != null) throw new Error(err.message)