<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: David Adeyemi</title>
    <description>The latest articles on DEV Community by David Adeyemi (@dayvvo).</description>
    <link>https://dev.to/dayvvo</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F648629%2F01a69cf3-3723-46ad-9d07-173e55f2744f.jpg</url>
      <title>DEV Community: David Adeyemi</title>
      <link>https://dev.to/dayvvo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dayvvo"/>
    <language>en</language>
    <item>
      <title>Output Descriptors in Bitcoin, What are they and why do we need them</title>
      <dc:creator>David Adeyemi</dc:creator>
      <pubDate>Thu, 28 Mar 2024 14:57:24 +0000</pubDate>
      <link>https://dev.to/dayvvo/output-descriptors-in-bitcoin-what-are-they-and-why-do-we-need-them-46g1</link>
      <guid>https://dev.to/dayvvo/output-descriptors-in-bitcoin-what-are-they-and-why-do-we-need-them-46g1</guid>
      <description>&lt;p&gt;Today we make another attempt to demystify a concept you'll come across when working with Bitcoin wallets, &lt;em&gt;Output Descriptors&lt;/em&gt;, also known as Wallet Descriptors. Before we go into defining output descriptors, Let's talk about some concepts that will not only help you understand descriptors but also how the need for them arose.&lt;/p&gt;

&lt;h2&gt;
  
  
  HIERARCHICAL DETERMINISTIC(HD) WALLETS, DERIVATION PATHS
&lt;/h2&gt;

&lt;p&gt;HD wallets utilize a singular seed to generate a continuous sequence of child keys. This key is known as the root seed. The child keys generated can be used to create multiple child addresses/child wallets linked together in a hierarchical manner i.e. parent key creates a child key. The child key creates it's own child key, a grandchild of the initial Parent key, etc. Each key can also have siblings, creating a tree-like hierarchy. Keys created can be encoded as an address where Bitcoin can be sent to and locked. Wallets that use Mnemonic keys operate on this principle.&lt;/p&gt;

&lt;p&gt;While the root key/ root seed serves as the starting point from which all other child keys that hold funds can be generated, it is not the only information required to successfully back up/transfer a Bitcoin wallet/address. It is also important to know the &lt;strong&gt;Derivation Path&lt;/strong&gt; of each key that holds funds in a wallet. &lt;/p&gt;

&lt;p&gt;The derivation Path lets your Bitcoin node know the route that was taken when this key was generated. For instance, a seed can have 4 child keys, each child key having 3 child keys. The derivation path of the second grandchild key of the 3rd child key would be written as [2/1]. Key numbering indexes start from 0. keys can have much longer derivation paths, with a key having a derivation path of  [1/0/1/4]. Without knowing the derivation Path of your keys, it is possible to lose some coins that are locked in certain paths. Your wallet software would have to result to randomly choosing derivation Paths and eventually giving up after continuous scanning.&lt;/p&gt;

&lt;h2&gt;
  
  
  Output Descriptors
&lt;/h2&gt;

&lt;p&gt;Ouput Descriptors, As the name implies are actually precise Descriptors of Output scripts. They help to describe how Bitcoin addresses are derived/encoded from certain inputs Depending on the type of address that was created. By reading a descriptor, you can know the type of input that was used to generate an address, the type of address, and it's derivation Path. Output Descriptors provide a human-readable, or rather "Engineer readable" format for reading this info. &lt;/p&gt;

&lt;p&gt;Descriptors are visible as fields in several commands such as listunspent and getaddressinfo&lt;/p&gt;

&lt;h2&gt;
  
  
  Structure of an Output Descriptor
&lt;/h2&gt;

