Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.
This repository was archived by the owner on May 27, 2025. It is now read-only.

[Discussion] Type proxies in btc: Address and Pubkey #235

@ShookLyngs

Description

@ShookLyngs

We can define type proxies for Address and Pubkey to improve the code readability of the btc lib. However, it would take some time to search for relevant code and update it. So, the discussion is: Do you think we should define the two type proxies, and do you think the change is worthwhile?

From this:

interface SendXProps {
  from: string;
  fromPubkey?: string;
  pubkeyMap?: Record<string, string>; // Record<address, pubkey>
}

Which can be refactored to this:

type Address = string;
type Pubkey = string;

interface SendXProps {
  from: Address;
  fromPubkey?: Pubkey;
  pubkeyMap?: Record<Address, Pubkey>;
}

Original commented at: #228 (comment)

The original comment was discussing about how to make the type of pubkeyMap more clear, in the PR I've chosen a simpler solution to only define a type AddressToPubkeyMap with an explanation comment:

/**
 * Type: Record<Address, Pubkey>
 * The map of address and pubkey, usually for recognizing the P2TR inputs in the transaction.
 */
type AddressToPubkeyMap = Record<string, string>;

interface SendXProps {
  from: string;
  fromPubkey?: string;
  pubkeyMap?: AddressToPubkeyMap;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions