-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff551f8
commit ad3adeb
Showing
8 changed files
with
471 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
### Simple P2P Ordinal Transactions Specification | ||
|
||
--- | ||
|
||
#### 1. Simple P2P Ordinal Payment Destinations | ||
|
||
|
||
This protocol provides a mechanism for requesting payment destinations specifically for ordinal transactions. It is similar to the P2P Payment Destination protocol but tailored for handling simple ordinal sends. | ||
|
||
#### Motivation | ||
Ordinals introduce a specific need in the Bitcoin ecosystem for transaction types that are simpler and more focused. While existing P2P payment protocols provide a broad range of functionalities, there is a demand for a protocol that specifically caters to ordinal transactions. This need arises from the unique characteristics of ordinals, ordinal transactions can not be differentiated from regular bitcoin transactions so it is needed for a specific path where only ordinal transactions go though to prevent accidental burns of an ordinal | ||
|
||
#### Capability Discovery | ||
|
||
The `.well-known/bsvalias` document is updated to include a declaration of the endpoint for ordinal payment destinations: | ||
|
||
```json | ||
{ | ||
"bsvalias": "1.0", | ||
"capabilities": { | ||
"cc2154bfa6a2": "https://example.bsvalias.tld/api/ordinal-p2p-payment-destination/{alias}@{domain.tld}" | ||
} | ||
} | ||
``` | ||
|
||
The capability `cc2154bfa6a2` returns a URI template where the client must perform a POST request with the number of ordinals to be sent. | ||
|
||
|
||
#### Client Request | ||
|
||
The request body structure: | ||
|
||
```json | ||
{ | ||
"ordinals": 2 | ||
} | ||
``` | ||
|
||
#### Server Response | ||
|
||
```json | ||
{ | ||
"outputs": [ | ||
{ | ||
"script": "hex-encoded-locking-script" | ||
}, | ||
{ | ||
"script": "another-or-the-same-hex-locking-script" | ||
} | ||
], | ||
"reference": "reference-id" | ||
} | ||
``` | ||
|
||
#### 2. Simple P2P Ordinal Receive Transaction | ||
This protocol allows Paymail providers to receive simple ordinal transactions sent to their users. | ||
|
||
#### Motivation | ||
|
||
The growing usage of ordinals requires a dedicated protocol for receiving such transactions. The existing P2P transaction protocols handle a wide array of transaction types, but a more focused approach is needed for the simplicity and specificity of ordinal transactions. | ||
|
||
#### Capability Discovery | ||
|
||
The `.well-known/bsvalias` document includes a declaration for the ordinal transaction receiving endpoint: | ||
|
||
```json | ||
{ | ||
"bsvalias": "1.0", | ||
"capabilities": { | ||
"2cc00c7f93c3": "https://example.bsvalias.tld/api/receive-ordinal-tx/{alias}@{domain.tld}" | ||
} | ||
} | ||
``` | ||
|
||
#### Client Request | ||
|
||
The request body structure: | ||
|
||
```json | ||
{ | ||
"hex": "hex-encoded-transaction", | ||
"reference": "reference-id", | ||
"metadata": { | ||
"sender": "someone@example.tld", | ||
"pubkey": "public-key", | ||
"signature": "signature", | ||
"note": "transaction-note" | ||
} | ||
} | ||
``` | ||
|
||
|
||
#### Server Response | ||
```json | ||
{ | ||
"txid": "transaction-id", | ||
"note": "optional-note" | ||
} | ||
``` | ||
|
||
### Conclusion | ||
|
||
These simple ordinal transaction capabilities are designed for straightforward and efficient handling of ordinal transactions. They complement the existing Paymail capabilities by focusing on a specific transaction type. As the ecosystem evolves, further protocols may be developed to accommodate more complex functions involving ordinals. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Capability from './capability.js' | ||
|
||
export default new Capability({ | ||
title: 'Simple P2P Ordinal Destinations', | ||
authors: ['Brandon Bryant (HandCash)'], | ||
version: '1', | ||
method: 'POST', | ||
code: 'cc2154bfa6a2' | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Capability from './capability.js' | ||
|
||
export default new Capability({ | ||
title: 'Simple P2P Ordinal Receive Transaction', | ||
authors: ['Brandon Bryant (HandCash)'], | ||
version: '1', | ||
method: 'POST', | ||
code: '2cc00c7f93c3' | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/paymailRouter/__tests/simple-p2p-ordinal-destinations.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import request from 'supertest' | ||
import express from 'express' | ||
import PaymailRouter from '../../../dist/cjs/src/paymailRouter/paymailRouter.js' | ||
import OrdinalP2pPaymentDestinationRoute from '../../../dist/cjs/src/paymailRouter/paymailRoutes/simpleP2pOrdinalDestinationsRoute.js' | ||
import PaymailClient from '../../../dist/cjs/src/paymailClient/paymailClient.js' | ||
|
||
describe('#Paymail Server - Simple Ordinal P2P Payment Destinations', () => { | ||
let app | ||
let client: PaymailClient | ||
|
||
beforeAll(() => { | ||
app = express(); | ||
const baseUrl = 'http://localhost:3000'; | ||
client = new PaymailClient(undefined, undefined, undefined); | ||
const routes = [ | ||
new OrdinalP2pPaymentDestinationRoute({ | ||
domainLogicHandler: (name, domain, body) => { | ||
return { | ||
outputs: [ | ||
{ | ||
script: '76a914f32281faa74e2ac037493f7a3cd317e8f5e9673688ac', | ||
} | ||
], | ||
reference: 'someref' | ||
}; | ||
} | ||
}) | ||
]; | ||
const paymailRouter = new PaymailRouter({ baseUrl, routes }); | ||
app.use(paymailRouter.getRouter()); | ||
}); | ||
|
||
it('should get ordinal p2p destination', async () => { | ||
const response = await request(app).post('/ordinal-p2p-payment-destination/satoshi@bsv.org').send({ | ||
ordinals: 1, | ||
}) | ||
expect(response.statusCode).toBe(200) | ||
expect(response.body.outputs[0].script).toEqual('76a914f32281faa74e2ac037493f7a3cd317e8f5e9673688ac') | ||
expect(response.body.reference).toEqual('someref') | ||
}) | ||
|
||
it('should return 400 if ordinals is not provided', async () => { | ||
const response = await request(app).post('/ordinal-p2p-payment-destination/satoshi@bsv.org').send({ | ||
BSV: 1 | ||
}) | ||
expect(response.statusCode).toBe(400) | ||
expect(response.error.text).toEqual('Invalid body: "ordinals" is required') | ||
}) | ||
}) |
Oops, something went wrong.