Skip to content

Commit c99340f

Browse files
committed
feat: Add reference links to stellar files
1 parent bdff72a commit c99340f

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed

apps/stellar_app/stellar_context.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#define STELLAR_SIGNATURE_SIZE 64
3333

3434
// Network passphrases
35+
// See https://developers.stellar.org/docs/learn/fundamentals/networks
3536
#define TESTNET_PASSPHRASE "Test SDF Network ; September 2015"
3637
#define MAINNET_PASSPHRASE "Public Global Stellar Network ; September 2015"
3738

@@ -44,6 +45,7 @@ typedef struct {
4445
} stellar_config_t;
4546

4647
// Stellar Memo types
48+
// See https://developers.stellar.org/docs/learn/encyclopedia/transactions-specialized/memos
4749
typedef enum {
4850
MEMO_NONE = 0,
4951
MEMO_TEXT = 1,
@@ -90,6 +92,7 @@ typedef enum {
9092
* 1. Creates a payload with account ID type (0x30) and the public key
9193
* 2. Calculates CRC16 checksum
9294
* 3. Encodes the result using base32
95+
* See https://developers.stellar.org/docs/fundamentals-and-concepts/stellar-data-structures/accounts
9396
*
9497
* @param public_key The 32-byte ED25519 public key
9598
* @param address Buffer to store the resulting address (must be at least

apps/stellar_app/stellar_helpers.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
#define STELLAR_IMPLICIT_ACCOUNT_DEPTH 3
2727

28+
// BIP44 derivation path: m/44'/148'/n'
29+
// See https://github.com/satoshilabs/slips/blob/master/slip-0044.md
2830
#define STELLAR_PURPOSE_INDEX 0x8000002C // 44'
2931
#define STELLAR_COIN_INDEX 0x80000094 // 148'
3032
#define STELLAR_ACCOUNT_INDEX 0x80000000 // 0'
@@ -47,6 +49,7 @@
4749
* 3, then this function return false indicating invalid derivation path. The
4850
* function supports checking derivation paths for HD wallets Types of
4951
* derivations: address: m/44'/148'/0'
52+
* See https://developers.stellar.org/docs/fundamentals-and-concepts/accounts
5053
*
5154
* @param[in] path The derivation path as an uint32 array
5255
* @param[in] levels The number of levels in the derivation path

apps/stellar_app/stellar_pub_key.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,14 +412,19 @@ bool stellar_generate_address(const uint8_t *public_key, char *address) {
412412
return false;
413413
}
414414

415+
// Stellar address encoding (StrKey format)
416+
// See https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0023.md
415417
uint8_t payload[35];
416-
payload[0] = 6 << 3; // Account ID type
418+
payload[0] = 6 << 3; // Account ID version byte (0x30)
417419
memcpy(payload + 1, public_key, 32);
418420

421+
// CRC16-XModem checksum calculation
422+
// See https://stellar.stackexchange.com/questions/255/which-cryptographic-algorithm-is-used-to-generate-the-secret-and-public-keys
419423
uint16_t checksum = crc16(payload, 33);
420424
payload[33] = checksum & 0xFF;
421425
payload[34] = checksum >> 8;
422426

427+
// RFC4648 base32 encoding without padding
423428
base32_encode(payload, 35, address, 57, BASE32_ALPHABET_RFC4648);
424429
return true;
425430
}

apps/stellar_app/stellar_txn.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,9 @@ static bool get_user_verification(void) {
490490
return true;
491491
}
492492

493+
// See https://developers.stellar.org/docs/learn/encyclopedia/data-format/xdr
494+
// Envelope type (4 bytes) - ENVELOPE_TYPE_TX = 2
495+
// See https://github.com/stellar/stellar-protocol/blob/master/core/cap-0015.md
493496
static void write_uint32_be(uint8_t *buffer, uint32_t value) {
494497
buffer[0] = (value >> 24) & 0xFF;
495498
buffer[1] = (value >> 16) & 0xFF;

apps/stellar_app/stellar_txn_helpers.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ static int parse_memo_data(const uint8_t *xdr,
185185
}
186186

187187
// Helper function 2: Parse operation data
188+
// Parse XDR transaction envelope format
189+
// See https://developers.stellar.org/docs/learn/encyclopedia/data-format/xdr
188190
static int parse_operation_data(const uint8_t *xdr,
189191
int *pos,
190192
int xdr_len,
@@ -257,6 +259,8 @@ int stellar_parse_transaction(const uint8_t *xdr,
257259
memset(payment, 0, sizeof(stellar_payment_t));
258260

259261
// 1. Parse Envelope Type (4 bytes)
262+
// ENVELOPE_TYPE_TX = 2
263+
// See https://github.com/stellar/stellar-protocol/blob/master/core/cap-0015.md
260264
uint32_t envelope_type = read_uint32_be_pos(xdr, &pos);
261265
if (envelope_type != 2) {
262266
return -1;

0 commit comments

Comments
 (0)