@@ -43,6 +43,14 @@ describe('RequestObfuscator', () => {
43
43
request . body . should . eql ( '{"id":"1485369469422","method":"importprivkey","params":["******"]}' ) ;
44
44
} ) ;
45
45
46
+ it ( 'should obfuscate the private key from `request.body` when `method` is `importprivkey` and RPC is called with named parameters' , ( ) => {
47
+ const request = { body : '{"id":"1485369469422","method":"importprivkey","params":{"privkey":"foobar"}}' , type : 'request' } ;
48
+
49
+ obfuscate ( request ) ;
50
+
51
+ request . body . should . eql ( '{"id":"1485369469422","method":"importprivkey","params":{"privkey":"******"}}' ) ;
52
+ } ) ;
53
+
46
54
it ( 'should obfuscate the private key from `request.body` when `method` is `signmessagewithprivkey`' , ( ) => {
47
55
const request = { body : '{"id":"1485369469422","method":"signmessagewithprivkey","params":["foobar", "foobiz"]}' , type : 'request' } ;
48
56
@@ -51,6 +59,14 @@ describe('RequestObfuscator', () => {
51
59
request . body . should . eql ( '{"id":"1485369469422","method":"signmessagewithprivkey","params":["******","foobiz"]}' ) ;
52
60
} ) ;
53
61
62
+ it ( 'should obfuscate the private key from `request.body` when `method` is `signmessagewithprivkey` and RPC is called with named parameters' , ( ) => {
63
+ const request = { body : '{"id":"1485369469422","method":"signmessagewithprivkey","params":{"privkey":"foobar","message":"foobiz"}}' , type : 'request' } ;
64
+
65
+ obfuscate ( request ) ;
66
+
67
+ request . body . should . eql ( '{"id":"1485369469422","method":"signmessagewithprivkey","params":{"privkey":"******","message":"foobiz"}}' ) ;
68
+ } ) ;
69
+
54
70
it ( 'should obfuscate all private keys from `request.body` when `method` is `signrawtransaction`' , ( ) => {
55
71
const request = { body : '{"id":"1485369469422","method":"signrawtransaction","params":["foo","bar",["biz", "boz"]]}' , type : 'request' } ;
56
72
@@ -59,6 +75,24 @@ describe('RequestObfuscator', () => {
59
75
request . body . should . eql ( '{"id":"1485369469422","method":"signrawtransaction","params":["foo","bar",["******","******"]]}' ) ;
60
76
} ) ;
61
77
78
+ it ( 'should obfuscate all private keys from `request.body` when `method` is `signrawtransaction` and RPC is called with named parameters' , ( ) => {
79
+ const request = { body : `{"id":"1485369469422","method":"signrawtransaction","params":${ JSON . stringify ( {
80
+ hexstring : 'foo' ,
81
+ prevtxs : [ ] ,
82
+ privkeys : [ 'foo' , 'bar' ] ,
83
+ sighashtype : 'bar'
84
+ } ) } }`, type : 'request' } ;
85
+
86
+ obfuscate ( request ) ;
87
+
88
+ request . body . should . eql ( `{"id":"1485369469422","method":"signrawtransaction","params":${ JSON . stringify ( {
89
+ hexstring : 'foo' ,
90
+ prevtxs : [ ] ,
91
+ privkeys : [ '******' , '******' ] ,
92
+ sighashtype : 'bar'
93
+ } ) } }`) ;
94
+ } ) ;
95
+
62
96
it ( 'should obfuscate the passphrase from `request.body` when `method` is `encryptwallet`' , ( ) => {
63
97
const request = { body : '{"id":"1485369469422","method":"encryptwallet","params":["foobar"]}' , type : 'request' } ;
64
98
@@ -67,6 +101,14 @@ describe('RequestObfuscator', () => {
67
101
request . body . should . eql ( '{"id":"1485369469422","method":"encryptwallet","params":["******"]}' ) ;
68
102
} ) ;
69
103
104
+ it ( 'should obfuscate the passphrase from `request.body` when `method` is `encryptwallet` and RPC is called with named parameters' , ( ) => {
105
+ const request = { body : '{"id":"1485369469422","method":"encryptwallet","params":{"passphrase":"foobar"}}' , type : 'request' } ;
106
+
107
+ obfuscate ( request ) ;
108
+
109
+ request . body . should . eql ( '{"id":"1485369469422","method":"encryptwallet","params":{"passphrase":"******"}}' ) ;
110
+ } ) ;
111
+
70
112
it ( 'should obfuscate the passphrase from `request.body` when `method` is `walletpassphrase`' , ( ) => {
71
113
const request = { body : '{"id":"1485369469422","method":"walletpassphrase","params":["foobar"]}' , type : 'request' } ;
72
114
@@ -75,6 +117,30 @@ describe('RequestObfuscator', () => {
75
117
request . body . should . eql ( '{"id":"1485369469422","method":"walletpassphrase","params":["******"]}' ) ;
76
118
} ) ;
77
119
120
+ it ( 'should obfuscate the passphrase from `request.body` when `method` is `walletpassphrase` and RPC is called with named parameters' , ( ) => {
121
+ const request = { body : '{"id":"1485369469422","method":"walletpassphrase","params":{"passphrase":"foobar"}}' , type : 'request' } ;
122
+
123
+ obfuscate ( request ) ;
124
+
125
+ request . body . should . eql ( '{"id":"1485369469422","method":"walletpassphrase","params":{"passphrase":"******"}}' ) ;
126
+ } ) ;
127
+
128
+ it ( 'should obfuscate the oldpassphrase and newpassphrase from `request.body` when `method` is `walletpassphrasechange`' , ( ) => {
129
+ const request = { body : '{"id":"1485369469422","method":"walletpassphrasechange","params":["foobar", "foobiz"]}' , type : 'request' } ;
130
+
131
+ obfuscate ( request ) ;
132
+
133
+ request . body . should . eql ( '{"id":"1485369469422","method":"walletpassphrasechange","params":["******","******"]}' ) ;
134
+ } ) ;
135
+
136
+ it ( 'should obfuscate the oldpassphrase and newpassphrase from `request.body` when `method` is `walletpassphrasechange` and RPC is called with named parameters' , ( ) => {
137
+ const request = { body : '{"id":"1485369469422","method":"walletpassphrasechange","params":{"oldpassphrase":"foobar","newpassphrase":"foobar"}}' , type : 'request' } ;
138
+
139
+ obfuscate ( request ) ;
140
+
141
+ request . body . should . eql ( '{"id":"1485369469422","method":"walletpassphrasechange","params":{"oldpassphrase":"******","newpassphrase":"******"}}' ) ;
142
+ } ) ;
143
+
78
144
it ( 'should obfuscate the `request.body` of a batch request' , ( ) => {
79
145
const request = { body : '[{"id":"1485369469422","method":"walletpassphrase","params":["foobar"]},{"id":"1485369469423","method":"walletpassphrase","params":["foobar"]}]' , type : 'request' } ;
80
146
0 commit comments