- 
                Notifications
    You must be signed in to change notification settings 
- Fork 300
feat(express): migrate handleCreateSignerMacaroon to typed routes #6967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            danielzhao122
  wants to merge
  12
  commits into
  master
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
WP-5445-express-migrate-api-v2-coin-wallet-id-signer-macaroon-to-typed-routes
  
      
      
   
  
    
  
  
  
 
  
      
    base: master
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from 7 commits
      Commits
    
    
            Show all changes
          
          
            12 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      395592d
              
                feat(express): migrate lightningSignerMacaroon to typed routes
              
              
                danielzhao122 7e45d7c
              
                refactor: minor edit to how we extract coinName
              
              
                danielzhao122 5a7e6f5
              
                refactor: removed any type cast and added reponse const variable
              
              
                danielzhao122 f27c7aa
              
                refactor: attempt to fix import
              
              
                danielzhao122 ec5453a
              
                docs: refactored the jsdocs
              
              
                danielzhao122 644435a
              
                refactor: added decoding to UT
              
              
                danielzhao122 3ff273a
              
                refactor: changed label of decodeOrElse
              
              
                danielzhao122 ae3b367
              
                Merge branch 'origin/master' into WP-5445-express-migrate-api-v2-coin…
              
              
                danielzhao122 ee326a2
              
                test(express): add supertests
              
              
                danielzhao122 2eb2b11
              
                test: remove the temporary file creation
              
              
                danielzhao122 515807f
              
                test: removed try-catch and split test into 4 seperate tests
              
              
                danielzhao122 30158d2
              
                Merge remote-tracking branch 'origin/master' into WP-5445-express-mig…
              
              
                danielzhao122 File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,58 @@ | ||
| import * as t from 'io-ts'; | ||
| import { httpRoute, httpRequest, optional } from '@api-ts/io-ts-http'; | ||
| import { BitgoExpressError } from '../../schemas/error'; | ||
|  | ||
| /** | ||
| * Path parameters for creating a signer macaroon | ||
| * @property {string} coin - A lightning coin name (e.g, lnbtc). | ||
| * @property {string} walletId - The ID of the wallet. | ||
| */ | ||
| export const SignerMacaroonParams = { | ||
| /** A lightning coin name (e.g, lnbtc). */ | ||
| coin: t.string, | ||
| /** The ID of the wallet. */ | ||
| walletId: t.string, | ||
| } as const; | ||
|  | ||
| /** | ||
| * Request body for creating a signer macaroon | ||
| * @property {string} passphrase - Passphrase to decrypt the admin macaroon of the signer node. | ||
| * @property {boolean} addIpCaveatToMacaroon - If true, adds an IP caveat to the generated signer macaroon. | ||
| */ | ||
| export const SignerMacaroonBody = { | ||
| /** Passphrase to decrypt the admin macaroon of the signer node. */ | ||
| passphrase: t.string, | ||
| /** If true, adds an IP caveat to the generated signer macaroon. */ | ||
| addIpCaveatToMacaroon: optional(t.boolean), | ||
| } as const; | ||
|  | ||
| /** | ||
| * Response | ||
| * - 200: Returns the updated wallet. On success, the wallet's `coinSpecific` includes the generated signer macaroon (derived from the signer node admin macaroon), optionally with an IP caveat. | ||
| * - 400: BitGo Express error payload when macaroon creation cannot proceed (e.g., invalid coin, wallet not self‑custody lightning, missing encrypted signer admin macaroon, or external IP not set when an IP caveat is requested). | ||
| * | ||
| * See platform spec: POST /api/v2/{coin}/wallet/{walletId}/signermacaroon | ||
| */ | ||
| export const SignerMacaroonResponse = { | ||
| /** The updated wallet with the generated signer macaroon. */ | ||
| 200: t.UnknownRecord, | ||
| /** BitGo Express error payload. */ | ||
| 400: BitgoExpressError, | ||
| } as const; | ||
|  | ||
| /** | ||
| * Lightning - Create signer macaroon | ||
| * | ||
| * This is only used for self-custody lightning. Create the signer macaroon for the watch-only Lightning Network Daemon (LND) node. This macaroon derives from the signer node admin macaroon and is used by the watch-only node to request signatures from the signer node for operational tasks. Returns the updated wallet with the encrypted signer macaroon in the `coinSpecific` response field. | ||
| * | ||
| * @operationId express.lightning.signerMacaroon | ||
| */ | ||
| export const PostSignerMacaroon = httpRoute({ | ||
| method: 'POST', | ||
| path: '/api/v2/{coin}/wallet/{walletId}/signermacaroon', | ||
| request: httpRequest({ | ||
| params: SignerMacaroonParams, | ||
| body: SignerMacaroonBody, | ||
| }), | ||
| response: SignerMacaroonResponse, | ||
| }); | 
  
    
      This file contains hidden or 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 hidden or 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
    
  
  
    
              
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.