Skip to content

Commit f05bf82

Browse files
feat(dpp)!: dashpay profile payment addresses for core and platform (#4380)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 56fe66b commit f05bf82

30 files changed

Lines changed: 1216 additions & 34 deletions

File tree

Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
{
2+
"profile": {
3+
"type": "object",
4+
"indices": [
5+
{
6+
"name": "ownerId",
7+
"properties": [
8+
{
9+
"$ownerId": "asc"
10+
}
11+
],
12+
"unique": true
13+
},
14+
{
15+
"name": "ownerIdAndUpdatedAt",
16+
"properties": [
17+
{
18+
"$ownerId": "asc"
19+
},
20+
{
21+
"$updatedAt": "asc"
22+
}
23+
]
24+
}
25+
],
26+
"properties": {
27+
"avatarUrl": {
28+
"type": "string",
29+
"format": "uri",
30+
"minLength": 1,
31+
"maxLength": 2048,
32+
"position": 0
33+
},
34+
"avatarHash": {
35+
"type": "array",
36+
"byteArray": true,
37+
"minItems": 32,
38+
"maxItems": 32,
39+
"description": "SHA256 hash of the bytes of the image specified by avatarUrl",
40+
"position": 1
41+
},
42+
"avatarFingerprint": {
43+
"type": "array",
44+
"byteArray": true,
45+
"minItems": 8,
46+
"maxItems": 8,
47+
"description": "dHash the image specified by avatarUrl",
48+
"position": 2
49+
},
50+
"publicMessage": {
51+
"type": "string",
52+
"minLength": 1,
53+
"maxLength": 140,
54+
"position": 3
55+
},
56+
"displayName": {
57+
"type": "string",
58+
"minLength": 1,
59+
"maxLength": 25,
60+
"position": 4
61+
},
62+
"corePaymentAddress": {
63+
"type": "array",
64+
"byteArray": true,
65+
"minItems": 21,
66+
"maxItems": 21,
67+
"description": "Core chain address in storage form (type byte 0x00 P2PKH / 0x01 P2SH followed by the 20-byte HASH160, i.e. RIPEMD160 of SHA256, of the public key or redeem script) for public payments. The type byte is consensus-enforced by a data trigger; clients render the address as Base58Check for the network they are on. Payments to it are publicly linkable to this profile.",
68+
"position": 5
69+
},
70+
"platformPaymentAddress": {
71+
"type": "array",
72+
"byteArray": true,
73+
"minItems": 21,
74+
"maxItems": 21,
75+
"description": "Platform address in storage form (type byte 0x00 P2PKH / 0x01 P2SH followed by the 20-byte HASH160, i.e. RIPEMD160 of SHA256, of the public key or redeem script) for public payments. The type byte is consensus-enforced by a data trigger.",
76+
"position": 6
77+
}
78+
},
79+
"minProperties": 1,
80+
"dependentRequired": {
81+
"avatarUrl": ["avatarHash", "avatarFingerprint"],
82+
"avatarHash": ["avatarUrl", "avatarFingerprint"],
83+
"avatarFingerprint": ["avatarUrl", "avatarHash"]
84+
},
85+
"required": [
86+
"$createdAt",
87+
"$updatedAt"
88+
],
89+
"additionalProperties": false
90+
},
91+
"contactInfo": {
92+
"type": "object",
93+
"indices": [
94+
{
95+
"name": "ownerIdAndKeys",
96+
"properties": [
97+
{
98+
"$ownerId": "asc"
99+
},
100+
{
101+
"rootEncryptionKeyIndex": "asc"
102+
},
103+
{
104+
"derivationEncryptionKeyIndex": "asc"
105+
}
106+
],
107+
"unique": true
108+
},
109+
{
110+
"name": "ownerIdAndUpdatedAt",
111+
"properties": [
112+
{
113+
"$ownerId": "asc"
114+
},
115+
{
116+
"$updatedAt": "asc"
117+
}
118+
]
119+
}
120+
],
121+
"properties": {
122+
"encToUserId": {
123+
"type": "array",
124+
"byteArray": true,
125+
"minItems": 32,
126+
"maxItems": 32,
127+
"position": 0
128+
},
129+
"rootEncryptionKeyIndex": {
130+
"type": "integer",
131+
"minimum": 0,
132+
"position": 1
133+
},
134+
"derivationEncryptionKeyIndex": {
135+
"type": "integer",
136+
"minimum": 0,
137+
"position": 2
138+
},
139+
"privateData": {
140+
"type": "array",
141+
"byteArray": true,
142+
"minItems": 48,
143+
"maxItems": 2048,
144+
"position": 3,
145+
"description": "This is the encrypted values of aliasName + note + displayHidden encoded as an array in cbor"
146+
}
147+
},
148+
"required": [
149+
"$createdAt",
150+
"$updatedAt",
151+
"encToUserId",
152+
"privateData",
153+
"rootEncryptionKeyIndex",
154+
"derivationEncryptionKeyIndex"
155+
],
156+
"additionalProperties": false
157+
},
158+
"contactRequest": {
159+
"documentsMutable": false,
160+
"canBeDeleted": false,
161+
"requiresIdentityEncryptionBoundedKey": 2,
162+
"requiresIdentityDecryptionBoundedKey": 2,
163+
"type": "object",
164+
"indices": [
165+
{
166+
"name": "ownerIdUserIdAndAccountRef",
167+
"properties": [
168+
{
169+
"$ownerId": "asc"
170+
},
171+
{
172+
"toUserId": "asc"
173+
},
174+
{
175+
"accountReference": "asc"
176+
}
177+
],
178+
"unique": true
179+
},
180+
{
181+
"name": "ownerIdUserId",
182+
"properties": [
183+
{
184+
"$ownerId": "asc"
185+
},
186+
{
187+
"toUserId": "asc"
188+
}
189+
]
190+
},
191+
{
192+
"name": "userIdCreatedAt",
193+
"properties": [
194+
{
195+
"toUserId": "asc"
196+
},
197+
{
198+
"$createdAt": "asc"
199+
}
200+
]
201+
},
202+
{
203+
"name": "ownerIdCreatedAt",
204+
"properties": [
205+
{
206+
"$ownerId": "asc"
207+
},
208+
{
209+
"$createdAt": "asc"
210+
}
211+
]
212+
}
213+
],
214+
"properties": {
215+
"toUserId": {
216+
"type": "array",
217+
"byteArray": true,
218+
"minItems": 32,
219+
"maxItems": 32,
220+
"position": 0,
221+
"contentMediaType": "application/x.dash.dpp.identifier"
222+
},
223+
"encryptedPublicKey": {
224+
"type": "array",
225+
"byteArray": true,
226+
"minItems": 96,
227+
"maxItems": 96,
228+
"position": 1
229+
},
230+
"senderKeyIndex": {
231+
"type": "integer",
232+
"minimum": 0,
233+
"position": 2
234+
},
235+
"recipientKeyIndex": {
236+
"type": "integer",
237+
"minimum": 0,
238+
"position": 3
239+
},
240+
"accountReference": {
241+
"type": "integer",
242+
"minimum": 0,
243+
"position": 4
244+
},
245+
"encryptedAccountLabel": {
246+
"type": "array",
247+
"byteArray": true,
248+
"minItems": 48,
249+
"maxItems": 80,
250+
"position": 5
251+
},
252+
"autoAcceptProof": {
253+
"type": "array",
254+
"byteArray": true,
255+
"minItems": 38,
256+
"maxItems": 102,
257+
"position": 6
258+
}
259+
},
260+
"required": [
261+
"$createdAt",
262+
"$createdAtCoreBlockHeight",
263+
"toUserId",
264+
"encryptedPublicKey",
265+
"senderKeyIndex",
266+
"recipientKeyIndex",
267+
"accountReference"
268+
],
269+
"additionalProperties": false
270+
}
271+
}

packages/dashpay-contract/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
mod error;
22
pub mod v1;
3+
pub mod v2;
34

45
pub use crate::error::Error;
56
use platform_value::{Identifier, IdentifierBytes32};
@@ -18,20 +19,21 @@ pub const OWNER_ID: Identifier = Identifier(IdentifierBytes32(OWNER_ID_BYTES));
1819

1920
pub fn load_definitions(platform_version: &PlatformVersion) -> Result<Option<Value>, Error> {
2021
match platform_version.system_data_contracts.dashpay {
21-
1 => Ok(None),
22+
1 | 2 => Ok(None),
2223
version => Err(Error::UnknownVersionMismatch {
2324
method: "dashpay_contract::load_definitions".to_string(),
24-
known_versions: vec![1],
25+
known_versions: vec![1, 2],
2526
received: version,
2627
}),
2728
}
2829
}
2930
pub fn load_documents_schemas(platform_version: &PlatformVersion) -> Result<Value, Error> {
3031
match platform_version.system_data_contracts.dashpay {
3132
1 => v1::load_documents_schemas(),
33+
2 => v2::load_documents_schemas(),
3234
version => Err(Error::UnknownVersionMismatch {
3335
method: "dashpay_contract::load_documents_schemas".to_string(),
34-
known_versions: vec![1],
36+
known_versions: vec![1, 2],
3537
received: version,
3638
}),
3739
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use crate::error::Error;
2+
use serde_json::Value;
3+
4+
// Document-type name and property constants live in `crate::v1::document_types`;
5+
// v2 does not change any names v1 defined, it only adds the optional
6+
// `corePaymentAddress` / `platformPaymentAddress` properties to `profile`.
7+
8+
pub fn load_documents_schemas() -> Result<Value, Error> {
9+
serde_json::from_str(include_str!("../../schema/v2/dashpay.schema.json"))
10+
.map_err(Error::InvalidSchemaJson)
11+
}

packages/rs-drive-abci/src/execution/check_tx/v0/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ mod tests {
644644

645645
assert_eq!(
646646
processing_result.aggregated_fees().processing_fee,
647-
24002489210
647+
24002816630
648648
);
649649

650650
let check_result = platform
@@ -1159,7 +1159,7 @@ mod tests {
11591159
// Plus we have 24_000_000_000 in base costs
11601160
assert_eq!(
11611161
processing_result.aggregated_fees().processing_fee,
1162-
24004978420
1162+
24005633260
11631163
);
11641164

11651165
let check_result = platform
@@ -1634,7 +1634,7 @@ mod tests {
16341634

16351635
assert_eq!(
16361636
processing_result.aggregated_fees().processing_fee,
1637-
24002489210
1637+
24002816630
16381638
);
16391639

16401640
platform
@@ -1721,7 +1721,7 @@ mod tests {
17211721

17221722
assert_eq!(
17231723
update_processing_result.aggregated_fees().processing_fee,
1724-
27002504030
1724+
27002879350
17251725
);
17261726

17271727
let check_result = platform
@@ -2093,7 +2093,7 @@ mod tests {
20932093

20942094
assert_eq!(
20952095
processing_result.aggregated_fees().processing_fee,
2096-
24002489210
2096+
24002816630
20972097
);
20982098

20992099
platform

0 commit comments

Comments
 (0)