-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate
bitcoinjs-lib
changes around deposit sweeps
Here we pull changes from #700
- Loading branch information
1 parent
18139cd
commit 45f46b9
Showing
11 changed files
with
585 additions
and
243 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,67 @@ | ||
import { payments } from "bitcoinjs-lib" | ||
|
||
/** | ||
* Checks if the provided script comes from a P2PKH input. | ||
* @param script The script to be checked. | ||
* @returns True if the script is P2PKH, false otherwise. | ||
*/ | ||
function isP2PKHScript(script: Buffer): boolean { | ||
try { | ||
payments.p2pkh({ output: script }) | ||
return true | ||
} catch (err) { | ||
return false | ||
} | ||
} | ||
|
||
/** | ||
* Checks if the provided script comes from a P2WPKH input. | ||
* @param script The script to be checked. | ||
* @returns True if the script is P2WPKH, false otherwise. | ||
*/ | ||
function isP2WPKHScript(script: Buffer): boolean { | ||
try { | ||
payments.p2wpkh({ output: script }) | ||
return true | ||
} catch (err) { | ||
return false | ||
} | ||
} | ||
|
||
/** | ||
* Checks if the provided script comes from a P2SH input. | ||
* @param script The script to be checked. | ||
* @returns True if the script is P2SH, false otherwise. | ||
*/ | ||
function isP2SHScript(script: Buffer): boolean { | ||
try { | ||
payments.p2sh({ output: script }) | ||
return true | ||
} catch (err) { | ||
return false | ||
} | ||
} | ||
|
||
/** | ||
* Checks if the provided script comes from a P2PKH input. | ||
* @param script The script to be checked. | ||
* @returns True if the script is P2WSH, false otherwise. | ||
*/ | ||
function isP2WSHScript(script: Buffer): boolean { | ||
try { | ||
payments.p2wsh({ output: script }) | ||
return true | ||
} catch (err) { | ||
return false | ||
} | ||
} | ||
|
||
/** | ||
* Utility functions allowing to deal with Bitcoin scripts. | ||
*/ | ||
export const BitcoinScriptUtils = { | ||
isP2PKHScript, | ||
isP2WPKHScript, | ||
isP2SHScript, | ||
isP2WSHScript, | ||
} |
This file contains 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
Oops, something went wrong.