2022-03-21 09:53:58 -07:00
|
|
|
/*
|
|
|
|
|
Order Model. Orders are 'internal' to the system and track the HD wallet index
|
|
|
|
|
that contains funds for that Order. This is in contrast to Offers, which
|
|
|
|
|
are 'external' to the system and mirrored by every instance of bch-dex.
|
2022-03-22 11:05:31 -07:00
|
|
|
|
|
|
|
|
See the dev-docs/specification.md for details on each property.
|
2022-03-21 09:53:58 -07:00
|
|
|
*/
|
|
|
|
|
|
2022-10-01 11:40:41 -07:00
|
|
|
import mongoose from 'mongoose'
|
2022-02-23 05:51:12 -08:00
|
|
|
|
|
|
|
|
const Order = new mongoose.Schema({
|
2022-03-11 18:23:36 -08:00
|
|
|
// Token data
|
2025-05-14 20:33:25 -04:00
|
|
|
tokenId: { type: String, required: true },
|
|
|
|
|
utxoTxid: { type: String, required: true },
|
|
|
|
|
utxoVout: { type: Number, required: true },
|
|
|
|
|
ticker: { type: String, required: true },
|
|
|
|
|
tokenType: { type: Number, required: true },
|
2022-03-11 18:23:36 -08:00
|
|
|
|
|
|
|
|
// Trade data
|
2025-05-14 20:33:25 -04:00
|
|
|
buyOrSell: { type: String, required: true },
|
|
|
|
|
numTokens: { type: Number, required: true },
|
|
|
|
|
rateInBaseUnit: { type: String, required: true },
|
2022-03-11 18:23:36 -08:00
|
|
|
minUnitsToExchange: { type: String },
|
2022-02-23 05:51:12 -08:00
|
|
|
p2wdbTxid: { type: String },
|
2022-03-09 14:25:37 -08:00
|
|
|
p2wdbHash: { type: String },
|
2025-05-14 20:33:25 -04:00
|
|
|
makerAddr: { type: String, required: true },
|
2025-11-10 18:45:37 -04:00
|
|
|
makerNpub: { type: String, required: true },
|
2022-03-11 18:23:36 -08:00
|
|
|
|
|
|
|
|
// Authentication data
|
|
|
|
|
signature: { type: String },
|
|
|
|
|
sigMsg: { type: String },
|
|
|
|
|
offerBchAddr: { type: String },
|
|
|
|
|
offerPubKey: { type: String },
|
|
|
|
|
|
|
|
|
|
// Wallet Data
|
2025-05-14 20:33:25 -04:00
|
|
|
hdIndex: { type: Number, required: true }, // HD index address holding the UTXO for this offer.
|
2022-03-11 18:23:36 -08:00
|
|
|
|
|
|
|
|
// SWaP Protocol Properties
|
|
|
|
|
lokadId: { type: String },
|
|
|
|
|
messageType: { type: Number },
|
2024-11-28 12:37:47 -04:00
|
|
|
messageClass: { type: Number },
|
2025-05-14 20:33:25 -04:00
|
|
|
nostrEventId: { type: String, required: true }, // Nostr Event Id.
|
|
|
|
|
|
|
|
|
|
// Additional properties found in createOrder
|
2025-06-01 18:18:34 -07:00
|
|
|
dataType: { type: String, required: true },
|
|
|
|
|
|
2025-08-09 15:02:29 -07:00
|
|
|
userId: { type: String, required: true },
|
|
|
|
|
|
|
|
|
|
// Operator fee and address
|
|
|
|
|
operatorAddress: { type: String },
|
|
|
|
|
operatorPercentage: { type: Number }
|
2022-02-23 05:51:12 -08:00
|
|
|
})
|
|
|
|
|
|
2022-10-01 11:40:41 -07:00
|
|
|
export default mongoose.model('order', Order)
|