&lt;p&gt;We will examine the structure of an Output Descriptor gotten from calling Bitcoin core's &lt;em&gt;getaddressinfo&lt;/em&gt; RPC on a specific address:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ bitcoin-cli getaddressinfo ms7ruzvL4atCu77n47dStMb3of6iScS8kZ&lt;br&gt;
{&lt;br&gt;
  "address": "ms7ruzvL4atCu77n47dStMb3of6iScS8kZ",&lt;br&gt;
  "scriptPubKey": "76a9147f437379bcc66c40745edc1891ea6b3830e1975d88ac",&lt;br&gt;
  "ismine": true,&lt;br&gt;
  "solvable": true,&lt;br&gt;
  "desc": "pkh([d6043800/0'/0'/18']03efdee34c0009fd175f3b20b5e5a5517fd5d16746f2e635b44617adafeaebc388)#4ahsl9pk",&lt;br&gt;
  "iswatchonly": false,&lt;br&gt;
  "isscript": false,&lt;br&gt;
  "iswitness": false,&lt;br&gt;
  "pubkey": "03efdee34c0009fd175f3b20b5e5a5517fd5d16746f2e635b44617adafeaebc388",&lt;br&gt;
  "iscompressed": true,&lt;br&gt;
  "ischange": false,&lt;br&gt;
  "timestamp": 1592335136,&lt;br&gt;
  "hdkeypath": "m/0'/0'/18'",&lt;br&gt;
  "hdseedid": "fdea8e2630f00d29a9d6ff2af7bf5b358d061078",&lt;br&gt;
  "hdmasterfingerprint": "d6043800",&lt;br&gt;
  "labels": [&lt;br&gt;
    ""&lt;br&gt;
  ]&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The descriptor field is contained above in the &lt;em&gt;desc&lt;/em&gt; field. The value of the desc field above is "pkh([d6043800/0'/0'/18']03efdee34c0009fd175f3b20b5e5a5517fd5d16746f2e635b44617adafeaebc388)#4ahsl9pk". Let's look at the breakdown of a descriptor below: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;function([derivation-path]key)#checksum&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Function: The function is used to create an address from that key. The type of function used determines the type of address that would be created. A legacy P2PKH address would use the &lt;em&gt;pkh&lt;/em&gt; function. A P2WSH SegWit address would use wsh and a P2WPKH address would use wpkh.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Derivation Path: This describe what part of an HD wallet is being exported. In this case it's a seed with the fingerprint d6043800 and then the 18th child of the 0th child of the 0th child (0'/0'/18') of that seed. There may also be a further derivation after the key: function([derivation-path]key/more-derivation)#checksum&lt;br&gt;
&lt;strong&gt;NB&lt;/strong&gt;: It's worth noting here that if you ever get a derivation path without a fingerprint, you can make it up. It's just that if there's an existing one, you should match it. This is because if you ever go back to the device that created the fingerprint, you'll need to have the same one.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Key: This refers to the key or set of keys that the descriptor function encodes. Depending on the type of address being created and it's requirement, This could be something traditional like an &lt;br&gt;
&lt;a href="https://river.com/learn/terms/x/xprv-extended-private-key/"&gt;extended private key&lt;/a&gt;, &lt;a href="https://river.com/learn/terms/x/xpub-extended-public-key/"&gt;extended public key&lt;/a&gt; or it could just be a public key for an address as in this case, it could be a set of addresses for a multi-signature, or it could be something else. This is the core data: the function explains what to do with it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Checksum: Descriptors are meant to be human transferrable. This checksum makes sure you got it right, especially in the case where it is being transferred by hand.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  CONCLUSION
&lt;/h2&gt;

&lt;p&gt;We have briefly examined what descriptors are and how they fit into the mechanism of HD wallets. Descriptors provide a readable way to describe output scripts. Also they assist HD wallets in recovering wallet keys by providing adequate information about the output script in it's Data.&lt;/p&gt;

&lt;h3&gt;
  
  
  Related Links
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://sadeeqcode.medium.com/how-output-descriptors-enable-wallet-recovery-2484362856fa"&gt;https://sadeeqcode.medium.com/how-output-descriptors-enable-wallet-recovery-2484362856fa&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/BlockchainCommons/Learning-Bitcoin-from-the-Command-Line/blob/master/03_5_Understanding_the_Descriptor.md#understand-a-descriptor"&gt;https://github.com/BlockchainCommons/Learning-Bitcoin-from-the-Command-Line/blob/master/03_5_Understanding_the_Descriptor.md#understand-a-descriptor&lt;/a&gt;&lt;/p&gt;

</description>
      <category>bitcoin</category>
      <category>blockchain</category>
    </item>
    <item>
      <title>Block Construction in Bitcoin: How it works</title>
      <dc:creator>David Adeyemi</dc:creator>
      <pubDate>Fri, 16 Feb 2024 14:06:25 +0000</pubDate>
      <link>https://dev.to/dayvvo/block-construction-in-bitcoin-how-it-works-3019</link>
      <guid>https://dev.to/dayvvo/block-construction-in-bitcoin-how-it-works-3019</guid>
      <description>&lt;p&gt;Let's talk about how blocks are constructed on the Bitcoin network. In Bitcoin, Blocks serve as a Data structure where valid transactions(Basically confirmed exchange of bitcoin between addresses). These Blocks are "Chained" together using a set of Cryptographic principles that make each block more inseparable from it's direct Subsequent block. &lt;/p&gt;

&lt;p&gt;Transactions are added to blocks by miners who compete to solve a Mathematical problem. The miner who is able to solve this Problem earns a reward for solving that problem, firstly from the block reward which is the reward for mining a new block and secondly from the accumulated transaction fees in that block&lt;/p&gt;

&lt;h2&gt;
  
  
  WHAT MAKES A VALID BLOCK?
&lt;/h2&gt;

&lt;p&gt;When selecting transactions to form a block, Miners select blocks in a way that would result in them having maximum profit. This would mean that transactions with the Highest transaction fees are given priority and transactions with the lowest fees linger and are sometimes never confirmed. These blocks however, have to abide by the Bitcoin Network's consensus rules. Some of the factors considered when constructing a block include:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. TRANSACTIONS SHOULD NOT EXCEED THE A RECOMMENDED COMBINED WEIGHT OF 4 MILLION.
&lt;/h3&gt;

&lt;p&gt;Transaction Weight is a unit of measurement adopted in Bitoin to measure the amount of space occupied by a single transaction, with the single smallest unit of measurement being referred to as a &lt;em&gt;Weight Unit&lt;/em&gt;. Weight units typically have a 4:1 ratio when converting to bytes i.e. 4 weight units = 1 byte. However, this is only the case when dealing with Legacy transactions. Legacy transactions as the name suggests, are the first version of transactions used in Bitcoin and are normal transactions that do not offer any extra features. When dealing with other types of transactions such as Multisig transactions. Weight units to bytes have a 1:1 ratio which means, 1 weight unit = 1 bytes. This means that multisig transactions weigh less, and as such occupy less space. &lt;/p&gt;

&lt;h3&gt;
  
  
  2.TRANSACTIONS IN A BLOCK MUST NOT OCCUR TWICE
&lt;/h3&gt;

&lt;p&gt;This is perhaps the golden and most obvious rule when including transactions in a block. The same transaction occurring twice would mean that Bitcoin has been double-spent i.e. The same value of currency has been present in a transfer twice. This would annul Bitcoin's validity as a means of exchanging value &lt;/p&gt;

&lt;h3&gt;
  
  
  3.PARENT TRANSACTIONS MUST APPEAR BEFORE CHILD TRANSACTIONS
&lt;/h3&gt;

&lt;p&gt;The terms Parent and Child transactions came to be in Bitcoin as a result of a Fee bumping Method known as &lt;em&gt;Child Pays For Parent (CPFP)&lt;/em&gt;. This Method is useful in helping to confirm transactions that were broadcast with a low fee and as such are not likely to be confirmed due to their low incentive for miners. &lt;br&gt;
&lt;em&gt;Child Pays For Parent (CPFP)&lt;/em&gt; can be explained as follows with a simple analogy; I'm shopping on AliExpress and I buy cheap s from a smartwatch from a particular vendor, one that has a free shipping tag attached. This item would normally take a while to deliver because well, it's free and as such wouldn't take priority. I now buy a really expensive item say, A gaming rig that has paid delivery. I then contacted the seller of the item and instructed him to ship my cheap necklace to my second order, the one with paid delivery which would be delivered in normal time. This is a typical example of what happens in &lt;em&gt;Child Pays For Parent (CPFP)&lt;/em&gt;, where a second transaction is broadcasted referencing one of the inputs of the previously broadcasted transactions with a low fee. This would incentivize the miner to confirm the transaction with a low fee that would have otherwise been left hanging in order the confirm the transaction with a high fee&lt;/p&gt;

&lt;h2&gt;
  
  
  CONCLUSION
&lt;/h2&gt;

&lt;p&gt;Block construction is an integral step in the working flow of the Bitcoin network and as such, Will likely not require you to write custom code as most mining software have already implemented this. However, hopefully this article helps you understand how the selection process occurred, the factors considered and the reason(s) behind it's mode of operation &lt;/p&gt;

</description>
      <category>bitcoin</category>
      <category>blocks</category>
    </item>
    <item>
      <title>Building Secure Bitcoin Applications with JavaScript Libraries; Dependency Management</title>
      <dc:creator>David Adeyemi</dc:creator>
      <pubDate>Fri, 02 Feb 2024 08:49:12 +0000</pubDate>
      <link>https://dev.to/dayvvo/building-secure-bitcoin-applications-with-javascript-libraries-dependency-management-5b8n</link>
      <guid>https://dev.to/dayvvo/building-secure-bitcoin-applications-with-javascript-libraries-dependency-management-5b8n</guid>
      <description>&lt;p&gt;Bitcoin, the pioneering cryptocurrency, is a decentralized and open-source digital currency that fundamentally reshapes traditional notions of finance. At its core, Bitcoin operates without a central authority, relying on a distributed network of nodes to validate and record transactions securely. It's development ecosystem is no different, also decentralized in it's management structure. As such, there are a handful of versions of the technology being built with various technologies and programming languages. JavaScript, the powerhouse of the Web, is one of them. &lt;/p&gt;

&lt;p&gt;Libraries built-in JavaScript are usually uploaded on the &lt;strong&gt;NPM registry&lt;/strong&gt; as packages, a centralized repository that hosts and manages JavaScript packages and modules. This registry is open source, and as such anyone can create and upload a JavaScript Package. This leaves little room for regulation against malware/ faulty code being bundled/disguised as a harmless package and uploaded onto the registry for public use. An example of such a case would be the recent &lt;a href="https://blog.npmjs.org/post/180565383195/details-about-the-event-stream-incident"&gt;event-stream&lt;/a&gt; incident, where malware was listed as a dependency to another popular npm package, event-stream. In Developing Bitcoin applications, It is very important to verify the suitability and authenticity of the dependency to ensure that the core security principles upon which the technology hinges, some of which include decentralization and privacy are not jeopardized by these packages or their dependencies&lt;/p&gt;

&lt;h1&gt;
  
  
  Dependency Management Practices
&lt;/h1&gt;

&lt;p&gt;These are some steps one can take toward effective dependency management in building Bitcoin applications. We look at them in this section. Some of the them include:&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Inspect Package Documentation/ Code
&lt;/h2&gt;

&lt;p&gt;A quick browse through the package documentation can give you a general idea of the idea behind the package implementation and some of it's core features as well as it's dependencies. This is strongly encouraged in the community as it promotes the spirit of open source collaboration&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Avoid using random, unpopular packages when necessary.
&lt;/h2&gt;

&lt;p&gt;Simply put, a package with few regular users/downloads, has fewer sets of eyes on it, and less community adoption. And as such the likelihood of a malicious user sneaking malicious code into said package is higher. While this is not a determining factor in ascertaining the safety of a package, it is one of the factors to consider.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Audit Packages Regularly:
&lt;/h3&gt;

&lt;p&gt;Auditing Packages is one step that can be taken toward detecting vulnerabilities in the packages used in your Bitcoin application. Audits are an inbuilt feature in npm, which can be triggered using &lt;code&gt;npm audit&lt;/code&gt;. This scans all the packages listed in your entire &lt;em&gt;package.json&lt;/em&gt; file and lists out the potential breaking changes, and vulnerabilities in your dependencies that may be a threat to your user's security. &lt;em&gt;audit&lt;/em&gt; can be further supplemented with a fix command, triggered by adding a &lt;em&gt;fix&lt;/em&gt; prefix to npm audit like so; &lt;code&gt;npm audit fix&lt;/code&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  4. Using a .npmrc file
&lt;/h3&gt;

&lt;p&gt;Adding this file to the root of your project folder can help limit the access of third-party packages. &lt;/p&gt;

&lt;h3&gt;
  
  
  5. Using vulnerability scanners
&lt;/h3&gt;

&lt;p&gt;Using Vulnerability scanners such as Synk can help detect vulnerabilities in your dependencies. Synk offers free support for individual projects and can be setup by installing Synk globally on your computer using the command &lt;code&gt;npm install -g synk&lt;/code&gt; and triggered using the &lt;em&gt;test&lt;/em&gt; command i.e &lt;code&gt;sync test&lt;/code&gt; from your project folder&lt;/p&gt;

&lt;h1&gt;
  
  
  CONCLUSION
&lt;/h1&gt;

&lt;p&gt;In the realm of Software engineering, It would be erroneous to say that your system, software or application is completely secure. With that said, The above practice, procedures do not completely guarantee you complete security against bad/malicious dependency packages. However, If applied properly they could help prevent a myraid of security problems and protect your user's funds/data&lt;/p&gt;

</description>
      <category>bitcoin</category>
      <category>webdev</category>
      <category>node</category>
    </item>
  </channel>
</rss>
