@@ -869,8 +869,8 @@ var DashTx = ("object" === typeof module && exports) || {};
869
869
870
870
// memo vs non-memo is settled by 'satoshis' being 0
871
871
// (otherwise there's a bug)
872
- if ( a . memo ) {
873
- if ( ! b . memo ) {
872
+ if ( typeof a . memo === "string" ) {
873
+ if ( typeof b . memo !== "string" ) {
874
874
throw new Error ( `'satoshis' must be above 0, except for memos` ) ;
875
875
}
876
876
if ( a . memo < b . memo ) {
@@ -1268,7 +1268,7 @@ var DashTx = ("object" === typeof module && exports) || {};
1268
1268
output . memo = TxUtils . strToHex ( output . message ) ;
1269
1269
}
1270
1270
}
1271
- if ( output . memo ) {
1271
+ if ( typeof output . memo === "string" ) {
1272
1272
let invalid = output . address || output . pubKeyHash ;
1273
1273
if ( invalid ) {
1274
1274
throw new Error ( `memo outputs must not have 'address' or 'pubKeyHash'` ) ;
@@ -1306,7 +1306,7 @@ var DashTx = ("object" === typeof module && exports) || {};
1306
1306
Tx . createDonationOutput = function ( opts ) {
1307
1307
let satoshis = 0 ;
1308
1308
let message = opts ?. message ;
1309
- if ( ! message ) {
1309
+ if ( typeof message !== "string" ) {
1310
1310
let gifts = [ "💸" , "🎁" , "🧧" ] ;
1311
1311
let indexIsh = Math . random ( ) * 3 ;
1312
1312
let index = Math . floor ( indexIsh ) ;
@@ -1606,8 +1606,10 @@ var DashTx = ("object" === typeof module && exports) || {};
1606
1606
output . scriptTypeHex = output . script . slice ( 0 , 2 ) ;
1607
1607
output . scriptType = parseInt ( output . scriptTypeHex , 16 ) ;
1608
1608
output . pubKeyHash = "" ;
1609
- output . memo = "" ;
1610
- output . message = "" ;
1609
+ /**@type {String? }*/
1610
+ output . memo = null ;
1611
+ /**@type {String? }*/
1612
+ output . message = null ;
1611
1613
if ( output . scriptTypeHex === OP_RETURN ) {
1612
1614
output . memo = output . script . slice ( 4 , 2 * output . lockScriptSize ) ;
1613
1615
output . message = "" ;
@@ -2052,8 +2054,8 @@ if ("object" === typeof module) {
2052
2054
2053
2055
/**
2054
2056
* @typedef TxOutput
2055
- * @prop {String } [memo] - hex bytes of a memo (incompatible with pubKeyHash / address)
2056
- * @prop {String } [message] - memo, but as a UTF-8 string
2057
+ * @prop {String? } [memo] - hex bytes of a memo (incompatible with pubKeyHash / address)
2058
+ * @prop {String? } [message] - memo, but as a UTF-8 string
2057
2059
* @prop {String } [address] - payAddr as Base58Check (human-friendly)
2058
2060
* @prop {String } [pubKeyHash] - payAddr's raw hex value (decoded, not Base58Check)
2059
2061
* @prop {Uint53 } satoshis - the number of smallest units of the currency
@@ -2063,7 +2065,7 @@ if ("object" === typeof module) {
2063
2065
* @typedef TxOutputSortable
2064
2066
* @prop {Uint53 } satoshis
2065
2067
* @prop {String } [script] - hex bytes in wire order
2066
- * @prop {String } [memo] - 0x6a, hex bytes
2068
+ * @prop {String? } [memo] - 0x6a, hex bytes
2067
2069
* @prop {String } [pubKeyHash] - 0x76, 0xa9, hex bytes
2068
2070
* @prop {String } [address] - 0x76, 0xa9, base58check bytes
2069
2071
*/
@@ -2105,7 +2107,7 @@ if ("object" === typeof module) {
2105
2107
* Create a donation output with a nice message.
2106
2108
* @callback TxCreateDonationOutput
2107
2109
* @param {Object } [opts]
2108
- * @param {String } [opts.message] - UTF-8 Memo String
2110
+ * @param {String? } [opts.message] - UTF-8 Memo String
2109
2111
*/
2110
2112
2111
2113
/**
0 commit comments