When multiple wallets are open, getpeginaddress does not specify the wallet when making a (hacky) recursive rpc call to getnewaddress.
The getnewaddress functionality should be refactored out into a helper function, or at least getpeginaddress should correctly set up the RPC request structure.